From 061fefc6cbeb883f85ba563380d8f1b733c18f7c Mon Sep 17 00:00:00 2001 From: Aleksandr Bezobchuk Date: Tue, 17 Jul 2018 22:07:02 -0400 Subject: [PATCH] Merge pull request #444: Disable IAVL Pruning --- main.go | 15 +++++++++++---- state/database.go | 4 ++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index d7b80a02..5d88e155 100644 --- a/main.go +++ b/main.go @@ -27,9 +27,10 @@ import ( dbm "github.com/tendermint/tendermint/libs/db" ) -var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`") +var cpuprofile = flag.String("cpu-profile", "", "write cpu profile `file`") var blockchain = flag.String("blockchain", "data/blockchain", "file containing blocks to load") var datadir = flag.String("datadir", "", "directory for ethermint data") +var blockStop = flag.Int("stop-block", 10000, "stop prematurely after processing a certain number of blocks") var ( // TODO: Document... @@ -40,16 +41,19 @@ var ( // TODO: Document... func main() { flag.Parse() + if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { fmt.Printf("could not create CPU profile: %v\n", err) return } + if err := pprof.StartCPUProfile(f); err != nil { fmt.Printf("could not start CPU profile: %v\n", err) return } + defer pprof.StopCPUProfile() } @@ -220,9 +224,11 @@ func main() { if (n % 10000) == 0 { fmt.Printf("processed %d blocks, time so far: %v\n", n, time.Since(startTime)) } - //if n >= 20000 { - // break - //} + + if *blockStop == n { + fmt.Println("haulting process prematurely") + break + } } fmt.Printf("processed %d blocks\n", n) @@ -249,6 +255,7 @@ func main() { if err != nil { panic(err) } + miner501BalanceAt501 := state501.GetBalance(miner501) fmt.Printf("investor's balance after block 500: %d\n", state500.GetBalance(genInvestor)) diff --git a/state/database.go b/state/database.go index 031f9814..6d00289c 100644 --- a/state/database.go +++ b/state/database.go @@ -3,6 +3,7 @@ package state import ( "github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/types" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ethermint/core" ethcommon "github.com/ethereum/go-ethereum/common" ethstate "github.com/ethereum/go-ethereum/core/state" @@ -69,6 +70,9 @@ func NewDatabase(stateDB, codeDB dbm.DB) (*Database, error) { stateStore: store.NewCommitMultiStore(stateDB), } + // currently do not prune any historical state + db.stateStore.SetPruning(sdk.PruneNothing) + // Create the underlying multi-store stores that will persist account and // account storage data. db.stateStore.MountStoreWithDB(AccountsKey, types.StoreTypeIAVL, nil)