Skip to content

chore(riscv-guest): More tests - #3785

Open
Filter94 wants to merge 2 commits into
test/l2-exec-guest-coverage-pr1-v2from
test/l2-exec-guest-coverage-pr2-v2
Open

chore(riscv-guest): More tests#3785
Filter94 wants to merge 2 commits into
test/l2-exec-guest-coverage-pr1-v2from
test/l2-exec-guest-coverage-pr2-v2

Conversation

@Filter94

Copy link
Copy Markdown
Contributor

This PR implements issue(s) #

Checklist

  • I wrote new tests for my new core changes.
  • I have successfully ran tests, style checker and build against my new changes locally.
  • If this change is deployed to any environment (including Devnet), E2E test coverage exists or is included in this
    PR.
  • I have informed the team of any breaking changes if there are any.

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.
Copilot AI lite review requested due to automatic review settings August 13, 2026 09:37
@Filter94 Filter94 changed the title Test/l2 exec guest coverage pr2 v2 chore(riscv-guest): More tests Aug 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.zig to build deterministic, sender-recoverable signed fixtures for legacy, EIP-1559, blob (EIP-4844), and EIP-7702 transactions.
  • Added a comprehensive test/l2_execution_test.zig unit-test suite for l2_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" {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants