Repository navigation
fix(storage): keep the payload verdict the finalized block's execution_optimistic flag is read from - #983
Open
pablodeymo wants to merge 4 commits into
Open
fix(storage): keep the payload verdict the finalized block's execution_optimistic flag is read from#983pablodeymo wants to merge 4 commits into
pablodeymo wants to merge 4 commits into
Conversation
…n_optimistic flag is read from From gloas a block's flag is the verdict of the latest FULL payload it builds on. For the finalized block that payload is below it, and the finality prune dropped every verdict below the checkpoint's slot, so the finalized block and every block below it read as optimistic on a synced node. A skipped epoch boundary also dropped the finalized block's own verdict, which a child on its FULL branch reads. The prune now keeps both. A block below the finalized one answers with the finalized block's flag. A restart seeds the kept verdict, and a VALID answer for a head that builds on that payload validates it, since the execution-chain walk stops at the finalized block. Closes #981
Collaborator
Author
|
/review |
AI security review: 1 finding(s) to checkReviewed by GPT, Kimi, DeepSeek. A judge model checked every one of the findings against the code.
DetailsM2. Do not inherit the finalized verdict for noncanonical blocks (medium, logic)
Pre-existing (real, but already on the base branch): 1
Cost of this review: ~$1.05 of a $30 budget (estimated from token counts). |
2 of 3 tasks
…escends from A block below the finalized one answered with the finalized block's execution_optimistic flag on its slot alone. A block of a fork that lost stays stored after finality passes its slot and can be asked for by root, so it reported the finalized chain's verdict although nothing vouched for its own fork's payloads. The flag now goes only to a block the canonical index names at its slot, which below the finalized block are its ancestors. Any other block is read on its own, as before: with its verdict pruned a gloas one reads as optimistic.
…lized block The check that a block is an ancestor of the finalized one asks the canonical index, which follows the stored head. An import moves the finalized checkpoint first and recomputes the head after. In between the index still names the old head's branch, so when finality moved to another branch a block of the old one passed for an ancestor of the finalized block and took its execution_optimistic flag. The index now has to name the finalized block as well, asked first. Until the head has followed finality no block below the finalized one takes its flag, and each is read on its own.
pablodeymo
added a commit
that referenced
this pull request
Dec 5, 2026
…n_optimistic flag is read from (#989) ## 🗒️ Description / Motivation Backport of #983 to `release/v2.0.1`, for v2.0.1. It fixes #981: on a network past Gloas, a synced node reports `execution_optimistic: true` for the finalized block and every block below it. v2.0.0 lists this under known limitations, and Hoodi reaches Gloas on December 15. `release/v2.0.1` is `v2.0.0` (`5340a088`, the commit tagged `v2.0.0-rc.3`) plus the version bump, so v2.0.1 carries the ENR fork-digest fix of that commit and this one. **#983 is not merged on `main` yet,** and this does not wait for it. The two carry the same three commits: #983's `a4379c76` and the two review fixes below, which are on #983 as `28dc63de` and `99c92cc6`. If review changes #983 further, the difference has to be ported here as well. ## What Changed `git cherry-pick a4379c7` on top of `5340a088`, the commit `release/v2.0.1` branches from. It applied without conflicts, and the patch is identical to the one in #983 (same `git patch-id`). Nothing was edited by hand. See #983 for the description of the change. `4157d593` fixes the finding of this PR's review (M3): a block below the finalized one took the finalized block's flag on its slot alone, so a stored block of a fork that lost reported the finalized chain's verdict. The flag now goes only to a block the canonical index names at its slot, which below the finalized block are its ancestors. Any other block is read on its own, as in v2.0.0. `11cb3497` fixes the finding of the second review (M4): the canonical index follows the head, and an import moves the finalized checkpoint before the head is recomputed, so a block of the old head's branch could pass for an ancestor of a finalized block on another branch. The index is now believed only once it names the finalized block too, asked first; until then no block below the finalized one takes its flag. `7fe5531a` is a merge of `release/v2.0.1` (the version bump), so CI runs on the tree the release will have. ## Correctness / Behavior Guarantees The same as #983. Two worth repeating for a patch release: - **Behavior change before Gloas:** a block the finalized one descends from answers with the finalized block's flag on every network. This differs from v2.0.0 only while the finalized block itself is optimistic (execution client still syncing). - **No storage change:** the verdicts are in memory only, so a v2.0.0 data directory is reused as it is. ## Tests Added / Run Run on this branch (`5340a088` plus the cherry-pick, before the version bump): - `cargo fmt --all -- --check` and `make lint`: clean. - `make test-consensus` and `make test-node`: passing, including the tests #983 adds. Run again on `7fe5531a` plus the review fix (the v2.0.1 tree): the same four, all passing, 4,582 tests. The new test, `a_block_of_a_losing_fork_below_finality_does_not_take_the_finalized_flag`, fails when the ancestry check is removed. Run once more on `11cb3497`: the same four, all passing, 4,583 tests. Its test, `a_block_of_the_old_heads_branch_does_not_take_the_finalized_flag`, fails when the new condition is removed. The review's two pre-existing findings (M4, the pre-gloas payload under a gloas finalized block; M1, a `VALID` answer for an EMPTY head that names the kept payload) are on the base already and are not changed here. Not run locally: `make test-ethrex` and the spec-fixture tests (`make test-beacon`); CI covers them. Not yet run against a live Gloas network. ## Related Issues / PRs - Original: #983. - Issue: #981 (closed by #983 when it merges on `main`). ## ✅ Verification Checklist - [x] Ran `make fmt` — clean - [x] Ran `make lint` (clippy with `-D warnings`) — clean - [ ] Ran `make test` (`test-consensus`, `test-node` and `test-ethrex`, at `release-fast`) — `test-consensus` and `test-node` passing; `test-ethrex` left to CI
2 of 3 tasks
…ad the finalized block builds on A gloas head with no FULL payload from the finalized block up sends, as its head hash, the payload the finalized block builds on. The verdict's walk (`payload_holder`) goes from the head down to the finalized block and finds no block carrying that hash, so a `VALID` answer for it was dropped. That payload's verdict is the one the finalized block's `execution_optimistic` flag is read from, and the head's too while no payload above it is FULL. Left `NOT_VALIDATED` (the execution client was syncing when finality passed it, or a restart seeded it `SYNCING`), the node kept reporting the finalized block and the head as optimistic, and refused attestation data for that head, until a FULL payload was validated above finality. `apply_gloas_forkchoice_verdict` now compares the head hash with that payload's own when no holder is found and the answer is `VALID`, and moves its verdict to `VALID` on a match. `INVALID` for a payload below finality is still ignored: nothing at or below finality leaves fork choice. Fixes #991.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗒️ Description / Motivation
On a network past Gloas, a synced node reported
execution_optimistic: truefor the finalized block and every block below it (#981). Seen on v2.0.0 on Sepolia and Platåberget, where it is listed under known limitations.From Gloas a block's flag is the verdict of the latest FULL payload the block builds on. For the finalized block that payload is below it, and
prune_beacon_block_payload_statusesdropped every verdict below the checkpoint's slot. A missing verdict reads asNOT_VALIDATED, so the flag turnedtrueeach time finality moved.The same prune also dropped the finalized block's own verdict when the epoch's first slot was skipped, since the block is then below the checkpoint's slot. A child on its FULL branch reads that verdict, so one unfinalized block read
trueas well (Platåberget, slot 815617 over a finalized block at 815615).What Changed
crates/storage/src/execution_optimistic.rs:is_beacon_block_optimisticis split into "where is this block's flag read from" (verdict_source, aVerdictSource) and reading it, so the prune and the API share the first half.finalized_verdict_source), because finality's sweep runs on every tick and every import and the walk decodes a block.is_finalized_ancestor, which asks the canonical index, and believes it only once it names the finalized block too).Store::beacon_finalized_payload_basenames the gloas block whose payload verdict the finalized block reads.crates/storage/src/store.rs:prune_beacon_block_payload_statusestakes the finalized root and keeps two entries below its bound: that root's own verdict and the one of the payload it builds on.crates/blockchain/src/beacon_payloads.rs:seed_resumed_payload_statusesalso seeds the payload the finalized block builds on. A resume reloads verified payloads at or above the finalized block only.mark_payloads_validatedalso validates that payload when the last block of the validated execution chain names it in its bid. The walk stops at the finalized block, one payload short.apply_gloas_forkchoice_verdictalso validates it when aVALIDanswer names it as the head hash (AVALIDforkchoiceUpdatedfor a head that builds on a payload below finality is dropped #991). A head with no FULL payload from the finalized block up sends that hash, and no block from the head down to the finalized one carries it, so the answer was dropped.crates/blockchain/src/lib.rs: the one call site of the prune.docs/rpc.md: how the flag is read at and below finality.Correctness / Behavior Guarantees
verdict_sourcedoes the same lookups in the same order as the old walk, and an unreadable block or link is still optimistic.VALIDonly when the hashes match, so a validated chain that does not build on that payload changes nothing. A verdict alreadyINVALIDis left alone.has_unvalidated_block_payloads: a kept verdict that isNOT_VALIDATEDkeeps thistrueuntil aVALIDanswer promotes it, which is what makesmark_payloads_validatedrun.true, its verdict being pruned). Found by the review of the backport, fix(storage): keep the payload verdict the finalized block's execution_optimistic flag is read from #989.503). TheVALIDanswer for that head names the kept payload itself and now promotes it.INVALIDfor a payload below finality is still ignored, since nothing at or below finality leaves fork choice. Found by fix(storage): keep the payload verdict the finalized block's execution_optimistic flag is read from #989's review (AVALIDforkchoiceUpdatedfor a head that builds on a payload below finality is dropped #991).truewhere the pruned optimistic set saidfalse.prune_beacon_optimistic_rootsstill drops a pre-gloas block below finality. At the fork boundary, a gloas finalized block that builds on an optimistic pre-gloas payload therefore reads as validated after the prune. That needs the execution client to be syncing across the fork epoch, and is the behavior before this change too.Tests Added / Run
Added, each checked to fail when its part of the fix is removed:
crates/net/rpc/src/shared/optimistic.rs:a_finalized_gloas_block_keeps_its_flag_when_finality_prunesa_finalized_gloas_block_on_an_unvalidated_payload_is_optimistica_finalized_block_below_its_checkpoint_slot_keeps_its_own_verdicta_block_below_the_finalized_one_answers_with_its_flaga_block_below_an_optimistic_pre_gloas_finalized_block_is_optimistica_block_of_a_losing_fork_below_finality_does_not_take_the_finalized_flaga_block_of_the_old_heads_branch_does_not_take_the_finalized_flagcrates/blockchain/src/beacon_payloads.rs:a_restart_seeds_the_payload_the_finalized_block_builds_ona_valid_head_validates_the_payload_the_finalized_block_builds_ona_valid_head_that_skipped_the_finalized_payload_validates_the_one_below_ita_valid_block_off_the_finalized_payload_validates_nothing_below_finalitya_valid_answer_naming_the_payload_below_finality_validates_ita_valid_answer_validates_the_payload_below_a_finalized_block_built_on_emptyno_other_answer_validates_the_payload_below_finality(a guard: it passes without the fix)crates/storage/src/store.rs:block_payload_statuses_default_to_not_validated_and_prune_below_finalitynow covers the finalized root's exemption.Run:
make fmt,make lint,make test-consensus,make test-node, all clean. Not run locally:make test-ethrexand the spec-fixture tests (make test-beacon). Not yet run against a live Gloas network.Related Issues / PRs
execution_optimisticistruefor finalized blocks on a network past Gloas #981VALIDforkchoiceUpdatedfor a head that builds on a payload below finality is dropped #991VALIDforkchoiceUpdatedfor a head that builds on a payload below finality is dropped #991 part✅ Verification Checklist
make fmt— cleanmake lint(clippy with-D warnings) — cleanmake test(test-consensus,test-nodeandtest-ethrex, atrelease-fast) —test-consensusandtest-nodepassing;test-ethrexleft to CI