@@ -281,7 +281,7 @@ var (
281
281
ShanghaiBlock : big .NewInt (0 ),
282
282
BernoulliBlock : big .NewInt (0 ),
283
283
CurieBlock : big .NewInt (6330180 ),
284
- DarwinTime : nil ,
284
+ Morph203Time : nil ,
285
285
TerminalTotalDifficulty : big .NewInt (0 ),
286
286
Morph : MorphConfig {
287
287
UseZktrie : true ,
@@ -311,7 +311,7 @@ var (
311
311
ShanghaiBlock : big .NewInt (0 ),
312
312
BernoulliBlock : big .NewInt (0 ),
313
313
CurieBlock : big .NewInt (0 ),
314
- DarwinTime : nil ,
314
+ Morph203Time : nil ,
315
315
TerminalTotalDifficulty : big .NewInt (0 ),
316
316
Morph : MorphConfig {
317
317
UseZktrie : true ,
@@ -347,7 +347,7 @@ var (
347
347
ShanghaiBlock : big .NewInt (0 ),
348
348
BernoulliBlock : big .NewInt (0 ),
349
349
CurieBlock : big .NewInt (0 ),
350
- DarwinTime : new (uint64 ),
350
+ Morph203Time : new (uint64 ),
351
351
TerminalTotalDifficulty : nil ,
352
352
Ethash : new (EthashConfig ),
353
353
Clique : nil ,
@@ -383,7 +383,7 @@ var (
383
383
ShanghaiBlock : big .NewInt (0 ),
384
384
BernoulliBlock : big .NewInt (0 ),
385
385
CurieBlock : big .NewInt (0 ),
386
- DarwinTime : new (uint64 ),
386
+ Morph203Time : new (uint64 ),
387
387
TerminalTotalDifficulty : nil ,
388
388
Ethash : nil ,
389
389
Clique : & CliqueConfig {Period : 0 , Epoch : 30000 },
@@ -414,7 +414,7 @@ var (
414
414
ShanghaiBlock : big .NewInt (0 ),
415
415
BernoulliBlock : big .NewInt (0 ),
416
416
CurieBlock : big .NewInt (0 ),
417
- DarwinTime : new (uint64 ),
417
+ Morph203Time : new (uint64 ),
418
418
TerminalTotalDifficulty : nil ,
419
419
Ethash : new (EthashConfig ),
420
420
Clique : nil ,
@@ -446,7 +446,7 @@ var (
446
446
ShanghaiBlock : big .NewInt (0 ),
447
447
BernoulliBlock : big .NewInt (0 ),
448
448
CurieBlock : big .NewInt (0 ),
449
- DarwinTime : new (uint64 ),
449
+ Morph203Time : new (uint64 ),
450
450
TerminalTotalDifficulty : nil ,
451
451
Ethash : new (EthashConfig ),
452
452
Clique : nil ,
@@ -537,7 +537,7 @@ type ChainConfig struct {
537
537
ShanghaiBlock * big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch block (nil = no fork, 0 = already on shanghai)
538
538
BernoulliBlock * big.Int `json:"bernoulliBlock,omitempty"` // Bernoulli switch block (nil = no fork, 0 = already on bernoulli)
539
539
CurieBlock * big.Int `json:"curieBlock,omitempty"` // Curie switch block (nil = no fork, 0 = already on curie)
540
- DarwinTime * uint64 `json:"darwinTime ,omitempty"` // Darwin switch time (nil = no fork, 0 = already on darwin )
540
+ Morph203Time * uint64 `json:"morph203Time ,omitempty"` // Morph203Time switch time (nil = no fork, 0 = already on morph203 )
541
541
542
542
// TerminalTotalDifficulty is the amount of total difficulty reached by
543
543
// the network that triggers the consensus upgrade.
@@ -630,7 +630,7 @@ func (c *ChainConfig) String() string {
630
630
default :
631
631
engine = "unknown"
632
632
}
633
- return fmt .Sprintf ("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, Archimedes: %v, Shanghai: %v, Bernoulli: %v, Curie: %v, Darwin : %v, Engine: %v, Morph config: %v}" ,
633
+ return fmt .Sprintf ("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v EIP150: %v EIP155: %v EIP158: %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, Archimedes: %v, Shanghai: %v, Bernoulli: %v, Curie: %v, Morph203 : %v, Engine: %v, Morph config: %v}" ,
634
634
c .ChainID ,
635
635
c .HomesteadBlock ,
636
636
c .DAOForkBlock ,
@@ -650,7 +650,7 @@ func (c *ChainConfig) String() string {
650
650
c .ShanghaiBlock ,
651
651
c .BernoulliBlock ,
652
652
c .CurieBlock ,
653
- c .DarwinTime ,
653
+ c .Morph203Time ,
654
654
engine ,
655
655
c .Morph ,
656
656
)
@@ -743,9 +743,9 @@ func (c *ChainConfig) IsCurie(num *big.Int) bool {
743
743
return isForked (c .CurieBlock , num )
744
744
}
745
745
746
- // IsDarwin returns whether num is either equal to the Darwin fork block or greater.
747
- func (c * ChainConfig ) IsDarwin (now uint64 ) bool {
748
- return isForkedTime (now , c .DarwinTime )
746
+ // IsMorph203 returns whether num is either equal to the Morph203 fork block or greater.
747
+ func (c * ChainConfig ) IsMorph203 (now uint64 ) bool {
748
+ return isForkedTime (now , c .Morph203Time )
749
749
}
750
750
751
751
// IsTerminalPoWBlock returns whether the given block is the last block of PoW stage.
@@ -778,9 +778,10 @@ func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *Confi
778
778
// to guarantee that forks can be implemented in a different order than on official networks
779
779
func (c * ChainConfig ) CheckConfigForkOrder () error {
780
780
type fork struct {
781
- name string
782
- block * big.Int
783
- optional bool // if true, the fork may be nil and next fork is still allowed
781
+ name string
782
+ block * big.Int
783
+ timestamp * uint64 // forks after the merge are scheduled using timestamps
784
+ optional bool // if true, the fork may be nil and next fork is still allowed
784
785
}
785
786
var lastFork fork
786
787
for _ , cur := range []fork {
@@ -801,22 +802,39 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
801
802
{name : "shanghaiBlock" , block : c .ShanghaiBlock , optional : true },
802
803
{name : "bernoulliBlock" , block : c .BernoulliBlock , optional : true },
803
804
{name : "curieBlock" , block : c .CurieBlock , optional : true },
805
+ {name : "morph203Time" , timestamp : c .Morph203Time , optional : true },
804
806
} {
805
807
if lastFork .name != "" {
806
- // Next one must be higher number
807
- if lastFork .block == nil && cur .block != nil {
808
- return fmt .Errorf ("unsupported fork ordering: %v not enabled, but %v enabled at %v" ,
809
- lastFork .name , cur .name , cur .block )
810
- }
811
- if lastFork .block != nil && cur .block != nil {
812
- if lastFork .block .Cmp (cur .block ) > 0 {
813
- return fmt .Errorf ("unsupported fork ordering: %v enabled at %v, but %v enabled at %v" ,
808
+ switch {
809
+ // Non-optional forks must all be present in the chain config up to the last defined fork
810
+ case lastFork .block == nil && lastFork .timestamp == nil && (cur .block != nil || cur .timestamp != nil ):
811
+ if cur .block != nil {
812
+ return fmt .Errorf ("unsupported fork ordering: %v not enabled, but %v enabled at block %v" ,
813
+ lastFork .name , cur .name , cur .block )
814
+ } else {
815
+ return fmt .Errorf ("unsupported fork ordering: %v not enabled, but %v enabled at timestamp %v" ,
816
+ lastFork .name , cur .name , * cur .timestamp )
817
+ }
818
+
819
+ // Fork (whether defined by block or timestamp) must follow the fork definition sequence
820
+ case (lastFork .block != nil && cur .block != nil ) || (lastFork .timestamp != nil && cur .timestamp != nil ):
821
+ if lastFork .block != nil && lastFork .block .Cmp (cur .block ) > 0 {
822
+ return fmt .Errorf ("unsupported fork ordering: %v enabled at block %v, but %v enabled at block %v" ,
814
823
lastFork .name , lastFork .block , cur .name , cur .block )
824
+ } else if lastFork .timestamp != nil && * lastFork .timestamp > * cur .timestamp {
825
+ return fmt .Errorf ("unsupported fork ordering: %v enabled at timestamp %v, but %v enabled at timestamp %v" ,
826
+ lastFork .name , * lastFork .timestamp , cur .name , * cur .timestamp )
827
+ }
828
+
829
+ // Timestamp based forks can follow block based ones, but not the other way around
830
+ if lastFork .timestamp != nil && cur .block != nil {
831
+ return fmt .Errorf ("unsupported fork ordering: %v used timestamp ordering, but %v reverted to block ordering" ,
832
+ lastFork .name , cur .name )
815
833
}
816
834
}
817
835
}
818
836
// If it was optional and not set, then ignore it
819
- if ! cur .optional || cur .block != nil {
837
+ if ! cur .optional || ( cur .block != nil || cur . timestamp != nil ) {
820
838
lastFork = cur
821
839
}
822
840
}
@@ -960,7 +978,7 @@ type Rules struct {
960
978
IsHomestead , IsEIP150 , IsEIP155 , IsEIP158 bool
961
979
IsByzantium , IsConstantinople , IsPetersburg , IsIstanbul bool
962
980
IsBerlin , IsLondon , IsArchimedes , IsShanghai bool
963
- IsBernoulli , IsCurie , IsDarwin bool
981
+ IsBernoulli , IsCurie , IsMorph203 bool
964
982
}
965
983
966
984
// Rules ensures c's ChainID is not nil.
@@ -985,6 +1003,6 @@ func (c *ChainConfig) Rules(num *big.Int, time uint64) Rules {
985
1003
IsShanghai : c .IsShanghai (num ),
986
1004
IsBernoulli : c .IsBernoulli (num ),
987
1005
IsCurie : c .IsCurie (num ),
988
- IsDarwin : c . IsDarwin (time ),
1006
+ IsMorph203 : c . IsMorph203 (time ),
989
1007
}
990
1008
}
0 commit comments