diff --git a/go/consensus/tendermint/abci/mux.go b/go/consensus/tendermint/abci/mux.go index 71a2c77d9a5..d249c7b6a48 100644 --- a/go/consensus/tendermint/abci/mux.go +++ b/go/consensus/tendermint/abci/mux.go @@ -67,6 +67,9 @@ type ApplicationConfig struct { // OwnTxSigner is the transaction signer identity of the local node. OwnTxSigner signature.PublicKey + + // TestingMemDB forces the MemDB to be used for the state storage. + TestingMemDB bool } // TransactionAuthHandler is the interface for ABCI applications that handle diff --git a/go/consensus/tendermint/abci/state.go b/go/consensus/tendermint/abci/state.go index 6738714201c..858f8d23a92 100644 --- a/go/consensus/tendermint/abci/state.go +++ b/go/consensus/tendermint/abci/state.go @@ -429,8 +429,15 @@ func (s *applicationState) metricsWorker() { } } +func newStateDB(cfg *ApplicationConfig) (dbm.DB, error) { + if cfg.TestingMemDB { + return dbm.NewMemDB(), nil + } + return db.New(filepath.Join(cfg.DataDir, "abci-mux-state"), false) +} + func newApplicationState(ctx context.Context, cfg *ApplicationConfig) (*applicationState, error) { - db, err := db.New(filepath.Join(cfg.DataDir, "abci-mux-state"), false) + db, err := newStateDB(cfg) if err != nil { return nil, err } diff --git a/go/oasis-node/cmd/debug/consim/consim.go b/go/oasis-node/cmd/debug/consim/consim.go index eee7f476520..f7c095ab51b 100644 --- a/go/oasis-node/cmd/debug/consim/consim.go +++ b/go/oasis-node/cmd/debug/consim/consim.go @@ -29,6 +29,7 @@ import ( const ( cfgNumKept = "consim.num_kept" + cfgMemDB = "consim.memdb" cfgWorkload = "consim.workload" cfgWorkloadSeed = "consim.workload.seed" ) @@ -115,6 +116,7 @@ func doRun(cmd *cobra.Command, args []string) error { tmChainID: tmChainID, txAuthHandler: txAuthApp.(abci.TransactionAuthHandler), numVersions: viper.GetInt64(cfgNumKept), + memDB: viper.GetBool(cfgMemDB), } mockChain, err := initMockChain(ctx, cfg) if err != nil { @@ -248,6 +250,7 @@ func Register(parentCmd *cobra.Command) { func init() { flagsConsim.Int64(cfgNumKept, 0, "number of versions kept (0 = all)") + flagsConsim.Bool(cfgMemDB, false, "use memory to store state") 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 cabfe3b474a..8fa86cbfbd0 100644 --- a/go/oasis-node/cmd/debug/consim/mockchain.go +++ b/go/oasis-node/cmd/debug/consim/mockchain.go @@ -26,6 +26,7 @@ type mockChainCfg struct { tmChainID string txAuthHandler abci.TransactionAuthHandler numVersions int64 + memDB bool } type mockChain struct { @@ -158,6 +159,7 @@ func initMockChain(ctx context.Context, cfg *mockChainCfg) (*mockChain, error) { HaltEpochHeight: math.MaxUint64, MinGasPrice: 0, // XXX: Should this be configurable? OwnTxSigner: localSigner.Public(), + TestingMemDB: cfg.memDB, } if cfg.numVersions > 0 { muxCfg.Pruning.Strategy = abci.PruneKeepN