Skip to content

The difficulty gate credits the checkpoint's work to peers that are not on that chain #252

Closed

Description

@SDL-A1

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

What is missing

Nothing ever checks that a peer's chain contains the checkpoint block.

ChainSampler::new takes skeleton entries the peer supplied, requests
samples by the hashes the peer named, and offer verifies each sampled
header's own proof of work. checkpoint.hash is never compared against
anything a peer sent — its only use anywhere is audit_own_chain, which checks
this node's chain.

Why that matters

ceiling_for starts from checkpoint.cumulative_difficulty and adds bounded
work above it. That base is the real chain's accumulated work, and it is
credited to any peer, including one on a fork that diverged below the
checkpoint and never did it.

On mainnet the work below the checkpoint is over 99% of the cumulative total.
So the ceiling a fabricated chain gets is within a fraction of a percent of the
ceiling the honest chain gets, and the gate cannot separate them.

Concretely: fork below the checkpoint, mine cheap low-difficulty blocks, raise
difficulty after the checkpoint height. The sampled half does constrain the
part above — those headers carry real proof of work at their stated
difficulties, and the retarget rule limits how fast difficulty can climb — but
the 99% underneath is handed over unproven.

The module header half-admits this ("It does not say which chain a peer is
on, only how much work it may claim") without drawing the consequence.

What stops the attack today

The header walk, not the gate: it verifies from the checkpoint down to ground
this node already holds, and a fork that diverged below will not link. The gate
is a pre-filter against overstated claims; it was never what catches
fabricated-but-self-consistent ones.

That is fine as a division of labour, but it means the gate is doing less than
its name suggests, and the walk costs hours where the gate costs seconds.

The fix

Ask the peer for the header at checkpoint.number and check
hash == checkpoint.hash. One request. If it does not match, the peer is
not on the checkpointed chain, the checkpoint's work does not apply to it, and
the base should be zero rather than ~33e27.

That turns the question from "how much work could any chain carry" into "how
much work could your chain carry", which is what the gate is named for.

Why this is a separate configuration option

Verifying the hash means shipping a statement about which chain is canonical,
which is a governance decision, not only a technical one — it asks core
developers to pick a fork in code. Bounding the work does not.

So the two belong behind separate switches, and a deployment should be able to
take the work bound without taking the fork declaration. See the companion
issue for the option matrix.

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