Skip to content

Commit

Permalink
chore(test): rebase fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-miao committed Sep 15, 2023
1 parent fcd5e93 commit 4544f4c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 33 deletions.
12 changes: 10 additions & 2 deletions crates/provider/src/traits/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use ethers::{
providers::ProviderError,
types::{
transaction::eip2718::TypedTransaction, Address, Block, BlockId, Bytes, Filter,
GethDebugTracingOptions, GethTrace, Log, Transaction, TransactionReceipt, TxHash, H256,
U256,
GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, Log, Transaction,
TransactionReceipt, TxHash, H256, U256,
},
};
#[cfg(feature = "test-utils")]
Expand Down Expand Up @@ -83,6 +83,14 @@ pub trait Provider: Send + Sync + 'static {
trace_options: GethDebugTracingOptions,
) -> Result<GethTrace, ProviderError>;

/// Debug trace a call
async fn debug_trace_call(
&self,
tx: TypedTransaction,
block_id: Option<BlockId>,
trace_options: GethDebugTracingCallOptions,
) -> Result<GethTrace, ProviderError>;

/// Get the latest block hash
async fn get_latest_block_hash(&self) -> anyhow::Result<H256>;

Expand Down
26 changes: 12 additions & 14 deletions crates/rundler/src/common/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use ethers::{
use indexmap::IndexSet;
#[cfg(test)]
use mockall::automock;
use rundler_provider::{AggregatorOut, AggregatorSimOut, EntryPoint, Provider};
use rundler_provider::{AggregatorOut, AggregatorSimOut, Provider};
use rundler_types::{contracts::i_entry_point::FailedOp, Entity, EntityType, UserOperation};
use tonic::async_trait;

Expand Down Expand Up @@ -72,7 +72,7 @@ pub trait Simulator: Send + Sync + 'static {
}

#[derive(Debug)]
pub struct SimulatorImpl<P: ProviderLike, T: SimulateValidationTracer> {
pub struct SimulatorImpl<P: Provider, T: SimulateValidationTracer> {
provider: Arc<P>,
entry_point_address: Address,
simulate_validation_tracer: T,
Expand All @@ -82,7 +82,7 @@ pub struct SimulatorImpl<P: ProviderLike, T: SimulateValidationTracer> {

impl<P, T> SimulatorImpl<P, T>
where
P: ProviderLike,
P: Provider,
T: SimulateValidationTracer,
{
pub fn new(
Expand Down Expand Up @@ -388,7 +388,7 @@ where
#[async_trait]
impl<P, T> Simulator for SimulatorImpl<P, T>
where
P: ProviderLike,
P: Provider,
T: SimulateValidationTracer,
{
async fn simulate_validation(
Expand Down Expand Up @@ -689,18 +689,16 @@ mod tests {
use ethers::{
abi::AbiEncode,
providers::{JsonRpcError, MockError, ProviderError},
types::{Address, BlockNumber},
types::{Address, BlockNumber, Bytes},
utils::hex,
};
use rundler_provider::{AggregatorOut, MockProvider};

use super::*;
use crate::common::{
tracer::{MockSimulateValidationTracer, Phase},
types::MockProviderLike,
};
use crate::common::tracer::{MockSimulateValidationTracer, Phase};

fn create_base_config() -> (MockProviderLike, MockSimulateValidationTracer) {
(MockProviderLike::new(), MockSimulateValidationTracer::new())
fn create_base_config() -> (MockProvider, MockSimulateValidationTracer) {
(MockProvider::new(), MockSimulateValidationTracer::new())
}

fn get_test_tracer_output() -> SimulationTracerOutput {
Expand Down Expand Up @@ -783,17 +781,17 @@ mod tests {
}

fn create_simulator(
provider: MockProviderLike,
provider: MockProvider,
simulate_validation_tracer: MockSimulateValidationTracer,
) -> SimulatorImpl<MockProviderLike, MockSimulateValidationTracer> {
) -> SimulatorImpl<MockProvider, MockSimulateValidationTracer> {
let settings = Settings::default();

let mut mempool_configs = HashMap::new();
mempool_configs.insert(H256::zero(), MempoolConfig::default());

let provider = Arc::new(provider);

let simulator: SimulatorImpl<MockProviderLike, MockSimulateValidationTracer> =
let simulator: SimulatorImpl<MockProvider, MockSimulateValidationTracer> =
SimulatorImpl::new(
Arc::clone(&provider),
Address::from_str("0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789").unwrap(),
Expand Down
24 changes: 7 additions & 17 deletions crates/rundler/src/common/tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ use std::{
sync::Arc,
};

use anyhow::{bail, Context};
use ethers::types::{
transaction::eip2718::TypedTransaction, Address, BlockId, GethDebugTracerType,
GethDebugTracingCallOptions, GethDebugTracingOptions, GethTrace, U256,
};
use anyhow::{bail, Context};
use ethers::types::{
Address, BlockId, GethDebugTracerType, GethDebugTracingCallOptions, GethDebugTracingOptions,
Expand All @@ -19,15 +14,10 @@ use ethers::types::{
use mockall::automock;
use rundler_provider::{EntryPoint, Provider};
use rundler_types::UserOperation;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::{Deserialize, Serialize};
use tonic::async_trait;

use super::{
context::LogWithContext,
types::{EntryPointLike, ProviderLike},
};
use crate::common::types::{ExpectedStorage, UserOperation};
use crate::common::types::ExpectedStorage;

#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -104,8 +94,8 @@ pub trait SimulateValidationTracer: Send + Sync + 'static {
#[derive(Debug)]
pub struct SimulateValidationTracerImpl<P, E>
where
P: ProviderLike,
E: EntryPointLike,
P: Provider,
E: EntryPoint,
{
provider: Arc<P>,
entry_point: E,
Expand All @@ -117,8 +107,8 @@ where
#[async_trait]
impl<P, E> SimulateValidationTracer for SimulateValidationTracerImpl<P, E>
where
P: ProviderLike,
E: EntryPointLike,
P: Provider,
E: EntryPoint,
{
async fn trace_simulate_validation(
&self,
Expand Down Expand Up @@ -153,8 +143,8 @@ where

impl<P, E> SimulateValidationTracerImpl<P, E>
where
P: ProviderLike,
E: EntryPointLike,
P: Provider,
E: EntryPoint,
{
pub fn new(provider: Arc<P>, entry_point: E) -> Self {
Self {
Expand Down

0 comments on commit 4544f4c

Please sign in to comment.