diff --git a/params/config.go b/params/config.go index d68d6d6a40..122e4d870e 100644 --- a/params/config.go +++ b/params/config.go @@ -66,6 +66,7 @@ var ( DonutBlock: big.NewInt(6774000), EspressoBlock: big.NewInt(11838440), GingerbreadBlock: nil, + GingerbreadP2Block: nil, Istanbul: &IstanbulConfig{ Epoch: 17280, ProposerPolicy: 2, @@ -92,6 +93,7 @@ var ( DonutBlock: big.NewInt(5002000), EspressoBlock: big.NewInt(9195000), GingerbreadBlock: nil, + GingerbreadP2Block: nil, Istanbul: &IstanbulConfig{ Epoch: 17280, ProposerPolicy: 2, @@ -118,6 +120,7 @@ var ( DonutBlock: big.NewInt(4960000), EspressoBlock: big.NewInt(9472000), GingerbreadBlock: nil, + GingerbreadP2Block: nil, Istanbul: &IstanbulConfig{ Epoch: 17280, ProposerPolicy: 2, @@ -145,10 +148,11 @@ var ( PetersburgBlock: big.NewInt(0), IstanbulBlock: big.NewInt(0), - ChurritoBlock: big.NewInt(0), - DonutBlock: big.NewInt(0), - EspressoBlock: big.NewInt(0), - GingerbreadBlock: big.NewInt(0), + ChurritoBlock: big.NewInt(0), + DonutBlock: big.NewInt(0), + EspressoBlock: big.NewInt(0), + GingerbreadBlock: big.NewInt(0), + GingerbreadP2Block: big.NewInt(0), Istanbul: &IstanbulConfig{ Epoch: 30000, @@ -251,10 +255,11 @@ type ChainConfig struct { // MuirGlacierBlock *big.Int `json:"muirGlacierBlock,omitempty"` // Eip-2384 (bomb delay) switch block (nil = no fork, 0 = already activated) // BerlinBlock *big.Int `json:"berlinBlock,omitempty"` // Berlin switch block (nil = no fork, 0 = already on berlin) // LondonBlock *big.Int `json:"londonBlock,omitempty"` // London switch block (nil = no fork, 0 = already on london) - ChurritoBlock *big.Int `json:"churritoBlock,omitempty"` // Churrito switch block (nil = no fork, 0 = already activated) - DonutBlock *big.Int `json:"donutBlock,omitempty"` // Donut switch block (nil = no fork, 0 = already activated) - EspressoBlock *big.Int `json:"espressoBlock,omitempty"` // Espresso switch block (nil = no fork, 0 = already activated) - GingerbreadBlock *big.Int `json:"gingerbreadBlock,omitempty"` // Gingerbread switch block (nil = no fork, 0 = already activated) + ChurritoBlock *big.Int `json:"churritoBlock,omitempty"` // Churrito switch block (nil = no fork, 0 = already activated) + DonutBlock *big.Int `json:"donutBlock,omitempty"` // Donut switch block (nil = no fork, 0 = already activated) + EspressoBlock *big.Int `json:"espressoBlock,omitempty"` // Espresso switch block (nil = no fork, 0 = already activated) + GingerbreadBlock *big.Int `json:"gingerbreadBlock,omitempty"` // Gingerbread switch block (nil = no fork, 0 = already activated) + GingerbreadP2Block *big.Int `json:"gingerbreadP2Block,omitempty"` // GingerbreadP2 switch block (nil = no fork, 0 = already activated) Istanbul *IstanbulConfig `json:"istanbul,omitempty"` // This does not belong here but passing it to every function is not possible since that breaks @@ -297,7 +302,7 @@ func (c *ChainConfig) String() string { } else { engine = "MockEngine" } - 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 Churrito: %v, Donut: %v, Espresso: %v, Gingerbread: %v, Engine: %v}", + 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 Churrito: %v, Donut: %v, Espresso: %v, Gingerbread: %v, Gingerbread P2: %v, Engine: %v}", c.ChainID, c.HomesteadBlock, c.DAOForkBlock, @@ -316,6 +321,7 @@ func (c *ChainConfig) String() string { c.DonutBlock, c.EspressoBlock, c.GingerbreadBlock, + c.GingerbreadP2Block, engine, ) } @@ -399,6 +405,11 @@ func (c *ChainConfig) IsGingerbread(num *big.Int) bool { return isForked(c.GingerbreadBlock, num) } +// IsGingerbreadP2 returns whether num represents a block number after the GingerbreadP2 fork +func (c *ChainConfig) IsGingerbreadP2(num *big.Int) bool { + return isForked(c.GingerbreadP2Block, num) +} + // CheckCompatible checks whether scheduled fork transitions have been imported // with a mismatching chain configuration. func (c *ChainConfig) CheckCompatible(newcfg *ChainConfig, height uint64) *ConfigCompatError { @@ -439,6 +450,7 @@ func (c *ChainConfig) CheckConfigForkOrder() error { {name: "donutBlock", block: c.DonutBlock}, {name: "espressoBlock", block: c.EspressoBlock}, {name: "gingerbreadBlock", block: c.GingerbreadBlock}, + {name: "gingerbreadP2Block", block: c.GingerbreadP2Block}, } { if lastFork.name != "" { // Next one must be higher number @@ -516,6 +528,9 @@ func (c *ChainConfig) checkCeloCompatible(newcfg *ChainConfig, head *big.Int) *C if isForkIncompatible(c.GingerbreadBlock, newcfg.GingerbreadBlock, head) { return newCompatError("Gingerbread fork block", c.GingerbreadBlock, newcfg.GingerbreadBlock) } + if isForkIncompatible(c.GingerbreadP2Block, newcfg.GingerbreadP2Block, head) { + return newCompatError("Gingerbread p2 fork block", c.GingerbreadP2Block, newcfg.GingerbreadP2Block) + } return nil } @@ -584,7 +599,8 @@ type Rules struct { IsHomestead, IsEIP150, IsEIP155, IsEIP158 bool IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool IsBerlin, IsLondon bool - IsChurrito, IsDonut, IsEspresso, IsGingerbread bool + IsChurrito, IsDonut, IsEspresso bool + IsGingerbread, IsGingerbreadP2 bool } // Rules ensures c's ChainID is not nil. @@ -609,6 +625,7 @@ func (c *ChainConfig) Rules(num *big.Int) Rules { IsDonut: c.IsDonut(num), IsEspresso: c.IsEspresso(num), IsGingerbread: c.IsGingerbread(num), + IsGingerbreadP2: c.IsGingerbreadP2(num), } } @@ -650,6 +667,7 @@ func (c *ChainConfig) DeepCopy() *ChainConfig { DonutBlock: copyBigIntOrNil(c.DonutBlock), EspressoBlock: copyBigIntOrNil(c.EspressoBlock), GingerbreadBlock: copyBigIntOrNil(c.GingerbreadBlock), + GingerbreadP2Block: copyBigIntOrNil(c.GingerbreadP2Block), Istanbul: &IstanbulConfig{ Epoch: c.Istanbul.Epoch,