Skip to content

Total difficulty can be stored lower than before without fork choice re-weighing #387

Open

Description

@SDL-A1

From the external review of #374.

total_difficulty::settle can store a total difficulty lower than what was
stored before, and fork choice does not re-weigh afterwards.

Total difficulty is the tiebreak that decides which branch wins. If a stored
value can decrease without fork choice reconsidering, a branch can keep a
position it would no longer earn on a fresh comparison.

Why it is filed Low

The reviewer did not demonstrate a reachable case, and nothing observed on
mainnet points at it. It is a shape-level concern about an invariant — "stored
total difficulty is monotonic for a given block" — that may simply not hold any
more.

What would settle it

State the intended invariant in settle's doc comment, then either enforce it or
trigger a fork-choice re-evaluation when a stored value decreases. A test that
settles a lower value and asserts the resulting head is the one we want would pin
whichever answer is correct.

Related: #258 (OverstatedDifficulty ceiling omits uncle work) and #253 (the
sampled difficulty bound runs only in snapshot sync) touch the same machinery.

Reported by the external reviewer; the anchor is theirs and has not been
re-derived here.

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