Skip to content

Commit 82ec555

Browse files
authored
cmd: add state.scheme to the database flag group for local flag handling (#28107)
1 parent f1b2ec0 commit 82ec555

File tree

6 files changed

+33
-45
lines changed

6 files changed

+33
-45
lines changed

cmd/geth/chaincmd.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ var (
5050
ArgsUsage: "<genesisPath>",
5151
Flags: flags.Merge([]cli.Flag{
5252
utils.CachePreimagesFlag,
53-
utils.StateSchemeFlag,
54-
}, utils.DatabasePathFlags),
53+
}, utils.DatabaseFlags),
5554
Description: `
5655
The init command initializes a new genesis block and definition for the network.
5756
This is a destructive action and changes the network in which you will be
@@ -97,9 +96,8 @@ if one is set. Otherwise it prints the genesis from the datadir.`,
9796
utils.MetricsInfluxDBOrganizationFlag,
9897
utils.TxLookupLimitFlag,
9998
utils.TransactionHistoryFlag,
100-
utils.StateSchemeFlag,
10199
utils.StateHistoryFlag,
102-
}, utils.DatabasePathFlags),
100+
}, utils.DatabaseFlags),
103101
Description: `
104102
The import command imports blocks from an RLP-encoded form. The form can be one file
105103
with several RLP-encoded blocks, or several files can be used.
@@ -115,8 +113,7 @@ processing will proceed even if an individual RLP-file import failure occurs.`,
115113
Flags: flags.Merge([]cli.Flag{
116114
utils.CacheFlag,
117115
utils.SyncModeFlag,
118-
utils.StateSchemeFlag,
119-
}, utils.DatabasePathFlags),
116+
}, utils.DatabaseFlags),
120117
Description: `
121118
Requires a first argument of the file to write to.
122119
Optional second and third arguments control the first and
@@ -132,7 +129,7 @@ be gzipped.`,
132129
Flags: flags.Merge([]cli.Flag{
133130
utils.CacheFlag,
134131
utils.SyncModeFlag,
135-
}, utils.DatabasePathFlags),
132+
}, utils.DatabaseFlags),
136133
Description: `
137134
The import-preimages command imports hash preimages from an RLP encoded stream.
138135
It's deprecated, please use "geth db import" instead.
@@ -146,7 +143,7 @@ It's deprecated, please use "geth db import" instead.
146143
Flags: flags.Merge([]cli.Flag{
147144
utils.CacheFlag,
148145
utils.SyncModeFlag,
149-
}, utils.DatabasePathFlags),
146+
}, utils.DatabaseFlags),
150147
Description: `
151148
The export-preimages command exports hash preimages to an RLP encoded stream.
152149
It's deprecated, please use "geth db export" instead.
@@ -165,8 +162,7 @@ It's deprecated, please use "geth db export" instead.
165162
utils.IncludeIncompletesFlag,
166163
utils.StartKeyFlag,
167164
utils.DumpLimitFlag,
168-
utils.StateSchemeFlag,
169-
}, utils.DatabasePathFlags),
165+
}, utils.DatabaseFlags),
170166
Description: `
171167
This command dumps out the state for a given block (or latest, if none provided).
172168
`,

