Skip to content

Commit

Permalink
feat: instrument tracer for async_trait calls
Browse files Browse the repository at this point in the history
  • Loading branch information
andysim3d committed Feb 21, 2025
1 parent e96738d commit 3d5dd04
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 2 deletions.
2 changes: 2 additions & 0 deletions crates/provider/src/alloy/da/arbitrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use alloy_provider::Provider as AlloyProvider;
use alloy_sol_types::sol;
use alloy_transport::Transport;
use rundler_types::da::{DAGasBlockData, DAGasUOData};
use tracing::instrument;
use NodeInterface::NodeInterfaceInstance;

use super::DAGasOracle;
Expand Down Expand Up @@ -62,6 +63,7 @@ where
AP: AlloyProvider<T>,
T: Transport + Clone,
{
#[instrument(skip(self))]
async fn estimate_da_gas(
&self,
uo_data: Bytes,
Expand Down
8 changes: 7 additions & 1 deletion crates/provider/src/alloy/da/local/bedrock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use reth_tasks::pool::BlockingTaskPool;
use rundler_types::da::{BedrockDAGasBlockData, BedrockDAGasUOData, DAGasBlockData, DAGasUOData};
use rundler_utils::cache::LruMap;
use tokio::sync::Mutex as TokioMutex;
use tracing::error;
use tracing::{error, instrument};

use super::multicall::{self, Multicall::MulticallInstance, MULTICALL_BYTECODE};
use crate::{
Expand Down Expand Up @@ -72,6 +72,7 @@ where
AP: AlloyProvider<T>,
T: Transport + Clone,
{
#[instrument(skip(self))]
async fn estimate_da_gas(
&self,
data: Bytes,
Expand All @@ -93,6 +94,7 @@ where
AP: AlloyProvider<T>,
T: Transport + Clone,
{
#[instrument(skip(self))]
async fn block_data(&self, block: BlockHashOrNumber) -> ProviderResult<DAGasBlockData> {
let mut cache = self.block_data_cache.lock().await;
match cache.get(&block) {
Expand All @@ -105,6 +107,7 @@ where
}
}

#[instrument(skip(self, uo_data))]
async fn uo_data(
&self,
uo_data: Bytes,
Expand Down Expand Up @@ -147,6 +150,7 @@ where
AP: AlloyProvider<T>,
T: Transport + Clone,
{
#[instrument(skip(self))]
async fn is_fjord(&self) -> bool {
self.oracle
.isFjord()
Expand All @@ -157,6 +161,7 @@ where
.unwrap_or(true) // Fail-open. Assume fjord if we can't check, so this can be used downstream in asserts w/o panic on RPC errors.
}

#[instrument(skip(self))]
async fn get_block_data(
&self,
block: BlockHashOrNumber,
Expand Down Expand Up @@ -230,6 +235,7 @@ where
})
}

#[instrument(skip(self, data))]
async fn get_uo_data(&self, data: Bytes) -> ProviderResult<BedrockDAGasUOData> {
// Blocking call compressing potentially a lot of data.
// Generally takes more than 100µs so should be spawned on blocking threadpool.
Expand Down
4 changes: 4 additions & 0 deletions crates/provider/src/alloy/da/local/nitro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use anyhow::Context;
use rundler_types::da::{DAGasBlockData, DAGasUOData, NitroDAGasBlockData, NitroDAGasUOData};
use rundler_utils::cache::LruMap;
use tokio::sync::Mutex as TokioMutex;
use tracing::instrument;

use crate::{
alloy::da::arbitrum::NodeInterface::NodeInterfaceInstance, BlockHashOrNumber, DAGasOracle,
Expand Down Expand Up @@ -55,6 +56,7 @@ where
AP: AlloyProvider<T>,
T: Transport + Clone,
{
#[instrument(skip(self))]
async fn estimate_da_gas(
&self,
data: Bytes,
Expand Down Expand Up @@ -103,6 +105,7 @@ where
AP: AlloyProvider<T>,
T: Transport + Clone,
{
#[instrument(skip(self))]
async fn block_data(&self, block: BlockHashOrNumber) -> ProviderResult<DAGasBlockData> {
let mut cache = self.block_data_cache.lock().await;
match cache.get(&block) {
Expand All @@ -115,6 +118,7 @@ where
}
}

#[instrument(skip(self))]
async fn uo_data(
&self,
uo_data: Bytes,
Expand Down
2 changes: 2 additions & 0 deletions crates/provider/src/alloy/da/optimism.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use alloy_sol_types::sol;
use alloy_transport::Transport;
use anyhow::Context;
use rundler_types::da::{DAGasBlockData, DAGasUOData};
use tracing::instrument;
use GasPriceOracle::GasPriceOracleInstance;

use super::DAGasOracle;
Expand Down Expand Up @@ -58,6 +59,7 @@ where
AP: AlloyProvider<T>,
T: Transport + Clone,
{
#[instrument(skip(self))]
async fn estimate_da_gas(
&self,
data: Bytes,
Expand Down
8 changes: 8 additions & 0 deletions crates/provider/src/alloy/entry_point/v0_6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ use rundler_types::{
GasFees, UserOperation as _, UserOpsPerAggregator, ValidationOutput, ValidationRevert,
};
use rundler_utils::authorization_utils;
use tracing::instrument;

use crate::{
AggregatorOut, AggregatorSimOut, BlockHashOrNumber, BundleHandler, DAGasOracle, DAGasProvider,
Expand Down Expand Up @@ -94,6 +95,7 @@ where
self.i_entry_point.address()
}

#[instrument(skip(self))]
async fn balance_of(
&self,
address: Address,
Expand All @@ -109,6 +111,7 @@ where
Ok(ret._0)
}

#[instrument(skip(self))]
async fn get_deposit_info(&self, address: Address) -> ProviderResult<DepositInfo> {
self.i_entry_point
.getDepositInfo(address)
Expand All @@ -118,6 +121,7 @@ where
.map(|r| r.info.into())
}

#[instrument(skip(self))]
async fn get_balances(&self, addresses: Vec<Address>) -> ProviderResult<Vec<U256>> {
let provider = self.i_entry_point.provider();
let call = GetBalances::deploy_builder(provider, *self.address(), addresses)
Expand Down Expand Up @@ -232,6 +236,7 @@ where
{
type UO = UserOperation;

#[instrument(skip(self))]
async fn call_handle_ops(
&self,
ops_per_aggregator: Vec<UserOpsPerAggregator<UserOperation>>,
Expand Down Expand Up @@ -328,6 +333,7 @@ where
{
type UO = UserOperation;

#[instrument(skip(self))]
async fn calc_da_gas(
&self,
user_op: UserOperation,
Expand Down Expand Up @@ -390,6 +396,7 @@ where
Ok((call, StateOverride::default()))
}

#[instrument(skip(self))]
async fn simulate_validation(
&self,
user_op: UserOperation,
Expand Down Expand Up @@ -455,6 +462,7 @@ where
}
}

#[instrument(skip(self))]
async fn simulate_handle_op(
&self,
op: Self::UO,
Expand Down
11 changes: 11 additions & 0 deletions crates/provider/src/alloy/entry_point/v0_7.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ use rundler_types::{
GasFees, UserOperation as _, UserOpsPerAggregator, ValidationOutput, ValidationRevert,
};
use rundler_utils::authorization_utils;
use tracing::instrument;

use crate::{
AggregatorOut, AggregatorSimOut, BlockHashOrNumber, BundleHandler, DAGasOracle, DAGasProvider,
DepositInfo, EntryPoint, EntryPointProvider as EntryPointProviderTrait, EvmCall,
ExecutionResult, HandleOpsOut, ProviderResult, SignatureAggregator, SimulationProvider,
};

/// Entry point provider for v0.7
#[derive(Clone)]
pub struct EntryPointProvider<AP, T, D> {
Expand Down Expand Up @@ -102,6 +104,7 @@ where
self.i_entry_point.address()
}

#[instrument(skip(self))]
async fn balance_of(
&self,
address: Address,
Expand All @@ -117,6 +120,7 @@ where
Ok(ret._0)
}

#[instrument(skip(self))]
async fn get_deposit_info(&self, address: Address) -> ProviderResult<DepositInfo> {
self.i_entry_point
.getDepositInfo(address)
Expand All @@ -126,6 +130,7 @@ where
.map(|r| r.info.into())
}

#[instrument(skip(self))]
async fn get_balances(&self, addresses: Vec<Address>) -> ProviderResult<Vec<U256>> {
let provider = self.i_entry_point.provider();
let call = GetBalances::deploy_builder(provider, *self.address(), addresses)
Expand Down Expand Up @@ -158,6 +163,7 @@ where
{
type UO = UserOperation;

#[instrument(skip(self))]
async fn aggregate_signatures(
&self,
aggregator_address: Address,
Expand Down Expand Up @@ -200,6 +206,7 @@ where
}
}

#[instrument(skip(self))]
async fn validate_user_op_signature(
&self,
aggregator_address: Address,
Expand Down Expand Up @@ -243,6 +250,7 @@ where
{
type UO = UserOperation;

#[instrument(skip(self))]
async fn call_handle_ops(
&self,
ops_per_aggregator: Vec<UserOpsPerAggregator<UserOperation>>,
Expand Down Expand Up @@ -336,6 +344,7 @@ where
{
type UO = UserOperation;

#[instrument(skip(self))]
async fn calc_da_gas(
&self,
user_op: UserOperation,
Expand Down Expand Up @@ -412,6 +421,7 @@ where
Ok((call, override_ep))
}

#[instrument(skip(self))]
async fn simulate_validation(
&self,
user_op: Self::UO,
Expand Down Expand Up @@ -459,6 +469,7 @@ where
}
}

#[instrument(skip(self))]
async fn simulate_handle_op(
&self,
op: Self::UO,
Expand Down
Loading

0 comments on commit 3d5dd04

Please sign in to comment.