Skip to content

Commit

Permalink
move InitChainErrorMessage to app.go
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Sep 26, 2024
1 parent 94f57ef commit 44c0acf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 7 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ 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 @@ -877,16 +876,21 @@ 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/"
// 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.
// 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(zetaconstant.InitChainErrorMessage)
Info(InitChainErrorMessage)
os.Exit(1)
}
}()
Expand Down
6 changes: 0 additions & 6 deletions pkg/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,4 @@ 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. " +
"Refer to the documentation for more information: " +
"https://www.zetachain.com/docs/nodes/start-here/syncing/"
)

0 comments on commit 44c0acf

Please sign in to comment.