Skip to content

Commit 34cb50c

Browse files
authored
fix: Handle nonce overflow (#3186)
# Description ## Linked Issues - Fixes # (issue, if applicable) - Related to # (issue) ## Testing Describe how these changes were tested. If you've added new features, have you added unit tests? ## Docs Describe where this code is documented. If it changes a documented interface, have the docs been updated?
1 parent b61217f commit 34cb50c

File tree

1 file changed

+9
-2
lines changed
  • crates/light-client-prover/src/circuit

1 file changed

+9
-2
lines changed

crates/light-client-prover/src/circuit/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,10 +699,17 @@ impl<S: Storage, DS: DaSpec, Z: Zkvm> LightClientProofCircuit<S, DS, Z> {
699699
let msg_nonce = sc_tx.tx_type.nonce();
700700
let current_nonce = SecurityCouncilNonceAccessor::<S>::get(working_set)
701701
.expect("Security council nonce must exist");
702-
if msg_nonce != current_nonce + 1 {
702+
let expected_nonce = match current_nonce.checked_add(1) {
703+
Some(n) => n,
704+
None => {
705+
log!("Security council nonce overflow");
706+
return;
707+
}
708+
};
709+
if msg_nonce != expected_nonce {
703710
log!(
704711
"Security council nonce mismatch: expected {}, got {}",
705-
current_nonce + 1,
712+
expected_nonce,
706713
msg_nonce
707714
);
708715
return;

0 commit comments

Comments
 (0)