aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorMartin Holst Swende <martin@swende.se>2019-06-24 22:16:44 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-06-24 22:16:44 +0800
commit1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5 (patch)
tree5b37b2225f4ac75c5468d7a29b045b62204fb9f0 /cmd
parente4a1488b2f9b0d8dbe51f8eda067374985d8b188 (diff)
downloadgo-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.gz
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.bz2
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.lz
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.xz
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.tar.zst
go-tangerine-1da5e0ebb0bf702f1e4d811b9dab9b3f4589e9e5.zip
core/state, cmd/geth: streaming json output for dump command (#15475)
* core/state, cmd/geth: streaming json output dump cmd + optional code+storage * dump: add option to continue even if preimages are missing * core, evm: lint nits * cmd: use local flags for dump, omit empty code/storage * core/state: fix state dump test
Diffstat (limited to 'cmd')
-rw-r--r--cmd/evm/runner.go2
-rw-r--r--cmd/evm/staterunner.go2
-rw-r--r--cmd/geth/chaincmd.go21
-rw-r--r--cmd/utils/flags.go16
4 files changed, 36 insertions, 5 deletions
diff --git a/cmd/evm/runner.go b/cmd/evm/runner.go
index bc5d00cfb..08f36dadc 100644
--- a/cmd/evm/runner.go
+++ b/cmd/evm/runner.go
@@ -209,7 +209,7 @@ func runCmd(ctx *cli.Context) error {
if ctx.GlobalBool(DumpFlag.Name) {
statedb.Commit(true)
statedb.IntermediateRoot(true)
- fmt.Println(string(statedb.Dump()))
+ fmt.Println(string(statedb.Dump(false, false, true)))
}
if memProfilePath := ctx.GlobalString(MemProfileFlag.Name); memProfilePath != "" {
diff --git a/cmd/evm/staterunner.go b/cmd/evm/staterunner.go
index b3c69d9b9..cef2aedb5 100644
--- a/cmd/evm/staterunner.go
+++ b/cmd/evm/staterunner.go
@@ -105,7 +105,7 @@ func stateTestCmd(ctx *cli.Context) error {
// Test failed, mark as so and dump any state to aid debugging
result.Pass, result.Error = false, err.Error()
if ctx.GlobalBool(DumpFlag.Name) && state != nil {
- dump := state.RawDump()
+ dump := state.RawDump(false, false, true)
result.State = &dump
}
}
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index c91545c7f..49e6a0594 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -162,6 +162,10 @@ Remove blockchain and state databases`,
utils.DataDirFlag,
utils.CacheFlag,
utils.SyncModeFlag,
+ utils.IterativeOutputFlag,
+ utils.ExcludeCodeFlag,
+ utils.ExcludeStorageFlag,
+ utils.IncludeIncompletesFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
@@ -287,7 +291,7 @@ func importChain(ctx *cli.Context) error {
fmt.Printf("Allocations: %.3f million\n", float64(mem.Mallocs)/1000000)
fmt.Printf("GC pause: %v\n\n", time.Duration(mem.PauseTotalNs))
- if ctx.GlobalIsSet(utils.NoCompactionFlag.Name) {
+ if ctx.GlobalBool(utils.NoCompactionFlag.Name) {
return nil
}
@@ -504,6 +508,7 @@ func dump(ctx *cli.Context) error {
defer stack.Close()
chain, chainDb := utils.MakeChain(ctx, stack)
+ defer chainDb.Close()
for _, arg := range ctx.Args() {
var block *types.Block
if hashish(arg) {
@@ -520,10 +525,20 @@ func dump(ctx *cli.Context) error {
if err != nil {
utils.Fatalf("could not create new state: %v", err)
}
- fmt.Printf("%s\n", state.Dump())
+ excludeCode := ctx.Bool(utils.ExcludeCodeFlag.Name)
+ excludeStorage := ctx.Bool(utils.ExcludeStorageFlag.Name)
+ includeMissing := ctx.Bool(utils.IncludeIncompletesFlag.Name)
+ if ctx.Bool(utils.IterativeOutputFlag.Name) {
+ state.IterativeDump(excludeCode, excludeStorage, !includeMissing, json.NewEncoder(os.Stdout))
+ } else {
+ if includeMissing {
+ fmt.Printf("If you want to include accounts with missing preimages, you need iterative output, since" +
+ " otherwise the accounts will overwrite each other in the resulting mapping.")
+ }
+ fmt.Printf("%v %s\n", includeMissing, state.Dump(excludeCode, excludeStorage, false))
+ }
}
}
- chainDb.Close()
return nil
}
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 8c5a0c99a..8d94539ab 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -196,6 +196,22 @@ var (
Name: "ulc.trusted",
Usage: "List of trusted ULC servers",
}
+ IterativeOutputFlag = cli.BoolFlag{
+ Name: "iterative",
+ Usage: "Print streaming JSON iteratively, delimited by newlines",
+ }
+ ExcludeStorageFlag = cli.BoolFlag{
+ Name: "nostorage",
+ Usage: "Exclude storage entries (save db lookups)",
+ }
+ IncludeIncompletesFlag = cli.BoolFlag{
+ Name: "incompletes",
+ Usage: "Include accounts for which we don't have the address (missing preimage)",
+ }
+ ExcludeCodeFlag = cli.BoolFlag{
+ Name: "nocode",
+ Usage: "Exclude contract code (save db lookups)",
+ }
defaultSyncMode = eth.DefaultConfig.SyncMode
SyncModeFlag = TextMarshalerFlag{
Name: "syncmode",