Skip to content

Commit

Permalink
header: verify aggregator hash against validators (cosmos#845)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxcanfly authored Apr 13, 2023
1 parent acf202b commit 23cc81a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 4 additions & 3 deletions node/full_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,15 @@ func getRandomValidatorSet() *tmtypes.ValidatorSet {
}
}

var genesisValidatorKey = ed25519.GenPrivKey()

// TODO: use n and return n validators
func getGenesisValidatorSetWithSigner(n int) ([]tmtypes.GenesisValidator, crypto.PrivKey) {
validatorKey := ed25519.GenPrivKey()
nodeKey := &p2p.NodeKey{
PrivKey: validatorKey,
PrivKey: genesisValidatorKey,
}
signingKey, _ := conv.GetNodeKey(nodeKey)
pubKey := validatorKey.PubKey()
pubKey := genesisValidatorKey.PubKey()

genesisValidators := []tmtypes.GenesisValidator{
{Address: pubKey.Address(), PubKey: pubKey, Power: int64(100), Name: "gen #1"},
Expand Down
4 changes: 4 additions & 0 deletions state/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ func (e *BlockExecutor) validate(state types.State, block *types.Block) error {
return errors.New("LastResultsHash mismatch")
}

if !bytes.Equal(block.SignedHeader.Header.AggregatorsHash[:], state.Validators.Hash()) {
return errors.New("AggregatorsHash mismatch")
}

return nil
}

Expand Down

0 comments on commit 23cc81a

Please sign in to comment.