You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The sampled difficulty bound runs only in snapshot sync, not in ordinary peer selection #253
The free half is in the Status handler (handler.rs), so it applies to every
peer on every connection. The sampled half exists only as Phase::SamplingClaim in snap/session.rs; ordinary sync never constructs a SamplingGate.
Why that is the wrong way round
The free half secures nothing against an adversary — the sidestep is to claim
a height above the checkpoint, which is what an attacker wants to claim anyway
(see docs/difficulty-gate.md). So on the ordinary sync path, a peer claiming
any height above #9,020,000 has its total difficulty accepted into
peer-selection metadata with no bound on it at all.
That matters more for ordinary sync than for snapshot sync, because of what the
claim is used for:
snapshot sync — the claim picks a checkpoint, and the header walk then
verifies the entire chain behind it. A lie is caught, expensively.
ordinary sync — the claim drives peer selection and best-chain comparison
continuously, with no walk-to-genesis behind it. The node simply prefers
whoever claims most.
So the only place the sampled bound runs is the place that already has a
thorough verification behind it, and the place with no backstop gets only the
check an attacker steps around for free.
The fix
Make the sampled bound available to ordinary peer selection, not only to a
snapshot session. The sampler is per-peer and costs requests, so when it runs
is a policy question — on first hearing a claim, on a claim that would change
the best peer, or on a schedule — but it should be reachable from the path
where the claim actually steers the node.
Configuration
This and #252 are two switches, and the matrix the user specified is:
check checkpoint hash
bound work + sample
result
no
no
no defence
yes
no
good defence
no
yes
good defence, and does not ask core developers to choose a fork in code
yes
yes
strongest
The second switch covers the cumulative-difficulty bound and the sampling
together, and they must not be separable: bounding without sampling is the free
half, which secures nothing. Enabling "check the bound" alone would be an
option that looks like a defence and is not.
Activity