42
42
EIP155Block : big .NewInt (2675000 ),
43
43
EIP158Block : big .NewInt (2675000 ),
44
44
ByzantiumBlock : big .NewInt (4370000 ),
45
- ConstantinopleBlock : nil ,
45
+ ConstantinopleBlock : big .NewInt (7280000 ),
46
+ PetersburgBlock : big .NewInt (7280000 ),
46
47
Ethash : new (EthashConfig ),
47
48
}
48
49
67
68
EIP158Block : big .NewInt (10 ),
68
69
ByzantiumBlock : big .NewInt (1700000 ),
69
70
ConstantinopleBlock : big .NewInt (4230000 ),
71
+ PetersburgBlock : big .NewInt (4939394 ),
70
72
Ethash : new (EthashConfig ),
71
73
}
72
74
91
93
EIP158Block : big .NewInt (3 ),
92
94
ByzantiumBlock : big .NewInt (1035301 ),
93
95
ConstantinopleBlock : big .NewInt (3660663 ),
96
+ PetersburgBlock : big .NewInt (9999999 ), //TODO! Insert Rinkeby block number
94
97
Clique : & CliqueConfig {
95
98
Period : 15 ,
96
99
Epoch : 30000 ,
@@ -111,16 +114,16 @@ var (
111
114
//
112
115
// This configuration is intentionally not using keyed fields to force anyone
113
116
// adding flags to the config to also have to set these fields.
114
- AllEthashProtocolChanges = & ChainConfig {big .NewInt (1337 ), big .NewInt (0 ), nil , false , big .NewInt (0 ), common.Hash {}, big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), nil , new (EthashConfig ), nil }
117
+ AllEthashProtocolChanges = & ChainConfig {big .NewInt (1337 ), big .NewInt (0 ), nil , false , big .NewInt (0 ), common.Hash {}, big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big . NewInt ( 0 ), nil , new (EthashConfig ), nil }
115
118
116
119
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
117
120
// and accepted by the Ethereum core developers into the Clique consensus.
118
121
//
119
122
// This configuration is intentionally not using keyed fields to force anyone
120
123
// adding flags to the config to also have to set these fields.
121
- AllCliqueProtocolChanges = & ChainConfig {big .NewInt (1337 ), big .NewInt (0 ), nil , false , big .NewInt (0 ), common.Hash {}, big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), nil , nil , & CliqueConfig {Period : 0 , Epoch : 30000 }}
124
+ AllCliqueProtocolChanges = & ChainConfig {big .NewInt (1337 ), big .NewInt (0 ), nil , false , big .NewInt (0 ), common.Hash {}, big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big . NewInt ( 0 ), nil , nil , & CliqueConfig {Period : 0 , Epoch : 30000 }}
122
125
123
- TestChainConfig = & ChainConfig {big .NewInt (1 ), big .NewInt (0 ), nil , false , big .NewInt (0 ), common.Hash {}, big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), nil , new (EthashConfig ), nil }
126
+ TestChainConfig = & ChainConfig {big .NewInt (1 ), big .NewInt (0 ), nil , false , big .NewInt (0 ), common.Hash {}, big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big . NewInt ( 0 ), nil , new (EthashConfig ), nil }
124
127
TestRules = TestChainConfig .Rules (new (big.Int ))
125
128
)
126
129
@@ -158,6 +161,7 @@ type ChainConfig struct {
158
161
159
162
ByzantiumBlock * big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium)
160
163
ConstantinopleBlock * big.Int `json:"constantinopleBlock,omitempty"` // Constantinople switch block (nil = no fork, 0 = already activated)
164
+ PetersburgBlock * big.Int `json:"petersburgBlock,omitempty"` // Petersburg switch block (nil = same as Constantinople)
161
165
EWASMBlock * big.Int `json:"ewasmBlock,omitempty"` // EWASM switch block (nil = no fork, 0 = already activated)
162
166
163
167
// Various consensus engines
@@ -195,7 +199,7 @@ func (c *ChainConfig) String() string {
195
199
default :
196
200
engine = "unknown"
197
201
}
198
- return fmt .Sprintf ("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Engine: %v}" ,
202
+ return fmt .Sprintf ("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v ConstantinopleFix: %v Engine: %v}" ,
199
203
c .ChainID ,
200
204
c .HomesteadBlock ,
201
205
c .DAOForkBlock ,
@@ -205,6 +209,7 @@ func (c *ChainConfig) String() string {
205
209
c .EIP158Block ,
206
210
c .ByzantiumBlock ,
207
211
c .ConstantinopleBlock ,
212
+ c .PetersburgBlock ,
208
213
engine ,
209
214
)
210
215
}
@@ -244,6 +249,13 @@ func (c *ChainConfig) IsConstantinople(num *big.Int) bool {
244
249
return isForked (c .ConstantinopleBlock , num )
245
250
}
246
251
252
+ // IsPetersburg returns whether num is either
253
+ // - equal to or greater than the PetersburgBlock fork block,
254
+ // - OR is nil, and Constantinople is active
255
+ func (c * ChainConfig ) IsPetersburg (num * big.Int ) bool {
256
+ return isForked (c .PetersburgBlock , num ) || c .PetersburgBlock == nil && isForked (c .ConstantinopleBlock , num )
257
+ }
258
+
247
259
// IsEWASM returns whether num represents a block number after the EWASM fork
248
260
func (c * ChainConfig ) IsEWASM (num * big.Int ) bool {
249
261
return isForked (c .EWASMBlock , num )
@@ -314,6 +326,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
314
326
if isForkIncompatible (c .ConstantinopleBlock , newcfg .ConstantinopleBlock , head ) {
315
327
return newCompatError ("Constantinople fork block" , c .ConstantinopleBlock , newcfg .ConstantinopleBlock )
316
328
}
329
+ if isForkIncompatible (c .PetersburgBlock , newcfg .PetersburgBlock , head ) {
330
+ return newCompatError ("ConstantinopleFix fork block" , c .PetersburgBlock , newcfg .PetersburgBlock )
331
+ }
317
332
if isForkIncompatible (c .EWASMBlock , newcfg .EWASMBlock , head ) {
318
333
return newCompatError ("ewasm fork block" , c .EWASMBlock , newcfg .EWASMBlock )
319
334
}
@@ -381,9 +396,9 @@ func (err *ConfigCompatError) Error() string {
381
396
// Rules is a one time interface meaning that it shouldn't be used in between transition
382
397
// phases.
383
398
type Rules struct {
384
- ChainID * big.Int
385
- IsHomestead , IsEIP150 , IsEIP155 , IsEIP158 bool
386
- IsByzantium , IsConstantinople bool
399
+ ChainID * big.Int
400
+ IsHomestead , IsEIP150 , IsEIP155 , IsEIP158 bool
401
+ IsByzantium , IsConstantinople , IsPetersburg bool
387
402
}
388
403
389
404
// Rules ensures c's ChainID is not nil.
@@ -400,5 +415,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
400
415
IsEIP158 : c .IsEIP158 (num ),
401
416
IsByzantium : c .IsByzantium (num ),
402
417
IsConstantinople : c .IsConstantinople (num ),
418
+ IsPetersburg : c .IsPetersburg (num ),
403
419
}
404
420
}
0 commit comments