Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# CHANGELOG

## UNRELEASED
## v7.0.1 - 2026-02-11

### Fixed

- Pick evm-chain-id from genesis instead of config / flag

## v7.0.0 - 2026-02-03

## Dependencies
- Bump Go version from 1.23 to 1.24
Expand Down
26 changes: 1 addition & 25 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import (
"strconv"
"strings"

"github.com/spf13/viper"

clienthelpers "cosmossdk.io/client/v2/helpers"

genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
Expand Down Expand Up @@ -72,28 +70,6 @@ func init() {
KiichainID = evmChainID
return
}
// If parsing fails, continue to check app.toml
}
}
}
if err != nil && !os.IsNotExist(err) {
panic(err)
}

// If genesis file does not exist or chain ID is not found, check app.toml
// to get the EVM chain ID
appTomlPath := filepath.Join(nodeHome, "config", "app.toml")
if _, err = os.Stat(appTomlPath); err == nil {
// File exists
v := viper.New()
v.SetConfigFile(appTomlPath)
v.SetConfigType("toml")

if err = v.ReadInConfig(); err == nil {
evmChainIDKey := "evm.evm-chain-id"
if v.IsSet(evmChainIDKey) {
evmChainID := v.GetUint64(evmChainIDKey)
KiichainID = evmChainID
}
}
}
Expand All @@ -112,7 +88,7 @@ func ParseChainID(chainID string) (uint64, error) {

matches := fullChainID.FindStringSubmatch(chainID)
if matches == nil || len(matches) != 4 || matches[1] == "" {
return 0, fmt.Errorf("chain-id '%s' does not match expected chain ID format: %s_%s-%s", chainID, regexChainID, regexEIP155, regexEpoch)
return 0, fmt.Errorf("chain-id '%s' does not match expected chain ID format: <chain name>_<evm chain id>-<epoch separator>, like localhost_1010-1", chainID)
}

// verify that the EIP155 part (matches[2]) is a base 10 integer
Expand Down
7 changes: 7 additions & 0 deletions cmd/kiichaind/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
"github.com/cosmos/cosmos-sdk/x/genutil/types"

kiichain "github.com/kiichain/kiichain/v7/app"
"github.com/kiichain/kiichain/v7/app/params"
)

Expand Down Expand Up @@ -94,6 +95,12 @@ func initCmd(mbm module.BasicManager, defaultNodeHome string) *cobra.Command {
chainID = fmt.Sprintf("test_1234-%d", unsafe.Int())
}

// Validate chain ID has evm counterpart
_, err := kiichain.ParseChainID(chainID)
if err != nil {
return err
}

// Get bip39 mnemonic and recover
var mnemonic string
recoverFlag, _ := cmd.Flags().GetBool(genutilcli.FlagRecover)
Expand Down
17 changes: 13 additions & 4 deletions cmd/kiichaind/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,12 @@ func (a appCreator) newApp(
panic(err)
}

// Validate chain ID has evm counterpart
_, err = kiichain.ParseChainID(chainID)
if err != nil {
panic(err)
}

snapshotDir := filepath.Join(homeDir, "data", "snapshots")
snapshotDB, err := dbm.NewDB("metadata", server.GetAppDBBackend(appOpts), snapshotDir)
if err != nil {
Expand Down Expand Up @@ -418,12 +424,15 @@ func (a appCreator) newApp(
panic("appOpts is not viper.Viper")
}

existingValue := viperAppOpts.Get(srvflags.EVMChainID)
// Check if value exists
if existingValue == nil || existingValue == "" {
viperAppOpts.Set(srvflags.EVMChainID, kiichain.KiichainID)
evmChainIdFlag := cast.ToUint64(viperAppOpts.Get(srvflags.EVMChainID))
// Warn if flag is not default
if evmChainIdFlag != evmserverconfig.DefaultEVMChainID {
logger.Warn(fmt.Sprintf("WARNING: The --%s flag is deprecrated. The evm chain ID is being overridden to %d. Remove it from the start command and the from '.kiichaind/config/app.toml' to remove warning.",
srvflags.EVMChainID, kiichain.KiichainID))
}

viperAppOpts.Set(srvflags.EVMChainID, kiichain.KiichainID)

return kiichain.NewKiichainApp(
logger,
db,
Expand Down
Loading