Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

feat: apply wasm opts #23

Merged
merged 1 commit into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -330,6 +330,7 @@ func NewLinkApp(
supportedFeatures,
nil,
nil,
wasmOpts...,
)

// register the proposal types
Expand Down
4 changes: 2 additions & 2 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions cli_test/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down
12 changes: 10 additions & 2 deletions cmd/lfb/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -195,13 +198,18 @@ 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,
cast.ToString(appOpts.Get(flags.FlagHome)),
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))),
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down