mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd, core/state: snapshot dump can skip EOA or CA
This commit is contained in:
parent
45a272c7b9
commit
a2ad6e1e86
4 changed files with 27 additions and 2 deletions
|
|
@ -177,6 +177,8 @@ It's deprecated, please use "geth db import" instead.
|
|||
utils.IterativeOutputFlag,
|
||||
utils.ExcludeCodeFlag,
|
||||
utils.ExcludeStorageFlag,
|
||||
utils.ExcludeContractFlag,
|
||||
utils.ExcludeEOAFlag,
|
||||
utils.IncludeIncompletesFlag,
|
||||
utils.StartKeyFlag,
|
||||
utils.DumpLimitFlag,
|
||||
|
|
@ -564,13 +566,15 @@ func parseDumpConfig(ctx *cli.Context, stack *node.Node) (*state.DumpConfig, eth
|
|||
var conf = &state.DumpConfig{
|
||||
SkipCode: ctx.Bool(utils.ExcludeCodeFlag.Name),
|
||||
SkipStorage: ctx.Bool(utils.ExcludeStorageFlag.Name),
|
||||
SkipContract: ctx.Bool(utils.ExcludeContractFlag.Name),
|
||||
SkipEOA: ctx.Bool(utils.ExcludeEOAFlag.Name),
|
||||
OnlyWithAddresses: !ctx.Bool(utils.IncludeIncompletesFlag.Name),
|
||||
Start: start.Bytes(),
|
||||
Max: ctx.Uint64(utils.DumpLimitFlag.Name),
|
||||
}
|
||||
log.Info("State dump configured", "block", header.Number, "hash", header.Hash().Hex(),
|
||||
"skipcode", conf.SkipCode, "skipstorage", conf.SkipStorage,
|
||||
"start", hexutil.Encode(conf.Start), "limit", conf.Max)
|
||||
"skipcode", conf.SkipCode, "skipstorage", conf.SkipStorage, "skipcontract", conf.SkipContract,
|
||||
"skipeoa", conf.SkipEOA, "start", hexutil.Encode(conf.Start), "limit", conf.Max)
|
||||
return conf, db, header.Root, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,6 +139,8 @@ It's also usable without snapshot enabled.
|
|||
Flags: flags.Merge([]cli.Flag{
|
||||
utils.ExcludeCodeFlag,
|
||||
utils.ExcludeStorageFlag,
|
||||
utils.ExcludeContractFlag,
|
||||
utils.ExcludeEOAFlag,
|
||||
utils.StartKeyFlag,
|
||||
utils.DumpLimitFlag,
|
||||
}, utils.NetworkFlags, utils.DatabaseFlags),
|
||||
|
|
@ -545,6 +547,9 @@ func dumpState(ctx *cli.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if conf.SkipEOA && conf.SkipContract {
|
||||
return fmt.Errorf("both EOA and contract accounts are skipped, nothing to dump")
|
||||
}
|
||||
triedb := utils.MakeTrieDatabase(ctx, db, false, true, false)
|
||||
defer triedb.Close()
|
||||
|
||||
|
|
@ -579,6 +584,12 @@ func dumpState(ctx *cli.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if conf.SkipContract && !bytes.Equal(account.CodeHash, types.EmptyCodeHash.Bytes()) {
|
||||
continue
|
||||
}
|
||||
if conf.SkipEOA && bytes.Equal(account.CodeHash, types.EmptyCodeHash.Bytes()) {
|
||||
continue
|
||||
}
|
||||
da := &state.DumpAccount{
|
||||
Balance: account.Balance.String(),
|
||||
Nonce: account.Nonce,
|
||||
|
|
|
|||
|
|
@ -208,6 +208,14 @@ var (
|
|||
Name: "nocode",
|
||||
Usage: "Exclude contract code (save db lookups)",
|
||||
}
|
||||
ExcludeContractFlag = &cli.BoolFlag{
|
||||
Name: "nocontract",
|
||||
Usage: "Exclude contract accounts",
|
||||
}
|
||||
ExcludeEOAFlag = &cli.BoolFlag{
|
||||
Name: "noeoa",
|
||||
Usage: "Exclude EOA accounts",
|
||||
}
|
||||
StartKeyFlag = &cli.StringFlag{
|
||||
Name: "start",
|
||||
Usage: "Start position. Either a hash or address",
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ import (
|
|||
type DumpConfig struct {
|
||||
SkipCode bool
|
||||
SkipStorage bool
|
||||
SkipContract bool
|
||||
SkipEOA bool
|
||||
OnlyWithAddresses bool
|
||||
Start []byte
|
||||
Max uint64
|
||||
|
|
|
|||
Loading…
Reference in a new issue