@@ -131,6 +131,7 @@ var (
131131 PetersburgBlock : big .NewInt (0 ),
132132 IstanbulBlock : big .NewInt (3_230_000 ),
133133 NeoBlock : big .NewInt (4_650_000 ),
134+ MercuryBlock : MERCURY_MAINNET ,
134135 TerminalTotalDifficulty : nil ,
135136 TerminalTotalDifficultyPassed : false ,
136137 Cuckoo : new (CuckooConfig ),
@@ -151,6 +152,7 @@ var (
151152 PetersburgBlock : big .NewInt (0 ),
152153 IstanbulBlock : big .NewInt (0 ),
153154 NeoBlock : big .NewInt (5_000_000 ),
155+ MercuryBlock : nil ,
154156 TerminalTotalDifficulty : nil ,
155157 TerminalTotalDifficultyPassed : false ,
156158 Clique : & CliqueConfig {
@@ -174,6 +176,7 @@ var (
174176 PetersburgBlock : big .NewInt (0 ),
175177 IstanbulBlock : big .NewInt (0 ),
176178 NeoBlock : big .NewInt (0 ),
179+ MercuryBlock : nil ,
177180 TerminalTotalDifficulty : nil ,
178181 TerminalTotalDifficultyPassed : false ,
179182 Cuckoo : new (CuckooConfig ),
@@ -194,6 +197,7 @@ var (
194197 PetersburgBlock : big .NewInt (0 ),
195198 IstanbulBlock : big .NewInt (0 ),
196199 NeoBlock : big .NewInt (0 ),
200+ MercuryBlock : nil ,
197201 TerminalTotalDifficulty : nil ,
198202 TerminalTotalDifficultyPassed : false ,
199203 Clique : & CliqueConfig {
@@ -221,6 +225,7 @@ var (
221225 PetersburgBlock : big .NewInt (0 ),
222226 IstanbulBlock : nil ,
223227 NeoBlock : nil ,
228+ MercuryBlock : nil ,
224229 TerminalTotalDifficulty : nil ,
225230 TerminalTotalDifficultyPassed : false ,
226231 Cuckoo : new (CuckooConfig ),
@@ -231,9 +236,9 @@ var (
231236 //
232237 // This configuration is intentionally not using keyed fields to force anyone
233238 // adding flags to the config to also have to set these fields.
234- 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 , nil , nil , false , nil , & CliqueConfig {Period : 0 , Epoch : 30000 }}
239+ 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 , nil , nil , nil , false , nil , & CliqueConfig {Period : 0 , Epoch : 30000 }}
235240
236- 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 , nil , nil , nil , false , new (CuckooConfig ), nil }
241+ 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 , nil , nil , nil , nil , false , new (CuckooConfig ), nil }
237242 TestRules = TestChainConfig .Rules (new (big.Int ), false , 0 )
238243)
239244
@@ -269,6 +274,7 @@ type ChainConfig struct {
269274 PetersburgBlock * big.Int `json:"petersburgBlock,omitempty"` // Petersburg switch block (nil = same as Constantinople)
270275 IstanbulBlock * big.Int `json:"istanbulBlock,omitempty"` // Istanbul switch block (nil = no fork, 0 = already on istanbul)
271276 NeoBlock * big.Int `json:"neoBlock,omitempty"`
277+ MercuryBlock * big.Int `json:"mercuryBlock,omitempty"`
272278 // TerminalTotalDifficulty is the amount of total difficulty reached by
273279 // the network that triggers the consensus upgrade.
274280 TerminalTotalDifficulty * big.Int `json:"terminalTotalDifficulty,omitempty"`
@@ -311,7 +317,7 @@ func (c *ChainConfig) String() string {
311317 default :
312318 engine = "unknown"
313319 }
314- return fmt .Sprintf ("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v TangerineWhistle(EIP150): %v SpuriousDragon(EIP155): %v SpuriousDragon(EIP158): %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v Neo:%v Engine: %v}" ,
320+ return fmt .Sprintf ("{ChainID: %v Homestead: %v DAO: %v DAOSupport: %v TangerineWhistle(EIP150): %v SpuriousDragon(EIP155): %v SpuriousDragon(EIP158): %v Byzantium: %v Constantinople: %v Petersburg: %v Istanbul: %v Neo:%v Mercury:%v Engine: %v}" ,
315321 c .ChainID ,
316322 c .HomesteadBlock ,
317323 c .DAOForkBlock ,
@@ -324,6 +330,7 @@ func (c *ChainConfig) String() string {
324330 c .PetersburgBlock ,
325331 c .IstanbulBlock ,
326332 c .NeoBlock ,
333+ c .MercuryBlock ,
327334 engine ,
328335 )
329336}
@@ -378,6 +385,10 @@ func (c *ChainConfig) IsNeo(num *big.Int) bool {
378385 return isForked (c .NeoBlock , num )
379386}
380387
388+ func (c * ChainConfig ) IsMercury (num * big.Int ) bool {
389+ return isForked (c .MercuryBlock , num )
390+ }
391+
381392// IsTerminalPoWBlock returns whether the given block is the last block of PoW stage.
382393func (c * ChainConfig ) IsTerminalPoWBlock (parentTotalDiff * big.Int , totalDiff * big.Int ) bool {
383394 if c .TerminalTotalDifficulty == nil {
@@ -442,6 +453,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error {
442453 {name : "petersburgBlock" , block : c .PetersburgBlock },
443454 {name : "istanbulBlock" , block : c .IstanbulBlock },
444455 {name : "neoBlock" , block : c .NeoBlock },
456+ {name : "mercuryBlock" , block : c .MercuryBlock },
445457 } {
446458 if lastFork .name != "" {
447459 // Next one must be higher number
@@ -505,6 +517,10 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
505517 if isForkIncompatible (c .NeoBlock , newcfg .NeoBlock , head ) {
506518 return newCompatError ("Neo fork block" , c .NeoBlock , newcfg .NeoBlock )
507519 }
520+
521+ if isForkIncompatible (c .MercuryBlock , newcfg .MercuryBlock , head ) {
522+ return newCompatError ("Mercury fork block" , c .MercuryBlock , newcfg .MercuryBlock )
523+ }
508524 return nil
509525}
510526
@@ -622,10 +638,10 @@ func (err *ConfigCompatError) Error() string {
622638// Rules is a one time interface meaning that it shouldn't be used in between transition
623639// phases.
624640type Rules struct {
625- ChainID * big.Int
626- IsHomestead , IsEIP150 , IsEIP155 , IsEIP158 bool
627- IsByzantium , IsConstantinople , IsPetersburg , IsIstanbul , IsNeo bool
628- IsMerge bool
641+ ChainID * big.Int
642+ IsHomestead , IsEIP150 , IsEIP155 , IsEIP158 bool
643+ IsByzantium , IsConstantinople , IsPetersburg , IsIstanbul , IsNeo , IsMercury bool
644+ IsMerge bool
629645}
630646
631647// Rules ensures c's ChainID is not nil.
@@ -634,7 +650,7 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
634650 if chainID == nil {
635651 chainID = new (big.Int )
636652 }
637- return Rules {ChainID : new (big.Int ).Set (chainID ), IsHomestead : c .IsHomestead (num ), IsEIP150 : c .IsEIP150 (num ), IsEIP155 : c .IsEIP155 (num ), IsEIP158 : c .IsEIP158 (num ), IsByzantium : c .IsByzantium (num ), IsPetersburg : c .IsPetersburg (num ), IsIstanbul : c .IsIstanbul (num ), IsNeo : c .IsNeo (num ), IsMerge : isMerge }
653+ return Rules {ChainID : new (big.Int ).Set (chainID ), IsHomestead : c .IsHomestead (num ), IsEIP150 : c .IsEIP150 (num ), IsEIP155 : c .IsEIP155 (num ), IsEIP158 : c .IsEIP158 (num ), IsByzantium : c .IsByzantium (num ), IsPetersburg : c .IsPetersburg (num ), IsIstanbul : c .IsIstanbul (num ), IsNeo : c .IsNeo (num ), IsMercury : c . IsMercury ( num ), IsMerge : isMerge }
638654}
639655
640656// Get Mature Block
0 commit comments