Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revm example #6855

Merged
merged 5 commits into from
Feb 29, 2024
Merged

Revm example #6855

merged 5 commits into from
Feb 29, 2024

Conversation

AbnerZheng
Copy link
Contributor

@AbnerZheng AbnerZheng commented Feb 28, 2024

close #6145

Add an example of how to use a custom inspector to trace new pending transactions
How to test:

> cargo run -p custom-inspector -- node --http --ws --dev`

and in another contracts project created by forge, and then run the following command to deploy a transaction:

forge create --mnemonic "test test test test test test test test test test test junk" src/Counter.sol:Counter

here is the running result from node:

Inspector result for transaction 0x21abbfee9d8e6af8bce70424425c8d3da92ed63d0d1de89cbd74cef108473e6a: 
 0: PUSH1
2: PUSH1
4: MSTORE
5: CALLVALUE
6: DUP1
7: ISZERO
8: PUSH2
11: JUMPI
16: JUMPDEST
17: POP
18: PUSH1
20: DUP1
21: PUSH2
24: PUSH1
26: CODECOPY
27: PUSH1
29: RETURN

@AbnerZheng AbnerZheng marked this pull request as ready for review February 28, 2024 18:08
Copy link
Collaborator

@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.

this is great!

only doc nit, and perhaps a few more docs about the what's going on, like
convert the pool transaction
configure the evm with the custom inspector
execute the transaction on a blocking task and await the inspector result

Comment on lines +54 to +57
#[derive(Default, Debug, Clone)]
struct DummyInspector {
ret_val: Vec<String>,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should add a smol doc here what this inspector does, listing opcodes at the program counter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, will do in tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@mattsse mattsse added C-enhancement New feature or request A-execution Related to the Execution and EVM labels Feb 28, 2024
Comment on lines 13 to 31
use reth::{
cli::{
components::{RethNodeComponents, RethRpcComponents, RethRpcServerHandles},
config::RethRpcConfig,
ext::{RethCliExt, RethNodeCommandConfig},
Cli,
},
primitives::{Address, BlockId, IntoRecoveredTransaction},
revm::{
inspector_handle_register, interpreter::Interpreter, revm, Database, EvmContext, Inspector,
},
rpc::{
compat::transaction::transaction_to_call_request,
eth::{revm_utils::EvmOverrides, EthTransactions},
},
tasks::TaskSpawner,
transaction_pool::TransactionPool,
};
use reth_revm::interpreter::OpCode;
Copy link
Member

Choose a reason for hiding this comment

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

we should make this way less verbose. Prelude or otherwise?

Copy link
Collaborator

Choose a reason for hiding this comment

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

these are already the reexports -.-

but can def make this nicer

Copy link
Collaborator

@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.

nice work

@mattsse mattsse added this pull request to the merge queue Feb 29, 2024
Merged via the queue into paradigmxyz:main with commit 7d6fb37 Feb 29, 2024
30 checks passed
@AbnerZheng AbnerZheng deleted the revm-example branch February 29, 2024 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-execution Related to the Execution and EVM C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add example using reth revm sims
3 participants