cmd/geth/dbcmd.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var (
4848
Name: "removedb",
4949
Usage: "Remove blockchain and state databases",
5050
ArgsUsage: "",
51-
Flags: utils.DatabasePathFlags,
51+
Flags: utils.DatabaseFlags,
5252
Description: `
5353
Remove blockchain and state databases`,
5454
}
@@ -77,15 +77,15 @@ Remove blockchain and state databases`,
7777
ArgsUsage: "<prefix> <start>",
7878
Flags: flags.Merge([]cli.Flag{
7979
utils.SyncModeFlag,
80-
}, utils.NetworkFlags, utils.DatabasePathFlags),
80+
}, utils.NetworkFlags, utils.DatabaseFlags),
8181
Usage: "Inspect the storage size for each type of data in the database",
8282
Description: `This commands iterates the entire database. If the optional 'prefix' and 'start' arguments are provided, then the iteration is limited to the given subset of data.`,
8383
}
8484
dbCheckStateContentCmd = &cli.Command{
8585
Action: checkStateContent,
8686
Name: "check-state-content",
8787
ArgsUsage: "<start (optional)>",
88-
Flags: flags.Merge(utils.NetworkFlags, utils.DatabasePathFlags),
88+
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
8989
Usage: "Verify that state data is cryptographically correct",
9090
Description: `This command iterates the entire database for 32-byte keys, looking for rlp-encoded trie nodes.
9191
For each trie node encountered, it checks that the key corresponds to the keccak256(value). If this is not true, this indicates
@@ -97,7 +97,7 @@ a data corruption.`,
9797
Usage: "Print leveldb statistics",
9898
Flags: flags.Merge([]cli.Flag{
9999
utils.SyncModeFlag,
100-
}, utils.NetworkFlags, utils.DatabasePathFlags),
100+
}, utils.NetworkFlags, utils.DatabaseFlags),
101101
}
102102
dbCompactCmd = &cli.Command{
103103
Action: dbCompact,
@@ -107,7 +107,7 @@ a data corruption.`,
107107
utils.SyncModeFlag,
108108
utils.CacheFlag,
109109
utils.CacheDatabaseFlag,
110-
}, utils.NetworkFlags, utils.DatabasePathFlags),
110+
}, utils.NetworkFlags, utils.DatabaseFlags),
111111
Description: `This command performs a database compaction.
112112
WARNING: This operation may take a very long time to finish, and may cause database
113113
corruption if it is aborted during execution'!`,
@@ -119,7 +119,7 @@ corruption if it is aborted during execution'!`,
119119
ArgsUsage: "<hex-encoded key>",
120120
Flags: flags.Merge([]cli.Flag{
121121
utils.SyncModeFlag,
122-
}, utils.NetworkFlags, utils.DatabasePathFlags),
122+
}, utils.NetworkFlags, utils.DatabaseFlags),
123123
Description: "This command looks up the specified database key from the database.",
124124
}
125125
dbDeleteCmd = &cli.Command{
@@ -129,7 +129,7 @@ corruption if it is aborted during execution'!`,
129129
ArgsUsage: "<hex-encoded key>",
130130
Flags: flags.Merge([]cli.Flag{
131131
utils.SyncModeFlag,
132-
}, utils.NetworkFlags, utils.DatabasePathFlags),
132+
}, utils.NetworkFlags, utils.DatabaseFlags),
133133
Description: `This command deletes the specified database key from the database.
134134
WARNING: This is a low-level operation which may cause database corruption!`,
135135
}
@@ -140,7 +140,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
140140
ArgsUsage: "<hex-encoded key> <hex-encoded value>",
141141
Flags: flags.Merge([]cli.Flag{
142142
utils.SyncModeFlag,
143-
}, utils.NetworkFlags, utils.DatabasePathFlags),
143+
}, utils.NetworkFlags, utils.DatabaseFlags),
144144
Description: `This command sets a given database key to the given value.
145145
WARNING: This is a low-level operation which may cause database corruption!`,
146146
}
@@ -151,8 +151,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
151151
ArgsUsage: "<hex-encoded state root> <hex-encoded account hash> <hex-encoded storage trie root> <hex-encoded start (optional)> <int max elements (optional)>",
152152
Flags: flags.Merge([]cli.Flag{
153153
utils.SyncModeFlag,
154-
utils.StateSchemeFlag,
155-
}, utils.NetworkFlags, utils.DatabasePathFlags),
154+
}, utils.NetworkFlags, utils.DatabaseFlags),
156155
Description: "This command looks up the specified database key from the database.",
157156
}
158157
dbDumpFreezerIndex = &cli.Command{
@@ -162,7 +161,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
162161
ArgsUsage: "<freezer-type> <table-type> <start (int)> <end (int)>",
163162
Flags: flags.Merge([]cli.Flag{
164163
utils.SyncModeFlag,
165-
}, utils.NetworkFlags, utils.DatabasePathFlags),
164+
}, utils.NetworkFlags, utils.DatabaseFlags),
166165
Description: "This command displays information about the freezer index.",
167166
}
168167
dbImportCmd = &cli.Command{
@@ -172,7 +171,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
172171
ArgsUsage: "<dumpfile> <start (optional)",
173172
Flags: flags.Merge([]cli.Flag{
174173
utils.SyncModeFlag,
175-
}, utils.NetworkFlags, utils.DatabasePathFlags),
174+
}, utils.NetworkFlags, utils.DatabaseFlags),
176175
Description: "The import command imports the specific chain data from an RLP encoded stream.",
177176
}
178177
dbExportCmd = &cli.Command{
@@ -182,7 +181,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
182181
ArgsUsage: "<type> <dumpfile>",
183182
Flags: flags.Merge([]cli.Flag{
184183
utils.SyncModeFlag,
185-
}, utils.NetworkFlags, utils.DatabasePathFlags),
184+
}, utils.NetworkFlags, utils.DatabaseFlags),
186185
Description: "Exports the specified chain data to an RLP encoded stream, optionally gzip-compressed.",
187186
}
188187
dbMetadataCmd = &cli.Command{
@@ -191,7 +190,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
191190
Usage: "Shows metadata about the chain status.",
192191
Flags: flags.Merge([]cli.Flag{
193192
utils.SyncModeFlag,
194-
}, utils.NetworkFlags, utils.DatabasePathFlags),
193+
}, utils.NetworkFlags, utils.DatabaseFlags),
195194
Description: "Shows metadata about the chain status.",
196195
}
197196
)

