Skip to content

Uncles are credited with difficulty without passing the full uncle rule #269

Closed

Description

@SDL-A1

Migrated from SergioDemianLerner/rustock#269 (issue by @SDL-A1, 2026-10-05).
Original: SergioDemianLerner/rustock#269

Follow-on from #268, which added the two checks that were missing entirely. The rest of the rule still is not run.

rustock_core::validation::uncles::UnclesValidationRule already implements rskj's BlockUnclesValidationRule in full — list limit, generation limit, no repeats, not an ancestor, not already used by an ancestor, a parent that is itself an ancestor, and every per-header and parent-relative rule a trunk block faces. Neither client path invokes it.

Why it is not simply wired up

The rule's AncestorSource needs two things: header(hash), which a header-only node has, and uncles_of(hash), which it does not — uncle headers arrive over the wire and are then discarded, so there is nothing to answer from. Without that, used_uncles returns an empty set and the "already used by an ancestor" clause silently passes everything.

Approach

UncleGuard (in progress on uncle-commitment-check): keep the uncle lists the wire already delivered, bounded to UNCLE_GENERATION_LIMIT plus slack, and answer uncles_of from that. A window is enough because consensus lets a block reference an uncle only within that many generations, so nothing older can change the verdict.

When the ancestry needed to judge is not all present — a skeleton chunk that has not landed, a window emptied by a restart — refuse rather than guess: credit no uncle difficulty for that block. The total is then a lower bound, which refuses a peer claiming too much rather than admitting one. ancestry_is_complete exists so the rule cannot read "this ancestor is not in the window" as "this ancestor referenced no uncles".

Applies to both manager.rs::note_proven_difficulties (ordinary sync) and snap/session.rs::on_headers_with_uncles.

Detail in /root/doc/uncle-commitment-unchecked.md, which stays off GitHub.


@SDL-A1 commented on 2026-10-06:

Expanding this: it was written deliberately vaguely on a disclosure rule that is broader than the one actually in force. rustock-only holes can be described plainly. This one is rustock-only — rsk/63 carries BlockHeadersWithUncles and rskj speaks rsk/62, so no rskj node can be sent this message.

What an attacker can do right now

After #268 the uncle list is bound to the trunk header by ommers_hash, and every uncle must carry its own valid merged-mining proof of work. So fabricated uncles no longer work. What still works is reusing real ones.

Nothing checks that an uncle has already been counted. A miner can reference the same real, valid-proof-of-work uncle under several of its own consecutive blocks, and this node credits its difficulty once per reference.

The cap is uncleListLimit (10) per block, so the claim inflates by up to 11x the trunk work actually performed — against an honest chain's measured ~1.9x. An attacker needs roughly 1.9 / 11 = 17% of the honest chain's trunk hashpower to out-claim it on this node's books, instead of more than 50%.

Also unchecked, each of which admits work from a block that is not an uncle of this chain at all:

  • the generation limit — an uncle more than 7 generations back
  • the ancestor test — a block already on the trunk, counted again as an uncle
  • the common-parent test — a header from an unrelated fork
  • the per-uncle parent-relative rules, difficulty among them

Where it bites hardest

snap/session.rs, because those figures flow into walked_difficulty → established_difficulty → the OverstatedDifficulty ceiling. A peer that inflates its uncle accounting widens the very ceiling its claim is checked against.

The approach in the issue above stands. The reason it is not a one-line wiring job is uncles_of(hash), which a header-only node cannot answer — hence #270.

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