Skip to content

feat(tests): add type-0 transaction RLP validity tests#3156

Open
chfast wants to merge 1 commit into
ethereum:forks/amsterdamfrom
chfast:invalid-tx-rlp-tests
Open

feat(tests): add type-0 transaction RLP validity tests#3156
chfast wants to merge 1 commit into
ethereum:forks/amsterdamfrom
chfast:invalid-tx-rlp-tests

Conversation

@chfast

@chfast chfast commented Jul 13, 2026

Copy link
Copy Markdown
Member

Description

Port the core malformation classes of the legacy TransactionTests suites (ttWrongRLP, ttNonce, ttValue, ttRSValue, ttVValue, ttAddress), which were never converted because the ported-static pipeline only handles state-test fillers and the raw malformed bytes cannot round-trip through a structured transaction model.

A local RLP encoder builds each corruption deliberately, since a correct encoder cannot emit non-canonical forms: per-field leading zeros, 33-byte field overflows, 19 and 21 byte addresses, fields encoded as lists, structural corruptions of the outer list (truncation, trailing bytes, wrong element counts, header size mismatches, size with leading zeros), and well-encoded but invalid signature values. A valid re-encoded control case anchors the encoder to the framework's byte-exact output.

The transaction_test fixture format records the declared exception without consulting the transition tool, so all 30 cases were verified externally by feeding the generated fixture bytes through EELS decode_transaction, recover_sender and validate_transaction at Frontier, London and Cancun: every invalid vector is rejected and the control is accepted with the matching sender. Notably the gas limit and gas price are unbounded scalars in the spec, so their oversized encodings are valid at the transaction level; the overflow cases cover the 256-bit bounded fields (nonce, value, r, s) only.

Related Issues or PRs

N/A.

Checklist

  • Ran fast static checks to avoid CI fails, see Code Standards & Verifying Changes: just static
  • PR title has the form <type>(<area>): <title>, where <type> and <area> come from an appropriate C-<type>, respectively A-<area>, label. The title should match the target squash commit message.

Port the core malformation classes of the legacy TransactionTests
suites (ttWrongRLP, ttNonce, ttValue, ttRSValue, ttVValue, ttAddress),
which were never converted because the ported-static pipeline only
handles state-test fillers and the raw malformed bytes cannot
round-trip through a structured transaction model.

A local RLP encoder builds each corruption deliberately, since a
correct encoder cannot emit non-canonical forms: per-field leading
zeros, 33-byte field overflows, 19 and 21 byte addresses, fields
encoded as lists, structural corruptions of the outer list (truncation,
trailing bytes, wrong element counts, header size mismatches, size
with leading zeros), and well-encoded but invalid signature values.
A valid re-encoded control case anchors the encoder to the framework's
byte-exact output.

The transaction_test fixture format records the declared exception
without consulting the transition tool, so all 30 cases were verified
externally by feeding the generated fixture bytes through EELS
decode_transaction, recover_sender and validate_transaction at
Frontier, London and Cancun: every invalid vector is rejected and the
control is accepted with the matching sender. Notably the gas limit
and gas price are unbounded scalars in the spec, so their oversized
encodings are valid at the transaction level; the overflow cases cover
the 256-bit bounded fields (nonce, value, r, s) only.
@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.31%. Comparing base (0f8b81b) to head (8cd3353).
⚠️ Report is 3 commits behind head on forks/amsterdam.

Additional details and impacted files
@@               Coverage Diff                @@
##           forks/amsterdam    #3156   +/-   ##
================================================
  Coverage            93.30%   93.31%           
================================================
  Files                  624      624           
  Lines                36991    36994    +3     
  Branches              3384     3384           
================================================
+ Hits                 34515    34521    +6     
+ Misses                1694     1693    -1     
+ Partials               782      780    -2     
Flag Coverage Δ
unittests 93.31% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danceratopz danceratopz self-assigned this Jul 13, 2026

@danceratopz danceratopz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @chfast! I think we have a bit of work to do regarding awareness of and ease of consuming the transaction_test format. Could you test these against evmone? If so, mind sharing how?

The other way to run transaction_test is via hive execute. I think we have a bit of work to do if that's the goal. No need to dive into this now, I'm not sure that should be the goal for these (invalid) tests, that should get rejected at the JSON RPC layer.

@danceratopz danceratopz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added some suggestions here chfast#2. Thanks!

@chfast

chfast commented Jul 14, 2026

Copy link
Copy Markdown
Member Author

This is discussion starter for transaction decoding testing. I don't consume the transaction tests in evmone, but I plan to do so soon as I'm adding full transaction decoding capability. But this seems to be working with evmone t8n.

The alternative to specific transaction_test format is to reuse state_test format. However, then you can only have txbytes representation of the transaction (no transaction decomposed to a JSON object). For me this is fine as well as I plan to add exactly support for txbytes in evmone. I believe some Clients should be already compatible.

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