mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-26 15:47:21 +00:00
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> |
||
|---|---|---|
| .. | ||
| testdata | ||
| accountcmd.go | ||
| accountcmd_test.go | ||
| attach_test.go | ||
| chaincmd.go | ||
| chaincmd_test.go | ||
| config.go | ||
| consolecmd.go | ||
| consolecmd_test.go | ||
| dbcmd.go | ||
| exportcmd_test.go | ||
| genesis_test.go | ||
| logging_test.go | ||
| logtestcmd_active.go | ||
| logtestcmd_inactive.go | ||
| main.go | ||
| misccmd.go | ||
| run_test.go | ||
| snapshot.go | ||
| verkle.go | ||
| version_check.go | ||
| version_check_test.go | ||