Skip to content

Conversation

rezbera
Copy link

@rezbera rezbera commented Jul 29, 2025

This PR adds system call inspection capabilities to alloy-evm by implementing the InspectSystemCallEvm trait and updating the SystemCallEvm implementation. The changes enable proper tracing and debugging of system calls during EVM execution, which is essential for comprehensive transaction and block tracing functionality. The implementation uses revm's inspection framework to capture system call execution details while maintaining compatibility with existing EVM execution flows.

builds on bluealloy/revm#2808

@rezbera rezbera requested review from klkvr and mattsse as code owners July 29, 2025 22:00
@rezbera rezbera marked this pull request as draft July 29, 2025 22:00
Comment on lines 66 to 80
[patch.crates-io]
# Use revm at specific commit 9008e93
revm = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-interpreter = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-inspector = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-handler = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-context = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-context-interface = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-database = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-database-interface = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-state = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-bytecode = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
revm-precompile = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
op-revm = { git = "https://github.com/bluealloy/revm", rev = "9008e93" }
Copy link
Author

Choose a reason for hiding this comment

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

todo use actual release for revm when its ready

@rezbera rezbera changed the title Add system call inspection support for EVM tracing feat: add system call inspection support for EVM tracing Jul 29, 2025
Comment on lines 146 to 150
if self.inspect {
self.inner.inspect_system_call_with_caller(caller, contract, data)
} else {
self.inner.system_call_with_caller(caller, contract, data)
}
Copy link
Member

Choose a reason for hiding this comment

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

this could potentially be a bit problematic because this would make all system calls show up in tracing, which is perhaps unexpected

perhaps we should instead add an

fn inspect_system_call( to the ethevm natievely, then users of this can do the check themselves

this is currently not an issue with reth rpc tracing because systemcalls are applied separately although this is likely going to change, which would then clash with the inspect setting.

for bera, I think the ideal change would be
invoke the fn transact_system_call( or inspect_system_call directly from beraevm's transact implementation if it's a pol tx

@rezbera rezbera force-pushed the rezbera/system-inspector-alloy branch from 2e1746f to bb7ffc0 Compare August 5, 2025 01:30
Adds a dedicated inspect_system_call method that executes system calls
with inspection enabled without committing state changes. This separates
the concerns of inspection and transaction execution for system calls.

- Add inspect_system_call to Evm trait with documentation
- Implement across all EVM types (Either, EthEvm, OpEvm)
- Refactor transact_system_call to always use non-inspecting variant
- Add required ResultAndState import to either.rs

Update Cargo.toml

Update either.rs
@rezbera
Copy link
Author

rezbera commented Aug 7, 2025

Noting issues here

let result = self.inner.evm.transact(tx.clone());

@rezbera
Copy link
Author

rezbera commented Aug 7, 2025

if self.inspect {
self.inner.inspect_system_call_with_caller(caller, contract, data)
} else {
self.inner.system_call_with_caller(caller, contract, data)
}

jank workaround for berachain. will need to figure out a real solution https://github.com/berachain/evm/pull/2/files#diff-65e6ca0a2d2c1d802db5fc74c5c40419664c63801269db2ba13fb3cc4aa7636cR136-R141

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

hmm, the evm itself, doesnt really have a notion of inspecting transaction,
due to how this is implemented it is assumed that this is controlled by the inspector toggle.

@rezbera I believe you're using the regular eth evm right?

could we perhaps make this an EthEvm native function first before we embedd this in the trait?

@rezbera
Copy link
Author

rezbera commented Aug 26, 2025

closing as it makes more sense to just have our own Evm

@rezbera rezbera closed this Aug 26, 2025
@mattsse
Copy link
Member

mattsse commented Aug 26, 2025

good call

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