diff --git a/lib/base-client/src/lib.rs b/lib/base-client/src/lib.rs index cff0dede64..11bf067ed1 100644 --- a/lib/base-client/src/lib.rs +++ b/lib/base-client/src/lib.rs @@ -21,7 +21,7 @@ pub async fn finalized_l2_block_number_of_l1_block_number( l1_provider, l1_block_number, l1_dispute_game_factory_proxy, - count - U256::ONE, + count.saturating_sub(U256::ONE), ) .await } diff --git a/lib/bob-client/src/lib.rs b/lib/bob-client/src/lib.rs index cff0dede64..11bf067ed1 100644 --- a/lib/bob-client/src/lib.rs +++ b/lib/bob-client/src/lib.rs @@ -21,7 +21,7 @@ pub async fn finalized_l2_block_number_of_l1_block_number( l1_provider, l1_block_number, l1_dispute_game_factory_proxy, - count - U256::ONE, + count.saturating_sub(U256::ONE), ) .await } diff --git a/voyager/plugins/client-update/base/src/main.rs b/voyager/plugins/client-update/base/src/main.rs index 8db46103b6..6a0543481d 100644 --- a/voyager/plugins/client-update/base/src/main.rs +++ b/voyager/plugins/client-update/base/src/main.rs @@ -618,6 +618,14 @@ impl Module { .await .map_err(|err| ErrorObject::owned(-1, ErrorReporter(err).to_string(), None::<()>))?; + if game_index.is_zero() { + return Err(ErrorObject::owned( + -1, + "no dispute games at this L1 block height".to_string(), + None::<()>, + )); + } + let game_index = game_index - U256::ONE; let dispute_game_factory_account_proof = self diff --git a/voyager/plugins/client-update/bob/src/main.rs b/voyager/plugins/client-update/bob/src/main.rs index d8f9cf4624..aeee201ba4 100644 --- a/voyager/plugins/client-update/bob/src/main.rs +++ b/voyager/plugins/client-update/bob/src/main.rs @@ -630,6 +630,14 @@ impl Module { .await .map_err(|err| ErrorObject::owned(-1, ErrorReporter(err).to_string(), None::<()>))?; + if game_index.is_zero() { + return Err(ErrorObject::owned( + -1, + "no dispute games at this L1 block height".to_string(), + None::<()>, + )); + } + let game_index = game_index - U256::ONE; let dispute_game_factory_account_proof = self