fix(internal): process prague system calls in eth_simulate #31176#2069
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refactors the EVM initialization pattern to fix an issue where Prague system calls (specifically ProcessParentBlockHash for EIP-2935) were not being executed in eth_simulate. The core change separates EVM initialization from transaction context setting, allowing an EVM instance to be created once per block and reused across multiple transactions by calling SetTxContext for each transaction.
Changes:
- Refactored vm.NewEVM() to no longer take TxContext as a parameter; transaction context is now set separately via evm.SetTxContext()
- Added ProcessParentBlockHash system call execution in eth_simulate for Prague-enabled chains
- Updated all EVM creation sites across the codebase (tests, tracers, miners, state processors, API handlers) to use the new initialization pattern
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| core/vm/evm.go | Modified NewEVM signature to remove TxContext parameter; added SetTxContext method to replace Reset; added SetTracer method |
| core/state_processor.go | Updated ProcessParentBlockHash signature to remove statedb parameter; refactored ApplyTransaction and ApplyTransactionWithEVM to accept pre-created EVM |
| internal/ethapi/simulate.go | Added Prague system call processing before transaction execution (main fix) |
| internal/ethapi/api.go | Updated applyMessage and AccessList to set balance before GetEVM and call SetTxContext after EVM creation |
| internal/ethapi/backend.go | Simplified GetEVM signature by removing msg parameter and balance setting (moved to callers) |
| miner/worker.go | Modified Work struct to include EVM field; EVM now created once per block and reused via commitTransaction |
| eth/tracers/api.go | Updated all tracing functions to create EVM without TxContext and set it separately; added Prague system call to traceBlock paths |
| eth/state_accessor.go | Updated stateAtTransaction to create EVM once and reuse with SetTxContext for replay |
| tests/*.go | Updated all test files to use new EVM initialization pattern |
| eth/tracers/*_test.go | Updated all tracer tests; added TestTraceBlockParallelPragueParentHashSystemCall to verify Prague system calls |
| core/state_processor_test.go | Added TestApplyTransactionWithEVMStateChangeHooks; updated Prague-related tests |
| Various helper files | Updated consensus tests, chain makers, gas estimator, runtime env, and simulated backend to new pattern |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f208bba to
a369f53
Compare
Proposed changes
Ref: ethereum#31176
Types of changes
What types of changes does your code introduce to XDC network?
Put an
✅in the boxes that applyImpacted Components
Which part of the codebase this PR will touch base on,
Put an
✅in the boxes that applyChecklist
Put an
✅in the boxes once you have confirmed below actions (or provide reasons on not doing so) that