execution/vm: fold EVMInterpreter into EVM#18765
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the EVM architecture by folding the EVMInterpreter struct into the EVM struct, eliminating an unnecessary layer of indirection. This is a cherry-pick from go-ethereum that simplifies the codebase by consolidating interpreter functionality directly into the EVM.
Changes:
- Merged EVMInterpreter fields and methods into the EVM struct
- Updated all opcode function signatures to accept
*EVMinstead of*EVMInterpreter - Removed the Interpreter interface and related test infrastructure
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| execution/vm/evm.go | Added interpreter fields (jt, depth, hasher, readOnly, returnData) to EVM struct and removed interpreter indirection |
| execution/vm/interpreter.go | Removed EVMInterpreter struct, Interpreter interface, and VM struct; refactored Run method to be on EVM |
| execution/vm/jump_table.go | Updated executionFunc signature to accept *EVM parameter |
| execution/vm/instructions.go | Updated all opcode implementations to accept *EVM instead of *EVMInterpreter |
| execution/vm/eips.go | Updated EIP-specific opcodes to accept *EVM parameter |
| execution/vm/instructions_test.go | Removed EVMInterpreter references from tests |
| execution/vm/mock_vm.go | Removed test mock file no longer needed |
| execution/vm/evm_test.go | Removed interpreter-specific tests |
| execution/tracing/tracers/logger/logger_test.go | Updated to call evm.Run directly |
| execution/tracing/tracers/js/tracer_test.go | Updated to call evm.Run directly |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| v, overflow = uint256.FromBig(evm.Context.Difficulty) | ||
| if overflow { | ||
| return pc, nil, errors.New("interpreter.evm.Context.Difficulty higher than 2^256-1") | ||
| return pc, nil, errors.New("evm.Context.Difficulty higher than 2^256-1") |
There was a problem hiding this comment.
The error message refers to "evm.Context.Difficulty" which is misleading. The error occurs when converting the difficulty value, but the message structure suggests a field path. Consider rewording to "difficulty value exceeds 2^256-1" for clarity.
| return pc, nil, errors.New("evm.Context.Difficulty higher than 2^256-1") | |
| return pc, nil, errors.New("difficulty value exceeds 2^256-1") |
| @@ -1,436 +0,0 @@ | |||
| // Copyright 2024 The Erigon Authors | |||
There was a problem hiding this comment.
It was added in PR #2508 as part of the work on TEVM (transpiled EVM), which we abandoned since then.
* main: (37 commits) Make `lastCommittedTxNum` atomic (erigontech#18820) integrity: fix redundant variable name in checkLogIdx (erigontech#18646) Fixed index building for v0 snapshot format (erigontech#18825) execution/vm: fold EVMInterpreter into EVM (erigontech#18765) fix: return correct prune mode value instead of nil (erigontech#18804) fix BuildMissedAccessors for caplin state (erigontech#18802) execution: EIP-7708: ETH transfers emit a log (erigontech#18761) refactor(rpc): remove redundant boolean comparison in AccountRange (erigontech#18814) Show the default P2P discovery bools in --help (erigontech#18818) fix(txpool): remove redundant Worst() calls in queued pool discard loop (erigontech#18810) node: remove unused logger and test helper (erigontech#18744) Disabled compression in collate function (erigontech#18813) Add missing tx.Commit() in stage_snapshots (erigontech#18816) Bumped major version of snapshot files (erigontech#18815) qa-tests: summary for RPC integration tests (erigontech#18809) perf: reuse hash buffer in witness storage leaf hash (erigontech#18803) execution/stagedsync: remove canPrune from serial_exec (erigontech#18800) Fixed deduplication intervals for rebuild cmd (erigontech#18796) Fix race due to warmup cache (erigontech#18799) fix(txpool): use instance logger instead of global log (erigontech#18797) ...
Cherry pick ethereum/go-ethereum#32352