cmd/geth/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ var (
8989
utils.SnapshotFlag,
9090
utils.TxLookupLimitFlag,
9191
utils.TransactionHistoryFlag,
92-
utils.StateSchemeFlag,
9392
utils.StateHistoryFlag,
9493
utils.LightServeFlag,
9594
utils.LightIngressFlag,
@@ -145,7 +144,7 @@ var (
145144
utils.GpoMaxGasPriceFlag,
146145
utils.GpoIgnoreGasPriceFlag,
147146
configFileFlag,
148-
}, utils.NetworkFlags, utils.DatabasePathFlags)
147+
}, utils.NetworkFlags, utils.DatabaseFlags)
149148

150149
rpcFlags = []cli.Flag{
151150
utils.HTTPEnabledFlag,

cmd/geth/snapshot.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var (
5151
Action: pruneState,
5252
Flags: flags.Merge([]cli.Flag{
5353
utils.BloomFilterSizeFlag,
54-
}, utils.NetworkFlags, utils.DatabasePathFlags),
54+
}, utils.NetworkFlags, utils.DatabaseFlags),
5555
Description: `
5656
geth snapshot prune-state <state-root>
5757
will prune historical state data with the help of the state snapshot.
@@ -69,9 +69,7 @@ WARNING: it's only supported in hash mode(--state.scheme=hash)".
6969
Usage: "Recalculate state hash based on the snapshot for verification",
7070
ArgsUsage: "<root>",
7171
Action: verifyState,
72-
Flags: flags.Merge([]cli.Flag{
73-
utils.StateSchemeFlag,
74-
}, utils.NetworkFlags, utils.DatabasePathFlags),
72+
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
7573
Description: `
7674
geth snapshot verify-state <state-root>
7775
will traverse the whole accounts and storages set based on the specified
@@ -84,7 +82,7 @@ In other words, this command does the snapshot to trie conversion.
8482
Usage: "Check that there is no 'dangling' snap storage",
8583
ArgsUsage: "<root>",
8684
Action: checkDanglingStorage,
87-
Flags: flags.Merge(utils.NetworkFlags, utils.DatabasePathFlags),
85+
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
8886
Description: `
8987
geth snapshot check-dangling-storage <state-root> traverses the snap storage
9088
data, and verifies that all snapshot storage data has a corresponding account.
@@ -95,7 +93,7 @@ data, and verifies that all snapshot storage data has a corresponding account.
9593
Usage: "Check all snapshot layers for the a specific account",
9694
ArgsUsage: "<address | hash>",
9795
Action: checkAccount,
98-
Flags: flags.Merge(utils.NetworkFlags, utils.DatabasePathFlags),
96+
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
9997
Description: `
10098
geth snapshot inspect-account <address | hash> checks all snapshot layers and prints out
10199
information about the specified address.
@@ -106,9 +104,7 @@ information about the specified address.
106104
Usage: "Traverse the state with given root hash and perform quick verification",
107105
ArgsUsage: "<root>",
108106
Action: traverseState,
109-
Flags: flags.Merge([]cli.Flag{
110-
utils.StateSchemeFlag,
111-
}, utils.NetworkFlags, utils.DatabasePathFlags),
107+
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
112108
Description: `
113109
geth snapshot traverse-state <state-root>
114110
will traverse the whole state from the given state root and will abort if any
@@ -123,9 +119,7 @@ It's also usable without snapshot enabled.
123119
Usage: "Traverse the state with given root hash and perform detailed verification",
124120
ArgsUsage: "<root>",
125121
Action: traverseRawState,
126-
Flags: flags.Merge([]cli.Flag{
127-
utils.StateSchemeFlag,
128-
}, utils.NetworkFlags, utils.DatabasePathFlags),
122+
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
129123
Description: `
130124
geth snapshot traverse-rawstate <state-root>
131125
will traverse the whole state from the given root and will abort if any referenced
@@ -146,8 +140,7 @@ It's also usable without snapshot enabled.
146140
utils.ExcludeStorageFlag,
147141
utils.StartKeyFlag,
148142
utils.DumpLimitFlag,
149-
utils.StateSchemeFlag,
150-
}, utils.NetworkFlags, utils.DatabasePathFlags),
143+
}, utils.NetworkFlags, utils.DatabaseFlags),
151144
Description: `
152145
This command is semantically equivalent to 'geth dump', but uses the snapshots
153146
as the backend data source, making this command a lot faster.

cmd/geth/verkle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var (
4545
Usage: "verify the conversion of a MPT into a verkle tree",
4646
ArgsUsage: "<root>",
4747
Action: verifyVerkle,
48-
Flags: flags.Merge(utils.NetworkFlags, utils.DatabasePathFlags),
48+
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
4949
Description: `
5050
geth verkle verify <state-root>
5151
This command takes a root commitment and attempts to rebuild the tree.
@@ -56,7 +56,7 @@ This command takes a root commitment and attempts to rebuild the tree.
5656
Usage: "Dump a verkle tree to a DOT file",
5757
ArgsUsage: "<root> <key1> [<key 2> ...]",
5858
Action: expandVerkle,
59-
Flags: flags.Merge(utils.NetworkFlags, utils.DatabasePathFlags),
59+
Flags: flags.Merge(utils.NetworkFlags, utils.DatabaseFlags),
6060
Description: `
6161
geth verkle dump <state-root> <key 1> [<key 2> ...]
6262
This command will produce a dot file representing the tree, rooted at <root>.

cmd/utils/flags.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -961,18 +961,19 @@ var (
961961
// NetworkFlags is the flag group of all built-in supported networks.
962962
NetworkFlags = append([]cli.Flag{MainnetFlag}, TestnetFlags...)
963963

964-
// DatabasePathFlags is the flag group of all database path flags.
965-
DatabasePathFlags = []cli.Flag{
964+
// DatabaseFlags is the flag group of all database flags.
965+
DatabaseFlags = []cli.Flag{
966966
DataDirFlag,
967967
AncientFlag,
968968
RemoteDBFlag,
969+
StateSchemeFlag,
969970
HttpHeaderFlag,
970971
}
971972
)
972973

973974
func init() {
974975
if rawdb.PebbleEnabled {
975-
DatabasePathFlags = append(DatabasePathFlags, DBEngineFlag)
976+
DatabaseFlags = append(DatabaseFlags, DBEngineFlag)
976977
}
977978
}
978979

0 commit comments

Comments
 (0)