@@ -58,15 +58,13 @@ use crate::{
5858#[ cfg( test) ]
5959mod scenario;
6060
61- /// Max allowed time (secs) between a game's deadline and the anchor game's deadline.
62- ///
63- /// Games beyond this threshold are skipped during incremental syncs to cut startup latency and
64- /// avoid caching stale data.
65- ///
66- /// The 14-day window is chosen with a 7-day challenge period in mind, plus a 7-day buffer,
67- /// ensuring all actionable games are included under normal conditions.
61+ /// Default cutoff between a game's deadline and the anchor game's deadline, in seconds.
62+ /// Configurable for factory discovery and pending-game eviction.
6863pub const MAX_GAME_DEADLINE_LAG : u64 = 60 * 60 * 24 * 14 ; // 14 days
6964
65+ /// Maximum lead of a game's L2 timestamp over local safe, in seconds.
66+ const MAX_FUTURE_GAME_TIMESTAMP_LAG : u64 = 60 * 60 * 24 * 14 ; // 14 days
67+
7068/// Nonzero identifier assigned to a proposer task.
7169#[ derive( Clone , Copy , Debug , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
7270pub ( crate ) struct TaskId ( NonZeroU64 ) ;
@@ -1609,7 +1607,11 @@ impl Proposer {
16091607 anchor_deadline = Some ( deadline) ;
16101608 }
16111609 if let Some ( anchor_d) = anchor_deadline &&
1612- beyond_deadline_lag ( anchor_d, deadline)
1610+ beyond_deadline_lag (
1611+ anchor_d,
1612+ deadline,
1613+ self . config . max_game_deadline_lag ,
1614+ )
16131615 {
16141616 tracing:: debug!(
16151617 game_index = %index,
@@ -1875,7 +1877,11 @@ impl Proposer {
18751877 "Keeping pending owned game re-checkable (eviction exempt)"
18761878 ) ;
18771879 } else if let Some ( anchor_deadline) = anchor_deadline &&
1878- beyond_deadline_lag ( anchor_deadline, deadline)
1880+ beyond_deadline_lag (
1881+ anchor_deadline,
1882+ deadline,
1883+ self . config . max_game_deadline_lag ,
1884+ )
18791885 {
18801886 tracing:: warn!(
18811887 game_index = %index,
@@ -2654,7 +2660,7 @@ impl Proposer {
26542660 // nearer is pending and re-validated next sync.
26552661 let local_safe = super_root_at. response . current_local_safe_timestamp ;
26562662 if local_safe > 0 &&
2657- sequence_number > local_safe. saturating_add ( MAX_GAME_DEADLINE_LAG )
2663+ sequence_number > local_safe. saturating_add ( MAX_FUTURE_GAME_TIMESTAMP_LAG )
26582664 {
26592665 tracing:: warn!(
26602666 game_index = %index,
@@ -4440,8 +4446,8 @@ pub fn withdrawal_matured(withdrawal_ts: u64, weth_delay: u64, l1_now: u64) -> b
44404446
44414447/// Returns whether a game deadline is more than the maximum allowed lag
44424448/// behind the anchor deadline.
4443- pub const fn beyond_deadline_lag ( anchor_deadline : u64 , game_deadline : u64 ) -> bool {
4444- game_deadline. saturating_add ( MAX_GAME_DEADLINE_LAG ) < anchor_deadline
4449+ pub const fn beyond_deadline_lag ( anchor_deadline : u64 , game_deadline : u64 , max_lag : u64 ) -> bool {
4450+ game_deadline. saturating_add ( max_lag ) < anchor_deadline
44454451}
44464452
44474453/// Policy for game creation when the registered prestate's programs cannot
@@ -5444,6 +5450,7 @@ mod tests {
54445450 fetch_interval : 30 ,
54455451 metrics_listen : MetricsListen :: Disabled ,
54465452 sync_l1_confirmations : 0 ,
5453+ max_game_deadline_lag : MAX_GAME_DEADLINE_LAG ,
54475454 tx_confirmation_timeout : 60 ,
54485455 max_fee_per_gas : None ,
54495456 max_priority_fee_per_gas : None ,
@@ -7095,7 +7102,7 @@ mod tests {
70957102 let cases = [
70967103 ( 100 , absent_super_root_at_timestamp ( 99 ) , canonical, false , Expected :: Pending ) ,
70977104 (
7098- super :: MAX_GAME_DEADLINE_LAG + 101 ,
7105+ super :: MAX_FUTURE_GAME_TIMESTAMP_LAG + 101 ,
70997106 absent_super_root_at_timestamp ( 100 ) ,
71007107 canonical,
71017108 false ,
@@ -9184,11 +9191,15 @@ mod tests {
91849191 #[ test]
91859192 fn cutoff_only_fires_behind_the_anchor ( ) {
91869193 let anchor = 1_000_000 + MAX_GAME_DEADLINE_LAG + 1 ;
9187- assert ! ( beyond_deadline_lag( anchor, 1_000_000 ) ) ;
9188- assert ! ( !beyond_deadline_lag( anchor - 1 , 1_000_000 ) ) ;
9189- assert ! ( !beyond_deadline_lag( 1_000_000 , 1_000_000 ) ) ;
9190- assert ! ( !beyond_deadline_lag( 1_000_000 , 1_000_000 + MAX_GAME_DEADLINE_LAG + 1 ) ) ;
9191- assert ! ( !beyond_deadline_lag( 1_000_000 , u64 :: MAX ) ) ;
9194+ assert ! ( beyond_deadline_lag( anchor, 1_000_000 , MAX_GAME_DEADLINE_LAG ) ) ;
9195+ assert ! ( !beyond_deadline_lag( anchor - 1 , 1_000_000 , MAX_GAME_DEADLINE_LAG ) ) ;
9196+ assert ! ( !beyond_deadline_lag( 1_000_000 , 1_000_000 , MAX_GAME_DEADLINE_LAG ) ) ;
9197+ assert ! ( !beyond_deadline_lag(
9198+ 1_000_000 ,
9199+ 1_000_000 + MAX_GAME_DEADLINE_LAG + 1 ,
9200+ MAX_GAME_DEADLINE_LAG ,
9201+ ) ) ;
9202+ assert ! ( !beyond_deadline_lag( 1_000_000 , u64 :: MAX , MAX_GAME_DEADLINE_LAG ) ) ;
91929203 }
91939204 }
91949205}
0 commit comments