From 55148b79d3d4d56db5a906dec1bfe81a29a9b390 Mon Sep 17 00:00:00 2001 From: Jordi Pinyana Date: Tue, 9 Jan 2024 10:55:57 +0100 Subject: [PATCH] enforce non empty chainID on node app init --- vochain/app.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/vochain/app.go b/vochain/app.go index 9f1d6cc22..9c2899cd9 100644 --- a/vochain/app.go +++ b/vochain/app.go @@ -340,6 +340,14 @@ func (app *BaseApplication) ChainID() string { // SetChainID sets the app and state chainID func (app *BaseApplication) SetChainID(chainID string) { + // A chain must have a chainID in order to be univocally identified. + // If the chainID is empty, panic here as it is the first part + // of the node app initialization. + // Stopping the execution at this point avoids carrying an invalid + // chainID in all subsequent operations. + if chainID == "" { + panic("chainID cannot be empty") + } app.chainID = chainID app.State.SetChainID(chainID) }