From 289924dba1e5bb78460e965c3686de28b94d5f04 Mon Sep 17 00:00:00 2001 From: Omri Date: Thu, 7 Nov 2024 10:36:42 +0100 Subject: [PATCH] fix(validation): Fixed wrong validation of proposer hash against header (#1178) Co-authored-by: Michael Tsitrin <114929630+mtsitrin@users.noreply.github.com> Co-authored-by: Michael Tsitrin --- types/validation.go | 6 +++--- types/validation_test.go | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/types/validation.go b/types/validation.go index 5734a636e..0d0c7a1ed 100644 --- a/types/validation.go +++ b/types/validation.go @@ -78,8 +78,8 @@ func (b *Block) ValidateWithState(state *State) error { } proposerHash := state.GetProposerHash() - if !bytes.Equal(b.Header.NextSequencersHash[:], proposerHash) { - return NewErrInvalidNextSequencersHashFraud([32]byte(proposerHash), b.Header.NextSequencersHash) + if !bytes.Equal(b.Header.SequencerHash[:], proposerHash) { + return NewErrInvalidSequencerHashFraud([32]byte(proposerHash), b.Header.SequencerHash[:]) } if !bytes.Equal(b.Header.AppHash[:], state.AppHash[:]) { @@ -152,7 +152,7 @@ func (c *Commit) ValidateWithHeader(proposerPubKey tmcrypto.PubKey, header *Head } if !bytes.Equal(header.SequencerHash[:], proposerHash) { - return NewErrInvalidSequencerHashFraud(header.SequencerHash, proposerHash) + return NewErrInvalidSequencerHashFraud(header.SequencerHash, proposerHash[:]) } if c.HeaderHash != header.Hash() { diff --git a/types/validation_test.go b/types/validation_test.go index c95ae9d68..14af79dd9 100644 --- a/types/validation_test.go +++ b/types/validation_test.go @@ -42,15 +42,15 @@ func TestBlock_ValidateWithState(t *testing.T) { Block: 1, App: 1, }, - Height: 10, - Time: uint64(currentTime.UnixNano()), - AppHash: [32]byte{1, 2, 3}, - LastResultsHash: [32]byte{4, 5, 6}, - ProposerAddress: []byte("proposer"), - DataHash: [32]byte{}, - LastHeaderHash: [32]byte{7, 8, 9}, - ChainID: "chainID", - NextSequencersHash: [32]byte(proposerHash), + Height: 10, + Time: uint64(currentTime.UnixNano()), + AppHash: [32]byte{1, 2, 3}, + LastResultsHash: [32]byte{4, 5, 6}, + ProposerAddress: []byte("proposer"), + DataHash: [32]byte{}, + LastHeaderHash: [32]byte{7, 8, 9}, + ChainID: "chainID", + SequencerHash: [32]byte(proposerHash), }, Data: Data{}, LastCommit: Commit{},