@@ -266,21 +266,124 @@ var (
266
266
267
267
// AllEthashProtocolChanges contains every protocol change (EIPs) introduced
268
268
// and accepted by the Ethereum core developers into the Ethash consensus.
269
- //
270
- // This configuration is intentionally not using keyed fields to force anyone
271
- // adding flags to the config to also have to set these fields.
272
- 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 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), nil , nil , nil , nil , false , new (EthashConfig ), nil }
269
+ AllEthashProtocolChanges = & ChainConfig {
270
+ ChainID : big .NewInt (1337 ),
271
+ HomesteadBlock : big .NewInt (0 ),
272
+ DAOForkBlock : nil ,
273
+ DAOForkSupport : false ,
274
+ EIP150Block : big .NewInt (0 ),
275
+ EIP150Hash : common.Hash {},
276
+ EIP155Block : big .NewInt (0 ),
277
+ EIP158Block : big .NewInt (0 ),
278
+ ByzantiumBlock : big .NewInt (0 ),
279
+ ConstantinopleBlock : big .NewInt (0 ),
280
+ PetersburgBlock : big .NewInt (0 ),
281
+ IstanbulBlock : big .NewInt (0 ),
282
+ MuirGlacierBlock : big .NewInt (0 ),
283
+ BerlinBlock : big .NewInt (0 ),
284
+ LondonBlock : big .NewInt (0 ),
285
+ ArrowGlacierBlock : big .NewInt (0 ),
286
+ GrayGlacierBlock : big .NewInt (0 ),
287
+ MergeNetsplitBlock : nil ,
288
+ ShanghaiTime : nil ,
289
+ CancunTime : nil ,
290
+ PragueTime : nil ,
291
+ TerminalTotalDifficulty : nil ,
292
+ TerminalTotalDifficultyPassed : false ,
293
+ Ethash : new (EthashConfig ),
294
+ Clique : nil ,
295
+ }
273
296
274
297
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
275
298
// and accepted by the Ethereum core developers into the Clique consensus.
276
- //
277
- // This configuration is intentionally not using keyed fields to force anyone
278
- // adding flags to the config to also have to set these fields.
279
- 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 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), nil , nil , nil , nil , nil , nil , false , nil , & CliqueConfig {Period : 0 , Epoch : 30000 }}
280
-
281
- 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 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), big .NewInt (0 ), nil , nil , nil , nil , false , new (EthashConfig ), nil }
282
- NonActivatedConfig = & ChainConfig {big .NewInt (1 ), nil , nil , false , nil , common.Hash {}, nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , nil , false , new (EthashConfig ), nil }
283
- TestRules = TestChainConfig .Rules (new (big.Int ), false , new (big.Int ))
299
+ AllCliqueProtocolChanges = & ChainConfig {
300
+ ChainID : big .NewInt (1337 ),
301
+ HomesteadBlock : big .NewInt (0 ),
302
+ DAOForkBlock : nil ,
303
+ DAOForkSupport : false ,
304
+ EIP150Block : big .NewInt (0 ),
305
+ EIP150Hash : common.Hash {},
306
+ EIP155Block : big .NewInt (0 ),
307
+ EIP158Block : big .NewInt (0 ),
308
+ ByzantiumBlock : big .NewInt (0 ),
309
+ ConstantinopleBlock : big .NewInt (0 ),
310
+ PetersburgBlock : big .NewInt (0 ),
311
+ IstanbulBlock : big .NewInt (0 ),
312
+ MuirGlacierBlock : big .NewInt (0 ),
313
+ BerlinBlock : big .NewInt (0 ),
314
+ LondonBlock : big .NewInt (0 ),
315
+ ArrowGlacierBlock : nil ,
316
+ GrayGlacierBlock : nil ,
317
+ MergeNetsplitBlock : nil ,
318
+ ShanghaiTime : nil ,
319
+ CancunTime : nil ,
320
+ PragueTime : nil ,
321
+ TerminalTotalDifficulty : nil ,
322
+ TerminalTotalDifficultyPassed : false ,
323
+ Ethash : nil ,
324
+ Clique : & CliqueConfig {Period : 0 , Epoch : 30000 },
325
+ }
326
+
327
+ // TestChainConfig contains every protocol change (EIPs) introduced
328
+ // and accepted by the Ethereum core developers for testing proposes.
329
+ TestChainConfig = & ChainConfig {
330
+ ChainID : big .NewInt (1 ),
331
+ HomesteadBlock : big .NewInt (0 ),
332
+ DAOForkBlock : nil ,
333
+ DAOForkSupport : false ,
334
+ EIP150Block : big .NewInt (0 ),
335
+ EIP150Hash : common.Hash {},
336
+ EIP155Block : big .NewInt (0 ),
337
+ EIP158Block : big .NewInt (0 ),
338
+ ByzantiumBlock : big .NewInt (0 ),
339
+ ConstantinopleBlock : big .NewInt (0 ),
340
+ PetersburgBlock : big .NewInt (0 ),
341
+ IstanbulBlock : big .NewInt (0 ),
342
+ MuirGlacierBlock : big .NewInt (0 ),
343
+ BerlinBlock : big .NewInt (0 ),
344
+ LondonBlock : big .NewInt (0 ),
345
+ ArrowGlacierBlock : big .NewInt (0 ),
346
+ GrayGlacierBlock : big .NewInt (0 ),
347
+ MergeNetsplitBlock : nil ,
348
+ ShanghaiTime : nil ,
349
+ CancunTime : nil ,
350
+ PragueTime : nil ,
351
+ TerminalTotalDifficulty : nil ,
352
+ TerminalTotalDifficultyPassed : false ,
353
+ Ethash : new (EthashConfig ),
354
+ Clique : nil ,
355
+ }
356
+
357
+ // NonActivatedConfig defines the chain configuration without activating
358
+ // any protocol change (EIPs).
359
+ NonActivatedConfig = & ChainConfig {
360
+ ChainID : big .NewInt (1 ),
361
+ HomesteadBlock : nil ,
362
+ DAOForkBlock : nil ,
363
+ DAOForkSupport : false ,
364
+ EIP150Block : nil ,
365
+ EIP150Hash : common.Hash {},
366
+ EIP155Block : nil ,
367
+ EIP158Block : nil ,
368
+ ByzantiumBlock : nil ,
369
+ ConstantinopleBlock : nil ,
370
+ PetersburgBlock : nil ,
371
+ IstanbulBlock : nil ,
372
+ MuirGlacierBlock : nil ,
373
+ BerlinBlock : nil ,
374
+ LondonBlock : nil ,
375
+ ArrowGlacierBlock : nil ,
376
+ GrayGlacierBlock : nil ,
377
+ MergeNetsplitBlock : nil ,
378
+ ShanghaiTime : nil ,
379
+ CancunTime : nil ,
380
+ PragueTime : nil ,
381
+ TerminalTotalDifficulty : nil ,
382
+ TerminalTotalDifficultyPassed : false ,
383
+ Ethash : new (EthashConfig ),
384
+ Clique : nil ,
385
+ }
386
+ TestRules = TestChainConfig .Rules (new (big.Int ), false , new (big.Int ))
284
387
)
285
388
286
389
// NetworkNames are user friendly names to use in the chain spec banner.
@@ -370,11 +473,12 @@ type ChainConfig struct {
370
473
ArrowGlacierBlock * big.Int `json:"arrowGlacierBlock,omitempty"` // Eip-4345 (bomb delay) switch block (nil = no fork, 0 = already activated)
371
474
GrayGlacierBlock * big.Int `json:"grayGlacierBlock,omitempty"` // Eip-5133 (bomb delay) switch block (nil = no fork, 0 = already activated)
372
475
MergeNetsplitBlock * big.Int `json:"mergeNetsplitBlock,omitempty"` // Virtual fork after The Merge to use as a network splitter
373
- CancunBlock * big.Int `json:"cancunBlock,omitempty"` // Cancun switch block (nil = no fork, 0 = already on cancun)
374
476
375
477
// Fork scheduling was switched from blocks to timestamps here
376
478
377
479
ShanghaiTime * big.Int `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already on shanghai)
480
+ CancunTime * big.Int `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already on cancun)
481
+ PragueTime * big.Int `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already on prague)
378
482
379
483
// TerminalTotalDifficulty is the amount of total difficulty reached by
380
484
// the network that triggers the consensus upgrade.
@@ -489,8 +593,11 @@ func (c *ChainConfig) Description() string {
489
593
if c .ShanghaiTime != nil {
490
594
banner += fmt .Sprintf (" - Shanghai: @%-10v (https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md)\n " , c .ShanghaiTime )
491
595
}
492
- if c .CancunBlock != nil {
493
- banner += fmt .Sprintf (" - Cancun: @%-10v\n " , c .CancunBlock )
596
+ if c .CancunTime != nil {
597
+ banner += fmt .Sprintf (" - Cancun: @%-10v\n " , c .CancunTime )
598
+ }
599
+ if c .PragueTime != nil {
600
+ banner += fmt .Sprintf (" - Prague: @%-10v\n " , c .PragueTime )
494
601
}
495
602
return banner
496
603
}
@@ -575,16 +682,21 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
575
682
return parentTotalDiff .Cmp (c .TerminalTotalDifficulty ) < 0 && totalDiff .Cmp (c .TerminalTotalDifficulty ) >= 0
576
683
}
577
684
578
- // IsCancun returns whether num is either equal to the Cancun fork block or greater.
579
- func (c * ChainConfig ) IsCancun (num * big.Int ) bool {
580
- return isBlockForked (c .CancunBlock , num )
581
- }
582
-
583
685
// IsShanghai returns whether time is either equal to the Shanghai fork time or greater.
584
686
func (c * ChainConfig ) IsShanghai (time * big.Int ) bool {
585
687
return isTimestampForked (c .ShanghaiTime , time )
586
688
}
587
689
690
+ // IsCancun returns whether num is either equal to the Cancun fork time or greater.
691
+ func (c * ChainConfig ) IsCancun (time * big.Int ) bool {
692
+ return isTimestampForked (c .CancunTime , time )
693
+ }
694
+
695
+ // IsPrague returns whether num is either equal to the Prague fork time or greater.
696
+ func (c * ChainConfig ) IsPrague (time * big.Int ) bool {
697
+ return isTimestampForked (c .PragueTime , time )
698
+ }
699
+
588
700
// CheckCompatible checks whether scheduled fork transitions have been imported
589
701
// with a mismatching chain configuration.
590
702
func (c * ChainConfig ) CheckCompatible (newcfg * ChainConfig , height uint64 , time uint64 ) * ConfigCompatError {
@@ -636,8 +748,9 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
636
748
{name : "arrowGlacierBlock" , block : c .ArrowGlacierBlock , optional : true },
637
749
{name : "grayGlacierBlock" , block : c .GrayGlacierBlock , optional : true },
638
750
{name : "mergeNetsplitBlock" , block : c .MergeNetsplitBlock , optional : true },
639
- {name : "cancunBlock" , block : c .CancunBlock , optional : true },
640
751
{name : "shanghaiTime" , timestamp : c .ShanghaiTime },
752
+ {name : "cancunTime" , timestamp : c .CancunTime , optional : true },
753
+ {name : "pragueTime" , timestamp : c .PragueTime , optional : true },
641
754
} {
642
755
if lastFork .name != "" {
643
756
switch {
@@ -732,12 +845,15 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, headNumber *big.Int,
732
845
if isForkBlockIncompatible (c .MergeNetsplitBlock , newcfg .MergeNetsplitBlock , headNumber ) {
733
846
return newBlockCompatError ("Merge netsplit fork block" , c .MergeNetsplitBlock , newcfg .MergeNetsplitBlock )
734
847
}
735
- if isForkBlockIncompatible (c .CancunBlock , newcfg .CancunBlock , headNumber ) {
736
- return newBlockCompatError ("Cancun fork block" , c .CancunBlock , newcfg .CancunBlock )
737
- }
738
848
if isForkTimestampIncompatible (c .ShanghaiTime , newcfg .ShanghaiTime , headTimestamp ) {
739
849
return newTimestampCompatError ("Shanghai fork timestamp" , c .ShanghaiTime , newcfg .ShanghaiTime )
740
850
}
851
+ if isForkTimestampIncompatible (c .CancunTime , newcfg .CancunTime , headTimestamp ) {
852
+ return newTimestampCompatError ("Cancun fork timestamp" , c .CancunTime , newcfg .CancunTime )
853
+ }
854
+ if isForkTimestampIncompatible (c .PragueTime , newcfg .PragueTime , headTimestamp ) {
855
+ return newTimestampCompatError ("Prague fork timestamp" , c .PragueTime , newcfg .PragueTime )
856
+ }
741
857
return nil
742
858
}
743
859
@@ -882,7 +998,7 @@ type Rules struct {
882
998
IsHomestead , IsEIP150 , IsEIP155 , IsEIP158 bool
883
999
IsByzantium , IsConstantinople , IsPetersburg , IsIstanbul bool
884
1000
IsBerlin , IsLondon bool
885
- IsMerge , IsShanghai , isCancun bool
1001
+ IsMerge , IsShanghai , isCancun , isPrague bool
886
1002
}
887
1003
888
1004
// Rules ensures c's ChainID is not nil.
@@ -905,6 +1021,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp *big.Int) Rule
905
1021
IsLondon : c .IsLondon (num ),
906
1022
IsMerge : isMerge ,
907
1023
IsShanghai : c .IsShanghai (timestamp ),
908
- isCancun : c .IsCancun (num ),
1024
+ isCancun : c .IsCancun (timestamp ),
1025
+ isPrague : c .IsPrague (timestamp ),
909
1026
}
910
1027
}
0 commit comments