Repository: paradigmxyz/reth (language: rust)

Issue:
Extend Maybeconditional with helper fn
### Describe the feature

in #14497 we added:

https://github.com/paradigmxyz/reth/blob/203e011fe8a31108cfc1a4218b4de874303ad308/crates/optimism/txpool/src/maintain.rs#L50-L54

we can simplify this by adding `has_exceeded_block_attributes` directly to the trait:

https://github.com/paradigmxyz/reth/blob/203e011fe8a31108cfc1a4218b4de874303ad308/crates/optimism/txpool/src/conditional.rs#L6-L6

so we don't need the extra option handling

## TODO
* add default impl for has_exceeded_block_attributes

### Additional context

_No response_


Discussion / hints:
Hey, I'd like to work on this

Fix patch:
diff --git a/crates/optimism/txpool/src/conditional.rs b/crates/optimism/txpool/src/conditional.rs
index 2a4b6b518afe..0c7727c2cba1 100644
--- a/crates/optimism/txpool/src/conditional.rs
+++ b/crates/optimism/txpool/src/conditional.rs
@@ -1,5 +1,6 @@
 //! Additional support for pooled transactions with [`TransactionConditional`]
 
+use alloy_consensus::conditional::BlockConditionalAttributes;
 use alloy_rpc_types_eth::erc4337::TransactionConditional;
 
 /// Helper trait that allows attaching a [`TransactionConditional`].
@@ -10,6 +11,11 @@ pub trait MaybeConditionalTransaction {
     /// Get attached [`TransactionConditional`] if any.
     fn conditional(&self) -> Option<&TransactionConditional>;
 
+    /// Check if the conditional has exceeded the block attributes.
+    fn has_exceeded_block_attributes(&self, block_attr: &BlockConditionalAttributes) -> bool {
+        self.conditional().map(|tc| tc.has_exceeded_block_attributes(block_attr)).unwrap_or(false)
+    }
+
     /// Helper that sets the conditional and returns the instance again
     fn with_conditional(mut self, conditional: TransactionConditional) -> Self
     where
diff --git a/crates/optimism/txpool/src/maintain.rs b/crates/optimism/txpool/src/maintain.rs
index d47cac207c06..b93ed378578d 100644
--- a/crates/optimism/txpool/src/maintain.rs
+++ b/crates/optimism/txpool/src/maintain.rs
@@ -47,10 +47,8 @@ where
             };
             let mut to_remove = Vec::new();
             for tx in &pool.pooled_transactions() {
-                if let Some(conditional) = tx.transaction.conditional() {
-                    if conditional.has_exceeded_block_attributes(&block_attr) {
-                        to_remove.push(*tx.hash());
-                    }
+                if tx.transaction.has_exceeded_block_attributes(&block_attr) {
+                    to_remove.push(*tx.hash());
                 }
             }
             let _ = pool.remove_transactions(to_remove);


Test patch: