Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/custom-bundle-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ impl Bundle<CustomPlatform> for CustomBundleType {
Eligibility::Eligible
}

fn is_allowed_to_fail(&self, tx: alloy::primitives::TxHash) -> bool {
self.reverting_txs.contains(&tx)
fn is_allowed_to_fail(&self, tx: &alloy::primitives::TxHash) -> bool {
self.reverting_txs.contains(tx)
}

fn is_optional(&self, tx: alloy::primitives::TxHash) -> bool {
self.dropping_txs.contains(&tx)
fn is_optional(&self, tx: &alloy::primitives::TxHash) -> bool {
self.dropping_txs.contains(tx)
}

fn validate_post_execution(
Expand Down
8 changes: 4 additions & 4 deletions src/payload/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl<P: Platform> Executable<P> {
let mut results = Vec::with_capacity(bundle.transactions().len());

for transaction in bundle.transactions() {
let tx_hash = *transaction.tx_hash();
let tx_hash = transaction.tx_hash();
let optional = bundle.is_optional(tx_hash);
let allowed_to_fail = bundle.is_allowed_to_fail(tx_hash);

Expand All @@ -224,16 +224,16 @@ impl<P: Platform> Executable<P> {
// Optional failing transaction, not allowed to fail
// or optional invalid transaction: discard it
Ok(_) | Err(_) if optional => {
discarded.push(tx_hash);
discarded.push(*tx_hash);
}
// Non-Optional failing transaction, not allowed to fail: invalidate the
// bundle
Ok(_) => {
return Err(ExecutionError::BundleTransactionReverted(tx_hash));
return Err(ExecutionError::BundleTransactionReverted(*tx_hash));
}
// Non-Optional invalid transaction: invalidate the bundle
Err(err) => {
return Err(ExecutionError::InvalidBundleTransaction(tx_hash, err));
return Err(ExecutionError::InvalidBundleTransaction(*tx_hash, err));
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/platform/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ pub trait Bundle<P: Platform>:
///
/// The `tx` is the hash of the transaction to check, that should be part of
/// this bundle.
fn is_allowed_to_fail(&self, tx: TxHash) -> bool;
fn is_allowed_to_fail(&self, tx: &TxHash) -> bool;

/// Checks if a transaction with the given hash may be removed from the
/// bundle without affecting its validity.
fn is_optional(&self, tx: TxHash) -> bool;
fn is_optional(&self, tx: &TxHash) -> bool;

/// An optional check for bundle implementations that have validity
/// requirements on the resulting state.
Expand Down Expand Up @@ -300,12 +300,12 @@ impl<P: Platform> Bundle<P> for FlashbotsBundle<P> {
)
}

fn is_allowed_to_fail(&self, tx: TxHash) -> bool {
self.reverting_tx_hashes.contains(&tx)
fn is_allowed_to_fail(&self, tx: &TxHash) -> bool {
self.reverting_tx_hashes.contains(tx)
}

fn is_optional(&self, tx: TxHash) -> bool {
self.dropping_tx_hashes.contains(&tx)
fn is_optional(&self, tx: &TxHash) -> bool {
self.dropping_tx_hashes.contains(tx)
}

fn hash(&self) -> B256 {
Expand Down
9 changes: 4 additions & 5 deletions src/platform/ext/bundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<P: Platform, T: Bundle<P>> BundleExt<P> for T {
self
.transactions()
.iter()
.filter(|tx| !self.is_allowed_to_fail(*tx.tx_hash()))
.filter(|tx| !self.is_allowed_to_fail(tx.tx_hash()))
}

/// Returns an iterator over all transactions that can be removed from the
Expand All @@ -49,7 +49,7 @@ impl<P: Platform, T: Bundle<P>> BundleExt<P> for T {
self
.transactions()
.iter()
.filter(|tx| self.is_optional(*tx.tx_hash()))
.filter(|tx| self.is_optional(tx.tx_hash()))
}

/// Returns an iterator over all transactions that are required to be present
Expand All @@ -61,7 +61,7 @@ impl<P: Platform, T: Bundle<P>> BundleExt<P> for T {
self
.transactions()
.iter()
.filter(|tx| !self.is_optional(*tx.tx_hash()))
.filter(|tx| !self.is_optional(tx.tx_hash()))
}

/// Returns an iterator over all transactions that must be included and may
Expand All @@ -70,8 +70,7 @@ impl<P: Platform, T: Bundle<P>> BundleExt<P> for T {
&self,
) -> impl Iterator<Item = &Recovered<types::Transaction<P>>> {
self.transactions().iter().filter(|tx| {
!self.is_allowed_to_fail(*tx.tx_hash())
&& !self.is_optional(*tx.tx_hash())
!self.is_allowed_to_fail(tx.tx_hash()) && !self.is_optional(tx.tx_hash())
})
}
}
4 changes: 2 additions & 2 deletions src/steps/revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl<P: Platform> Step<P> for RemoveRevertedTransactions {
.failed_txs()
.filter_map(|(tx, result)| {
bundle
.is_optional(*tx.tx_hash())
.is_optional(tx.tx_hash())
.then_some((*tx.tx_hash(), result.gas_used()))
})
.collect::<Vec<_>>();
Expand Down Expand Up @@ -241,7 +241,7 @@ fn has_failures<P: Platform>(checkpoint: &Checkpoint<P>) -> bool {
.iter()
.map(|r| !r.is_success())
.zip(result.transactions().iter().map(|tx| tx.tx_hash()))
.any(|(is_failure, tx_hash)| is_failure && bundle.is_optional(*tx_hash));
.any(|(is_failure, tx_hash)| is_failure && bundle.is_optional(tx_hash));
}

false
Expand Down
Loading