Skip to content

Commit

Permalink
go/oasis-node/cmd/debug/consim: Wire in the pruner
Browse files Browse the repository at this point in the history
  • Loading branch information
Yawning committed Apr 9, 2020
1 parent 7249fc4 commit 41b800c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/oasis-node/cmd/debug/consim/consim.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
)

const (
cfgNumKept = "consim.num_kept"
cfgWorkload = "consim.workload"
cfgWorkloadSeed = "consim.workload.seed"
)
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions go/oasis-node/cmd/debug/consim/mockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type mockChainCfg struct {
genesisDoc *genesis.Document
tmChainID string
txAuthHandler abci.TransactionAuthHandler
numVersions int64
}

type mockChain struct {
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 41b800c

Please sign in to comment.