Repository navigation
fix(validation): bind sections to the header's roots in apply_state - #23
Open
cafebedouin wants to merge 1 commit into
Open
cafebedouin wants to merge 1 commit into
cafebedouin wants to merge 1 commit into
Conversation
Both validators parsed the transactions and extension sections without comparing them to header.transaction_root / header.extension_root. Any body that reached validation by a route other than the bound receive path — a store written before v0.8.2, a direct caller, the conformance runners — was applied as-is. Recompute both roots via enr_chain (the workspace's single implementations) and reject mismatches as TransactionsRootMismatch / ExtensionRootMismatch (JVM bsCorrespondsToHeader). Test fixtures carried zero roots; they now bind them (test_support:: bind_roots; block_version_gate.rs binds per test). New tests: honest body applies, reordered transactions rejected, tampered extension rejected. facts/validation.md gains the seam's contract; CHANGELOG under Unreleased.
This was referenced Sep 16, 2026
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.
Branch:
ergo-logic/apply-root-binding(from5b8e6f3). Files:validation/Cargo.toml,validation/src/{lib,sections,utxo,digest,test_support}.rs,validation/tests/block_version_gate.rs,facts/validation.md,Cargo.lock.Why
Both validators parse the transactions and extension sections without comparing them to
header.transaction_root/header.extension_root. The receive path binds peer deliveries at thestore write since v0.8.2, so today this is reachable by any route that bypasses that write: a store
populated before v0.8.2 (see the companion rebind PR, #24), a direct caller, and the conformance runners.
Executed through
SANTA's block tier on the captured testnet block 2666: three tampered extensions (a flipped value, a
65-byte value, a duplicate key) validate with the identical post-digest and cost; arkadianet/ergo
rejects all three from its own validator (
ExtensionRootMismatch).What
sections::check_section_roots(header, &parsed_txs, &parsed_ext)runs right after parsing in bothapply_statepaths; roots come fromenr_chain::transactions_root/extension_root(the singleworkspace implementations, per v0.8.2's changelog). New errors
TransactionsRootMismatch/ExtensionRootMismatch, clean rejections. The transactions root is recomputed withheader.version,not the version the body declares about itself (
ParsedBlockTransactions::block_version, read fromthe body's own wire bytes): that flag decides whether witness leaves fold into the root, and the
header is the verified side of the comparison.
validationgains a path-dep onenr-chain(nocycle:
chaindepends on neithervalidationnorstate).Tests
Fixtures carried zero roots; they now bind them (
test_support::bind_roots;block_version_gate.rsbinds per test so each still reaches the gate it targets). New:
section_root_binding:: {honest_body_still_applies, reordered_transactions_are_rejected, tampered_extension_is_rejected}.cargo test -p ergo-validation: 69 + 2 + 4 + 3 passed, 0 failed (re-run after theheader.versionchange; workspace run on the prior revision: every crate green, 0 failures).Contract
facts/validation.md§ "Section-to-header binding at apply". Relation tofacts/receive-path.md:the store binds the network sink; this is the validation seam's own guarantee.
Changelog entry
Not in the patch (your repo instructions reserve
CHANGELOG.mdfor the main session, and four PRsinserting an Unreleased block at the same spot conflict with each other). Text, if useful:
🤖 Generated with Claude Code