diff --git a/app/app.go b/app/app.go index cc271fc35f..4fe5595199 100644 --- a/app/app.go +++ b/app/app.go @@ -4,6 +4,7 @@ import ( "io" "net/http" "os" + "runtime/debug" "time" cosmoserrors "cosmossdk.io/errors" @@ -876,6 +877,26 @@ 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. + const 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/` + + // 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) + 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) diff --git a/changelog.md b/changelog.md index d78c1861ae..437b97382d 100644 --- a/changelog.md +++ b/changelog.md @@ -45,6 +45,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