Skip to content

Commit b0ed083

Browse files
committed
cmd, core, params: add support for Goerli
1 parent bb7c786 commit b0ed083

7 files changed

Lines changed: 77 additions & 3 deletions

File tree

‎cmd/geth/main.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ var (
128128
utils.DeveloperPeriodFlag,
129129
utils.TestnetFlag,
130130
utils.RinkebyFlag,
131+
utils.GoerliFlag,
131132
utils.VMEnableDebugFlag,
132133
utils.NetworkIdFlag,
133134
utils.ConstantinopleOverrideFlag,

‎cmd/geth/usage.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ var AppHelpFlagGroups = []flagGroup{
7474
utils.NetworkIdFlag,
7575
utils.TestnetFlag,
7676
utils.RinkebyFlag,
77+
utils.GoerliFlag,
7778
utils.SyncModeFlag,
7879
utils.ExitWhenSyncedFlag,
7980
utils.GCModeFlag,

‎cmd/utils/flags.go‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ var (
141141
Name: "rinkeby",
142142
Usage: "Rinkeby network: pre-configured proof-of-authority test network",
143143
}
144+
GoerliFlag = cli.BoolFlag{
145+
Name: "goerli",
146+
Usage: "Görli network: pre-configured proof-of-authority test network",
147+
}
144148
ConstantinopleOverrideFlag = cli.Uint64Flag{
145149
Name: "override.constantinople",
146150
Usage: "Manually specify constantinople fork-block, overriding the bundled setting",
@@ -692,6 +696,9 @@ func MakeDataDir(ctx *cli.Context) string {
692696
if ctx.GlobalBool(RinkebyFlag.Name) {
693697
return filepath.Join(path, "rinkeby")
694698
}
699+
if ctx.GlobalBool(GoerliFlag.Name) {
700+
return filepath.Join(path, "goerli")
701+
}
695702
return path
696703
}
697704
Fatalf("Cannot determine default data directory, please set manually (--datadir)")
@@ -746,6 +753,8 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
746753
urls = params.TestnetBootnodes
747754
case ctx.GlobalBool(RinkebyFlag.Name):
748755
urls = params.RinkebyBootnodes
756+
case ctx.GlobalBool(GoerliFlag.Name):
757+
urls = params.GoerliBootnodes
749758
case cfg.BootstrapNodes != nil:
750759
return // already set, don't apply defaults.
751760
}
@@ -775,6 +784,8 @@ func setBootstrapNodesV5(ctx *cli.Context, cfg *p2p.Config) {
775784
}
776785
case ctx.GlobalBool(RinkebyFlag.Name):
777786
urls = params.RinkebyBootnodes
787+
case ctx.GlobalBool(GoerliFlag.Name):
788+
urls = params.GoerliBootnodes
778789
case cfg.BootstrapNodesV5 != nil:
779790
return // already set, don't apply defaults.
780791
}
@@ -1080,7 +1091,6 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
10801091
setGraphQL(ctx, cfg)
10811092
setWS(ctx, cfg)
10821093
setNodeUserIdent(ctx, cfg)
1083-
10841094
setDataDir(ctx, cfg)
10851095

10861096
if ctx.GlobalIsSet(KeyStoreDirFlag.Name) {
@@ -1104,6 +1114,8 @@ func setDataDir(ctx *cli.Context, cfg *node.Config) {
11041114
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "testnet")
11051115
case ctx.GlobalBool(RinkebyFlag.Name):
11061116
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "rinkeby")
1117+
case ctx.GlobalBool(GoerliFlag.Name):
1118+
cfg.DataDir = filepath.Join(node.DefaultDataDir(), "goerli")
11071119
}
11081120
}
11091121

@@ -1260,7 +1272,7 @@ func SetShhConfig(ctx *cli.Context, stack *node.Node, cfg *whisper.Config) {
12601272
// SetEthConfig applies eth-related command line flags to the config.
12611273
func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
12621274
// Avoid conflicting network flags
1263-
checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag)
1275+
checkExclusive(ctx, DeveloperFlag, TestnetFlag, RinkebyFlag, GoerliFlag)
12641276
checkExclusive(ctx, LightServFlag, SyncModeFlag, "light")
12651277

