-
Notifications
You must be signed in to change notification settings - Fork 596
Call SetFinality when processing a milestone #2226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,14 @@ func (h *ethHandler) handleMilestone(ctx context.Context, eth *Ethereum, milesto | |
|
|
||
| h.downloader.ProcessMilestone(num, hash) | ||
|
|
||
| // Publish the milestone block as finalized and safe. Re-resolve via the | ||
| // canonical number→hash mapping so a reorg between verification and this | ||
| // write can't promote a stale or non-canonical header. | ||
| if block := eth.blockchain.GetBlockByNumber(num); block != nil && block.Hash() == hash { | ||
| eth.blockchain.SetFinalized(block.Header()) | ||
| eth.blockchain.SetSafe(block.Header()) | ||
| } | ||
|
Comment on lines
+131
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 This PR's first non-nil Extended reasoning...The bug: Why this PR activates a dormant path: Before this PR, Why this defeats the PR's own explicit decision: The PR originally also called Concrete walkthrough:
Why nothing in the current code prevents this: Impact: This is a semantic/observability inconsistency, not a crash or fund-loss bug — the resulting Suggested fix: Either explicitly clear
Comment on lines
+131
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 SetFinalized(block.Header()) is called unconditionally whenever a milestone's end block resolves to a canonical block, with no check that the new finalized number is >= the currently stored CurrentFinalBlock(). Because MultiHeimdallClient (and the WS failover client) can fail over to a lagging heimdall endpoint, a stale-but-still-canonical milestone could regress currentFinalBlock, the persisted finalized hash, and headFinalizedBlockGauge. This was already flagged as a non-blocking suggestion in an earlier review pass (suggestion #3); a simple Extended reasoning...The gap:
Trigger path: Bor supports Step-by-step proof:
Why this doesn't block merge: Suggested fix: guard the call with a simple monotonicity check, as already suggested non-blockingly in the original review thread: if block := eth.blockchain.GetBlockByNumber(num); block != nil && block.Hash() == hash {
if current := eth.blockchain.CurrentFinalBlock(); current == nil || block.NumberU64() > current.Number.Uint64() {
eth.blockchain.SetFinalized(block.Header())
}
}This is a one-line robustness improvement, not a correctness-blocking fix, since nothing durably breaks if it's omitted.
Comment on lines
+131
to
+136
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 The block comment above the SetFinalized call still says the milestone block is published as "finalized and safe", but the SetSafe call was removed per reviewer request (Bor has no soft finality), leaving only SetFinalized. Please drop "and safe" from the comment so it matches the code. Extended reasoning...What the bug is: The comment at // Publish the milestone block as finalized and safe. Re-resolve via the
// canonical number→hash mapping so a reorg between verification and this
// write can'\''t promote a stale or non-canonical header.but the code beneath it only calls How this happened: Looking at the PR timeline, the original version of this diff called both Why this matters: A future reader of this function — without access to the PR discussion — will read "Publish the milestone block as finalized and safe" and reasonably conclude that safe-block tracking happens here. That'''s exactly the kind of incorrect assumption @kamuikatsurgi'''s review comment was trying to prevent (teams making decisions based on Step-by-step proof:
Fix: Simply update the comment to remove "and safe", e.g.: This is purely a documentation/comment mismatch — no runtime, correctness, or security impact, and does not block merge. |
||
|
|
||
| return nil | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.