Skip to content

Check the uncle commitment and proof of work before crediting difficulty #268

Closed

Description

@SDL-A1

Migrated from SergioDemianLerner/rustock#268 (pull request by @SDL-A1, 2026-10-05).
Merged: yes. The commits are already in this repository's history.
Original: SergioDemianLerner/rustock#268

HeaderWithUncles::commitment_matches existed, its doc comment called it "the whole security argument for the message", and it was called in exactly one place: the server side, on what this node sends out.

Neither client path called it.

Both took cumulative_difficulty() — the sender's arithmetic over the uncles the sender chose to send — and recorded it as proven:

path where it lands
manager.rs (ordinary sync) the total difficulty recorded for a header, which is the input to chain selection
snap/session.rs walked_difficulty → established_difficulty → the OverstatedDifficulty ceiling

The second is the worse of the two: fabricated uncles would widen the one guard against an overstated claim.

Two checks, neither implying the other

  • ommers_hash is inside what the trunk header's proof of work commits to, so a list matching it cannot have been added to, dropped from or altered.
  • Each uncle's own merged-mining proof of work, because a matching commitment only proves the block's miner chose this list — not that the difficulty each uncle states was ever performed.

Failure is in the safe direction

A header failing either check still goes through as a bare header; only its uncle-derived difficulty is withheld. That understates the chain rather than overstating it, and understated is the direction that refuses a liar rather than admitting one.

Exposure

Bounded: rsk/63 carries this message and rskj speaks rsk/62, so only rustock peers could send it. That stops being true if rskj adopts RSKIP-698.

Tests

Two, one per check, each asserting the difficulty is not credited — a forged uncle list, and a committed uncle with no valid proof of work.

2,035 workspace tests pass.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions