Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
samricotta committed Oct 15, 2024
1 parent 81fff9d commit 70d3422
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 109 deletions.
2 changes: 1 addition & 1 deletion proto/babylon/checkpointing/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ message BlsPublicKeyListResponse {
// validator_address is the address of the validator
string validator_address = 1;
// bls_pub_key is the BLS public key of the validator
bytes bls_pub_key = 2;
string bls_pub_key_hex = 2;
// voting_power is the voting power of the validator at the given epoch
uint64 voting_power = 3;
}
Expand Down
12 changes: 7 additions & 5 deletions x/checkpointing/keeper/grpc_query_bls.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
"context"
"encoding/hex"

"github.com/babylonlabs-io/babylon/x/checkpointing/types"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -52,13 +53,14 @@ func (k Keeper) BlsPublicKeyList(c context.Context, req *types.QueryBlsPublicKey
}

func convertToBlsPublicKeyListResponse(valBLSKeys []*types.ValidatorWithBlsKey) []*types.BlsPublicKeyListResponse {
var blsPublicKeyListResponse []*types.BlsPublicKeyListResponse
for _, valBlsKey := range valBLSKeys {
blsPublicKeyListResponse = append(blsPublicKeyListResponse, &types.BlsPublicKeyListResponse{
blsPublicKeyListResponse := make([]*types.BlsPublicKeyListResponse, len(valBLSKeys))

for i, valBlsKey := range valBLSKeys {
blsPublicKeyListResponse[i] = &types.BlsPublicKeyListResponse{
ValidatorAddress: valBlsKey.ValidatorAddress,
BlsPubKey: valBlsKey.BlsPubKey,
BlsPubKeyHex: hex.EncodeToString(valBlsKey.BlsPubKey),
VotingPower: valBlsKey.VotingPower,
})
}
}
return blsPublicKeyListResponse
}
3 changes: 2 additions & 1 deletion x/checkpointing/keeper/grpc_query_bls_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper_test

import (
"encoding/hex"
"math/rand"
"testing"

Expand Down Expand Up @@ -48,7 +49,7 @@ func FuzzQueryBLSKeySet(f *testing.F) {
res, err := queryClient.BlsPublicKeyList(ctx, queryRequest)
require.NoError(t, err)
require.Len(t, res.ValidatorWithBlsKeys, 1)
require.Equal(t, res.ValidatorWithBlsKeys[0].BlsPubKey, genesisBLSPubkey.Bytes())
require.Equal(t, res.ValidatorWithBlsKeys[0].BlsPubKeyHex, hex.EncodeToString(genesisBLSPubkey.Bytes()))
require.Equal(t, res.ValidatorWithBlsKeys[0].VotingPower, uint64(1000))
require.Equal(t, res.ValidatorWithBlsKeys[0].ValidatorAddress, genesisVal.GetValAddressStr())

Expand Down
Loading

0 comments on commit 70d3422

Please sign in to comment.