4242 EIP155Block : big .NewInt (2675000 ),
4343 EIP158Block : big .NewInt (2675000 ),
4444 ByzantiumBlock : big .NewInt (4370000 ),
45- ConstantinopleBlock : nil ,
45+ ConstantinopleBlock : big .NewInt (7280000 ),
46+ PetersburgBlock : big .NewInt (7280000 ),
4647 Ethash : new (EthashConfig ),
4748 }
4849
6768 EIP158Block : big .NewInt (10 ),
6869 ByzantiumBlock : big .NewInt (1700000 ),
6970 ConstantinopleBlock : big .NewInt (4230000 ),
71+ PetersburgBlock : big .NewInt (4939394 ),
7072 Ethash : new (EthashConfig ),
7173 }
7274
9193 EIP158Block : big .NewInt (3 ),
9294 ByzantiumBlock : big .NewInt (1035301 ),
9395 ConstantinopleBlock : big .NewInt (3660663 ),
96+ PetersburgBlock : big .NewInt (9999999 ), //TODO! Insert Rinkeby block number
9497 Clique : & CliqueConfig {
9598 Period : 15 ,
9699 Epoch : 30000 ,
@@ -111,16 +114,16 @@ var (
111114 //
112115 // This configuration is intentionally not using keyed fields to force anyone
113116 // 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 }
115118
116119 // AllCliqueProtocolChanges contains every protocol change (EIPs) introduced
117120 // and accepted by the Ethereum core developers into the Clique consensus.
118121 //
119122 // This configuration is intentionally not using keyed fields to force anyone
120123 // 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 }}
122125
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 }
124127 TestRules = TestChainConfig .Rules (new (big.Int ))
125128)
126129
@@ -158,6 +161,7 @@ type ChainConfig struct {
158161
159162 ByzantiumBlock * big.Int `json:"byzantiumBlock,omitempty"` // Byzantium switch block (nil = no fork, 0 = already on byzantium)
160163 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)
161165 EWASMBlock * big.Int `json:"ewasmBlock,omitempty"` // EWASM switch block (nil = no fork, 0 = already activated)
162166
163167 // Various consensus engines
@@ -195,7 +199,7 @@ func (c *ChainConfig) String() string {
195199 default :
196200 engine = "unknown"
197201 }
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}" ,
199203 c .ChainID ,
200204 c .HomesteadBlock ,
201205 c .DAOForkBlock ,
@@ -205,6 +209,7 @@ func (c *ChainConfig) String() string {
205209 c .EIP158Block ,
206210 c .ByzantiumBlock ,
207211 c .ConstantinopleBlock ,
212+ c .PetersburgBlock ,
208213 engine ,
209214 )
210215}
@@ -244,6 +249,13 @@ func (c *ChainConfig) IsConstantinople(num *big.Int) bool {
244249 return isForked (c .ConstantinopleBlock , num )
245250}
246251
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+
247259// IsEWASM returns whether num represents a block number after the EWASM fork
248260func (c * ChainConfig ) IsEWASM (num * big.Int ) bool {
249261 return isForked (c .EWASMBlock , num )
@@ -314,6 +326,9 @@ func (c *ChainConfig) checkCompatible(newcfg *ChainConfig, head *big.Int) *Confi
314326 if isForkIncompatible (c .ConstantinopleBlock , newcfg .ConstantinopleBlock , head ) {
315327 return newCompatError ("Constantinople fork block" , c .ConstantinopleBlock , newcfg .ConstantinopleBlock )
316328 }
329+ if isForkIncompatible (c .PetersburgBlock , newcfg .PetersburgBlock , head ) {
330+ return newCompatError ("ConstantinopleFix fork block" , c .PetersburgBlock , newcfg .PetersburgBlock )
331+ }
317332 if isForkIncompatible (c .EWASMBlock , newcfg .EWASMBlock , head ) {
318333 return newCompatError ("ewasm fork block" , c .EWASMBlock , newcfg .EWASMBlock )
319334 }
@@ -381,9 +396,9 @@ func (err *ConfigCompatError) Error() string {
381396// Rules is a one time interface meaning that it shouldn't be used in between transition
382397// phases.
383398type 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
387402}
388403
389404// Rules ensures c's ChainID is not nil.
@@ -400,5 +415,6 @@ func (c *ChainConfig) Rules(num *big.Int) Rules {
400415 IsEIP158 : c .IsEIP158 (num ),
401416 IsByzantium : c .IsByzantium (num ),
402417 IsConstantinople : c .IsConstantinople (num ),
418+ IsPetersburg : c .IsPetersburg (num ),
403419 }
404420}
0 commit comments