Skip to content

Commit

Permalink
return nil when we need a no-op panic handler
Browse files Browse the repository at this point in the history
  • Loading branch information
zacshowa committed Jul 10, 2024
1 parent 99eca6d commit 01f1cdb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 1 addition & 4 deletions cmd/replay/espresso_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,5 @@ func handleEspressoPreConditions(message *arbostypes.MessageWithMetadata, isEnab
panic("The messaged received by the STF is not an Espresso message, but the validator is running in Espresso mode")
}
}
panicCase := func() {
// This no-op allows us to cause no panic in the code that receives the result of this function while keeping the function signature consistent.
}
return validatingAgainstEspresso, panicCase
return validatingAgainstEspresso, nil // return nil for the panic handler such that it is a no-op in the caller if no errors need occur.
}
4 changes: 3 additions & 1 deletion cmd/replay/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,9 @@ func main() {

} else {

Check failure on line 328 in cmd/replay/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)

Check failure on line 328 in cmd/replay/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)

Check failure on line 328 in cmd/replay/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)

Check failure on line 328 in cmd/replay/main.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

elseif: can replace 'else {if cond {}}' with 'else if cond {}' (gocritic)
// Call the error case closure returned by handleEspressoPreconditions()
panicHandler()
if panicHandler != nil {
panicHandler()
}
}

newBlock, _, err = arbos.ProduceBlock(message.Message, message.DelayedMessagesRead, lastBlockHeader, statedb, chainContext, chainConfig, batchFetcher, false)
Expand Down

0 comments on commit 01f1cdb

Please sign in to comment.