diff --git a/app/app.go b/app/app.go index 9acdfd0b3..3605e9c22 100644 --- a/app/app.go +++ b/app/app.go @@ -202,6 +202,7 @@ func NewAxelarApp( loadLatest bool, skipUpgradeHeights map[int64]bool, homePath string, + wasmDir string, invCheckPeriod uint, encodingConfig axelarParams.EncodingConfig, appOpts servertypes.AppOptions, @@ -255,7 +256,12 @@ func NewAxelarApp( SetKeeper(keepers, initAxelarIBCKeeper(keepers)) if IsWasmEnabled() { - SetKeeper(keepers, initWasmKeeper(encodingConfig, keys, keepers, bApp, appOpts, wasmOpts, homePath)) + if wasmDir == "" { + dbDir := cast.ToString(appOpts.Get("db_dir")) + wasmDir = filepath.Join(homePath, dbDir, "wasm") + } + + SetKeeper(keepers, initWasmKeeper(encodingConfig, keys, keepers, bApp, appOpts, wasmOpts, wasmDir)) SetKeeper(keepers, initWasmContractKeeper(keepers)) // set the contract keeper for the Ics20WasmHooks diff --git a/app/app_test.go b/app/app_test.go index 558f4689a..a8698b0e1 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -41,6 +41,7 @@ func TestNewAxelarApp(t *testing.T) { true, nil, "", + "", 0, app.MakeEncodingConfig(), simapp.EmptyAppOptions{}, diff --git a/app/keepers.go b/app/keepers.go index 94cf736de..e8ae81af4 100644 --- a/app/keepers.go +++ b/app/keepers.go @@ -2,7 +2,6 @@ package app import ( "fmt" - "path/filepath" "reflect" "strings" @@ -162,8 +161,7 @@ func InitStakingKeeper(appCodec codec.Codec, keys map[string]*sdk.KVStoreKey, ke return &stakingK } -func initWasmKeeper(encodingConfig axelarParams.EncodingConfig, keys map[string]*sdk.KVStoreKey, keepers *KeeperCache, bApp *bam.BaseApp, appOpts types.AppOptions, wasmOpts []wasm.Option, homePath string) *wasm.Keeper { - wasmDir := filepath.Join(homePath, "wasm") +func initWasmKeeper(encodingConfig axelarParams.EncodingConfig, keys map[string]*sdk.KVStoreKey, keepers *KeeperCache, bApp *bam.BaseApp, appOpts types.AppOptions, wasmOpts []wasm.Option, wasmDir string) *wasm.Keeper { wasmConfig := mustReadWasmConfig(appOpts) // The last arguments can contain custom message handlers, and custom query handlers, diff --git a/cmd/axelard/cmd/root.go b/cmd/axelard/cmd/root.go index 5f9f3d685..045f0b718 100644 --- a/cmd/axelard/cmd/root.go +++ b/cmd/axelard/cmd/root.go @@ -47,7 +47,10 @@ import ( axelarnet "github.com/axelarnetwork/axelar-core/x/axelarnet/exported" ) -var minGasPrice = "0.007" + axelarnet.NativeAsset +var ( + minGasPrice = "0.007" + axelarnet.NativeAsset + wasmDirFlag = "wasm-dir" +) // NewRootCmd creates a new root command for axelard. It is called once in the // main function. @@ -201,7 +204,12 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) { SetGenesisAuthCmd(app.DefaultNodeHome), ) - server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, export(encodingConfig), crisis.AddModuleInitFlags) + starterFlags := func(startCmd *cobra.Command) { + crisis.AddModuleInitFlags(startCmd) + startCmd.Flags().String(wasmDirFlag, "", "path to the wasm directory, by default set to 'wasm' directory inside the '--db_dir' directory") + } + + server.AddCommands(rootCmd, app.DefaultNodeHome, newApp, export(encodingConfig), starterFlags) // add keybase, auxiliary RPC, query, and tx child commands rootCmd.AddCommand( @@ -264,6 +272,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty return app.NewAxelarApp( logger, db, traceStore, true, skipUpgradeHeights, cast.ToString(appOpts.Get(flags.FlagHome)), + cast.ToString(appOpts.Get(wasmDirFlag)), cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), app.MakeEncodingConfig(), appOpts, @@ -291,7 +300,8 @@ func export(encCfg params.EncodingConfig) servertypes.AppExporter { return servertypes.ExportedApp{}, errors.New("application home not set") } - aApp := app.NewAxelarApp(logger, db, traceStore, height == -1, map[int64]bool{}, homePath, + wasmdir := cast.ToString(appOpts.Get(wasmDirFlag)) + aApp := app.NewAxelarApp(logger, db, traceStore, height == -1, map[int64]bool{}, homePath, wasmdir, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts, []wasm.Option{}) if height != -1 { if err := aApp.LoadHeight(height); err != nil { diff --git a/docs/cli/axelard_start.md b/docs/cli/axelard_start.md index 5ba47b2c5..b82c4d9a7 100644 --- a/docs/cli/axelard_start.md +++ b/docs/cli/axelard_start.md @@ -88,6 +88,7 @@ axelard start [flags] --trace-store string Enable KVStore tracing to an output file --transport string Transport protocol: socket, grpc (default "socket") --unsafe-skip-upgrades ints Skip a set of upgrade heights to continue the old binary + --wasm-dir string path to the wasm directory, by default set to 'wasm' directory inside the '--db_dir' directory --with-tendermint Run abci app embedded in-process with tendermint (default true) --x-crisis-skip-assert-invariants Skip x/crisis invariants check on startup ```