Skip to content

Commit e1c000b

Browse files
authored
cmd/geth: add support for sepolia testnet (#23730)
* cmd/geth: add support for sepolia testnet * core: last details on sepolia genesis * params: fix sepolia hash + reduce testing code * Update params/bootnodes.go * cmd/geth: fix attach path for sepolia * params: update bootnodes * params: fix * core: fix docstring * params: add sepolia CHT
1 parent 8be8ba4 commit e1c000b

File tree

15 files changed

+127
-44
lines changed

15 files changed

+127
-44
lines changed

cmd/devp2p/nodesetcmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ func ethFilter(args []string) (nodeFilter, error) {
235235
filter = forkid.NewStaticFilter(params.GoerliChainConfig, params.GoerliGenesisHash)
236236
case "ropsten":
237237
filter = forkid.NewStaticFilter(params.RopstenChainConfig, params.RopstenGenesisHash)
238+
case "sepolia":
239+
filter = forkid.NewStaticFilter(params.SepoliaChainConfig, params.SepoliaGenesisHash)
238240
default:
239241
return nil, fmt.Errorf("unknown network %q", args[0])
240242
}

cmd/geth/chaincmd.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ It expects the genesis file as argument.`,
6666
Flags: []cli.Flag{
6767
utils.MainnetFlag,
6868
utils.RopstenFlag,
69+
utils.SepoliaFlag,
6970
utils.RinkebyFlag,
7071
utils.GoerliFlag,
7172
},

cmd/geth/consolecmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ func remoteConsole(ctx *cli.Context) error {
134134
path = filepath.Join(path, "rinkeby")
135135
} else if ctx.GlobalBool(utils.GoerliFlag.Name) {
136136
path = filepath.Join(path, "goerli")
137+
} else if ctx.GlobalBool(utils.SepoliaFlag.Name) {
138+
path = filepath.Join(path, "sepolia")
137139
}
138140
}
139141
endpoint = fmt.Sprintf("%s/geth.ipc", path)

cmd/geth/dbcmd.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ Remove blockchain and state databases`,
8080
utils.SyncModeFlag,
8181
utils.MainnetFlag,
8282
utils.RopstenFlag,
83+
utils.SepoliaFlag,
8384
utils.RinkebyFlag,
8485
utils.GoerliFlag,
8586
},
@@ -95,6 +96,7 @@ Remove blockchain and state databases`,
9596
utils.SyncModeFlag,
9697
utils.MainnetFlag,
9798
utils.RopstenFlag,
99+
utils.SepoliaFlag,
98100
utils.RinkebyFlag,
99101
utils.GoerliFlag,
100102
},
@@ -108,6 +110,7 @@ Remove blockchain and state databases`,
108110
utils.SyncModeFlag,
109111
utils.MainnetFlag,
110112
utils.RopstenFlag,
113+
utils.SepoliaFlag,
111114
utils.RinkebyFlag,
112115
utils.GoerliFlag,
113116
utils.CacheFlag,
@@ -127,6 +130,7 @@ corruption if it is aborted during execution'!`,
127130
utils.SyncModeFlag,
128131
utils.MainnetFlag,
129132
utils.RopstenFlag,
133+
utils.SepoliaFlag,
130134
utils.RinkebyFlag,
131135
utils.GoerliFlag,
132136
},
@@ -142,6 +146,7 @@ corruption if it is aborted during execution'!`,
142146
utils.SyncModeFlag,
143147
utils.MainnetFlag,
144148
utils.RopstenFlag,
149+
utils.SepoliaFlag,
145150
utils.RinkebyFlag,
146151
utils.GoerliFlag,
147152
},
@@ -158,6 +163,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
158163
utils.SyncModeFlag,
159164
utils.MainnetFlag,
160165
utils.RopstenFlag,
166+
utils.SepoliaFlag,
161167
utils.RinkebyFlag,
162168
utils.GoerliFlag,
163169
},
@@ -174,6 +180,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
174180
utils.SyncModeFlag,
175181
utils.MainnetFlag,
176182
utils.RopstenFlag,
183+
utils.SepoliaFlag,
177184
utils.RinkebyFlag,
178185
utils.GoerliFlag,
179186
},
@@ -189,6 +196,7 @@ WARNING: This is a low-level operation which may cause database corruption!`,
189196
utils.SyncModeFlag,
190197
utils.MainnetFlag,
191198
utils.RopstenFlag,
199+
utils.SepoliaFlag,
192200
utils.RinkebyFlag,
193201
utils.GoerliFlag,
194202
},

cmd/geth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ var (
140140
utils.DeveloperFlag,
141141
utils.DeveloperPeriodFlag,
142142
utils.RopstenFlag,
143+
utils.SepoliaFlag,
143144
utils.RinkebyFlag,
144145
utils.GoerliFlag,
145146
utils.VMEnableDebugFlag,

cmd/geth/snapshot.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ var (
6262
utils.DataDirFlag,
6363
utils.AncientFlag,
6464
utils.RopstenFlag,
65+
utils.SepoliaFlag,
6566
utils.RinkebyFlag,
6667
utils.GoerliFlag,
6768
utils.CacheTrieJournalFlag,
@@ -92,6 +93,7 @@ the trie clean cache with default directory will be deleted.
9293
utils.DataDirFlag,
9394
utils.AncientFlag,
9495
utils.RopstenFlag,
96+
utils.SepoliaFlag,
9597
utils.RinkebyFlag,
9698
utils.GoerliFlag,
9799
},
@@ -112,6 +114,7 @@ In other words, this command does the snapshot to trie conversion.
112114
utils.DataDirFlag,
113115
utils.AncientFlag,
114116
utils.RopstenFlag,
117+
utils.SepoliaFlag,
115118
utils.RinkebyFlag,
116119
utils.GoerliFlag,
117120
},
@@ -134,6 +137,7 @@ It's also usable without snapshot enabled.
134137
utils.DataDirFlag,
135138
utils.AncientFlag,
136139
utils.RopstenFlag,
140+
utils.SepoliaFlag,
137141
utils.RinkebyFlag,
138142
utils.GoerliFlag,
139143
},
@@ -157,6 +161,7 @@ It's also usable without snapshot enabled.
157161
utils.DataDirFlag,
158162
utils.AncientFlag,
159163
utils.RopstenFlag,
164+
utils.SepoliaFlag,
160165
utils.RinkebyFlag,
161166
utils.GoerliFlag,
162167
utils.ExcludeCodeFlag,

cmd/geth/usage.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var AppHelpFlagGroups = []flags.FlagGroup{
4545
utils.GoerliFlag,
4646
utils.RinkebyFlag,
4747
utils.RopstenFlag,
48+
utils.SepoliaFlag,
4849
utils.SyncModeFlag,
4950
utils.ExitWhenSyncedFlag,
5051
utils.GCModeFlag,

cmd/utils/flags.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ var (
155155
Name: "ropsten",
156156
Usage: "Ropsten network: pre-configured proof-of-work test network",
157157
}
158+
SepoliaFlag = cli.BoolFlag{
159+
Name: "sepolia",
160+
Usage: "Sepolia network: pre-configured proof-of-work test network",
161+
}
158162
DeveloperFlag = cli.BoolFlag{
159163
Name: "dev",
160164
Usage: "Ephemeral proof-of-authority network with a pre-funded developer account, mining enabled",
@@ -798,6 +802,9 @@ func MakeDataDir(ctx *cli.Context) string {
798802
if ctx.GlobalBool(GoerliFlag.Name) {
799803
return filepath.Join(path, "goerli")
800804
}
805+
if ctx.GlobalBool(SepoliaFlag.Name) {
806+
return filepath.Join(path, "sepolia")
807+
}
801808
return path
802809
}
803810
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
@@ -846,6 +853,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
846853
urls = SplitAndTrim(ctx.GlobalString(BootnodesFlag.Name))
847854
case ctx.GlobalBool(RopstenFlag.Name):
848855
urls = params.RopstenBootnodes
856+
case ctx.GlobalBool(SepoliaFlag.Name):
857+
urls = params.SepoliaBootnodes
849858
case ctx.GlobalBool(RinkebyFlag.Name):
850859
urls = params.RinkebyBootnodes
851860
case ctx.GlobalBool(GoerliFlag.Name):
@@ -1269,6 +1278,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
12691278
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
12701279
case ctx.GlobalBool(GoerliFlag.Name) && cfg.DataDir == node.DefaultDataDir():
12711280
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli")
1281+
case ctx.GlobalBool(SepoliaFlag.Name) && cfg.DataDir == node.DefaultDataDir():
1282+
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "sepolia")
12721283
}
12731284
}
12741285

@@ -1454,7 +1465,7 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
14541465
// SetEthConfig applies eth-related command line flags to the config.
14551466
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
14561467
// Avoid conflicting network flags
1457-
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag)
1468+
CheckExclusive(ctx, MainnetFlag, DeveloperFlag, RopstenFlag, RinkebyFlag, GoerliFlag, SepoliaFlag)
14581469
CheckExclusive(ctx, LightServeFlag, SyncModeFlag, "light")
14591470
CheckExclusive(ctx, DeveloperFlag, ExternalSignerFlag) // Can't use both ephemeral unlocked and external signer
14601471
if ctx.GlobalString(GCModeFlag.Name) == "archive" && ctx.GlobalUint64(TxLookupLimitFlag.Name) != 0 {
@@ -1598,6 +1609,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
15981609
}
15991610
cfg.Genesis = core.DefaultRopstenGenesisBlock()
16001611
SetDNSDiscoveryDefaults(cfg, params.RopstenGenesisHash)
1612+
case ctx.GlobalBool(SepoliaFlag.Name):
1613+
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
1614+
cfg.NetworkId = 11155111
1615+
}
1616+
cfg.Genesis = core.DefaultSepoliaGenesisBlock()
1617+
SetDNSDiscoveryDefaults(cfg, params.SepoliaGenesisHash)
16011618
case ctx.GlobalBool(RinkebyFlag.Name):
16021619
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
16031620
cfg.NetworkId = 4
@@ -1826,6 +1843,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
18261843
genesis = core.DefaultGenesisBlock()
18271844
case ctx.GlobalBool(RopstenFlag.Name):
18281845
genesis = core.DefaultRopstenGenesisBlock()
1846+
case ctx.GlobalBool(SepoliaFlag.Name):
1847+
genesis = core.DefaultSepoliaGenesisBlock()
18291848
case ctx.GlobalBool(RinkebyFlag.Name):
18301849
genesis = core.DefaultRinkebyGenesisBlock()
18311850
case ctx.GlobalBool(GoerliFlag.Name):

core/genesis.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ func (g *Genesis) configOrDefault(ghash common.Hash) *params.ChainConfig {
244244
return params.MainnetChainConfig
245245
case ghash == params.RopstenGenesisHash:
246246
return params.RopstenChainConfig
247+
case ghash == params.SepoliaGenesisHash:
248+
return params.SepoliaChainConfig
247249
case ghash == params.RinkebyGenesisHash:
248250
return params.RinkebyChainConfig
249251
case ghash == params.GoerliGenesisHash:
@@ -400,6 +402,19 @@ func DefaultGoerliGenesisBlock() *Genesis {
400402
}
401403
}
402404

405+
// DefaultSepoliaGenesisBlock returns the Sepolia network genesis block.
406+
func DefaultSepoliaGenesisBlock() *Genesis {
407+
return &Genesis{
408+
Config: params.SepoliaChainConfig,
409+
Nonce: 0,
410+
ExtraData: []byte("Sepolia, Athens, Attica, Greece!"),
411+
GasLimit: 0x1c9c380,
412+
Difficulty: big.NewInt(0x20000),
413+
Timestamp: 1633267481,
414+
Alloc: decodePrealloc(sepoliaAllocData),
415+
}
416+
}
417+
403418
// DeveloperGenesisBlock returns the 'geth --dev' genesis block.
404419
func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {
405420
// Override the default period to the user requested one

0 commit comments

Comments
 (0)