diff --git a/chain/cosmos/chain_node.go b/chain/cosmos/chain_node.go index 8ac5e9d86..0c89bcfbc 100644 --- a/chain/cosmos/chain_node.go +++ b/chain/cosmos/chain_node.go @@ -556,7 +556,14 @@ func (tn *ChainNode) AddGenesisAccount(ctx context.Context, address string, gene ctx, cancel := context.WithTimeout(ctx, time.Minute) defer cancel() - _, _, err := tn.ExecBin(ctx, "add-genesis-account", address, amount) + var command []string + if tn.Chain.Config().UsingNewGenesisCommand { + command = append(command, "genesis") + } + + command = append(command, "add-genesis-account", address, amount) + _, _, err := tn.ExecBin(ctx, command...) + return err } @@ -565,20 +572,28 @@ func (tn *ChainNode) Gentx(ctx context.Context, name string, genesisSelfDelegati tn.lock.Lock() defer tn.lock.Unlock() - _, _, err := tn.ExecBin(ctx, - "gentx", valKey, fmt.Sprintf("%d%s", genesisSelfDelegation.Amount.Int64(), genesisSelfDelegation.Denom), + var command []string + if tn.Chain.Config().UsingNewGenesisCommand { + command = append(command, "genesis") + } + + command = append(command, "gentx", valKey, fmt.Sprintf("%d%s", genesisSelfDelegation.Amount.Int64(), genesisSelfDelegation.Denom), "--keyring-backend", keyring.BackendTest, - "--chain-id", tn.Chain.Config().ChainID, - ) + "--chain-id", tn.Chain.Config().ChainID) + + _, _, err := tn.ExecBin(ctx, command...) return err } // CollectGentxs runs collect gentxs on the node's home folders func (tn *ChainNode) CollectGentxs(ctx context.Context) error { - command := []string{tn.Chain.Config().Bin, "collect-gentxs", - "--home", tn.HomeDir(), + command := []string{tn.Chain.Config().Bin} + if tn.Chain.Config().UsingNewGenesisCommand { + command = append(command, "genesis") } + command = append(command, "collect-gentxs", "--home", tn.HomeDir()) + tn.lock.Lock() defer tn.lock.Unlock() diff --git a/chainspec.go b/chainspec.go index a32f070d8..d40beb214 100644 --- a/chainspec.go +++ b/chainspec.go @@ -141,6 +141,7 @@ func (s *ChainSpec) applyConfigOverrides(cfg ibc.ChainConfig) (*ibc.ChainConfig, if s.ModifyGenesis != nil { cfg.ModifyGenesis = s.ModifyGenesis } + cfg.UsingNewGenesisCommand = s.UsingNewGenesisCommand // Set the version depending on the chain type. switch cfg.Type { diff --git a/chainspec_test.go b/chainspec_test.go index cbf0b21b5..24e25f2a3 100644 --- a/chainspec_test.go +++ b/chainspec_test.go @@ -133,6 +133,18 @@ func TestChainSpec_Config(t *testing.T) { require.Equal(t, m, cfg.NoHostMount) }) + + t.Run("UsingNewGenesisCommand", func(t *testing.T) { + require.False(t, baseCfg.UsingNewGenesisCommand) + + s := baseSpec + s.UsingNewGenesisCommand = true + + cfg, err := s.Config(zaptest.NewLogger(t)) + require.NoError(t, err) + + require.True(t, cfg.UsingNewGenesisCommand) + }) }) t.Run("error cases", func(t *testing.T) { diff --git a/ibc/types.go b/ibc/types.go index 741b13e96..9f8166414 100644 --- a/ibc/types.go +++ b/ibc/types.go @@ -40,6 +40,8 @@ type ChainConfig struct { ConfigFileOverrides map[string]any // Non-nil will override the encoding config, used for cosmos chains only. EncodingConfig *testutil.TestEncodingConfig + // Required when the chain uses the new sub commands for genesis (https://github.com/cosmos/cosmos-sdk/pull/14149) + UsingNewGenesisCommand bool `yaml:"using-new-genesis-command"` } func (c ChainConfig) Clone() ChainConfig {