Skip to content

Commit

Permalink
Refactor ChainID
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed Apr 8, 2024
1 parent c0b7ef0 commit f52f130
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
16 changes: 15 additions & 1 deletion cmd/ethermintd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"cosmossdk.io/simapp/params"
rosettaCmd "cosmossdk.io/tools/rosetta/cmd"
tmtypes "github.com/cometbft/cometbft/types"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/config"
Expand Down Expand Up @@ -246,6 +247,19 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer,
cast.ToUint32(appOpts.Get(sdkserver.FlagStateSyncSnapshotKeepRecent)),
)

homeDir := cast.ToString(appOpts.Get(flags.FlagHome))

// Setup chainId
chainID := cast.ToString(appOpts.Get(flags.FlagChainID))
if len(chainID) == 0 {
// fallback to genesis chain-id
appGenesis, err := tmtypes.GenesisDocFromFile(filepath.Join(homeDir, "config", "genesis.json"))
if err != nil {
panic(err)
}
chainID = appGenesis.ChainID
}

ethermintApp := app.NewEthermintApp(
logger, db, traceStore, true, skipUpgradeHeights,
cast.ToString(appOpts.Get(flags.FlagHome)),
Expand All @@ -263,7 +277,7 @@ func (a appCreator) newApp(logger tmlog.Logger, db dbm.DB, traceStore io.Writer,
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(sdkserver.FlagIAVLCacheSize))),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(sdkserver.FlagDisableIAVLFastNode))),
baseapp.SetChainID("ethermint_9000-1"),
baseapp.SetChainID(chainID),
)

return ethermintApp
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_tests/test_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test_cosmovisor_upgrade(custom_ethermint: Ethermint):
)
assert rsp["code"] == 0, rsp["raw_log"]
# wait until tx will be processed
time.sleep(3)
time.sleep(5)
approve_proposal(custom_ethermint, rsp)

# update cli chain binary
Expand Down
4 changes: 3 additions & 1 deletion tests/integration_tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,10 @@ def cb(attrs):
for i in range(len(n.config["validators"])):
rsp = n.cosmos_cli(i).gov_vote("validator", proposal_id, "yes", gas=1000000)
assert rsp["code"] == 0, rsp["raw_log"]

# wait until txs will be processed
time.sleep(5)
wait_for_new_blocks(cli, 1)

res = cli.query_tally(proposal_id)
res = res.get("tally") or res
assert (
Expand Down

0 comments on commit f52f130

Please sign in to comment.