diff --git a/p2p/pkg/rpc/provider/service.go b/p2p/pkg/rpc/provider/service.go index 3db1adefe..5a30648ae 100644 --- a/p2p/pkg/rpc/provider/service.go +++ b/p2p/pkg/rpc/provider/service.go @@ -271,7 +271,15 @@ func (s *Service) Stake( } for i, _ := range stake.BlsPublicKeys { - tx, txErr = s.registryContract.AddVerifiedBLSKey(opts, []byte(stake.BlsPublicKeys[i]), []byte(stake.BlsSignatures[i])) + blsPublicKey, err := hex.DecodeString(strings.TrimPrefix(stake.BlsPublicKeys[i], "0x")) + if err != nil { + return nil, status.Errorf(codes.Internal, "decoding bls public key: %v", err) + } + blsSignature, err := hex.DecodeString(strings.TrimPrefix(stake.BlsSignatures[i], "0x")) + if err != nil { + return nil, status.Errorf(codes.Internal, "decoding bls signature: %v", err) + } + tx, txErr = s.registryContract.AddVerifiedBLSKey(opts, blsPublicKey, blsSignature) if txErr != nil { return nil, status.Errorf(codes.Internal, "adding verified bls key: %v", txErr) } @@ -288,7 +296,7 @@ func (s *Service) Stake( for _, log := range receipt.Logs { if blsKeyEvent, err := s.registryContract.ParseBLSKeyAdded(*log); err == nil { s.logger.Info("verified bls key added", "key", blsKeyEvent.BlsPublicKey) - stakeResponse.BlsPublicKeys = append(stakeResponse.BlsPublicKeys, string(blsKeyEvent.BlsPublicKey)) + stakeResponse.BlsPublicKeys = append(stakeResponse.BlsPublicKeys, hex.EncodeToString(blsKeyEvent.BlsPublicKey)) } } } diff --git a/p2p/pkg/rpc/provider/service_test.go b/p2p/pkg/rpc/provider/service_test.go index 2fe5508e6..e71d70d46 100644 --- a/p2p/pkg/rpc/provider/service_test.go +++ b/p2p/pkg/rpc/provider/service_test.go @@ -30,10 +30,11 @@ import ( ) type testRegistryContract struct { - stake *big.Int - topup *big.Int - minStake *big.Int - blsKey []byte + stake *big.Int + topup *big.Int + minStake *big.Int + blsKey []byte + blsSignature []byte } func (t *testRegistryContract) ProviderRegistered(opts *bind.CallOpts, address common.Address) (bool, error) { @@ -50,6 +51,7 @@ func (t *testRegistryContract) RegisterAndStake(opts *bind.TransactOpts) (*types func (t *testRegistryContract) AddVerifiedBLSKey(opts *bind.TransactOpts, blsPublicKey []byte, blsSignature []byte) (*types.Transaction, error) { t.blsKey = blsPublicKey + t.blsSignature = blsSignature return types.NewTransaction(1, common.Address{}, nil, 0, nil, nil), nil }