AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 43 Bitcoin

Replace Block PartialEq/Eq derive with manual impl

Public commit record

What the developer wrote

Authored by Mitchell Bagot

95/100 · Strong
Replace Block PartialEq/Eq derive with manual impl

The PartialEq/Eq derive on Block results in incorrect equality
comparisons depending on the method of construction due to the
witness_root cache. Instead, equality for Block should be implemented
manually, comparing the header and transaction lists only.

Replace PartialEq/Eq derive with manual implementations that correctly
compare only the header and transaction lists.
Add test to kill mutants.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a bug in how Bitcoin 'Block' objects are compared for equality. The old code automatically compared every internal field, including a cached 'witness_root' value that can be missing or different depending on how the block was built. That meant two blocks with the same header and transactions could incorrectly look different, or two blocks with different cached values could look the same. The fix manually compares only the header and the list of transactions, which is the correct definition of block equality. It also adds tests to prevent the bug from returning.

Recommended action

Review downstream code that relies on Block equality or uses Block as a HashMap/BTreeMap key to ensure no logic depended on the previous incorrect behavior. The patch should be merged and backported if the affected release is stable. No immediate incident response is required.

Security signals we found

01

Incorrect equality semantics on a core consensus-adjacent data structure (Block)

02

Derived equality included a cache field (witness_root) that is not part of the canonical block identity

03

Potential for logic bugs, test failures, or incorrect caching/lookup behavior downstream

04

No direct memory-safety or cryptographic vulnerability in the diff

Risk score

Why this scored 43/100

Our methodology →
Potential impact 12/30
Exploitability 5/25
Stealth signal 8/15
Affected reach 7/15
Confidence 7/10
Evidence quality 4/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.