chore(riscv-guest): More tests - #3785
Open
Filter94 wants to merge 2 commits into
Open
Conversation
Introduce l2_execution_test.zig here (relocated from the base branch, finalized to "Python reference implementation" wording from the start) alongside this PR's own unit-gap and adversarial-SSZ coverage: FTX dispatch edge cases (unknown acceptance, contract-creation filtering, absent-sender, in-block BAD_NONCE, deadline boundary, type-2/3/4 BAD_BALANCE), malformed message-log rejection, and composed L1<->L2 bridge-state reads. Generalize the shared tx fixture builder (legacy-only -> legacy/EIP-1559/EIP-4844/EIP-7702) and collapse its four near-identical per-type doc comments into one shared explanation at the module level.
… (pr2-v2) Missed when reconstructing this branch: PR2's adversarial-input tests for decodeInput's offset/bounds/ordering checks, located dynamically off the same offset-table fields the codec itself reads.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the riscv-guests/l2-execution test suite by introducing a shared transaction-fixture builder (including real secp256k1 signing) and adding new unit tests that exercise src/l2_execution.zig logic plus additional adversarial SSZ decoding cases. It also removes the now-redundant legacy-tx-only helper and updates the build/test wiring to use the new shared fixtures.
Changes:
- Added
test/tx_fixtures.zigto build deterministic, sender-recoverable signed fixtures for legacy, EIP-1559, blob (EIP-4844), and EIP-7702 transactions. - Added a comprehensive
test/l2_execution_test.zigunit-test suite forl2_execution(forced-tx dispatch, message extraction, MPT reads, and formula checks). - Hardened SSZ input decoding tests with targeted corruption scenarios and updated build/test imports to use the new fixtures module.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| riscv-guests/l2-execution/test/tx_fixtures.zig | New shared RLP builders and real signing helpers for test fixtures (legacy + typed txs). |
| riscv-guests/l2-execution/test/stateless_input_encode_test.zig | Switched legacy tx RLP helper import to the new shared tx_fixtures module. |
| riscv-guests/l2-execution/test/legacy_tx_rlp.zig | Removed legacy-only RLP encoder (superseded by tx_fixtures). |
| riscv-guests/l2-execution/test/l2_execution_test.zig | New unit tests covering l2_execution logic with deterministic fixtures and expected values. |
| riscv-guests/l2-execution/test/l2_execution_ssz_test.zig | Added adversarial-input corruption tests targeting SSZ offset/ordering/bounds behavior. |
| riscv-guests/l2-execution/test/l2_execution_range_test.zig | Refactored range tests to use shared signed-tx fixtures; added additional scenarios. |
| riscv-guests/l2-execution/src/l2_execution.zig | Clarified/expanded storage-layout and witness-semantics commentary. |
| riscv-guests/l2-execution/build.zig | Added tx_fixtures module wiring, new l2_execution_test artifact, and removed legacy helper module wiring. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+99
to
+101
| pub fn buildSignedLegacyTx(alloc: std.mem.Allocator, comptime label: []const u8, args: LegacyTxArgs) ![]const u8 { | ||
| const unsigned_rlp = try buildLegacyTxRlp(alloc, args.nonce, args.gas_price, args.gas, args.to, args.value, args.data, args.chain_id, 0, 0); | ||
| const sig = try signHash(mpt.keccak256(unsigned_rlp), fixturePrivateKey(label)); |
| // ─── Witness-backed MPT state reads (mirrors state_transition.py's L2State) ─────────────────────── | ||
| // | ||
| // Semantics (must match the Python reference implementation exactly — see Readme.md's state_transition.py docstrings): | ||
| // Semantics must match Readme.md's specification exactly (state_transition.py is its reference implementation): |
| // These tests exercise the Linea-layer logic — the FTX rolling hash, dynamicChainConfigHash, | ||
| // hashAddressList/hashDigestList, the L1->L2 bridge storage-slot math, L2->L1 message | ||
| // extraction, forced-transaction dispatch, and the witness-backed MPT account/storage reads — | ||
| // against hand-built fixtures and Python-computed expected values (see Readme.md §6.3/§6.5/§2.1). |
| // Expected bytes computed with `rollup_spec/.venv/bin/python` against the same formulas in | ||
| // `rollup_spec/src/rollup_spec/l2_execution.py` / `block.py`. | ||
|
|
||
| test "chainConfigHash matches Readme.md's §2.1 dynamicChainConfigHash formula" { |
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.
This PR implements issue(s) #
Checklist
PR.