Skip to content

Commit

Permalink
Merge PR #96: Remove the nil ethsigner addresses from valset
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzampolin authored Jul 26, 2021
1 parent bdd870c commit ab75758
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 5 additions & 7 deletions module/x/gravity/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,19 +286,17 @@ func (k Keeper) CreateSignerSetTx(ctx sdk.Context) *types.SignerSetTx {
// implementations are involved.
func (k Keeper) CurrentSignerSet(ctx sdk.Context) types.EthereumSigners {
validators := k.StakingKeeper.GetBondedValidatorsByPower(ctx)
ethereumSigners := make([]*types.EthereumSigner, len(validators))
ethereumSigners := make([]*types.EthereumSigner, 0)
var totalPower uint64
// TODO someone with in depth info on Cosmos staking should determine
// if this is doing what I think it's doing
for i, validator := range validators {
for _, validator := range validators {
val := validator.GetOperator()

p := uint64(k.StakingKeeper.GetLastValidatorPower(ctx, val))
totalPower += p

ethereumSigners[i] = &types.EthereumSigner{Power: p}
if ethAddr := k.GetValidatorEthereumAddress(ctx, val); ethAddr.Hex() != "0x0000000000000000000000000000000000000000" {
ethereumSigners[i].EthereumAddress = ethAddr.Hex()
es := &types.EthereumSigner{Power: p, EthereumAddress: ethAddr.Hex()}
ethereumSigners = append(ethereumSigners, es)
totalPower += p
}
}
// normalize power values
Expand Down
4 changes: 3 additions & 1 deletion module/x/gravity/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ func TestCurrentValsetNormalization(t *testing.T) {
t.Run(msg, func(t *testing.T) {
operators := make([]MockStakingValidatorData, len(spec.srcPowers))
for i, v := range spec.srcPowers {
cAddr := bytes.Repeat([]byte{byte(i)}, sdk.AddrLen)
operators[i] = MockStakingValidatorData{
// any unique addr
Operator: bytes.Repeat([]byte{byte(i)}, sdk.AddrLen),
Operator: cAddr,
Power: int64(v),
}
input.GravityKeeper.setValidatorEthereumAddress(ctx, cAddr, common.HexToAddress("0xf71402f886b45c134743F4c00750823Bbf5Fd045"))
}
input.GravityKeeper.StakingKeeper = NewStakingKeeperWeightedMock(operators...)
r := input.GravityKeeper.CreateSignerSetTx(ctx)
Expand Down

0 comments on commit ab75758

Please sign in to comment.