@@ -293,61 +293,17 @@ impl<P: Platform> Bundle<P> for FlashbotsBundle<P> {
293293 }
294294
295295 fn is_eligible ( & self , block : & BlockContext < P > ) -> Eligibility {
296- if self . transactions ( ) . is_empty ( ) {
297- // empty bundles are never eligible
298- return Eligibility :: PermanentlyIneligible ;
299- }
300-
301- if self
302- . max_timestamp
303- . is_some_and ( |max_ts| max_ts > block. timestamp ( ) )
304- {
305- // this bundle will never be eligible for inclusion anymore
306- return Eligibility :: PermanentlyIneligible ;
307- }
308-
309- if self
310- . min_timestamp
311- . is_some_and ( |min_ts| min_ts < block. timestamp ( ) )
312- {
313- // this bundle is not eligible yet
314- return Eligibility :: TemporarilyIneligible ;
315- }
316-
317- if self . block_number != 0 && self . block_number > block. parent ( ) . number ( ) {
318- // this bundle is not eligible yet
319- return Eligibility :: TemporarilyIneligible ;
320- }
321-
322- if self . block_number != 0 && self . block_number < block. parent ( ) . number ( ) {
323- // this bundle will never be eligible for inclusion anymore
324- return Eligibility :: PermanentlyIneligible ;
325- }
326-
327- Eligibility :: Eligible
296+ self . eligibility_at ( block. timestamp ( ) , block. number ( ) )
328297 }
329298
330299 fn is_permanently_ineligible (
331300 & self ,
332301 block : & SealedHeader < types:: Header < P > > ,
333302 ) -> bool {
334- if self . transactions ( ) . is_empty ( ) {
335- // empty bundles are never eligible
336- return true ;
337- }
338-
339- if self
340- . max_timestamp
341- . is_some_and ( |max_ts| max_ts < block. timestamp ( ) )
342- {
343- return true ;
344- }
345-
346- if self . block_number != 0 && self . block_number < block. number ( ) {
347- return true ;
348- }
349-
350- false
303+ matches ! (
304+ self . eligibility_at( block. timestamp( ) , block. number( ) ) ,
305+ Eligibility :: PermanentlyIneligible
306+ )
351307 }
352308
353309 fn is_allowed_to_fail ( & self , tx : TxHash ) -> bool {
@@ -367,6 +323,39 @@ impl<P: Platform> Bundle<P> for FlashbotsBundle<P> {
367323 }
368324}
369325
326+ impl < P : Platform > FlashbotsBundle < P > {
327+ fn eligibility_at ( & self , timestamp : u64 , number : u64 ) -> Eligibility {
328+ // Permanent ineligibility checked first
329+ if self . transactions ( ) . is_empty ( ) {
330+ // empty bundles are never eligible
331+ return Eligibility :: PermanentlyIneligible ;
332+ }
333+
334+ if self . max_timestamp . is_some_and ( |max_ts| max_ts < timestamp) {
335+ return Eligibility :: PermanentlyIneligible ;
336+ }
337+
338+ if self . block_number != 0 && self . block_number < number {
339+ return Eligibility :: PermanentlyIneligible ;
340+ }
341+
342+ // Temporary ineligibility checked next
343+ if self . min_timestamp . is_some_and ( |min_ts| min_ts > timestamp) {
344+ return Eligibility :: TemporarilyIneligible ;
345+ }
346+
347+ if self . block_number != 0 && self . block_number > number {
348+ return Eligibility :: TemporarilyIneligible ;
349+ }
350+
351+ // assertions:
352+ // - transaction count > 0
353+ // - min_timestamp < timestamp < max_timestamp
354+ // - block_number == number
355+ Eligibility :: Eligible
356+ }
357+ }
358+
370359#[ derive( Debug , thiserror:: Error ) ]
371360pub enum BundleConversionError {
372361 #[ error( "EIP-2718 decoding error: {0}" ) ]
0 commit comments