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: eth_simulateV1 support #10829

Merged
merged 16 commits into from
Sep 18, 2024
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -583,3 +583,31 @@ test-fuzz = "5"
tikv-jemalloc-ctl = "0.6"
tikv-jemallocator = "0.6"
tracy-client = "0.17.3"

#[patch.crates-io]
#alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-admin = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-anvil = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-beacon = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-debug = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-eth = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-mev = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-rpc-types-txpool = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
#alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "8c499409"}
5 changes: 5 additions & 0 deletions book/cli/reth/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ RPC:

[default: 50000000]

--rpc.max-simulate-blocks <BLOCKS_COUNT>
Maximum number of blocks for `eth_simulateV1` call

[default: 256]

--rpc.eth-proof-window <RPC_ETH_PROOF_WINDOW>
The maximum proof window for historical proof generation. This value allows for generating historical proofs up to configured number of blocks from current tip (up to `tip - window`)

Expand Down
9 changes: 9 additions & 0 deletions crates/node/core/src/args/rpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,14 @@ pub struct RpcServerArgs {
)]
pub rpc_gas_cap: u64,

/// Maximum number of blocks for `eth_simulateV1` call.
#[arg(
long = "rpc.max-simulate-blocks",
value_name = "BLOCKS_COUNT",
default_value_t = constants::DEFAULT_MAX_SIMULATE_BLOCKS
)]
pub rpc_max_simulate_blocks: u64,

/// The maximum proof window for historical proof generation.
/// This value allows for generating historical proofs up to
/// configured number of blocks from current tip (up to `tip - window`).
Expand Down Expand Up @@ -300,6 +308,7 @@ impl Default for RpcServerArgs {
rpc_max_blocks_per_filter: constants::DEFAULT_MAX_BLOCKS_PER_FILTER.into(),
rpc_max_logs_per_response: (constants::DEFAULT_MAX_LOGS_PER_RESPONSE as u64).into(),
rpc_gas_cap: constants::gas_oracle::RPC_DEFAULT_GAS_CAP,
rpc_max_simulate_blocks: constants::DEFAULT_MAX_SIMULATE_BLOCKS,
rpc_eth_proof_window: constants::DEFAULT_ETH_PROOF_WINDOW,
gas_price_oracle: GasPriceOracleArgs::default(),
rpc_state_cache: RpcStateCacheArgs::default(),
Expand Down
5 changes: 5 additions & 0 deletions crates/optimism/rpc/src/eth/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ where
self.inner.gas_cap()
}

#[inline]
fn max_simulate_blocks(&self) -> u64 {
self.inner.max_simulate_blocks()
}

#[inline]
fn evm_config(&self) -> &impl ConfigureEvm<Header = Header> {
self.inner.evm_config()
Expand Down
1 change: 1 addition & 0 deletions crates/optimism/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ where
ctx.cache.clone(),
ctx.new_gas_price_oracle(),
ctx.config.rpc_gas_cap,
ctx.config.rpc_max_simulate_blocks,
ctx.config.eth_proof_window,
blocking_task_pool,
ctx.new_fee_history_cache(),
Expand Down
1 change: 1 addition & 0 deletions crates/rpc/rpc-builder/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ impl RethRpcServerConfig for RpcServerArgs {
.max_logs_per_response(self.rpc_max_logs_per_response.unwrap_or_max() as usize)
.eth_proof_window(self.rpc_eth_proof_window)
.rpc_gas_cap(self.rpc_gas_cap)
.rpc_max_simulate_blocks(self.rpc_max_simulate_blocks)
.state_cache(self.state_cache_config())
.gpo_config(self.gas_price_oracle_config())
.proof_permits(self.rpc_proof_permits)
Expand Down
12 changes: 6 additions & 6 deletions crates/rpc/rpc-eth-api/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use reth_primitives::{transaction::AccessListResult, BlockId, BlockNumberOrTag};
use reth_rpc_server_types::{result::internal_rpc_err, ToRpcResult};
use reth_rpc_types::{
serde_helpers::JsonStorageKey,
simulate::{SimBlock, SimulatedBlock},
simulate::{SimulatePayload, SimulatedBlock},
state::{EvmOverrides, StateOverride},
AnyTransactionReceipt, BlockOverrides, Bundle, EIP1186AccountProofResponse, EthCallResponse,
FeeHistory, Header, Index, StateContext, SyncStatus, TransactionRequest, Work,
Expand Down Expand Up @@ -211,9 +211,9 @@ pub trait EthApi<T: RpcObject, B: RpcObject, R: RpcObject> {
#[method(name = "simulateV1")]
async fn simulate_v1(
&self,
opts: SimBlock,
opts: SimulatePayload,
block_number: Option<BlockId>,
) -> RpcResult<Vec<SimulatedBlock>>;
) -> RpcResult<Vec<SimulatedBlock<B>>>;

/// Executes a new message call immediately without creating a transaction on the block chain.
#[method(name = "call")]
Expand Down Expand Up @@ -618,11 +618,11 @@ where
/// Handler for: `eth_simulateV1`
async fn simulate_v1(
&self,
opts: SimBlock,
payload: SimulatePayload,
block_number: Option<BlockId>,
) -> RpcResult<Vec<SimulatedBlock>> {
) -> RpcResult<Vec<SimulatedBlock<RpcBlock<T::NetworkTypes>>>> {
trace!(target: "rpc::eth", ?block_number, "Serving eth_simulateV1");
Ok(EthCall::simulate_v1(self, opts, block_number).await?)
Ok(EthCall::simulate_v1(self, payload, block_number).await?)
}

/// Handler for: `eth_call`
Expand Down
Loading
Loading