Skip to content

Commit 714fa4f

Browse files
authored
cmd/geth: update geth subcommand arguments (#31293)
1 parent cc273ce commit 714fa4f

File tree

3 files changed

+53
-77
lines changed

3 files changed

+53
-77
lines changed

cmd/geth/chaincmd.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ import (
3737
"github.com/ethereum/go-ethereum/crypto"
3838
"github.com/ethereum/go-ethereum/eth/ethconfig"
3939
"github.com/ethereum/go-ethereum/ethdb"
40+
"github.com/ethereum/go-ethereum/internal/debug"
4041
"github.com/ethereum/go-ethereum/internal/era"
42+
"github.com/ethereum/go-ethereum/internal/flags"
4143
"github.com/ethereum/go-ethereum/log"
4244
"github.com/ethereum/go-ethereum/params"
4345
"github.com/urfave/cli/v2"
@@ -66,7 +68,7 @@ It expects the genesis file as argument.`,
6668
Name: "dumpgenesis",
6769
Usage: "Dumps genesis block JSON configuration to stdout",
6870
ArgsUsage: "",
69-
Flags: append([]cli.Flag{utils.DataDirFlag}, utils.NetworkFlags...),
71+
Flags: slices.Concat([]cli.Flag{utils.DataDirFlag}, utils.NetworkFlags),
7072
Description: `
7173
The dumpgenesis command prints the genesis configuration of the network preset
7274
if one is set. Otherwise it prints the genesis from the datadir.`,
@@ -78,11 +80,11 @@ if one is set. Otherwise it prints the genesis from the datadir.`,
7880
ArgsUsage: "<filename> (<filename 2> ... <filename N>) ",
7981
Flags: slices.Concat([]cli.Flag{
8082
utils.CacheFlag,
81-
utils.SyncModeFlag,
8283
utils.GCModeFlag,
8384
utils.SnapshotFlag,
8485
utils.CacheDatabaseFlag,
8586
utils.CacheGCFlag,
87+
utils.NoCompactionFlag,
8688
utils.MetricsEnabledFlag,
8789
utils.MetricsEnabledExpensiveFlag,
8890
utils.MetricsHTTPFlag,
@@ -105,7 +107,11 @@ if one is set. Otherwise it prints the genesis from the datadir.`,
105107
utils.LogNoHistoryFlag,
106108
utils.LogExportCheckpointsFlag,
107109
utils.StateHistoryFlag,
108-
}, utils.DatabaseFlags),
110+
}, utils.DatabaseFlags, debug.Flags),
111+
Before: func(ctx *cli.Context) error {
112+
flags.MigrateGlobalFlags(ctx)
113+
return debug.Setup(ctx)
114+
},
109115
Description: `
110116
The import command allows the import of blocks from an RLP-encoded format. This format can be a single file
111117
containing multiple RLP-encoded blocks, or multiple files can be given.
@@ -119,10 +125,7 @@ to import successfully.`,
119125
Name: "export",
120126
Usage: "Export blockchain into file",
121127
ArgsUsage: "<filename> [<blockNumFirst> <blockNumLast>]",
122-
Flags: slices.Concat([]cli.Flag{
123-
utils.CacheFlag,
124-
utils.SyncModeFlag,
125-
}, utils.DatabaseFlags),
128+
Flags: slices.Concat([]cli.Flag{utils.CacheFlag}, utils.DatabaseFlags),
126129
Description: `
127130
Requires a first argument of the file to write to.
128131
Optional second and third arguments control the first and
@@ -135,12 +138,7 @@ be gzipped.`,
135138
Name: "import-history",
136139
Usage: "Import an Era archive",
137140
ArgsUsage: "<dir>",
138-
Flags: slices.Concat([]cli.Flag{
139-
utils.TxLookupLimitFlag,
140-
},
141-
utils.DatabaseFlags,
142-
utils.NetworkFlags,
143-
),
141+
Flags: slices.Concat([]cli.Flag{utils.TxLookupLimitFlag, utils.TransactionHistoryFlag}, utils.DatabaseFlags, utils.NetworkFlags),
144142
Description: `
145143
The import-history command will import blocks and their corresponding receipts
146144
from Era archives.
@@ -151,7 +149,7 @@ from Era archives.
151149
Name: "export-history",
152150
Usage: "Export blockchain history to Era archives",
153151
ArgsUsage: "<dir> <first> <last>",
154-
Flags: slices.Concat(utils.DatabaseFlags),
152+
Flags: utils.DatabaseFlags,
155153
Description: `
156154
The export-history command will export blocks and their corresponding receipts
157155
into Era archives. Eras are typically packaged in steps of 8192 blocks.
@@ -162,10 +160,7 @@ into Era archives. Eras are typically packaged in steps of 8192 blocks.
162160
Name: "import-preimages",
163161
Usage: "Import the preimage database from an RLP stream",
164162
ArgsUsage: "<datafile>",
165-
Flags: slices.Concat([]cli.Flag{
166-
utils.CacheFlag,
167-
utils.SyncModeFlag,
168-
}, utils.DatabaseFlags),
163+
Flags: slices.Concat([]cli.Flag{utils.CacheFlag}, utils.DatabaseFlags),
169164
Description: `
170165
The import-preimages command imports hash preimages from an RLP encoded stream.
171166
It's deprecated, please use "geth db import" instead.
@@ -435,6 +430,10 @@ func importHistory(ctx *cli.Context) error {
435430
network = "mainnet"
436431
case ctx.Bool(utils.SepoliaFlag.Name):
437432
network = "sepolia"
433+
case ctx.Bool(utils.HoleskyFlag.Name):
434+
network = "holesky"
435+
case ctx.Bool(utils.HoodiFlag.Name):
436+
network = "hoodi"
438437
}
439438
} else {
440439
// No network flag set, try to determine network based on files

cmd/geth/dbcmd.go

Lines changed: 36 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ Remove blockchain and state databases`,
8686
},
8787
}
8888
dbInspectCmd = &cli.Command{
89-
Action: inspect,
90-
Name: "inspect",
91-
ArgsUsage: "<prefix> <start>",
92-
Flags: slices.Concat([]cli.Flag{
93-
utils.SyncModeFlag,
94-
}, utils.NetworkFlags, utils.DatabaseFlags),
89+
Action: inspect,
90+
Name: "inspect",
91+
ArgsUsage: "<prefix> <start>",
92+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
9593
Usage: "Inspect the storage size for each type of data in the database",
9694
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.`,
9795
}
@@ -109,16 +107,13 @@ a data corruption.`,
109107
Action: dbStats,
110108
Name: "stats",
111109
Usage: "Print leveldb statistics",
112-
Flags: slices.Concat([]cli.Flag{
113-
utils.SyncModeFlag,
114-
}, utils.NetworkFlags, utils.DatabaseFlags),
110+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
115111
}
116112
dbCompactCmd = &cli.Command{
117113
Action: dbCompact,
118114
Name: "compact",
119115
Usage: "Compact leveldb database. WARNING: May take a very long time",
120116
Flags: slices.Concat([]cli.Flag{
121-
utils.SyncModeFlag,
122117
utils.CacheFlag,
123118
utils.CacheDatabaseFlag,
124119
}, utils.NetworkFlags, utils.DatabaseFlags),
@@ -127,23 +122,19 @@ WARNING: This operation may take a very long time to finish, and may cause datab
127122
corruption if it is aborted during execution'!`,
128123
}
129124
dbGetCmd = &cli.Command{
130-
Action: dbGet,
131-
Name: "get",
132-
Usage: "Show the value of a database key",
133-
ArgsUsage: "<hex-encoded key>",
134-
Flags: slices.Concat([]cli.Flag{
135-
utils.SyncModeFlag,
136-
}, utils.NetworkFlags, utils.DatabaseFlags),
125+
Action: dbGet,
126+
Name: "get",
127+
Usage: "Show the value of a database key",
128+
ArgsUsage: "<hex-encoded key>",
129+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
137130
Description: "This command looks up the specified database key from the database.",
138131
}
139132
dbDeleteCmd = &cli.Command{
140133
Action: dbDelete,
141134
Name: "delete",
142135
Usage: "Delete a database key (WARNING: may corrupt your database)",
143136
ArgsUsage: "<hex-encoded key>",
144-
Flags: slices.Concat([]cli.Flag{
145-
utils.SyncModeFlag,
146-
}, utils.NetworkFlags, utils.DatabaseFlags),
137+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
147138
Description: `This command deletes the specified database key from the database.
148139
WARNING: This is a low-level operation which may cause database corruption!`,
149140
}
@@ -152,59 +143,47 @@ WARNING: This is a low-level operation which may cause database corruption!`,
152143
Name: "put",
153144
Usage: "Set the value of a database key (WARNING: may corrupt your database)",
154145
ArgsUsage: "<hex-encoded key> <hex-encoded value>",
155-
Flags: slices.Concat([]cli.Flag{
156-
utils.SyncModeFlag,
157-
}, utils.NetworkFlags, utils.DatabaseFlags),
146+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
158147
Description: `This command sets a given database key to the given value.
159148
WARNING: This is a low-level operation which may cause database corruption!`,
160149
}
161150
dbGetSlotsCmd = &cli.Command{
162-
Action: dbDumpTrie,
163-
Name: "dumptrie",
164-
Usage: "Show the storage key/values of a given storage trie",
165-
ArgsUsage: "<hex-encoded state root> <hex-encoded account hash> <hex-encoded storage trie root> <hex-encoded start (optional)> <int max elements (optional)>",
166-
Flags: slices.Concat([]cli.Flag{
167-
utils.SyncModeFlag,
168-
}, utils.NetworkFlags, utils.DatabaseFlags),
151+
Action: dbDumpTrie,
152+
Name: "dumptrie",
153+
Usage: "Show the storage key/values of a given storage trie",
154+
ArgsUsage: "<hex-encoded state root> <hex-encoded account hash> <hex-encoded storage trie root> <hex-encoded start (optional)> <int max elements (optional)>",
155+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
169156
Description: "This command looks up the specified database key from the database.",
170157
}
171158
dbDumpFreezerIndex = &cli.Command{
172-
Action: freezerInspect,
173-
Name: "freezer-index",
174-
Usage: "Dump out the index of a specific freezer table",
175-
ArgsUsage: "<freezer-type> <table-type> <start (int)> <end (int)>",
176-
Flags: slices.Concat([]cli.Flag{
177-
utils.SyncModeFlag,
178-
}, utils.NetworkFlags, utils.DatabaseFlags),
159+
Action: freezerInspect,
160+
Name: "freezer-index",
161+
Usage: "Dump out the index of a specific freezer table",
162+
ArgsUsage: "<freezer-type> <table-type> <start (int)> <end (int)>",
163+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
179164
Description: "This command displays information about the freezer index.",
180165
}
181166
dbImportCmd = &cli.Command{
182-
Action: importLDBdata,
183-
Name: "import",
184-
Usage: "Imports leveldb-data from an exported RLP dump.",
185-
ArgsUsage: "<dumpfile> <start (optional)",
186-
Flags: slices.Concat([]cli.Flag{
187-
utils.SyncModeFlag,
188-
}, utils.NetworkFlags, utils.DatabaseFlags),
167+
Action: importLDBdata,
168+
Name: "import",
169+
Usage: "Imports leveldb-data from an exported RLP dump.",
170+
ArgsUsage: "<dumpfile> <start (optional)",
171+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
189172
Description: "The import command imports the specific chain data from an RLP encoded stream.",
190173
}
191174
dbExportCmd = &cli.Command{
192-
Action: exportChaindata,
193-
Name: "export",
194-
Usage: "Exports the chain data into an RLP dump. If the <dumpfile> has .gz suffix, gzip compression will be used.",
195-
ArgsUsage: "<type> <dumpfile>",
196-
Flags: slices.Concat([]cli.Flag{
197-
utils.SyncModeFlag,
198-
}, utils.NetworkFlags, utils.DatabaseFlags),
175+
Action: exportChaindata,
176+
Name: "export",
177+
Usage: "Exports the chain data into an RLP dump. If the <dumpfile> has .gz suffix, gzip compression will be used.",
178+
ArgsUsage: "<type> <dumpfile>",
179+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
199180
Description: "Exports the specified chain data to an RLP encoded stream, optionally gzip-compressed.",
200181
}
201182
dbMetadataCmd = &cli.Command{
202-
Action: showMetaData,
203-
Name: "metadata",
204-
Usage: "Shows metadata about the chain status.",
205-
Flags: slices.Concat([]cli.Flag{
206-
utils.SyncModeFlag,
207-
}, utils.NetworkFlags, utils.DatabaseFlags),
183+
Action: showMetaData,
184+
Name: "metadata",
185+
Usage: "Shows metadata about the chain status.",
186+
Flags: slices.Concat(utils.NetworkFlags, utils.DatabaseFlags),
208187
Description: "Shows metadata about the chain status.",
209188
}
210189
dbInspectHistoryCmd = &cli.Command{
@@ -213,7 +192,6 @@ WARNING: This is a low-level operation which may cause database corruption!`,
213192
Usage: "Inspect the state history within block range",
214193
ArgsUsage: "<address> [OPTIONAL <storage-slot>]",
215194
Flags: slices.Concat([]cli.Flag{
216-
utils.SyncModeFlag,
217195
&cli.Uint64Flag{
218196
Name: "start",
219197
Usage: "block number of the range start, zero means earliest history",

cmd/geth/main.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ var (
142142
utils.VMTraceJsonConfigFlag,
143143
utils.NetworkIdFlag,
144144
utils.EthStatsURLFlag,
145-
utils.NoCompactionFlag,
146145
utils.GpoBlocksFlag,
147146
utils.GpoPercentileFlag,
148147
utils.GpoMaxGasPriceFlag,

0 commit comments

Comments
 (0)