From 35c4ea5cd7276422c9fb03b9e24bf36eae3b769f Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 20 Nov 2024 19:02:02 +0400 Subject: [PATCH] fix(server(/v2)): fix fallback genesis path (#22564) (cherry picked from commit 1effb80c8b789c7b3aa7eee587182c6998426f38) --- server/util.go | 7 ++++++- server/v2/cometbft/server.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/server/util.go b/server/util.go index 254dc8f558a..3ac629f6e99 100644 --- a/server/util.go +++ b/server/util.go @@ -507,7 +507,12 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) { chainID := cast.ToString(appOpts.Get(flags.FlagChainID)) if chainID == "" { // fallback to genesis chain-id - reader, err := os.Open(filepath.Join(homeDir, "config", "genesis.json")) + genesisPathCfg := appOpts.GetString("genesis_file") + if genesisPathCfg == "" { + genesisPathCfg = filepath.Join("config", "genesis.json") + } + + reader, err := os.Open(filepath.Join(homeDir, genesisPathCfg)) if err != nil { panic(err) } diff --git a/server/v2/cometbft/server.go b/server/v2/cometbft/server.go index a8269317fad..58eb7b44257 100644 --- a/server/v2/cometbft/server.go +++ b/server/v2/cometbft/server.go @@ -94,7 +94,7 @@ func New[T transaction.Tx]( chainID, _ := cfg[FlagChainID].(string) if chainID == "" { // fallback to genesis chain-id - reader, err := os.Open(filepath.Join(home, "config", "genesis.json")) + reader, err := os.Open(srv.config.ConfigTomlConfig.GenesisFile()) if err != nil { return nil, fmt.Errorf("failed to open genesis file: %w", err) }