diff --git a/app/app.go b/app/app.go index 49762d9..58388ff 100644 --- a/app/app.go +++ b/app/app.go @@ -203,7 +203,7 @@ func init() { // NewLinkApp returns a reference to an initialized Link. func NewLinkApp( logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool, - homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp), + homePath string, invCheckPeriod uint, encodingConfig appparams.EncodingConfig, appOpts servertypes.AppOptions, wasmOpts []wasm.Option, baseAppOptions ...func(*baseapp.BaseApp), ) *LinkApp { appCodec := encodingConfig.Marshaler legacyAmino := encodingConfig.Amino @@ -330,6 +330,7 @@ func NewLinkApp( supportedFeatures, nil, nil, + wasmOpts..., ) // register the proposal types diff --git a/app/sim_test.go b/app/sim_test.go index f03ef40..61cf3c5 100644 --- a/app/sim_test.go +++ b/app/sim_test.go @@ -42,7 +42,7 @@ func BenchmarkFullAppSimulation(b *testing.B) { } }() - app := link.NewLinkApp(logger, db, nil, true, map[int64]bool{}, link.DefaultNodeHome, simapp.FlagPeriodValue, link.MakeEncodingConfig(), simapp.EmptyAppOptions{}, interBlockCacheOpt()) + app := link.NewLinkApp(logger, db, nil, true, map[int64]bool{}, link.DefaultNodeHome, simapp.FlagPeriodValue, link.MakeEncodingConfig(), simapp.EmptyAppOptions{}, nil, interBlockCacheOpt()) // Run randomized simulation:w _, simParams, simErr := simulation.SimulateFromSeed( @@ -108,7 +108,7 @@ func TestAppStateDeterminism(t *testing.T) { } db := memdb.NewDB() - app := link.NewLinkApp(logger, db, nil, true, map[int64]bool{}, link.DefaultNodeHome, simapp.FlagPeriodValue, link.MakeEncodingConfig(), simapp.EmptyAppOptions{}, interBlockCacheOpt()) + app := link.NewLinkApp(logger, db, nil, true, map[int64]bool{}, link.DefaultNodeHome, simapp.FlagPeriodValue, link.MakeEncodingConfig(), simapp.EmptyAppOptions{}, nil, interBlockCacheOpt()) fmt.Printf( "running non-determinism simulation; seed %d: %d/%d, attempt: %d/%d\n", diff --git a/cli_test/test_helpers.go b/cli_test/test_helpers.go index 85811df..c799b38 100644 --- a/cli_test/test_helpers.go +++ b/cli_test/test_helpers.go @@ -1342,6 +1342,7 @@ func newTestnetConfig(t *testing.T, genesisState map[string]json.RawMessage, cha return app.NewLinkApp(val.Ctx.Logger, db, nil, true, make(map[int64]bool), val.Dir, 0, encodingCfg, val.Ctx.Viper, + nil, baseapp.SetPruning(storetypes.NewPruningOptionsFromString(storetypes.PruningOptionNothing)), baseapp.SetMinGasPrices(minGasPrices), ) diff --git a/cmd/lfb/cmd/root.go b/cmd/lfb/cmd/root.go index 0050908..0ca27e5 100644 --- a/cmd/lfb/cmd/root.go +++ b/cmd/lfb/cmd/root.go @@ -26,14 +26,17 @@ import ( banktypes "github.com/line/lfb-sdk/x/bank/types" "github.com/line/lfb-sdk/x/crisis" genutilcli "github.com/line/lfb-sdk/x/genutil/client/cli" + "github.com/line/lfb-sdk/x/wasm" lfbtypes "github.com/line/lfb/types" ostcli "github.com/line/ostracon/libs/cli" "github.com/line/ostracon/libs/log" dbm "github.com/line/tm-db/v2" + "github.com/prometheus/client_golang/prometheus" "github.com/spf13/cast" "github.com/spf13/cobra" "github.com/spf13/viper" + wasmkeeper "github.com/line/lfb-sdk/x/wasm/keeper" "github.com/line/lfb/app" "github.com/line/lfb/app/params" ) @@ -195,6 +198,10 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty if err != nil { panic(err) } + var wasmOpts []wasm.Option + if cast.ToBool(appOpts.Get("telemetry.enabled")) { + wasmOpts = append(wasmOpts, wasmkeeper.WithVMCacheMetrics(prometheus.DefaultRegisterer)) + } return app.NewLinkApp( logger, db, traceStore, true, skipUpgradeHeights, @@ -202,6 +209,7 @@ func newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts serverty cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), app.MakeEncodingConfig(), // Ideally, we would reuse the one created by NewRootCmd. appOpts, + wasmOpts, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), baseapp.SetHaltHeight(cast.ToUint64(appOpts.Get(server.FlagHaltHeight))), @@ -228,13 +236,13 @@ func createSimappAndExport( return servertypes.ExportedApp{}, errors.New("application home not set") } if height != -1 { - linkApp = app.NewLinkApp(logger, db, traceStore, false, map[int64]bool{}, homePath, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts) + linkApp = app.NewLinkApp(logger, db, traceStore, false, map[int64]bool{}, homePath, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts, nil) if err := linkApp.LoadHeight(height); err != nil { return servertypes.ExportedApp{}, err } } else { - linkApp = app.NewLinkApp(logger, db, traceStore, true, map[int64]bool{}, homePath, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts) + linkApp = app.NewLinkApp(logger, db, traceStore, true, map[int64]bool{}, homePath, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encCfg, appOpts, nil) } return linkApp.ExportAppStateAndValidators(forZeroHeight, jailAllowedAddrs) diff --git a/go.mod b/go.mod index 96d551e..fffd4dc 100644 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ require ( github.com/line/lfb-sdk v1.0.0-init.1.0.20210720072128-577c2c01cf60 github.com/line/ostracon v0.34.9-0.20210610071151-a52812ac9add github.com/line/tm-db/v2 v2.0.0-init.1.0.20210413083915-5bb60e117524 + github.com/prometheus/client_golang v1.11.0 github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.3.1 github.com/spf13/cobra v1.1.3