go-ethereum/cmd/geth
lightclient f12f0ec0cd
cmd/utils: allow --networkid to override other config options (#32999)
Recently in #31630 we removed support for overriding the network id in
preset networks. While this feature is niche, it is useful for shadow
forks. This PR proposes we add the functionality back, but in a simpler
way.

Instead of checking whether the flag is set in each branch of the
network switch statement, simply apply the network flag after the switch
statement is complete. This retains the following behavior:

1. Auto network id based on chain id still works, because `IsSet` only
returns true if the flag is _actually_ set. Not if it just has a default
set.
2. The preset networks will set their network id directly and only if
the network id flag is set is it overridden. This, combined with the
override genesis flag is what allows the shadow forks.
3. Setting the network id to the same network id that the preset _would
have_ set causes no issues and simply emits the `WARN` that the flag is
being set explicitly. I don't think people explicitly set the network id
flag often.

```
WARN [10-22|09:36:15.052] Setting network id with flag             id=10
```

---------

Co-authored-by: Felix Lange <fjl@twurst.com>
2025-11-28 15:24:21 +01:00
..
testdata cmd/geth: update vcheck testdata, add docs on generating signatures (#32121) 2025-07-11 13:55:18 -06:00
accountcmd.go cmd/geth: remove unlock commandline flag (#30737) 2024-11-15 10:15:15 +01:00
accountcmd_test.go cmd/geth: remove unlock commandline flag (#30737) 2024-11-15 10:15:15 +01:00
attach_test.go all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00
chaincmd.go all: add bpo1 and bpo2 overrides (#32737) 2025-09-25 10:21:41 +02:00
chaincmd_test.go cmd/geth: era-download logic fix (#32081) 2025-06-24 15:12:11 +08:00
config.go common: introduce IsHexHash and use it (#32998) 2025-11-04 21:09:36 +08:00
consolecmd.go internal/flags: remove Merge, it's identical to slices.Concat (#30706) 2024-10-31 19:26:02 +02:00
consolecmd_test.go cmd/utils: allow --networkid to override other config options (#32999) 2025-11-28 15:24:21 +01:00
dbcmd.go core, cmd: removed tablewriter from the dependencies (#33218) 2025-11-24 21:50:48 +08:00
exportcmd_test.go all: simplify tests using t.TempDir() (#30150) 2024-07-15 15:26:58 +02:00
genesis_test.go all: remove TerminalTotalDifficultyPassed (#30609) 2024-10-23 08:26:18 +02:00
logging_test.go .github: run tests with ci.go (#32590) 2025-09-11 20:15:51 +02:00
logtestcmd_active.go all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00
logtestcmd_inactive.go all: update license comments and AUTHORS (#31133) 2025-02-05 23:01:17 +01:00
main.go miner: add --miner.maxblobs flag (#33129) 2025-11-26 15:53:03 +01:00
misccmd.go build, internal, version: break ci.go/version->common dependency (#30638) 2024-10-20 19:28:39 +03:00
run_test.go cmd, les, tests: remove light client code (#28586) 2023-11-23 16:28:26 +02:00
snapshot.go common: introduce IsHexHash and use it (#32998) 2025-11-04 21:09:36 +08:00
verkle.go cmd/geth: skip resolver for zero-commitment verkle children (#33265) 2025-11-25 20:34:58 +08:00
version_check.go cmd: migrate to urfave/cli/v2 (#24751) 2022-06-27 18:22:36 +02:00
version_check_test.go cmd/geth: update vcheck testdata, add docs on generating signatures (#32121) 2025-07-11 13:55:18 -06:00