Skip to content

Commit

Permalink
feat(sequencer): add safety checks (#1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
kstoykov authored Sep 27, 2024
1 parent 8426464 commit b650ff6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions zk/stages/stage_sequence_execute_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ func newBatchState(forkId, batchNumber, blockNumber uint64, hasExecutorForThisBa
batchState.limboRecoveryData = newLimboRecoveryData(limboBlock.BlockTimestamp, limboTxHash)
}

if batchState.isL1Recovery() && batchState.isLimboRecovery() {
panic("Both recoveries cannot be active simultaneously")
if batchState.isMoreThanSingleRecovery() {
panic(fmt.Errorf("only single recovery could be active at a time, L1Recovery: %t, limboRecovery: %t, ResequenceRecovery: %t", batchState.isL1Recovery(), batchState.isLimboRecovery(), batchState.isResequence()))
}
}

Expand All @@ -108,6 +108,24 @@ func (bs *BatchState) isAnyRecovery() bool {
return bs.isL1Recovery() || bs.isLimboRecovery() || bs.isResequence()
}

func (bs *BatchState) isMoreThanSingleRecovery() bool {
recoveryCounter := 0

if bs.isL1Recovery() {
recoveryCounter++
}

if bs.isLimboRecovery() {
recoveryCounter++
}

if bs.isResequence() {
recoveryCounter++
}

return recoveryCounter > 1
}

func (bs *BatchState) isThereAnyTransactionsToRecover() bool {
if !bs.isL1Recovery() {
return false
Expand Down

0 comments on commit b650ff6

Please sign in to comment.