-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce streams of events from the op pool and builder, which provide detailed debug information and can be consumed from broadcast channels. As an initial application, provide logging based on the content of these streams, which can be used to debug the path a user op takes. To make this possible, several refactors are required: * The input side of the channel is threaded through various structs used throughout, such as the bundle proposer. * A new `emit` submodule is added in each of `cli::node``, `builder`, `op_pool`, and `common`. In each case, this module defines the relevant event types, including `Display` implementations for the default logging. The one in `common` also defines some helper functions for managing event streams. them into log messages (logged via `tracing`). * The transaction tracker now has separate steps for submitting a transaction and then waiting for it, rather than a singule function which does both. This is because we do not know the transaction hash until the transaction is sent, due to last-minute changes made by the transaction sender, and we want to be able to log the send as it occurs.
- Loading branch information
1 parent
a29ff9f
commit 69f6814
Showing
20 changed files
with
847 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
use std::{fmt::Display, sync::Arc}; | ||
|
||
use ethers::types::{transaction::eip2718::TypedTransaction, Address, H256}; | ||
|
||
use crate::common::{gas::GasFees, strs}; | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum BuilderEvent { | ||
FormedBundle { | ||
/// If `None`, means that the bundle contained no operations and so no | ||
/// transaction was created. | ||
tx_details: Option<BundleTxDetails>, | ||
nonce: u64, | ||
fee_increase_count: u64, | ||
required_fees: Option<GasFees>, | ||
}, | ||
TransactionMined { | ||
tx_hash: H256, | ||
nonce: u64, | ||
block_number: u64, | ||
}, | ||
LatestTransactionDropped { | ||
nonce: u64, | ||
}, | ||
NonceUsedForOtherTransaction { | ||
nonce: u64, | ||
}, | ||
SkippedOp { | ||
op_hash: H256, | ||
reason: SkipReason, | ||
}, | ||
RejectedOp { | ||
op_hash: H256, | ||
reason: OpRejectionReason, | ||
}, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct BundleTxDetails { | ||
pub tx_hash: H256, | ||
pub tx: TypedTransaction, | ||
pub op_hashes: Arc<Vec<H256>>, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum SkipReason { | ||
AccessedOtherSender { other_sender: Address }, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum OpRejectionReason { | ||
FailedRevalidation, | ||
FailedInBundle { message: Arc<String> }, | ||
} | ||
|
||
impl Display for BuilderEvent { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
BuilderEvent::FormedBundle { | ||
tx_details, | ||
nonce, | ||
fee_increase_count, | ||
required_fees, | ||
} => { | ||
let required_max_fee_per_gas = | ||
strs::to_string_or(required_fees.map(|fees| fees.max_fee_per_gas), "(default)"); | ||
let required_max_priority_fee_per_gas = strs::to_string_or( | ||
required_fees.map(|fees| fees.max_priority_fee_per_gas), | ||
"(default)", | ||
); | ||
match tx_details { | ||
Some(tx_details) => { | ||
let op_hashes = tx_details | ||
.op_hashes | ||
.iter() | ||
.map(|hash| format!("{hash:?}")) | ||
.collect::<Vec<_>>() | ||
.join(", "); | ||
write!( | ||
f, | ||
concat!( | ||
"Bundle transaction sent!", | ||
" Transaction hash: {:?}", | ||
" Nonce: {}", | ||
" Fee increases: {}", | ||
" Required maxFeePerGas: {}", | ||
" Required maxPriorityFeePerGas: {}", | ||
" Op hashes: {}", | ||
), | ||
tx_details.tx_hash, | ||
nonce, | ||
fee_increase_count, | ||
required_max_fee_per_gas, | ||
required_max_priority_fee_per_gas, | ||
op_hashes, | ||
) | ||
} | ||
None => write!( | ||
f, | ||
concat!( | ||
"Bundle was empty.", | ||
" Nonce: {}", | ||
" Fee increases: {}", | ||
" Required maxFeePerGas: {}", | ||
" Required maxPriorityFeePerGas: {}", | ||
), | ||
nonce, | ||
fee_increase_count, | ||
required_max_fee_per_gas, | ||
required_max_priority_fee_per_gas | ||
), | ||
} | ||
} | ||
BuilderEvent::TransactionMined { | ||
tx_hash, | ||
nonce, | ||
block_number, | ||
} => write!( | ||
f, | ||
concat!( | ||
"Transaction mined!", | ||
" Transaction hash: {:?}", | ||
" Nonce: {}", | ||
" Block number: {}", | ||
), | ||
tx_hash, nonce, block_number, | ||
), | ||
BuilderEvent::LatestTransactionDropped { nonce } => { | ||
write!( | ||
f, | ||
"Latest transaction dropped. Higher fees are needed. Nonce: {nonce}" | ||
) | ||
} | ||
BuilderEvent::NonceUsedForOtherTransaction { nonce } => { | ||
write!(f, "Transaction failed because nonce was used by another transaction outside of this Rundler. Nonce: {nonce}") | ||
} | ||
BuilderEvent::SkippedOp { op_hash, reason } => { | ||
write!(f, "Op skipped in bundle (but remains in pool). Op hash: {op_hash:?} Reason: {reason:?}") | ||
} | ||
BuilderEvent::RejectedOp { op_hash, reason } => { | ||
write!(f, "Op rejected from bundle and removed from pool. Op hash: {op_hash:?} Reason: {reason:?}") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
mod bundle_proposer; | ||
pub mod emit; | ||
mod sender; | ||
mod server; | ||
mod signer; | ||
|
Oops, something went wrong.