Skip to content

Commit b78305e

Browse files
author
Alex | Interchain Labs
authored
chore: remove the use of simapp (#3783)
* fix * fix * cl
1 parent 72f22cc commit b78305e

File tree

6 files changed

+76
-23
lines changed

6 files changed

+76
-23
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
### STATE BREAKING
99
- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.53.0](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.53.0) (#3773)
10+
-
11+
### BUG-FIXES
12+
- Fix the `testnet` command to use the proper gaia binary ([\#3783](https://github.com/cosmos/gaia/pull/3783))
1013

1114
## v24.0.0
1215

app/app.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gaia
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"io"
67
"net/http"
@@ -440,6 +441,11 @@ func (app *GaiaApp) AppCodec() codec.Codec {
440441
return app.appCodec
441442
}
442443

444+
// DefaultGenesis returns a default genesis from the registered AppModuleBasic's.
445+
func (app *GaiaApp) DefaultGenesis() map[string]json.RawMessage {
446+
return app.ModuleBasics.DefaultGenesis(app.appCodec)
447+
}
448+
443449
// InterfaceRegistry returns Gaia's InterfaceRegistry
444450
func (app *GaiaApp) InterfaceRegistry() types.InterfaceRegistry {
445451
return app.interfaceRegistry

cmd/gaiad/cmd/testnet.go

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ import (
1616
"github.com/cometbft/cometbft/types"
1717
tmtime "github.com/cometbft/cometbft/types/time"
1818

19+
dbm "github.com/cosmos/cosmos-db"
20+
21+
"cosmossdk.io/log"
1922
"cosmossdk.io/math"
20-
"cosmossdk.io/simapp"
23+
pruningtypes "cosmossdk.io/store/pruning/types"
2124

25+
bam "github.com/cosmos/cosmos-sdk/baseapp"
2226
"github.com/cosmos/cosmos-sdk/client"
2327
"github.com/cosmos/cosmos-sdk/client/flags"
2428
"github.com/cosmos/cosmos-sdk/client/tx"
@@ -28,15 +32,20 @@ import (
2832
"github.com/cosmos/cosmos-sdk/runtime"
2933
"github.com/cosmos/cosmos-sdk/server"
3034
srvconfig "github.com/cosmos/cosmos-sdk/server/config"
35+
servertypes "github.com/cosmos/cosmos-sdk/server/types"
3136
"github.com/cosmos/cosmos-sdk/testutil"
3237
"github.com/cosmos/cosmos-sdk/testutil/network"
38+
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
3339
sdk "github.com/cosmos/cosmos-sdk/types"
3440
"github.com/cosmos/cosmos-sdk/types/module"
41+
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
3542
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
3643
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
3744
"github.com/cosmos/cosmos-sdk/x/genutil"
3845
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
3946
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
47+
48+
gaia "github.com/cosmos/gaia/v25/app"
4049
)
4150

4251
var (
@@ -230,13 +239,13 @@ func initTestnetFiles(
230239
nodeIDs := make([]string, args.numValidators)
231240
valPubKeys := make([]cryptotypes.PubKey, args.numValidators)
232241

233-
simappConfig := srvconfig.DefaultConfig()
234-
simappConfig.MinGasPrices = args.minGasPrices
235-
simappConfig.API.Enable = true
236-
simappConfig.Telemetry.Enabled = true
237-
simappConfig.Telemetry.PrometheusRetentionTime = 60
238-
simappConfig.Telemetry.EnableHostnameLabel = false
239-
simappConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}}
242+
gaiadConfig := srvconfig.DefaultConfig()
243+
gaiadConfig.MinGasPrices = args.minGasPrices
244+
gaiadConfig.API.Enable = true
245+
gaiadConfig.Telemetry.Enabled = true
246+
gaiadConfig.Telemetry.PrometheusRetentionTime = 60
247+
gaiadConfig.Telemetry.EnableHostnameLabel = false
248+
gaiadConfig.Telemetry.GlobalLabels = [][]string{{"chain_id", args.chainID}}
240249

241250
var (
242251
genAccounts []authtypes.GenesisAccount
@@ -354,7 +363,7 @@ func initTestnetFiles(
354363
return err
355364
}
356365

357-
srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config", "app.toml"), simappConfig)
366+
srvconfig.WriteConfigFile(filepath.Join(nodeDir, "config", "app.toml"), gaiadConfig)
358367
}
359368

360369
if err := initGenFiles(clientCtx, mbm, args.chainID, genAccounts, genBalances, genFiles, args.numValidators); err != nil {
@@ -508,7 +517,7 @@ func writeFile(name string, dir string, contents []byte) error {
508517

509518
// startTestnet starts an in-process testnet
510519
func startTestnet(cmd *cobra.Command, args startArgs) error {
511-
networkConfig := network.DefaultConfig(simapp.NewTestNetworkFixture)
520+
networkConfig := network.DefaultConfig(NewTestNetworkFixture)
512521

513522
// Default networkConfig.ChainID is random, and we should only override it if chainID provided
514523
// is non-empty
@@ -548,3 +557,50 @@ func startTestnet(cmd *cobra.Command, args startArgs) error {
548557

549558
return nil
550559
}
560+
561+
// NewTestNetworkFixture returns a new gaiad AppConstructor for network simulation tests
562+
func NewTestNetworkFixture() network.TestFixture {
563+
dir, err := os.MkdirTemp("", "gaia")
564+
if err != nil {
565+
panic(fmt.Sprintf("failed creating temporary directory: %v", err))
566+
}
567+
defer os.RemoveAll(dir)
568+
569+
app := gaia.NewGaiaApp(
570+
log.NewNopLogger(),
571+
dbm.NewMemDB(),
572+
nil,
573+
true,
574+
nil,
575+
dir,
576+
simtestutil.NewAppOptionsWithFlagHome(dir),
577+
nil,
578+
)
579+
580+
appCtr := func(val network.ValidatorI) servertypes.Application {
581+
return gaia.NewGaiaApp(
582+
log.NewNopLogger(),
583+
dbm.NewMemDB(),
584+
nil,
585+
true,
586+
nil,
587+
val.GetCtx().Config.RootDir,
588+
simtestutil.NewAppOptionsWithFlagHome(val.GetCtx().Config.RootDir),
589+
nil,
590+
bam.SetPruning(pruningtypes.NewPruningOptionsFromString(val.GetAppConfig().Pruning)),
591+
bam.SetMinGasPrices(val.GetAppConfig().MinGasPrices),
592+
bam.SetChainID(val.GetCtx().Viper.GetString(flags.FlagChainID)),
593+
)
594+
}
595+
596+
return network.TestFixture{
597+
AppConstructor: appCtr,
598+
GenesisState: app.DefaultGenesis(),
599+
EncodingConfig: moduletestutil.TestEncodingConfig{
600+
InterfaceRegistry: app.InterfaceRegistry(),
601+
Codec: app.AppCodec(),
602+
TxConfig: app.GetTxConfig(),
603+
Amino: app.LegacyAmino(),
604+
},
605+
}
606+
}

docs/docs/resources/service-providers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Available Commands:
8787
start Run the full node
8888
status Query remote node for status
8989
tendermint Tendermint subcommands
90-
testnet Initialize files for a simapp testnet
90+
testnet Initialize files for a gaia testnet
9191
tx Transactions subcommands
9292
unsafe-reset-all Resets the blockchain database, removes address book files, and resets data/priv_validator_state.json to the genesis state
9393
validate-genesis validates the genesis file at the default location or at the location passed as an arg

go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require (
1111
cosmossdk.io/errors v1.0.2
1212
cosmossdk.io/log v1.6.0
1313
cosmossdk.io/math v1.5.3
14-
cosmossdk.io/simapp v0.0.0-20240118210941-3897926e722e
1514
cosmossdk.io/store v1.1.2
1615
cosmossdk.io/tools/confix v0.1.2
1716
cosmossdk.io/tools/rosetta v0.2.1-0.20230613133644-0a778132a60f
@@ -23,7 +22,6 @@ require (
2322
github.com/CosmWasm/wasmvm/v2 v2.2.3
2423
github.com/cometbft/cometbft v0.38.17
2524
github.com/cometbft/cometbft-db v1.0.4
26-
github.com/cometbft/cometbft/api v1.0.0
2725
github.com/cosmos/cosmos-db v1.1.1
2826
github.com/cosmos/cosmos-proto v1.0.0-beta.5
2927
github.com/cosmos/cosmos-sdk v0.53.0
@@ -74,8 +72,6 @@ require (
7472
cloud.google.com/go/storage v1.49.0 // indirect
7573
cosmossdk.io/collections v1.2.1 // indirect
7674
cosmossdk.io/depinject v1.2.0 // indirect
77-
cosmossdk.io/x/circuit v0.2.0-rc.2 // indirect
78-
cosmossdk.io/x/nft v0.2.0-rc.2 // indirect
7975
dario.cat/mergo v1.0.0 // indirect
8076
filippo.io/edwards25519 v1.1.0 // indirect
8177
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect

go.sum

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,6 @@ cosmossdk.io/math v1.5.3 h1:WH6tu6Z3AUCeHbeOSHg2mt9rnoiUWVWaQ2t6Gkll96U=
636636
cosmossdk.io/math v1.5.3/go.mod h1:uqcZv7vexnhMFJF+6zh9EWdm/+Ylyln34IvPnBauPCQ=
637637
cosmossdk.io/schema v1.1.0 h1:mmpuz3dzouCoyjjcMcA/xHBEmMChN+EHh8EHxHRHhzE=
638638
cosmossdk.io/schema v1.1.0/go.mod h1:Gb7pqO+tpR+jLW5qDcNOSv0KtppYs7881kfzakguhhI=
639-
cosmossdk.io/simapp v0.0.0-20240118210941-3897926e722e h1:prrEM8wTWf6Rv0XchutuUtWfWlQHG4G3OylkTYgPlNk=
640-
cosmossdk.io/simapp v0.0.0-20240118210941-3897926e722e/go.mod h1:MoWto/xnPVt23TgkMEp5Rssw9Z7sV7VUQb8j5/y+fXY=
641639
cosmossdk.io/store v1.1.2 h1:3HOZG8+CuThREKv6cn3WSohAc6yccxO3hLzwK6rBC7o=
642640
cosmossdk.io/store v1.1.2/go.mod h1:60rAGzTHevGm592kFhiUVkNC9w7gooSEn5iUBPzHQ6A=
643641
cosmossdk.io/tools/confix v0.1.2 h1:2hoM1oFCNisd0ltSAAZw2i4ponARPmlhuNu3yy0VwI4=
@@ -650,8 +648,6 @@ cosmossdk.io/x/evidence v0.2.0-rc.2 h1:cLTCebjHTye/QoehLM8WJG4xZTFE6ET0WRY108aF/
650648
cosmossdk.io/x/evidence v0.2.0-rc.2/go.mod h1:FH9n6k1oCDoVk4hSd1JOiVpKO3HrFsBAL6kzfrVqagc=
651649
cosmossdk.io/x/feegrant v0.2.0-rc.2 h1:yA7a+wF0ax0p5d0L19KYAwaLBLawtc5woZgF0R2zzcA=
652650
cosmossdk.io/x/feegrant v0.2.0-rc.2/go.mod h1:Z1daRnKKiqdJqwc5+Iq8jrI2tJn2c0IKT3PwPmGpPdY=
653-
cosmossdk.io/x/nft v0.2.0-rc.2 h1:YrxiSienta4SLQOq8TBj1o8nvUDsZAfO2ZLMjLnVIgg=
654-
cosmossdk.io/x/nft v0.2.0-rc.2/go.mod h1:8bASPHFv8KOpu3pCUriZZD2LYfEcelzJGeI9mnjNS8c=
655651
cosmossdk.io/x/tx v0.14.0 h1:hB3O25kIcyDW/7kMTLMaO8Ripj3yqs5imceVd6c/heA=
656652
cosmossdk.io/x/tx v0.14.0/go.mod h1:Tn30rSRA1PRfdGB3Yz55W4Sn6EIutr9xtMKSHij+9PM=
657653
cosmossdk.io/x/upgrade v0.2.0-rc.2 h1:JYxl0qAEaIPG/bYfuNkJVd9blAgr2fPaCxquf1S6AXI=
@@ -880,8 +876,6 @@ github.com/cometbft/cometbft v0.38.17 h1:FkrQNbAjiFqXydeAO81FUzriL4Bz0abYxN/eOHr
880876
github.com/cometbft/cometbft v0.38.17/go.mod h1:5l0SkgeLRXi6bBfQuevXjKqML1jjfJJlvI1Ulp02/o4=
881877
github.com/cometbft/cometbft-db v1.0.4 h1:cezb8yx/ZWcF124wqUtAFjAuDksS1y1yXedvtprUFxs=
882878
github.com/cometbft/cometbft-db v1.0.4/go.mod h1:M+BtHAGU2XLrpUxo3Nn1nOCcnVCiLM9yx5OuT0u5SCA=
883-
github.com/cometbft/cometbft/api v1.0.0 h1:gGBwvsJi/gnHJEtwYfjPIGs2AKg/Vfa1ZuKCPD1/Ko4=
884-
github.com/cometbft/cometbft/api v1.0.0/go.mod h1:EkQiqVSu/p2ebrZEnB2z6Re7r8XNe//M7ylR0qEwWm0=
885879
github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ=
886880
github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
887881
github.com/consensys/bavard v0.1.22 h1:Uw2CGvbXSZWhqK59X0VG/zOjpTFuOMcPLStrp1ihI0A=
@@ -929,8 +923,6 @@ github.com/cosmos/ics23/go v0.11.0 h1:jk5skjT0TqX5e5QJbEnwXIS2yI2vnmLOgpQPeM5Rtn
929923
github.com/cosmos/ics23/go v0.11.0/go.mod h1:A8OjxPE67hHST4Icw94hOxxFEJMBG031xIGF/JHNIY0=
930924
github.com/cosmos/interchain-security/v7 v7.0.0-20250408210344-06e0dc6bf6d6 h1:SzJ/+uqrTsJmI+f/GqPdC4lGxgDQKYvtRCMXFdJljNM=
931925
github.com/cosmos/interchain-security/v7 v7.0.0-20250408210344-06e0dc6bf6d6/go.mod h1:W7JHsNaZ5XoH88cKT+wuCRsXkx/Fcn2kEwzpeGdJBxI=
932-
github.com/cosmos/interchain-security/v7 v7.0.1 h1:jg2pMbchCBN5LRDDgd9l86fcvw1v8dezGAxazhI0gtQ=
933-
github.com/cosmos/interchain-security/v7 v7.0.1/go.mod h1:pcb0SYZVxy1LuY4UK9ceIdQ+kjnosa9tzE3tcCWdIZw=
934926
github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo=
935927
github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA=
936928
github.com/cosmos/ledger-cosmos-go v0.14.0 h1:WfCHricT3rPbkPSVKRH+L4fQGKYHuGOK9Edpel8TYpE=

0 commit comments

Comments
 (0)