Skip to content

Commit

Permalink
lets check
Browse files Browse the repository at this point in the history
  • Loading branch information
danwt committed Dec 20, 2024
1 parent e873050 commit 9ac05e3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
16 changes: 11 additions & 5 deletions types/dym_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@ func MakeDymHeader(consMessages []*proto.Any) DymHeader {
}
}

func (h *Header) SetDymHeader(dh DymHeader) {
h.ConsensusMessagesHash = dh.ConsensusMessagesHash
}

func (h *Header) DymHash() cmtbytes.HexBytes {
func (h DymHeader) Hash() cmtbytes.HexBytes {
// 32 bytes long
return merkle.HashFromByteSlices([][]byte{
h.ConsensusMessagesHash[:],
// can be extended with other things if we need to later
})
}

func (h *Header) SetDymHeader(dh DymHeader) {
h.ConsensusMessagesHash = dh.ConsensusMessagesHash
}

func (h *Header) DymHash() cmtbytes.HexBytes {
return DymHeader{
ConsensusMessagesHash: h.ConsensusMessagesHash,
}.Hash()
}

func dymHashFr(blocks []*Block) cmtbytes.HexBytes {
// 32 bytes long
bzz := make([][]byte, len(blocks))
Expand Down
8 changes: 3 additions & 5 deletions types/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ func (b *Block) ValidateBasic() error {
}

func (b *Block) validateDymHeader() error {
if !bytes.Equal(b.Header.DymHash(), NewDymHeader(b.Data.ConsensusMessages).Hash()) {
if !bytes.Equal(b.Header.Dym.Hash(), NewDymHeader(b.Data.ConsensusMessages).Hash()) {
exp := b.Header.DymHash()
got := MakeDymHeader(b.Data.ConsensusMessages).Hash()
if !bytes.Equal(exp, got) {
return ErrInvalidDymHeaderHash
}
return nil
Expand Down Expand Up @@ -114,9 +115,6 @@ func (h *Header) ValidateBasic() error {
if len(h.ProposerAddress) == 0 {
return ErrEmptyProposerAddress
}
if err := h.Dym.ValidateBasic(); err != nil {
return fmt.Errorf("dym header: %w", err)
}

return nil
}
Expand Down

0 comments on commit 9ac05e3

Please sign in to comment.