Skip to content

test(l1): add builder/validator parity check to blockchain ef-tests#6552

Draft
edg-l wants to merge 1 commit intomainfrom
feat/builder-parity-ef-tests
Draft

test(l1): add builder/validator parity check to blockchain ef-tests#6552
edg-l wants to merge 1 commit intomainfrom
feat/builder-parity-ef-tests

Conversation

@edg-l
Copy link
Copy Markdown
Contributor

@edg-l edg-l commented Apr 30, 2026

Summary

Cross-checks ethrex's block builder against the same EEST fixtures the validator already runs. For each Amsterdam fixture, the builder constructs a block from the fixture's parent + transactions and the produced header is compared to the expected fixture header.

  • New Blockchain::apply_tx_to_payload extracts the per-tx pipeline (BAL index/checkpoint, sender/recipient touches, execute, rollback-on-err, push) out of fill_transactions so the same code path can be driven by the test runner. Pure code-motion — functionally equivalent to the previous inline body.
  • New run_builder_parity driver in tooling/ef_tests/blockchain/test_runner.rs. For each Amsterdam fixture without expect_exception and without 4844 blob txs, builds a block from the fixture parent + txs, runs apply_system_operationsapply_tx_to_payload over fixture txs in order → post-tx BAL bookkeeping → extract_requestsapply_withdrawalsfinalize_payload, then asserts produced state_root, transactions_root, receipts_root, withdrawals_root, requests_hash, block_access_list_hash, gas_used, and logs_bloom match the fixture header.

Off by default (feature + "builder-parity" + ). Run with:

+ "```" +
make -C tooling/ef_tests/blockchain test-builder-parity
+ "```" +

Why

The validator never constructs a header from scratch — it only validates pre-built ones. That leaves a class of builder-side bugs uncaught:

  • Builder-side header construction (the eight fields above)
  • System-call drift between builder's apply_system_operations and validator's prepare_block
  • Request-extraction drift between Blockchain::extract_requests and LEVM::extract_all_requests_levm
  • Builder-side gas accumulation in apply_plain_transaction vs validator's accumulation in LEVM::execute_block*

The two-pass-parallel test only exercises the validator paths. This PR adds the builder-side cross-check.

Test plan

  • + "make -C tooling/ef_tests/blockchain test" + (default) still passes — no behavioural change to fill_transactions
  • + "make -C tooling/ef_tests/blockchain test-builder-parity" + passes on existing Amsterdam fixtures
  • Sabotage smoke check: temporarily zero out transactions_root in finalize_payload → parity reports the exact mismatch field. Verified on bal-devnet-6 (where this PR's sibling commit landed): produces transactions_root: got 0x0000…0000 expected 0x4028…f1cc. Revert before merge.

Extract the per-tx pipeline out of `fill_transactions` into
`Blockchain::apply_tx_to_payload` so the builder logic (BAL
index/checkpoint, sender/recipient touches, execute, rollback-on-err)
can be driven from outside the mempool loop.

Wire a feature-gated `run_builder_parity` driver into the blockchain
ef-test runner: for each Amsterdam fixture with no expected exception
and no 4844 txs, build a block from the fixture's parent + txs and
assert the produced state_root, transactions_root, receipts_root,
withdrawals_root, requests_hash, block_access_list_hash, gas_used and
logs_bloom match the fixture header.

Off by default (feature \`builder-parity\`); run via:
  make -C tooling/ef_tests/blockchain test-builder-parity

Catches drift between builder and validator on:
- Builder-side header construction (the validator never builds a header)
- System-call drift between `apply_system_operations` and `prepare_block`
- Request extraction drift between `Blockchain::extract_requests` and
  `LEVM::extract_all_requests_levm`
- Builder-side gas accumulation
@github-actions github-actions Bot added the L1 Ethereum client label Apr 30, 2026
@github-actions
Copy link
Copy Markdown

Lines of code report

Total lines added: 10
Total lines removed: 0
Total lines changed: 10

Detailed view
+-------------------------------------+-------+------+
| File                                | Lines | Diff |
+-------------------------------------+-------+------+
| ethrex/crates/blockchain/payload.rs | 823   | +10  |
+-------------------------------------+-------+------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L1 Ethereum client

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant