mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
avoid main network and test networks don't match the network id
This commit is contained in:
parent
a9444ea312
commit
0ffd06ab44
1 changed files with 15 additions and 10 deletions
|
|
@ -1743,33 +1743,38 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
|
||||||
// Override any default configs for hard coded networks.
|
// Override any default configs for hard coded networks.
|
||||||
switch {
|
switch {
|
||||||
case ctx.Bool(MainnetFlag.Name):
|
case ctx.Bool(MainnetFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if ctx.IsSet(NetworkIdFlag.Name) && ctx.Uint64(NetworkIdFlag.Name) != 1 {
|
||||||
cfg.NetworkId = 1
|
Fatalf("Network ID %d is not allowed on mainnet", ctx.Uint64(NetworkIdFlag.Name))
|
||||||
}
|
}
|
||||||
|
cfg.NetworkId = 1
|
||||||
cfg.Genesis = core.DefaultGenesisBlock()
|
cfg.Genesis = core.DefaultGenesisBlock()
|
||||||
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
|
SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash)
|
||||||
case ctx.Bool(HoleskyFlag.Name):
|
case ctx.Bool(HoleskyFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if ctx.IsSet(NetworkIdFlag.Name) && ctx.Uint64(NetworkIdFlag.Name) != 17000 {
|
||||||
cfg.NetworkId = 17000
|
Fatalf("Network ID %d is not allowed on holesky", ctx.Uint64(NetworkIdFlag.Name))
|
||||||
}
|
}
|
||||||
|
cfg.NetworkId = 17000
|
||||||
cfg.Genesis = core.DefaultHoleskyGenesisBlock()
|
cfg.Genesis = core.DefaultHoleskyGenesisBlock()
|
||||||
SetDNSDiscoveryDefaults(cfg, params.HoleskyGenesisHash)
|
SetDNSDiscoveryDefaults(cfg, params.HoleskyGenesisHash)
|
||||||
case ctx.Bool(SepoliaFlag.Name):
|
case ctx.Bool(SepoliaFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if ctx.IsSet(NetworkIdFlag.Name) && ctx.Uint64(NetworkIdFlag.Name) != 11155111 {
|
||||||
cfg.NetworkId = 11155111
|
Fatalf("Network ID %d is not allowed on sepolia", ctx.Uint64(NetworkIdFlag.Name))
|
||||||
}
|
}
|
||||||
|
cfg.NetworkId = 11155111
|
||||||
cfg.Genesis = core.DefaultSepoliaGenesisBlock()
|
cfg.Genesis = core.DefaultSepoliaGenesisBlock()
|
||||||
SetDNSDiscoveryDefaults(cfg, params.SepoliaGenesisHash)
|
SetDNSDiscoveryDefaults(cfg, params.SepoliaGenesisHash)
|
||||||
case ctx.Bool(HoodiFlag.Name):
|
case ctx.Bool(HoodiFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if ctx.IsSet(NetworkIdFlag.Name) && ctx.Uint64(NetworkIdFlag.Name) != 560048 {
|
||||||
cfg.NetworkId = 560048
|
Fatalf("Network ID %d is not allowed on hoodi", ctx.Uint64(NetworkIdFlag.Name))
|
||||||
}
|
}
|
||||||
|
cfg.NetworkId = 560048
|
||||||
cfg.Genesis = core.DefaultHoodiGenesisBlock()
|
cfg.Genesis = core.DefaultHoodiGenesisBlock()
|
||||||
SetDNSDiscoveryDefaults(cfg, params.HoodiGenesisHash)
|
SetDNSDiscoveryDefaults(cfg, params.HoodiGenesisHash)
|
||||||
case ctx.Bool(DeveloperFlag.Name):
|
case ctx.Bool(DeveloperFlag.Name):
|
||||||
if !ctx.IsSet(NetworkIdFlag.Name) {
|
if ctx.IsSet(NetworkIdFlag.Name) && ctx.Uint64(NetworkIdFlag.Name) != 1337 {
|
||||||
cfg.NetworkId = 1337
|
Fatalf("Network ID %d is not allowed on hoodi", ctx.Uint64(NetworkIdFlag.Name))
|
||||||
}
|
}
|
||||||
|
cfg.NetworkId = 1337
|
||||||
cfg.SyncMode = ethconfig.FullSync
|
cfg.SyncMode = ethconfig.FullSync
|
||||||
// Create new developer account or reuse existing one
|
// Create new developer account or reuse existing one
|
||||||
var (
|
var (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue