From 4528c8fa093f6beb967327f031e0cef22255b431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Mon, 24 Jun 2019 15:48:32 +0300 Subject: [PATCH] cmd: use local flags for dump, omit empty code/storage --- cmd/geth/chaincmd.go | 10 +++++----- cmd/geth/main.go | 8 -------- cmd/utils/flags.go | 18 +++++++++--------- core/state/dump.go | 4 ++-- 4 files changed, 16 insertions(+), 24 deletions(-) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index bd39e84a22..49e6a05949 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -165,7 +165,7 @@ Remove blockchain and state databases`, utils.IterativeOutputFlag, utils.ExcludeCodeFlag, utils.ExcludeStorageFlag, - utils.IncludeMissingPreimagesFlag, + utils.IncludeIncompletesFlag, }, Category: "BLOCKCHAIN COMMANDS", Description: ` @@ -525,10 +525,10 @@ func dump(ctx *cli.Context) error { if err != nil { utils.Fatalf("could not create new state: %v", err) } - excludeCode := ctx.GlobalBool(utils.ExcludeCodeFlag.Name) - excludeStorage := ctx.GlobalBool(utils.ExcludeStorageFlag.Name) - includeMissing := ctx.GlobalBool(utils.IncludeMissingPreimagesFlag.Name) - if ctx.GlobalBool(utils.IterativeOutputFlag.Name) { + 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 { diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 47c2c401e2..00809e2e10 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -188,13 +188,6 @@ var ( utils.MetricsInfluxDBPasswordFlag, utils.MetricsInfluxDBTagsFlag, } - - dumpFlags = []cli.Flag{ - utils.IterativeOutputFlag, - utils.ExcludeCodeFlag, - utils.ExcludeStorageFlag, - utils.IncludeMissingPreimagesFlag, - } ) func init() { @@ -238,7 +231,6 @@ func init() { app.Flags = append(app.Flags, debug.Flags...) app.Flags = append(app.Flags, whisperFlags...) app.Flags = append(app.Flags, metricsFlags...) - app.Flags = append(app.Flags, dumpFlags...) app.Before = func(ctx *cli.Context) error { logdir := "" diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 57447ae2e8..8d94539ab9 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -197,20 +197,20 @@ var ( Usage: "List of trusted ULC servers", } IterativeOutputFlag = cli.BoolFlag{ - Name: "dump.iterative", - Usage: "Print streaming JSON iteratively as json objects, delimited by newlines", + Name: "iterative", + Usage: "Print streaming JSON iteratively, delimited by newlines", } ExcludeStorageFlag = cli.BoolFlag{ - Name: "dump.nostorage", - Usage: "When set, exclude storage entries (saves db lookups)", + Name: "nostorage", + Usage: "Exclude storage entries (save db lookups)", } - IncludeMissingPreimagesFlag = cli.BoolFlag{ - Name: "dump.includeincomplete", - Usage: "When set, include also those we do not have address of (missing preimage)", + IncludeIncompletesFlag = cli.BoolFlag{ + Name: "incompletes", + Usage: "Include accounts for which we don't have the address (missing preimage)", } ExcludeCodeFlag = cli.BoolFlag{ - Name: "dump.nocode", - Usage: "When set, exclude contract code (saves db lookups)", + Name: "nocode", + Usage: "Exclude contract code (save db lookups)", } defaultSyncMode = eth.DefaultConfig.SyncMode SyncModeFlag = TextMarshalerFlag{ diff --git a/core/state/dump.go b/core/state/dump.go index 4a8e813d69..51d3e5554f 100644 --- a/core/state/dump.go +++ b/core/state/dump.go @@ -33,8 +33,8 @@ type DumpAccount struct { Nonce uint64 `json:"nonce"` Root string `json:"root"` CodeHash string `json:"codeHash"` - Code string `json:"code"` - Storage map[common.Hash]string `json:"storage"` + Code string `json:"code,omitempty"` + Storage map[common.Hash]string `json:"storage,omitempty"` Address *common.Address `json:"address,omitempty"` // Address only present in iterative (line-by-line) mode SecureKey hexutil.Bytes `json:"key,omitempty"` // If we don't have address, we can output the key