Skip to content

Bletner/runtime header refactor#2050

Merged
andreaslyn merged 1 commit intomainfrom
bletner/runtime_header_refactor
Feb 27, 2026
Merged

Bletner/runtime header refactor#2050
andreaslyn merged 1 commit intomainfrom
bletner/runtime_header_refactor

Conversation

@brett-monad
Copy link
Copy Markdown
Contributor

No description provided.

@brett-monad brett-monad force-pushed the bletner/runtime_header_refactor branch 2 times, most recently from aac2e28 to 2e275f2 Compare February 4, 2026 23:42
@brett-monad brett-monad marked this pull request as ready for review February 5, 2026 01:58
Copy link
Copy Markdown

Copilot AI left a comment

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 refactors the VM runtime code by moving function implementations from header files to separate compilation units. The primary goal is to reduce header bloat and improve compilation times by separating interface declarations from implementations.

Changes:

  • Moved template and inline function implementations from .hpp to new .cpp files for storage, selfdestruct, memory, log, keccak, environment, data, create, and call modules
  • Renamed top-level functions monad::create and monad::call to monad::execute_create_message and monad::execute_call_message for clarity
  • Refactored anonymous namespace usage in evm.cpp from macro-based to explicit namespace syntax

Reviewed changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
category/vm/runtime/storage.hpp Converted inline implementations to forward declarations
category/vm/runtime/storage.cpp Added implementations with EXPLICIT_TRAITS for template instantiation
category/vm/runtime/selfdestruct.hpp Converted inline implementation to forward declaration
category/vm/runtime/selfdestruct.cpp Added implementation with EXPLICIT_TRAITS
category/vm/runtime/memory.hpp Converted inline implementations to forward declarations
category/vm/runtime/memory.cpp Added implementations with EXPLICIT_TRAITS
category/vm/runtime/log.hpp Converted inline implementations to forward declarations
category/vm/runtime/log.cpp Added implementations with EXPLICIT_TRAITS
category/vm/runtime/keccak.hpp Moved implementation to .cpp and removed ethash include from header
category/vm/runtime/keccak.cpp Added implementation with ethash include
category/vm/runtime/environment.hpp Converted inline implementations to forward declarations
category/vm/runtime/environment.cpp Added implementations for blockhash, selfbalance, and blobhash
category/vm/runtime/data.hpp Converted inline implementations to forward declarations
category/vm/runtime/data.cpp Added implementations with EXPLICIT_TRAITS for templated functions
category/vm/runtime/create.hpp Converted inline implementations to forward declarations
category/vm/runtime/create.cpp Added implementations with EXPLICIT_TRAITS
category/vm/runtime/call.hpp Converted inline implementations to forward declarations
category/vm/runtime/call.cpp Added implementations with EXPLICIT_TRAITS
category/vm/runtime/CMakeLists.txt Added all new .cpp files to build system
test/vm/unit/runtime/fixture.cpp Updated includes, added ethash/keccak.hpp and span
category/execution/ethereum/evm.hpp Renamed create/call to execute_create_message/execute_call_message
category/execution/ethereum/evm.cpp Updated function names and refactored anonymous namespace syntax
category/execution/ethereum/evmc_host.hpp Updated function calls to use new names
category/execution/ethereum/execute_transaction.cpp Updated function calls to use new names
category/execution/ethereum/evm_test.cpp Updated all test calls to use new function names

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread category/vm/runtime/call.cpp Outdated
@brett-monad brett-monad force-pushed the bletner/runtime_header_refactor branch from 2e275f2 to 8142db5 Compare February 5, 2026 15:15
Comment thread category/execution/ethereum/evm.cpp
Comment thread category/execution/ethereum/evm.cpp
Comment thread category/vm/runtime/call.cpp Outdated
Comment thread category/vm/runtime/call.hpp
Comment thread category/vm/runtime/create.hpp Outdated
Comment thread category/vm/runtime/environment.cpp Outdated
Comment thread category/vm/runtime/environment.cpp
Baltoli
Baltoli previously requested changes Feb 6, 2026
Copy link
Copy Markdown
Contributor

@Baltoli Baltoli left a comment

Choose a reason for hiding this comment

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

Minor nits above

Comment thread category/vm/runtime/call.hpp Outdated
Copy link
Copy Markdown
Contributor

@andreaslyn andreaslyn left a comment

Choose a reason for hiding this comment

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

Performance of some of these runtime functions is potentially negatively affected by not getting inlined. Can you find a representative set of micro benchmarks and report the before and after numbers?

@brett-monad brett-monad force-pushed the bletner/runtime_header_refactor branch 3 times, most recently from f06849c to 47b9dcf Compare February 27, 2026 00:00
Comment thread category/vm/runtime/call.hpp Outdated
Comment thread category/vm/runtime/create.hpp Outdated
Comment thread category/vm/runtime/data.hpp Outdated
Comment thread category/vm/runtime/log.hpp Outdated
Comment thread category/vm/runtime/selfdestruct.hpp Outdated
Comment thread category/vm/runtime/storage.hpp Outdated
@brett-monad brett-monad force-pushed the bletner/runtime_header_refactor branch 2 times, most recently from 66b7751 to 1ce8637 Compare February 27, 2026 14:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 23 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

andreaslyn
andreaslyn previously approved these changes Feb 27, 2026
Refactor category/vm/runtime to separate interface from implementation while maintaining performance for hot-path functions and minimizing header dependencies.

Implementation separation:
- Create 7 new .cpp files (call, data, create, log, environment, selfdestruct, storage)
- Move large function implementations from .hpp to .cpp files
- Apply EXPLICIT_TRAITS macro for template instantiation across EVM and Monad traits
- Update CMakeLists.txt to build new .cpp files

Performance optimizations:
- Keep critical hot-path functions as inline in headers:
  * Memory operations: mload, mstore, mstore8, mcopy
  * Transient storage: tload, tstore
  * Hashing: sha3
  * Data access: calldataload
  * Call helpers: message_flags
- Enable compiler inlining at call sites for frequently-executed operations
- Avoid cross-translation-unit call overhead for performance-critical paths

Header dependency cleanup:
- Remove unused includes from headers (assert.h, evmc.hpp, limits, array)
- Move implementation-only includes to .cpp files (delegation.hpp, storage_costs.hpp, uint256.hpp)
- Remove unnecessary forward declarations
- Headers now only include what they need for declarations and inline implementations
- Improves compilation times by reducing transitive dependencies

Additional changes:
- Fix fixture.cpp to include ethash/keccak.hpp directly
- Rename monad::call/create to execute_call_message/execute_create_message
- Update evm_test.cpp to use renamed functions
- Re-add explicit instantiations in evm.cpp
- Fix storage.cpp to include transmute.hpp unconditionally
- Use angle bracket includes (<category/...>) instead of double quotes in .cpp files
- Fix include ordering to match clang-tidy requirements (std headers, third-party, project)

These functions are executed thousands of times per contract and benefit significantly from inlining. Without LTO, keeping them inline prevents performance degradation from cross-TU calls.

Verified with:
- 400 EVM tests passing
- Clean clang-tidy results
- Clean clang-format-19 formatting

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@andreaslyn andreaslyn merged commit ae431aa into main Feb 27, 2026
19 checks passed
@brett-monad brett-monad deleted the bletner/runtime_header_refactor branch February 27, 2026 16:55
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.

5 participants