@@ -271,17 +271,20 @@ var (
271
271
//
272
272
// This configuration is intentionally not using keyed fields to force anyone
273
273
// adding flags to the config to also have to set these fields.
274
- 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 , nil }
274
+ 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 , big . NewInt ( 0 ), nil , false , new (EthashConfig ), nil , nil }
275
275
276
276
// AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
277
277
// and accepted by the Ethereum core developers into the Clique consensus.
278
278
//
279
279
// This configuration is intentionally not using keyed fields to force anyone
280
280
// adding flags to the config to also have to set these fields.
281
- 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 }, nil }
281
+ 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 , big . NewInt ( 0 ), nil , false , nil , & CliqueConfig {Period : 0 , Epoch : 30000 }, nil }
282
282
283
- 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 , nil }
284
- 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 , nil }
283
+ // This is a optimism config with bedrock starting a block 5
284
+ AllOptimismProtocolChanges = & 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 , big .NewInt (5 ), nil , false , nil , nil , & OptimismConfig {EIP1559Elasticity : 50 , EIP1559Denominator : 10 }}
285
+
286
+ 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 , big .NewInt (0 ), nil , false , new (EthashConfig ), nil , nil }
287
+ 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 , big .NewInt (0 ), nil , false , new (EthashConfig ), nil , nil }
285
288
TestRules = TestChainConfig .Rules (new (big.Int ), false )
286
289
)
287
290
@@ -374,6 +377,7 @@ type ChainConfig struct {
374
377
MergeNetsplitBlock * big.Int `json:"mergeNetsplitBlock,omitempty"` // Virtual fork after The Merge to use as a network splitter
375
378
ShanghaiBlock * big.Int `json:"shanghaiBlock,omitempty"` // Shanghai switch block (nil = no fork, 0 = already on shanghai)
376
379
CancunBlock * big.Int `json:"cancunBlock,omitempty"` // Cancun switch block (nil = no fork, 0 = already on cancun)
380
+ BedrockBlock * big.Int `json:"bedrockBlock,omitempty"` // Bedrock switch block (nil = no fork, 0 = already on optimism bedrock)
377
381
378
382
// TerminalTotalDifficulty is the amount of total difficulty reached by
379
383
// the network that triggers the consensus upgrade.
@@ -594,6 +598,26 @@ func (c *ChainConfig) IsCancun(num *big.Int) bool {
594
598
return isForked (c .CancunBlock , num )
595
599
}
596
600
601
+ // IsBedrock returns whether num is either equal to the Bedrock fork block or greater.
602
+ func (c * ChainConfig ) IsBedrock (num * big.Int ) bool {
603
+ return isForked (c .BedrockBlock , num )
604
+ }
605
+
606
+ // IsOptimism returns whether the node is an optimism node or not.
607
+ func (c * ChainConfig ) IsOptimism () bool {
608
+ return c .Optimism != nil
609
+ }
610
+
611
+ // IsOptimismBedrock returns true iff this is an optimism node & bedrock is active
612
+ func (c * ChainConfig ) IsOptimismBedrock (num * big.Int ) bool {
613
+ return c .IsOptimism () && c .IsBedrock (num )
614
+ }
615
+
616
+ // IsOptimismPreBedrock returns true iff this is an optimism node & bedrock is not yet active
617
+ func (c * ChainConfig ) IsOptimismPreBedrock (num * big.Int ) bool {
618
+ return c .IsOptimism () && ! c .IsBedrock (num )
619
+ }
620
+
597
621
// CheckCompatible checks whether scheduled fork transitions have been imported
598
622
// with a mismatching chain configuration.
599
623
func (c * ChainConfig ) CheckCompatible (newcfg * ChainConfig , height uint64 ) * ConfigCompatError {
@@ -808,6 +832,7 @@ type Rules struct {
808
832
IsByzantium , IsConstantinople , IsPetersburg , IsIstanbul bool
809
833
IsBerlin , IsLondon bool
810
834
IsMerge , IsShanghai , isCancun bool
835
+ IsOptimismBedrock bool
811
836
}
812
837
813
838
// Rules ensures c's ChainID is not nil.
@@ -817,19 +842,20 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool) Rules {
817
842
chainID = new (big.Int )
818
843
}
819
844
return Rules {
820
- ChainID : new (big.Int ).Set (chainID ),
821
- IsHomestead : c .IsHomestead (num ),
822
- IsEIP150 : c .IsEIP150 (num ),
823
- IsEIP155 : c .IsEIP155 (num ),
824
- IsEIP158 : c .IsEIP158 (num ),
825
- IsByzantium : c .IsByzantium (num ),
826
- IsConstantinople : c .IsConstantinople (num ),
827
- IsPetersburg : c .IsPetersburg (num ),
828
- IsIstanbul : c .IsIstanbul (num ),
829
- IsBerlin : c .IsBerlin (num ),
830
- IsLondon : c .IsLondon (num ),
831
- IsMerge : isMerge ,
832
- IsShanghai : c .IsShanghai (num ),
833
- isCancun : c .IsCancun (num ),
845
+ ChainID : new (big.Int ).Set (chainID ),
846
+ IsHomestead : c .IsHomestead (num ),
847
+ IsEIP150 : c .IsEIP150 (num ),
848
+ IsEIP155 : c .IsEIP155 (num ),
849
+ IsEIP158 : c .IsEIP158 (num ),
850
+ IsByzantium : c .IsByzantium (num ),
851
+ IsConstantinople : c .IsConstantinople (num ),
852
+ IsPetersburg : c .IsPetersburg (num ),
853
+ IsIstanbul : c .IsIstanbul (num ),
854
+ IsBerlin : c .IsBerlin (num ),
855
+ IsLondon : c .IsLondon (num ),
856
+ IsMerge : isMerge ,
857
+ IsShanghai : c .IsShanghai (num ),
858
+ isCancun : c .IsCancun (num ),
859
+ IsOptimismBedrock : c .IsOptimismBedrock (num ),
834
860
}
835
861
}
0 commit comments