12661278
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
@@ -1359,6 +1371,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
13591371
cfg.NetworkId = 4
13601372
}
13611373
cfg.Genesis = core.DefaultRinkebyGenesisBlock()
1374+
case ctx.GlobalBool(GoerliFlag.Name):
1375+
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
1376+
cfg.NetworkId = 5
1377+
}
1378+
cfg.Genesis = core.DefaultGoerliGenesisBlock()
13621379
case ctx.GlobalBool(DeveloperFlag.Name):
13631380
if !ctx.GlobalIsSet(NetworkIdFlag.Name) {
13641381
cfg.NetworkId = 1337
@@ -1516,6 +1533,8 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis {
15161533
genesis = core.DefaultTestnetGenesisBlock()
15171534
case ctx.GlobalBool(RinkebyFlag.Name):
15181535
genesis = core.DefaultRinkebyGenesisBlock()
1536+
case ctx.GlobalBool(GoerliFlag.Name):
1537+
genesis = core.DefaultGoerliGenesisBlock()
15191538
case ctx.GlobalBool(DeveloperFlag.Name):
15201539
Fatalf("Developer chains are ephemeral")
15211540
}

‎core/genesis.go‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, genesis *Genesis, constant
157157
if genesis != nil && genesis.Config == nil {
158158
return params.AllEthashProtocolChanges, common.Hash{}, errGenesisNoConfig
159159
}
160-
161160
// Just commit the new block if there is no stored genesis block.
162161
stored := rawdb.ReadCanonicalHash(db, 0)
163162
if (stored == common.Hash{}) {
@@ -340,6 +339,18 @@ func DefaultRinkebyGenesisBlock() *Genesis {
340339
}
341340
}
342341

342+
// DefaultGoerliGenesisBlock returns the Görli network genesis block.
343+
func DefaultGoerliGenesisBlock() *Genesis {
344+
return &Genesis{
345+
Config: params.GoerliChainConfig,
346+
Timestamp: 1548854791,
347+
ExtraData: hexutil.MustDecode("0x22466c6578692069732061207468696e6722202d204166726900000000000000e0a2bd4258d2768837baa26a28fe71dc079f84c70000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
348+
GasLimit: 10485760,
349+
Difficulty: big.NewInt(1),
350+
Alloc: decodePrealloc(goerliAllocData),
351+
}
352+
}
353+
343354
// DeveloperGenesisBlock returns the 'geth --dev' genesis block. Note, this must
344355
// be seeded with the
345356
func DeveloperGenesisBlock(period uint64, faucet common.Address) *Genesis {

‎core/genesis_alloc.go‎

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

‎params/bootnodes.go‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ var RinkebyBootnodes = []string{
4747
"enode://b6b28890b006743680c52e64e0d16db57f28124885595fa03a562be1d2bf0f3a1da297d56b13da25fb992888fd556d4c1a27b1f39d531bde7de1921c90061cc6@159.89.28.211:30303", // AKASHA
4848
}
4949

50+
// GoerliBootnodes are the enode URLs of the P2P bootstrap nodes running on the
51+
// Görli test network.
52+
var GoerliBootnodes = []string{
53+
// Upstrem bootnodes
54+
"enode://011f758e6552d105183b1761c5e2dea0111bc20fd5f6422bc7f91e0fabbec9a6595caf6239b37feb773dddd3f87240d99d859431891e4a642cf2a0a9e6cbb98a@51.141.78.53:30303",
55+
"enode://176b9417f511d05b6b2cf3e34b756cf0a7096b3094572a8f6ef4cdcb9d1f9d00683bf0f83347eebdf3b81c3521c2332086d9592802230bf528eaf606a1d9677b@13.93.54.137:30303",
56+
"enode://46add44b9f13965f7b9875ac6b85f016f341012d84f975377573800a863526f4da19ae2c620ec73d11591fa9510e992ecc03ad0751f53cc02f7c7ed6d55c7291@94.237.54.114:30313",
57+
"enode://c1f8b7c2ac4453271fa07d8e9ecf9a2e8285aa0bd0c07df0131f47153306b0736fd3db8924e7a9bf0bed6b1d8d4f87362a71b033dc7c64547728d953e43e59b2@52.64.155.147:30303",
58+
"enode://f4a9c6ee28586009fb5a96c8af13a58ed6d8315a9eee4772212c1d4d9cebe5a8b8a78ea4434f318726317d04a3f531a1ef0420cf9752605a562cfe858c46e263@213.186.16.82:30303",
59+
60+
// Ethereum Foundation bootnode
61+
"enode://573b6607cd59f241e30e4c4943fd50e99e2b6f42f9bd5ca111659d309c06741247f4f1e93843ad3e8c8c18b6e2d94c161b7ef67479b3938780a97134b618b5ce@52.56.136.200:30303",
62+
}
63+
5064
// DiscoveryV5Bootnodes are the enode URLs of the P2P bootstrap nodes for the
5165
// experimental RLPx v5 topic-discovery network.
5266
var DiscoveryV5Bootnodes = []string{

‎params/config.go‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,33 @@ var (
109109
BloomRoot: common.HexToHash("0xcf74ca2c14e843b366561dab4fc64237bf6bb335119cbc97d723f3b501863470"),
110110
}
111111

112+
// GoerliChainConfig contains the chain parameters to run a node on the Görli test network.
113+
GoerliChainConfig = &ChainConfig{
114+
ChainID: big.NewInt(5),
115+
HomesteadBlock: big.NewInt(0),
116+
DAOForkBlock: nil,
117+
DAOForkSupport: true,
118+
EIP150Block: big.NewInt(0),
119+
EIP155Block: big.NewInt(0),
120+
EIP158Block: big.NewInt(0),
121+
ByzantiumBlock: big.NewInt(0),
122+
ConstantinopleBlock: big.NewInt(0),
123+
PetersburgBlock: big.NewInt(0),
124+
Clique: &CliqueConfig{
125+
Period: 15,
126+
Epoch: 30000,
127+
},
128+
}
129+
130+
// GoerliTrustedCheckpoint contains the light client trusted checkpoint for the Görli test network.
131+
GoerliTrustedCheckpoint = &TrustedCheckpoint{
132+
Name: "goerli",
133+
SectionIndex: 0,
134+
SectionHead: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
135+
CHTRoot: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
136+
BloomRoot: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
137+
}
138+
112139
// AllEthashProtocolChanges contains every protocol change (EIPs) introduced
113140
// and accepted by the Ethereum core developers into the Ethash consensus.
114141
//

0 commit comments

Comments
 (0)