diff --git a/crates/provider/src/fillers/nonce.rs b/crates/provider/src/fillers/nonce.rs index 273499bab72..ad81f83ac13 100644 --- a/crates/provider/src/fillers/nonce.rs +++ b/crates/provider/src/fillers/nonce.rs @@ -46,6 +46,8 @@ impl NonceManager for SimpleNonceManager { } } +/// Cached nonce manager +/// /// This [`NonceManager`] implementation will fetch the transaction count for any new account it /// sees, store it locally and increment the locally stored nonce as transactions are sent via /// [`Provider::send_transaction`]. diff --git a/crates/rpc-types-eth/src/simulate.rs b/crates/rpc-types-eth/src/simulate.rs index be61122456c..c27750449c1 100644 --- a/crates/rpc-types-eth/src/simulate.rs +++ b/crates/rpc-types-eth/src/simulate.rs @@ -1,9 +1,9 @@ //! 'eth_simulateV1' Request / Response types: -use alloy_primitives::{Address, Bytes, Log, B256}; +use alloy_primitives::Bytes; use serde::{Deserialize, Serialize}; -use crate::{state::StateOverride, BlockOverrides, TransactionRequest}; +use crate::{state::StateOverride, Block, BlockOverrides, Log, TransactionRequest}; /// The maximum number of blocks that can be simulated in a single request, pub const MAX_SIMULATE_BLOCKS: u64 = 256; @@ -15,47 +15,26 @@ pub const MAX_SIMULATE_BLOCKS: u64 = 256; #[serde(rename_all = "camelCase")] pub struct SimBlock { /// Modifications to the default block characteristics. - pub block_overrides: BlockOverrides, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub block_overrides: Option, /// State modifications to apply before executing the transactions. - pub state_overrides: StateOverride, + #[serde(default, skip_serializing_if = "Option::is_none")] + pub state_overrides: Option, /// A vector of transactions to be simulated. pub calls: Vec, } + /// Represents the result of simulating a block. #[derive(Clone, Debug, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] -pub struct SimulatedBlock { - /// The number of the block. - #[serde(with = "alloy_serde::quantity")] - pub number: u64, - /// The hash of the block. - pub hash: B256, - /// The timestamp of the block. - #[serde(with = "alloy_serde::quantity")] - pub timestamp: u64, - /// The gas limit of the block. - #[serde(with = "alloy_serde::quantity")] - pub gas_limit: u64, - /// The amount of gas used in the block. - #[serde(with = "alloy_serde::quantity")] - pub gas_used: u64, - /// The recipient of the block's fees. - pub fee_recipient: Address, - /// The base fee per gas unit for the block. - #[serde(with = "alloy_serde::quantity")] - pub base_fee_per_gas: u64, - /// The previous RANDAO value of the block. - pub prev_randao: B256, +pub struct SimulatedBlock { + /// The simulated block. + #[serde(flatten)] + pub inner: B, /// A vector of results for each call in the block. pub calls: Vec, } -/// The response type for the eth_simulateV1 method. -#[derive(Clone, Debug, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct SimulateV1Response { - /// Simulated blocks vector. - pub simulated_blocks: Vec, -} + /// Captures the outcome of a transaction simulation. /// It includes the return value, logs produced, gas used, and the status of the transaction. #[derive(Clone, Debug, Serialize, Deserialize)] @@ -71,7 +50,7 @@ pub struct SimCallResult { pub gas_used: u64, /// The final status of the transaction, typically indicating success or failure. #[serde(with = "alloy_serde::quantity")] - pub status: u64, + pub status: bool, /// Error in case the call failed #[serde(default, skip_serializing_if = "Option::is_none")] pub error: Option, @@ -168,11 +147,21 @@ mod tests { assert_eq!(sim_opts.block_state_calls.len(), 2); let block_state_call_1 = &sim_opts.block_state_calls[0]; - assert!(block_state_call_1.state_overrides.contains_key(&address_1)); - assert_eq!(block_state_call_1.state_overrides.get(&address_1).unwrap().nonce.unwrap(), 5); + assert!(block_state_call_1.state_overrides.as_ref().unwrap().contains_key(&address_1)); + assert_eq!( + block_state_call_1 + .state_overrides + .as_ref() + .unwrap() + .get(&address_1) + .unwrap() + .nonce + .unwrap(), + 5 + ); let block_state_call_2 = &sim_opts.block_state_calls[1]; - assert!(block_state_call_2.state_overrides.contains_key(&address_1)); + assert!(block_state_call_2.state_overrides.as_ref().unwrap().contains_key(&address_1)); assert_eq!(block_state_call_2.calls.len(), 2); assert_eq!(block_state_call_2.calls[0].from.unwrap(), address_1); diff --git a/crates/rpc-types-eth/src/state.rs b/crates/rpc-types-eth/src/state.rs index 4746e5368da..ef35c85cf73 100644 --- a/crates/rpc-types-eth/src/state.rs +++ b/crates/rpc-types-eth/src/state.rs @@ -29,6 +29,11 @@ pub struct AccountOverride { /// the call. #[serde(default, skip_serializing_if = "Option::is_none")] pub state_diff: Option>, + /// Moves addresses precompile into the specified address. This move is done before the 'code' + /// override is set. When the specified address is not a precompile, the behaviour is undefined + /// and different clients might behave differently. + #[serde(default, skip_serializing_if = "Option::is_none", rename = "movePrecompileToAddress")] + pub move_precompile_to: Option
, } /// Helper type that bundles various overrides for EVM Execution.