Skip to content

Commit

Permalink
feat: log failed eth call
Browse files Browse the repository at this point in the history
  • Loading branch information
andysim3d committed Feb 14, 2025
1 parent fdfb2f3 commit 37fc9b7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
7 changes: 6 additions & 1 deletion crates/provider/src/alloy/entry_point/v0_6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ where
if r.reason.contains("return data out of bounds") {
Ok(HandleOpsOut::PostOpRevert)
} else {
tracing::debug!("handle_ops failed with request: {:?}", tx);
Err(TransportError::ErrorResp(resp).into())
}
}
Expand All @@ -294,10 +295,14 @@ where
} else if let Some(revert_data) = resp.as_revert_data() {
Ok(HandleOpsOut::Revert(revert_data))
} else {
tracing::debug!("handle_ops failed with request: {:?}", tx);
Err(TransportError::ErrorResp(resp).into())
}
}
Err(error) => Err(error.into()),
Err(error) => {
tracing::debug!("handle_ops failed with request: {:?}", tx);
Err(error.into())
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion crates/provider/src/alloy/entry_point/v0_7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,14 @@ where
} else if let Some(revert_data) = resp.as_revert_data() {
Ok(HandleOpsOut::Revert(revert_data))
} else {
tracing::debug!("handle_ops failed with request: {:?}", tx);
Err(TransportError::ErrorResp(resp).into())
}
}
Err(error) => Err(error.into()),
Err(error) => {
tracing::debug!("handle_ops failed with request: {:?}", tx);
Err(error.into())
}
}
}

Expand Down
14 changes: 13 additions & 1 deletion crates/provider/src/traits/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

//! Trait for interacting with chain data and contracts.
use std::fmt::Display;

use alloy_primitives::{Address, Bytes, TxHash, B256, U256};

use crate::{
Expand All @@ -23,7 +25,7 @@ use crate::{

/// An EVM call, a subset of a transaction that is not meant to be executed onchain, but
/// can be simulated via an eth_call, debug_traceCall, or similar.
#[derive(Debug)]
#[derive(Debug, Clone)]
pub struct EvmCall {
/// The address to call
pub to: Address,
Expand All @@ -35,6 +37,16 @@ pub struct EvmCall {
pub state_override: StateOverride,
}

impl Display for EvmCall {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"to: {:?}, data: {:?}, value: {:?}, state_override: {:?} ",
self.to, self.data, self.value, self.state_override
)
}
}

/// Trait for interacting with chain data and contracts.
#[async_trait::async_trait]
#[auto_impl::auto_impl(&, &mut, Rc, Arc, Box)]
Expand Down
7 changes: 6 additions & 1 deletion crates/sim/src/estimation/estimate_verification_gas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ where

let gas_used = self
.provider
.get_gas_used(call)
.get_gas_used(call.clone())
.await
.context("failed to run initial guess")?;

Expand All @@ -125,6 +125,11 @@ where
))?;
}
} else if let Some(revert) = E::decode_simulate_handle_ops_revert(&gas_used.result)?.err() {
tracing::debug!(
" simulation reverted with evm call: {}, error: {}",
call,
revert
);
return Err(GasEstimationError::RevertInValidation(revert));
}

Expand Down

0 comments on commit 37fc9b7

Please sign in to comment.