fix: handle Marshal error in CertificateResult.Hash() - #592
Open
yasinlex wants to merge 1 commit into
Open
Conversation
Previously, CertificateResult.Hash() silently ignored the error from Marshal(), which could return a hash of nil bytes if marshaling failed. This could lead to incorrect consensus decisions. Changes: - Hash() now returns ([]byte, ErrorI) instead of []byte - Updated all callers in bft/bft.go, bft/msg.go, and controller/consensus.go - Errors are properly propagated to callers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CertificateResult.Hash()silently ignored the error fromMarshal():If marshaling fails, this returns a hash of nil bytes, which could lead to incorrect consensus decisions in the BFT protocol.
Changes
lib/certificate.goHash()now returns([]byte, ErrorI)instead of[]byteMarshal()is properly propagatedbft/bft.go(6 call sites)StartProposePhase(): compute hash before struct literal, return on errorStartProposeVotePhase(): compute hash before sending voteStartPrecommitPhase(): compute hash before sending precommitStartPrecommitVotePhase(): compute hash before sending voteStartCommitPhase(): compute hash before sending commitCheckProposerAndProposal(): handle error when comparing hashesSafeNode(): handle error when validating HighQCbft/msg.goGetValidateMessageParams(): handle error when computing results hashcontroller/consensus.goImpact