Skip to content

[execution/vm] Add in-tree monad_tx_context type - #2539

Open
khordadi wants to merge 1 commit into
mainfrom
akhordadi/exe-171-port-evmc_tx_context-to-an-in-tree-monad-type
Open

khordadi wants to merge 1 commit into
mainfrom
akhordadi/exe-171-port-evmc_tx_context-to-an-in-tree-monad-type

Conversation

@khordadi

@khordadi khordadi commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Part of EXE-171 (EXE-162), reduced to the type. monad_tx_context mirrors evmc_tx_context field-for-field with bytes32_t/Address members, including the fork's block_round; tx_context.cpp asserts layout, field offsets and integer field types. Purely additive, nothing references the type yet.

The producer migration moves into the vm::Host port, EXE-173. With get_tx_context returning the in-tree type the host holds no evmc_tx_context copy, which this PR's earlier shape needed (256 bytes per host instance).

Verification. gcc-15 RelWithDebInfo build clean; clang-format-19 and clang-tidy-19 on the new files clean. tx_context.cpp includes <evmc/evmc.h> exactly as revision.cpp and status_code.cpp already do, so the zkVM guest sees nothing new.

Conflicts trivially with #2540 on category/vm/evm/CMakeLists.txt; whichever lands first, the other rebases.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 5, 2026 00:11

@khordadi khordadi left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Notes for the reviewer on the non-obvious lines.

Comment thread category/vm/evm/tx_context.hpp
Comment thread category/vm/evm/tx_context.cpp

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.

🟢 Approval recommended

The refactor keeps evmc confined to the host vtable boundary and includes strong compile-time layout checks plus updated call sites/tests with no evident correctness regressions.

Pull request overview

Ports transaction-context producers to an in-tree monad_tx_context while keeping evmc_tx_context at the vm::Host vtable boundary (via a single by-value copy in EvmcHostBase). This continues the repo-wide effort to push the evmc dependency toward leaf ABI boundaries without changing live execution behavior.

Changes:

  • Added monad_tx_context and a to_evmc_tx_context() bridge, with compile-time layout/offset verification against evmc_tx_context.
  • Updated get_tx_context() / system_call() producers to build/return monad_tx_context, and updated EvmcHostBase to store an internal evmc_tx_context copy for the vtable slot.
  • Updated affected tests/utilities and a couple of comments to reference monad_tx_context.

Verdict: CORRECT

File summaries
File Description
test/vm/utils/test_host.hpp Switch test host’s stored tx context to monad_tx_context.
category/vm/evm/tx_context.hpp Introduce monad_tx_context and declare to_evmc_tx_context bridge.
category/vm/evm/tx_context.cpp Prove layout parity with evmc_tx_context and implement std::bit_cast bridge.
category/vm/evm/CMakeLists.txt Add new tx-context sources to monad-vm-evm target.
category/rpc/monad_executor.cpp Update comment to reference monad_tx_context.block_round.
category/execution/runloop/runloop_monad.cpp Update comment to reference monad_tx_context.block_round.
category/execution/monad/reserve_balance/reserve_balance_contract_test.cpp Use monad_tx_context in test setup.
category/execution/ethereum/tx_context.hpp Change EMPTY_TX_CONTEXT and API to monad_tx_context.
category/execution/ethereum/tx_context.cpp Produce monad_tx_context from get_tx_context().
category/execution/ethereum/test/test_call_trace.cpp Update tests to use monad_tx_context.
category/execution/ethereum/process_requests.cpp Build monad_tx_context for system_call() execution path.
category/execution/ethereum/evmc_host.hpp Store an evmc_tx_context by value; accept monad_tx_context in ctor.
category/execution/ethereum/evmc_host.cpp Construct the stored evmc_tx_context via to_evmc_tx_context().
category/execution/ethereum/evmc_host_test.cpp Update comparison helper and expected context type to monad_tx_context.
category/execution/ethereum/block_hash_history_test.cpp Update test to use monad_tx_context result type.

🤖 Generated with Claude Code

Review details
  • Files reviewed: 15/15 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread category/vm/evm/tx_context.hpp Outdated

@github-actions github-actions Bot 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.

Reviewed per REVIEW.md. The port is clean: layout compatibility between monad_tx_context and evmc_tx_context is pinned exhaustively at compile time (total size, per-field offsets, integer field types — a reorder or dropped field fails the build); the switch from a reference member to a by-value evmc_tx_context copy in EvmcHostBase is safe at every construction site (all callers build a local const context and never mutate it after constructing the host, and the copy removes a dangling-reference hazard rather than adding one); the updated sizeof static_asserts (328/392) match the 8-byte-reference-to-264-byte-value change; the VM consumer side is deliberately untouched per the staging described for EXE-173; and category/vm/evmcategory/core is an established dependency (delegation.hpp already includes category/core/address.hpp, and the target links monad_core PUBLIC). Single-commit PR, rebased on main, no FFI or RLP surface touched.

One non-blocking inline comment: to_evmc_tx_context should be noexcept, since it is invoked from a noexcept constructor's member-init list.

Verdict: CORRECT

🤖 Generated with Claude Code

@khordadi
khordadi force-pushed the akhordadi/exe-171-port-evmc_tx_context-to-an-in-tree-monad-type branch from 9608478 to c1d9357 Compare September 9, 2026 09:53
Comment thread category/execution/ethereum/evmc_host.hpp Outdated
@khordadi
khordadi force-pushed the akhordadi/exe-171-port-evmc_tx_context-to-an-in-tree-monad-type branch 2 times, most recently from 4b6a751 to b097d3a Compare September 15, 2026 13:38
@khordadi khordadi changed the title [execution/vm] Port evmc_tx_context producers to in-tree monad_tx_context [execution/vm] Add in-tree monad_tx_context type Sep 15, 2026
@khordadi
khordadi force-pushed the akhordadi/exe-171-port-evmc_tx_context-to-an-in-tree-monad-type branch from b097d3a to 85d3732 Compare September 18, 2026 11:16
EXE-171, part of EXE-162. monad_tx_context mirrors evmc_tx_context
field-for-field with bytes32_t/Address members, including the fork's
block_round. tx_context.cpp asserts standard layout, sizeof, alignof, the
offsetof of all 15 fields and the exact type of the six integer fields. The
header has no evmc include.

Purely additive; nothing references the type yet. The producer migration goes
with the vm::Host port (EXE-173), where get_tx_context returns the in-tree
type and the host holds no evmc copy.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@khordadi
khordadi force-pushed the akhordadi/exe-171-port-evmc_tx_context-to-an-in-tree-monad-type branch from 85d3732 to fe4b98d Compare September 18, 2026 14:44
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.

3 participants