mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(rpc): add block_overrides in eth_call (#3096)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -6,7 +6,7 @@ use reth_rpc_types::{
|
||||
ForkchoiceUpdated, PayloadAttributes, PayloadId, PayloadStatus, TransitionConfiguration,
|
||||
},
|
||||
state::StateOverride,
|
||||
CallRequest, Filter, Log, RichBlock, SyncStatus,
|
||||
BlockOverrides, CallRequest, Filter, Log, RichBlock, SyncStatus,
|
||||
};
|
||||
|
||||
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "engine"))]
|
||||
@ -123,6 +123,7 @@ pub trait EngineEthApi {
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
state_overrides: Option<StateOverride>,
|
||||
block_overrides: Option<Box<BlockOverrides>>,
|
||||
) -> RpcResult<Bytes>;
|
||||
|
||||
/// Returns code at a given address at given block number.
|
||||
|
||||
@ -4,8 +4,8 @@ use reth_primitives::{
|
||||
H256, H64, U256, U64,
|
||||
};
|
||||
use reth_rpc_types::{
|
||||
state::StateOverride, CallRequest, EIP1186AccountProofResponse, FeeHistory, Index, RichBlock,
|
||||
SyncStatus, Transaction, TransactionReceipt, TransactionRequest, Work,
|
||||
state::StateOverride, BlockOverrides, CallRequest, EIP1186AccountProofResponse, FeeHistory,
|
||||
Index, RichBlock, SyncStatus, Transaction, TransactionReceipt, TransactionRequest, Work,
|
||||
};
|
||||
|
||||
/// Eth rpc interface: <https://ethereum.github.io/execution-apis/api-documentation/>
|
||||
@ -143,6 +143,7 @@ pub trait EthApi {
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
state_overrides: Option<StateOverride>,
|
||||
block_overrides: Option<Box<BlockOverrides>>,
|
||||
) -> RpcResult<Bytes>;
|
||||
|
||||
/// Generates an access list for a transaction.
|
||||
|
||||
@ -90,7 +90,7 @@ where
|
||||
EthApiClient::estimate_gas(client, call_request.clone(), Some(block_number.into()))
|
||||
.await
|
||||
.unwrap();
|
||||
EthApiClient::call(client, call_request.clone(), Some(block_number.into()), None)
|
||||
EthApiClient::call(client, call_request.clone(), Some(block_number.into()), None, None)
|
||||
.await
|
||||
.unwrap();
|
||||
EthApiClient::syncing(client).await.unwrap();
|
||||
|
||||
@ -256,7 +256,7 @@ where
|
||||
let at = block_id.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest));
|
||||
let GethDebugTracingCallOptions { tracing_options, state_overrides, block_overrides } =
|
||||
opts;
|
||||
let overrides = EvmOverrides::new(state_overrides, block_overrides);
|
||||
let overrides = EvmOverrides::new(state_overrides, block_overrides.map(Box::new));
|
||||
let GethDebugTracingOptions { config, tracer, tracer_config, .. } = tracing_options;
|
||||
|
||||
if let Some(tracer) = tracer {
|
||||
|
||||
@ -3,7 +3,9 @@ use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, H256, U256, U64
|
||||
use reth_rpc_api::{EngineEthApiServer, EthApiServer, EthFilterApiServer};
|
||||
/// Re-export for convenience
|
||||
pub use reth_rpc_engine_api::EngineApi;
|
||||
use reth_rpc_types::{state::StateOverride, CallRequest, Filter, Log, RichBlock, SyncStatus};
|
||||
use reth_rpc_types::{
|
||||
state::StateOverride, BlockOverrides, CallRequest, Filter, Log, RichBlock, SyncStatus,
|
||||
};
|
||||
use tracing_futures::Instrument;
|
||||
|
||||
macro_rules! engine_span {
|
||||
@ -60,8 +62,12 @@ where
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
state_overrides: Option<StateOverride>,
|
||||
block_overrides: Option<Box<BlockOverrides>>,
|
||||
) -> Result<Bytes> {
|
||||
self.eth.call(request, block_number, state_overrides).instrument(engine_span!()).await
|
||||
self.eth
|
||||
.call(request, block_number, state_overrides, block_overrides)
|
||||
.instrument(engine_span!())
|
||||
.await
|
||||
}
|
||||
|
||||
/// Handler for: `eth_getCode`
|
||||
|
||||
@ -5,7 +5,7 @@ use crate::{
|
||||
error::{ensure_success, EthApiError, EthResult, RevertError, RpcInvalidTransactionError},
|
||||
revm_utils::{
|
||||
build_call_evm_env, cap_tx_gas_limit_with_caller_allowance, get_precompiles, inspect,
|
||||
transact,
|
||||
transact, EvmOverrides,
|
||||
},
|
||||
EthTransactions,
|
||||
},
|
||||
@ -19,7 +19,7 @@ use reth_revm::{
|
||||
access_list::AccessListInspector,
|
||||
database::{State, SubState},
|
||||
};
|
||||
use reth_rpc_types::{state::StateOverride, CallRequest};
|
||||
use reth_rpc_types::CallRequest;
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use revm::{
|
||||
db::{CacheDB, DatabaseRef},
|
||||
@ -53,13 +53,13 @@ where
|
||||
&self,
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
state_overrides: Option<StateOverride>,
|
||||
overrides: EvmOverrides,
|
||||
) -> EthResult<Bytes> {
|
||||
let (res, _env) = self
|
||||
.transact_call_at(
|
||||
request,
|
||||
block_number.unwrap_or(BlockId::Number(BlockNumberOrTag::Latest)),
|
||||
state_overrides.into(),
|
||||
overrides,
|
||||
)
|
||||
.await?;
|
||||
|
||||
|
||||
@ -3,7 +3,10 @@
|
||||
|
||||
use super::EthApiSpec;
|
||||
use crate::{
|
||||
eth::api::{EthApi, EthTransactions},
|
||||
eth::{
|
||||
api::{EthApi, EthTransactions},
|
||||
revm_utils::EvmOverrides,
|
||||
},
|
||||
result::{internal_rpc_err, ToRpcResult},
|
||||
};
|
||||
use jsonrpsee::core::RpcResult as Result;
|
||||
@ -18,8 +21,8 @@ use reth_provider::{
|
||||
};
|
||||
use reth_rpc_api::EthApiServer;
|
||||
use reth_rpc_types::{
|
||||
state::StateOverride, CallRequest, EIP1186AccountProofResponse, FeeHistory, Index, RichBlock,
|
||||
SyncStatus, TransactionReceipt, TransactionRequest, Work,
|
||||
state::StateOverride, BlockOverrides, CallRequest, EIP1186AccountProofResponse, FeeHistory,
|
||||
Index, RichBlock, SyncStatus, TransactionReceipt, TransactionRequest, Work,
|
||||
};
|
||||
use reth_transaction_pool::TransactionPool;
|
||||
use serde_json::Value;
|
||||
@ -218,11 +221,17 @@ where
|
||||
request: CallRequest,
|
||||
block_number: Option<BlockId>,
|
||||
state_overrides: Option<StateOverride>,
|
||||
block_overrides: Option<Box<BlockOverrides>>,
|
||||
) -> Result<Bytes> {
|
||||
trace!(target: "rpc::eth", ?request, ?block_number, ?state_overrides, "Serving eth_call");
|
||||
trace!(target: "rpc::eth", ?request, ?block_number, ?state_overrides, ?block_overrides, "Serving eth_call");
|
||||
Ok(self
|
||||
.on_blocking_task(|this| async move {
|
||||
this.call(request, block_number, state_overrides).await
|
||||
this.call(
|
||||
request,
|
||||
block_number,
|
||||
EvmOverrides::new(state_overrides, block_overrides),
|
||||
)
|
||||
.await
|
||||
})
|
||||
.await?)
|
||||
}
|
||||
|
||||
@ -36,8 +36,8 @@ pub struct EvmOverrides {
|
||||
|
||||
impl EvmOverrides {
|
||||
/// Creates a new instance with the given overrides
|
||||
pub fn new(state: Option<StateOverride>, block: Option<BlockOverrides>) -> Self {
|
||||
Self { state, block: block.map(Box::new) }
|
||||
pub fn new(state: Option<StateOverride>, block: Option<Box<BlockOverrides>>) -> Self {
|
||||
Self { state, block }
|
||||
}
|
||||
|
||||
/// Creates a new instance with the given state overrides.
|
||||
|
||||
Reference in New Issue
Block a user