Skip to content

fix(evm-tools): encode accepted transactions in t8n body - #3361

Open
skbaek wants to merge 1 commit into
ethereum:forks/amsterdamfrom
skbaek:codex/fix-t8n-body-encoding
Open

fix(evm-tools): encode accepted transactions in t8n body#3361
skbaek wants to merge 1 commit into
ethereum:forks/amsterdamfrom
skbaek:codex/fix-t8n-body-encoding

Conversation

@skbaek

@skbaek skbaek commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

t8n currently builds its emitted block body before execution with
rlp.encode([tx.rlp() for tx in self.txs]). Transaction.rlp() already
returns the complete encoded transaction, so putting those bytes directly in
another RLP list wraps legacy transactions as byte strings instead of encoding
them as inline lists. Building the body before execution also includes
transactions that t8n later reports as rejected.

This change records a transaction only after process_transaction accepts it,
then builds the body after execution using the active fork's canonical
transaction representation: legacy transactions remain inline RLP lists and
typed transactions remain envelope byte strings. It also removes the unused
duplicate body construction from the CLI JSON parser.

The regression test uses a legacy transaction, a rejected legacy transaction,
and an accepted type-2 transaction. It checks that the rejected input is
absent, the accepted legacy transaction is inline, and the type-2 envelope is
preserved.

On that case, the old output is a 307-byte, three-member body beginning
0xf90130b862f860; the new output is a 204-byte, two-member body beginning
0xf8caf860, byte-identical to Geth 1.15.6.

Found while building a t8n frontend for Jaune, a Lean 4 executable EVM specification whose conformance gate is byte-exact against ethereum-spec-evm.

Validation

just static
just test-tests
just spec-tools

just test-tests passes with 2,080 tests passed; it is the recipe that
collects packages/testing/src/execution_testing/evm_tools/tests/test_t8n_body.py.
just spec-tools separately passes all 22 tests.

Related Issues or PRs

N/A. The separately observed trie-indexing behavior is intentionally not
changed by this PR.

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.

Cute Animal Picture

long-tailed tit

@skbaek
skbaek marked this pull request as ready for review August 11, 2026 21:38
@zexoverz

Copy link
Copy Markdown

Heads up that this needs a rebase. #3307 moved the tree while this was open, and both paths this PR touches are gone on forks/amsterdam at 3d473e8:

src/ethereum_spec_tools/evm_tools/   ->  packages/testing/src/execution_testing/evm_tools/
tests/evm_tools/                     ->  packages/testing/src/execution_testing/evm_tools/tests/

The second one matters more than a path change. I could not find any Just recipe or CI job that runs tests/evm_tools. just spec-tools runs tests/spec_tools, just test-tests runs the packages/testing tree, and the other recipes point at tests/json_loader, tests/ported_static and tests/benchmark. So test_t8n_body.py would not have been collected where it currently sits, which is worth knowing before you read anything into the run you quoted.

On HEAD the collected home for a t8n regression test is packages/testing/src/execution_testing/evm_tools/tests/, which just test-tests picks up. The vendored fixture layout under .../evm_tools/tests/fixtures/ that came in with #3307 is a close model for the testdata files here.

I was reading #3362 and reproduced the sparse receipts trie on Prague, keys {0, 2} for a three transaction body with the middle one rejected. It is real. I am not going to open anything there since you said you would rather have maintainer direction first, and the two candidate directions push txRoot opposite ways, so it does look like a call someone else has to make.

@skbaek skbaek changed the title fix(spec-tools): encode accepted transactions in t8n body fix(evm-tools): encode accepted transactions in t8n body Aug 22, 2026
@skbaek
skbaek force-pushed the codex/fix-t8n-body-encoding branch from 0b79966 to 6d963d3 Compare August 22, 2026 21:37
@skbaek

skbaek commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

@zexoverz Thanks for the heads-up. I rebased onto the current forks/amsterdam, moved the regression test and fixtures under packages/testing/src/execution_testing/evm_tools/tests/ so they’re collected by just test-tests, and updated the Validation section. just static, just test-tests, and just spec-tools all pass locally. CI is currently awaiting workflow approval.

@danceratopz
danceratopz self-requested a review August 24, 2026 13:38
@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.53%. Comparing base (78d8b0d) to head (6d963d3).
⚠️ Report is 5 commits behind head on forks/amsterdam.

Additional details and impacted files
@@                 Coverage Diff                 @@
##           forks/amsterdam    #3361      +/-   ##
===================================================
+ Coverage            93.19%   93.53%   +0.34%     
===================================================
  Files                  624      624              
  Lines                37074    37074              
  Branches              3394     3394              
===================================================
+ Hits                 34551    34679     +128     
+ Misses                1726     1645      -81     
+ Partials               797      750      -47     
Flag Coverage Δ
unittests 93.53% <ø> (+0.34%) ⬆️

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.

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