Commit f12f0ec
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 <[email protected]>1 parent fbbaa3c commit f12f0ec
2 files changed
+14
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | | - | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
140 | | - | |
| 140 | + | |
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| |||
1615 | 1615 | | |
1616 | 1616 | | |
1617 | 1617 | | |
1618 | | - | |
1619 | | - | |
| 1618 | + | |
| 1619 | + | |
1620 | 1620 | | |
1621 | 1621 | | |
1622 | 1622 | | |
| |||
1663 | 1663 | | |
1664 | 1664 | | |
1665 | 1665 | | |
1666 | | - | |
1667 | | - | |
1668 | | - | |
1669 | 1666 | | |
1670 | 1667 | | |
1671 | 1668 | | |
| |||
1915 | 1912 | | |
1916 | 1913 | | |
1917 | 1914 | | |
1918 | | - | |
| 1915 | + | |
1919 | 1916 | | |
1920 | 1917 | | |
1921 | 1918 | | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
1922 | 1927 | | |
1923 | 1928 | | |
1924 | 1929 | | |
| |||
0 commit comments