Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add recover to InitChainer to diplay informative message when starting a node from block 1 #2925

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"io"
"net/http"
"os"
"runtime/debug"
"time"

cosmoserrors "cosmossdk.io/errors"
Expand Down Expand Up @@ -875,6 +876,24 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo

// InitChainer application update at chain initialization
func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.ResponseInitChain {
// InitChainErrorMessage is the error message displayed when trying to sync testnet or mainnet from block 1 using the latest binary.
InitChainErrorMessage := "Unable to sync testnet or mainnet from block 1 using the latest version. " +
"Please use a snapshot to sync your node. " +
"Refer to the documentation for more information: " +
"https://www.zetachain.com/docs/nodes/start-here/syncing/"
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
// The defer is used to catch panics during InitChain
// and display a more meaningful message for people trying to sync a node from block 1 using the latest binary.
// We exit the process after displaying the message as we do not need to start a node with empty state.

defer func() {
if r := recover(); r != nil {
ctx.Logger().Error("panic occurred during InitGenesis", "error", r)
kingpinXD marked this conversation as resolved.
Show resolved Hide resolved
ctx.Logger().Debug("stack trace", "stack", string(debug.Stack()))
ctx.Logger().
Info(InitChainErrorMessage)
os.Exit(1)
}
}()
var genesisState GenesisState
if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil {
panic(err)
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
* [2944](https://github.com/zeta-chain/node/pull/2844) - add tsspubkey to index for tss keygen voting
* [2842](https://github.com/zeta-chain/node/pull/2842) - fix: move interval assignment out of cctx loop in EVM outbound tx scheduler
* [2853](https://github.com/zeta-chain/node/pull/2853) - calling precompile through sc with sc state update
* [2925](https://github.com/zeta-chain/node/pull/2925) - add recover to init chainer to diplay informative message when starting a node from block 1

## v20.0.0

Expand Down
Loading