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

feat(rpc): initial work in eth_call+estimate #1514

Merged
merged 1 commit into from
Feb 22, 2023
Merged

Conversation

mattsse
Copy link
Collaborator

@mattsse mattsse commented Feb 22, 2023

initial scaffolding for eth_call+estimate ref #1504

I will come up with something along the way and would like to make the changes incrementally rather than submitting them as a whole. because this will become quite large.

for now, this just outlines some functions for eth_call and estimate.

next step is figuring out how to actually create the Env, then porting some logic from anvil.

@mattsse mattsse requested a review from gakonst as a code owner February 22, 2023 15:59
@mattsse mattsse added C-enhancement New feature or request A-rpc Related to the RPC implementation labels Feb 22, 2023
@codecov-commenter
Copy link

codecov-commenter commented Feb 22, 2023

Codecov Report

Merging #1514 (97b2a95) into main (8094ab1) will decrease coverage by 0.15%.
The diff coverage is 0.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main    #1514      +/-   ##
==========================================
- Coverage   76.07%   75.92%   -0.15%     
==========================================
  Files         358      359       +1     
  Lines       42759    42805      +46     
==========================================
- Hits        32528    32501      -27     
- Misses      10231    10304      +73     
Flag Coverage Δ
integration-tests 21.79% <0.00%> (-0.03%) ⬇️
unit-tests 70.40% <0.00%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
crates/rpc/rpc/src/eth/api/call.rs 0.00% <0.00%> (ø)
crates/rpc/rpc/src/eth/api/mod.rs 69.13% <0.00%> (-5.54%) ⬇️
crates/transaction-pool/src/test_utils/mock.rs 60.34% <0.00%> (-6.56%) ⬇️
crates/net/network/src/session/mod.rs 76.59% <0.00%> (-1.36%) ⬇️
crates/storage/provider/src/test_utils/mock.rs 47.71% <0.00%> (-0.66%) ⬇️
crates/transaction-pool/src/pool/txpool.rs 61.06% <0.00%> (-0.50%) ⬇️
crates/stages/src/stages/bodies.rs 92.43% <0.00%> (-0.43%) ⬇️
crates/net/network/src/peers/manager.rs 82.46% <0.00%> (-0.09%) ⬇️
crates/net/discv4/src/lib.rs 66.23% <0.00%> (+0.07%) ⬆️
crates/net/eth-wire/src/ethstream.rs 84.44% <0.00%> (+0.47%) ⬆️
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

OK w doing the scaffolding and things incrementally. See here how it's done in the Executor. Would like to avoid code duplication there, and would love your thoughts on better executor-related abstractions, as @onbjerg and I are refactoring etc.

use reth_primitives::{BlockId, U256};
use reth_provider::{BlockProvider, StateProvider, StateProviderFactory};
use reth_rpc_types::CallRequest;
use revm::primitives::{BlockEnv, Env, ResultAndState};
Copy link
Member

Choose a reason for hiding this comment

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

let's re-export these from reth_executor

Comment on lines +34 to +39
let mut db = SubState::new(State::new(state));
let mut evm = revm::EVM::new();
evm.env = self.build_call_env(request, block_env);
evm.database(db);
// TODO error conversion from EMVError to EthApiErr
let res = evm.transact_ref().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

We'll probably want to push these helpers to the executor, and have the API maybe own an executor/reference to one?

@gakonst gakonst merged commit 3c77dd9 into main Feb 22, 2023
@gakonst gakonst deleted the matt/babysteps-ethcall branch February 22, 2023 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rpc Related to the RPC implementation C-enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants