@@ -6,30 +6,30 @@ import (
6
6
"os"
7
7
"path/filepath"
8
8
9
- "github.com/spf13/cast"
10
- "github.com/spf13/cobra"
11
- tmcli "github.com/tendermint/tendermint/libs/cli"
12
- "github.com/tendermint/tendermint/libs/log"
13
- dbm "github.com/tendermint/tm-db"
14
-
15
9
"github.com/cosmos/cosmos-sdk/baseapp"
16
10
"github.com/cosmos/cosmos-sdk/client"
17
- config "github.com/cosmos/cosmos-sdk/client/config"
11
+ "github.com/cosmos/cosmos-sdk/client/config"
18
12
"github.com/cosmos/cosmos-sdk/client/debug"
19
13
"github.com/cosmos/cosmos-sdk/client/flags"
20
14
"github.com/cosmos/cosmos-sdk/client/keys"
21
15
"github.com/cosmos/cosmos-sdk/client/rpc"
22
16
"github.com/cosmos/cosmos-sdk/server"
17
+ serverconfig "github.com/cosmos/cosmos-sdk/server/config"
23
18
servertypes "github.com/cosmos/cosmos-sdk/server/types"
24
19
"github.com/cosmos/cosmos-sdk/snapshots"
25
20
"github.com/cosmos/cosmos-sdk/store"
26
21
sdk "github.com/cosmos/cosmos-sdk/types"
27
22
authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
28
23
"github.com/cosmos/cosmos-sdk/x/auth/types"
29
- vestingcli "github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
30
24
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
31
25
"github.com/cosmos/cosmos-sdk/x/crisis"
32
26
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
27
+ "github.com/spf13/cast"
28
+ "github.com/spf13/cobra"
29
+ tmcli "github.com/tendermint/tendermint/libs/cli"
30
+ "github.com/tendermint/tendermint/libs/log"
31
+ dbm "github.com/tendermint/tm-db"
32
+
33
33
"github.com/cosmos/ibc-go/testing/simapp"
34
34
"github.com/cosmos/ibc-go/testing/simapp/params"
35
35
)
@@ -39,13 +39,12 @@ import (
39
39
func NewRootCmd () (* cobra.Command , params.EncodingConfig ) {
40
40
encodingConfig := simapp .MakeTestEncodingConfig ()
41
41
initClientCtx := client.Context {}.
42
- WithJSONCodec (encodingConfig .Marshaler ).
42
+ WithCodec (encodingConfig .Marshaler ).
43
43
WithInterfaceRegistry (encodingConfig .InterfaceRegistry ).
44
44
WithTxConfig (encodingConfig .TxConfig ).
45
45
WithLegacyAmino (encodingConfig .Amino ).
46
46
WithInput (os .Stdin ).
47
47
WithAccountRetriever (types.AccountRetriever {}).
48
- WithBroadcastMode (flags .BroadcastBlock ).
49
48
WithHomeDir (simapp .DefaultNodeHome ).
50
49
WithViper ("" ) // In simapp, we don't use any prefix for env variables.
51
50
@@ -68,7 +67,9 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
68
67
return err
69
68
}
70
69
71
- return server .InterceptConfigsPreRunHandler (cmd )
70
+ customAppTemplate , customAppConfig := initAppConfig ()
71
+
72
+ return server .InterceptConfigsPreRunHandler (cmd , customAppTemplate , customAppConfig )
72
73
},
73
74
}
74
75
@@ -77,7 +78,66 @@ func NewRootCmd() (*cobra.Command, params.EncodingConfig) {
77
78
return rootCmd , encodingConfig
78
79
}
79
80
81
+ // initAppConfig helps to override default appConfig template and configs.
82
+ // return "", nil if no custom configuration is required for the application.
83
+ func initAppConfig () (string , interface {}) {
84
+ // The following code snippet is just for reference.
85
+
86
+ // WASMConfig defines configuration for the wasm module.
87
+ type WASMConfig struct {
88
+ // This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
89
+ QueryGasLimit uint64 `mapstructure:"query_gas_limit"`
90
+
91
+ // Address defines the gRPC-web server to listen on
92
+ LruSize uint64 `mapstructure:"lru_size"`
93
+ }
94
+
95
+ type CustomAppConfig struct {
96
+ serverconfig.Config
97
+
98
+ WASM WASMConfig `mapstructure:"wasm"`
99
+ }
100
+
101
+ // Optionally allow the chain developer to overwrite the SDK's default
102
+ // server config.
103
+ srvCfg := serverconfig .DefaultConfig ()
104
+ // The SDK's default minimum gas price is set to "" (empty value) inside
105
+ // app.toml. If left empty by validators, the node will halt on startup.
106
+ // However, the chain developer can set a default app.toml value for their
107
+ // validators here.
108
+ //
109
+ // In summary:
110
+ // - if you leave srvCfg.MinGasPrices = "", all validators MUST tweak their
111
+ // own app.toml config,
112
+ // - if you set srvCfg.MinGasPrices non-empty, validators CAN tweak their
113
+ // own app.toml to override, or use this default value.
114
+ //
115
+ // In simapp, we set the min gas prices to 0.
116
+ srvCfg .MinGasPrices = "0stake"
117
+
118
+ customAppConfig := CustomAppConfig {
119
+ Config : * srvCfg ,
120
+ WASM : WASMConfig {
121
+ LruSize : 1 ,
122
+ QueryGasLimit : 300000 ,
123
+ },
124
+ }
125
+
126
+ customAppTemplate := serverconfig .DefaultConfigTemplate + `
127
+ [wasm]
128
+ # This is the maximum sdk gas (wasm and storage) that we allow for any x/wasm "smart" queries
129
+ query_gas_limit = 300000
130
+ # This is the number of wasm vm instances we keep cached in memory for speed-up
131
+ # Warning: this is currently unstable and may lead to crashes, best to keep for 0 unless testing locally
132
+ lru_size = 0`
133
+
134
+ return customAppTemplate , customAppConfig
135
+ }
136
+
80
137
func initRootCmd (rootCmd * cobra.Command , encodingConfig params.EncodingConfig ) {
138
+ cfg := sdk .GetConfig ()
139
+ cfg .Seal ()
140
+
81
141
rootCmd .AddCommand (
82
142
genutilcli .InitCmd (simapp .ModuleBasics , simapp .DefaultNodeHome ),
83
143
genutilcli .CollectGenTxsCmd (banktypes.GenesisBalancesIterator {}, simapp .DefaultNodeHome ),
@@ -149,12 +209,9 @@ func txCommand() *cobra.Command {
149
209
authcmd .GetMultiSignCommand (),
150
210
authcmd .GetMultiSignBatchCmd (),
151
211
authcmd .GetValidateSignaturesCommand (),
152
- flags .LineBreak ,
153
212
authcmd .GetBroadcastCommand (),
154
213
authcmd .GetEncodeCommand (),
155
214
authcmd .GetDecodeCommand (),
156
- flags .LineBreak ,
157
- vestingcli .GetTxCmd (),
158
215
)
159
216
160
217
simapp .ModuleBasics .AddTxCommands (cmd )
@@ -167,7 +224,7 @@ type appCreator struct {
167
224
encCfg params.EncodingConfig
168
225
}
169
226
170
- // newApp is an AppCreator
227
+ // newApp is an appCreator
171
228
func (a appCreator ) newApp (logger log.Logger , db dbm.DB , traceStore io.Writer , appOpts servertypes.AppOptions ) servertypes.Application {
172
229
var cache sdk.MultiStorePersistentCache
173
230
0 commit comments