From 41b800cd6c875dfcdb8b2a5f475ba6129f589b69 Mon Sep 17 00:00:00 2001 From: Yawning Angel Date: Wed, 8 Apr 2020 13:52:45 +0000 Subject: [PATCH] go/oasis-node/cmd/debug/consim: Wire in the pruner --- go/oasis-node/cmd/debug/consim/consim.go | 3 +++ go/oasis-node/cmd/debug/consim/mockchain.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/go/oasis-node/cmd/debug/consim/consim.go b/go/oasis-node/cmd/debug/consim/consim.go index 6d4aab955e0..eee7f476520 100644 --- a/go/oasis-node/cmd/debug/consim/consim.go +++ b/go/oasis-node/cmd/debug/consim/consim.go @@ -28,6 +28,7 @@ import ( ) const ( + cfgNumKept = "consim.num_kept" cfgWorkload = "consim.workload" cfgWorkloadSeed = "consim.workload.seed" ) @@ -113,6 +114,7 @@ func doRun(cmd *cobra.Command, args []string) error { genesisDoc: genesisDoc, tmChainID: tmChainID, txAuthHandler: txAuthApp.(abci.TransactionAuthHandler), + numVersions: viper.GetInt64(cfgNumKept), } mockChain, err := initMockChain(ctx, cfg) if err != nil { @@ -245,6 +247,7 @@ func Register(parentCmd *cobra.Command) { } func init() { + flagsConsim.Int64(cfgNumKept, 0, "number of versions kept (0 = all)") flagsConsim.String(cfgWorkload, fileWorkloadName, "workload to execute") flagsConsim.String(cfgWorkloadSeed, "seeeeeeeeeeeeeeeeeeeeeeeeeeeeeed", "DRBG seed for workloads") _ = viper.BindPFlags(flagsConsim) diff --git a/go/oasis-node/cmd/debug/consim/mockchain.go b/go/oasis-node/cmd/debug/consim/mockchain.go index 4dcdc22d9d2..cabfe3b474a 100644 --- a/go/oasis-node/cmd/debug/consim/mockchain.go +++ b/go/oasis-node/cmd/debug/consim/mockchain.go @@ -25,6 +25,7 @@ type mockChainCfg struct { genesisDoc *genesis.Document tmChainID string txAuthHandler abci.TransactionAuthHandler + numVersions int64 } type mockChain struct { @@ -158,6 +159,10 @@ func initMockChain(ctx context.Context, cfg *mockChainCfg) (*mockChain, error) { MinGasPrice: 0, // XXX: Should this be configurable? OwnTxSigner: localSigner.Public(), } + if cfg.numVersions > 0 { + muxCfg.Pruning.Strategy = abci.PruneKeepN + muxCfg.Pruning.NumKept = cfg.numVersions + } mux, err := abci.NewMockMux(ctx, upgrade.NewDummyUpgradeManager(), muxCfg) if err != nil { logger.Error("failed to initialize mock mux",