From 23cc81a4ad9073dfaf6bf6ce79bfba29b07cbb7b Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Wed, 12 Apr 2023 20:02:30 -0700 Subject: [PATCH] header: verify aggregator hash against validators (#845) Fixes #833 --- node/full_client_test.go | 7 ++++--- state/executor.go | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/node/full_client_test.go b/node/full_client_test.go index 511ffa6f2f9..ba535bd4fb9 100644 --- a/node/full_client_test.go +++ b/node/full_client_test.go @@ -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"}, diff --git a/state/executor.go b/state/executor.go index 46c2335daa7..9f7ba5ab42f 100644 --- a/state/executor.go +++ b/state/executor.go @@ -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 }