Skip to content

Commit

Permalink
Merge branch 'master' into replace-red-black-trees-#128
Browse files Browse the repository at this point in the history
  • Loading branch information
JekaMas committed Nov 21, 2019
2 parents ba6aa87 + 244d70f commit e137116
Show file tree
Hide file tree
Showing 35 changed files with 1,189 additions and 581 deletions.
1 change: 1 addition & 0 deletions cmd/geth/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ func exportPreimages(ctx *cli.Context) error {
return nil
}

// TODO [Andrew] BadgerDB
func copyDb(ctx *cli.Context) error {
// Ensure we have a source chain directory to copy
if len(ctx.Args()) < 1 {
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ var (
utils.DownloadOnlyFlag,
utils.NoHistory,
utils.ArchiveSyncInterval,
utils.BadgerFlag,
utils.ListenPortFlag,
utils.MaxPeersFlag,
utils.MaxPendingPeersFlag,
Expand Down
1 change: 1 addition & 0 deletions cmd/geth/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ var AppHelpFlagGroups = []flagGroup{
utils.CacheGCFlag,
utils.CacheNoPrefetchFlag,
utils.TrieCacheGenFlag,
utils.BadgerFlag,
},
},
{
Expand Down
16 changes: 9 additions & 7 deletions cmd/hack/hack.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var block = flag.Int("block", 1, "specifies a block number for operation")
var account = flag.String("account", "0x", "specifies account to investigate")
var name = flag.String("name", "", "name to add to the file names")
var chaindata = flag.String("chaindata", "chaindata", "path to the chaindata database file")
var image = flag.String("image", "0x1", "image value for preimage action")
var hash = flag.String("hash", "0x00", "image for preimage or state root for testBlockHashes action")

func bucketList(db *bolt.DB) [][]byte {
bucketList := [][]byte{}
Expand Down Expand Up @@ -872,13 +872,15 @@ func testDifficulty() {
fmt.Printf("Block 1 difficulty: %d\n", d1)
}

func testBlockHashes() {
ethDb, err := ethdb.NewBoltDatabase("/Users/alexeyakhunov/Library/Ethereum/geth/chaindata")
// Searches 1000 blocks from the given one to try to find the one with the given state root hash
func testBlockHashes(chaindata string, block int, stateRoot common.Hash) {
ethDb, err := ethdb.NewBoltDatabase(chaindata)
check(err)
for i := uint64(1000000); i < uint64(1751612); i++ {
blocksToSearch := 1000
for i := uint64(block); i < uint64(block+blocksToSearch); i++ {
hash := rawdb.ReadCanonicalHash(ethDb, i)
header := rawdb.ReadHeader(ethDb, hash, i)
if header.Root == common.BytesToHash(common.FromHex("0x18186d0c469558437ade9b424ca9176b56fa0a8ca465eaf0f468294b37b693f8")) {
if header.Root == stateRoot || stateRoot == (common.Hash{}) {
fmt.Printf("\n===============\nCanonical hash for %d: %x\n", i, hash)
fmt.Printf("Header.Root: %x\n", header.Root)
fmt.Printf("Header.TxHash: %x\n", header.TxHash)
Expand Down Expand Up @@ -1208,7 +1210,7 @@ func main() {
// testReset(uint64(*reset))
//}
if *action == "testBlockHashes" {
testBlockHashes()
testBlockHashes(*chaindata, *block, common.HexToHash(*hash))
}
//printBuckets(db)
//printTxHashes()
Expand All @@ -1222,7 +1224,7 @@ func main() {
//invTree("iw", "ir", "id", *block, true)
//loadAccount()
if *action == "preimage" {
preimage(*chaindata, common.HexToHash(*image))
preimage(*chaindata, common.HexToHash(*hash))
}
//printBranches(uint64(*block))
//execToBlock(*block)
Expand Down
2 changes: 1 addition & 1 deletion cmd/pics/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ func initialState1() error {
return err
}
var witness bytes.Buffer
if err = bwb.WriteTo(&witness); err != nil {
if _, err = bwb.WriteTo(&witness); err != nil {
return err
}
var witnessTrie *trie.Trie
Expand Down
29 changes: 11 additions & 18 deletions cmd/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ var start = flag.Int("start", 0, "number of data points to skip when making a ch
var window = flag.Int("window", 1024, "size of the window for moving average")
var triesize = flag.Int("triesize", 1024*1024, "maximum number of nodes in the state trie")
var preroot = flag.Bool("preroot", false, "Attempt to compute hash of the trie without modifying it")
var snapshotInterval = flag.Uint64("snapshotInterval", 0, "how often to take snapshots (0 - never, 1 - every block, 1000 - every 1000th block, etc)")
var snapshotFrom = flag.Uint64("snapshotFrom", 0, "from which block to start snapshots")
var witnessInterval = flag.Uint64("witnessInterval", 1, "after which block to extract witness (put a large number like 10000000 to disable)")
var statsfile = flag.String("statsfile", "stateless.csv", "path where to write the stats file")

func check(e error) {
if e != nil {
Expand Down Expand Up @@ -1674,26 +1678,15 @@ func main() {
//nakedAccountChart()
//specExecChart1()
if *action == "stateless" {
stateless(*chaindata, *statefile, *triesize, *preroot)
createDb := func(path string) (ethdb.Database, error) {
return ethdb.NewBoltDatabase(path)
}

stateless(*chaindata, *statefile, *triesize, *preroot, *snapshotInterval, *snapshotFrom, *witnessInterval, *statsfile, createDb)
}
if *action == "stateless_chart" {
stateless_chart_key_values("/Users/alexeyakhunov/mygit/go-ethereum/st_1/stateless.csv", []int{21, 20, 19, 18}, "breakdown.png", 2800000, 1)
}
//stateless_chart_key_values("stateless1.csv", []int{17}, "total.png", 1, 0)
//stateless_chart_key_values("stateless1_256.csv", []int{17}, "total256.png", 1, 0)
//stateless_chart_key_values([]int{17}, "total_2675000.png", 2675000, 0)
//stateless_chart_key_values("stateless1.csv", []int{12, 15, 16}, "breakdown.png", 1, 1)
//stateless_chart_key_values("stateless1_256.csv", []int{12, 15, 16}, "breakdown256.png", 1, 1)
//stateless_chart_key_values([]int{12, 15, 16}, "breakdown_2675000.png", 2675000, 1)
//stateless_chart_key_values("stateless1.csv", []int{13,14}, "key_vals.png", 1, 4)
//stateless_chart_key_values("stateless1_256.csv", []int{13,14}, "key_vals256.png", 1, 4)
//stateless_chart_key_values("stateless1.csv", []int{10,11}, "c_key_vals.png", 1, 4)
//stateless_chart_key_values("stateless1_256.csv", []int{10,11}, "c_key_vals256.png", 1, 4)
//stateless_chart_key_values("stateless1.csv", []int{6, 7}, "mask_hash.png", 1, 4)
//stateless_chart_key_values("stateless1_256.csv", []int{6, 7}, "mask_hash256.png", 1, 4)
//stateless_chart_key_values("stateless1.csv", []int{1, 2}, "c_mask_hash.png", 1, 4)
//stateless_chart_key_values("stateless1_256.csv", []int{1, 2}, "c_mask_hash256.png", 1, 4)
//stateless_chart_key_values([]int{12}, "codes_28m.png", 2800000)
statelessDoKVChart(*statsfile, []int{21, 20, 19, 18}, fmt.Sprintf("%s-chart.png", *statsfile), 2800000, 1)
}
if *action == "stateSnapshot" {
if err := stateSnapshot(); err != nil {
fmt.Printf("Error: %v\n", err)
Expand Down
Loading

0 comments on commit e137116

Please sign in to comment.