test(l1): add builder/validator parity check to blockchain ef-tests#6552
Draft
test(l1): add builder/validator parity check to blockchain ef-tests#6552
Conversation
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
Lines of code reportTotal lines added: Detailed view |
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.
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.
Blockchain::apply_tx_to_payloadextracts the per-tx pipeline (BAL index/checkpoint, sender/recipient touches, execute, rollback-on-err, push) out offill_transactionsso the same code path can be driven by the test runner. Pure code-motion — functionally equivalent to the previous inline body.run_builder_paritydriver intooling/ef_tests/blockchain/test_runner.rs. For each Amsterdam fixture withoutexpect_exceptionand without 4844 blob txs, builds a block from the fixture parent + txs, runsapply_system_operations→apply_tx_to_payloadover fixture txs in order → post-tx BAL bookkeeping →extract_requests→apply_withdrawals→finalize_payload, then asserts producedstate_root,transactions_root,receipts_root,withdrawals_root,requests_hash,block_access_list_hash,gas_used, andlogs_bloommatch 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:
apply_system_operationsand validator'sprepare_blockBlockchain::extract_requestsandLEVM::extract_all_requests_levmapply_plain_transactionvs validator's accumulation inLEVM::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 tofill_transactions+ "make -C tooling/ef_tests/blockchain test-builder-parity" +passes on existing Amsterdam fixturestransactions_rootinfinalize_payload→ parity reports the exact mismatch field. Verified on bal-devnet-6 (where this PR's sibling commit landed): producestransactions_root: got 0x0000…0000 expected 0x4028…f1cc. Revert before merge.