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 2 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
11 changes: 11 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 @@ -91,6 +92,7 @@ import (

"github.com/zeta-chain/node/app/ante"
"github.com/zeta-chain/node/docs/openapi"
zetaconstant "github.com/zeta-chain/node/pkg/constant"
zetamempool "github.com/zeta-chain/node/pkg/mempool"
"github.com/zeta-chain/node/precompiles"
srvflags "github.com/zeta-chain/node/server/flags"
Expand Down Expand Up @@ -875,6 +877,15 @@ 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 {
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(zetaconstant.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
3 changes: 3 additions & 0 deletions pkg/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ const (

// OptionUnpause is the argument used in CmdUpdateERC20CustodyPauseStatus to unpause the ERC20 custody contract
OptionUnpause = "unpause"

// InitChainErrorMessage is the error message displayed when trying to sync testnet or mainnet from block 1
InitChainErrorMessage = "You cannot sync testnet or mainnet from block 1 using the latest version. You should sync your node from a snapshot"
)
Loading