Add Prague fork support (#913)

Prague is the next EL fork after
[Cancun](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/cancun.md)
This commit is contained in:
Andrew Ashikhmin 2023-03-02 17:12:35 +01:00 committed by GitHub
parent 5edc0612ce
commit 37a1bdc806
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,6 +65,7 @@ type Config struct {
ShanghaiTime *big.Int `json:"shanghaiTime,omitempty"` // Shanghai switch time (nil = no fork, 0 = already activated)
CancunTime *big.Int `json:"cancunTime,omitempty"` // Cancun switch time (nil = no fork, 0 = already activated)
ShardingForkTime *big.Int `json:"shardingForkTime,omitempty"` // Mini-Danksharding switch block (nil = no fork, 0 = already activated)
PragueTime *big.Int `json:"pragueTime,omitempty"` // Prague switch time (nil = no fork, 0 = already activated)
// Parlia fork blocks
RamanujanBlock *big.Int `json:"ramanujanBlock,omitempty" toml:",omitempty"` // ramanujanBlock switch block (nil = no fork, 0 = already activated)
@ -109,7 +110,7 @@ func (c *Config) String() string {
)
}
return fmt.Sprintf("{ChainID: %v, Homestead: %v, DAO: %v, DAO Support: %v, Tangerine Whistle: %v, Spurious Dragon: %v, Byzantium: %v, Constantinople: %v, Petersburg: %v, Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, Gray Glacier: %v, Terminal Total Difficulty: %v, Merge Netsplit: %v, Shanghai: %v, Cancun: %v, Engine: %v}",
return fmt.Sprintf("{ChainID: %v, Homestead: %v, DAO: %v, DAO Support: %v, Tangerine Whistle: %v, Spurious Dragon: %v, Byzantium: %v, Constantinople: %v, Petersburg: %v, Istanbul: %v, Muir Glacier: %v, Berlin: %v, London: %v, Arrow Glacier: %v, Gray Glacier: %v, Terminal Total Difficulty: %v, Merge Netsplit: %v, Shanghai: %v, Cancun: %v, Sharding: %v, Prague: %v, Engine: %v}",
c.ChainID,
c.HomesteadBlock,
c.DAOForkBlock,
@ -129,6 +130,8 @@ func (c *Config) String() string {
c.MergeNetsplitBlock,
c.ShanghaiTime,
c.CancunTime,
c.ShardingForkTime,
c.PragueTime,
engine,
)
}
@ -307,6 +310,11 @@ func (c *Config) IsCancun(time uint64) bool {
return isForked(c.CancunTime, time)
}
// IsPrague returns whether time is either equal to the Prague fork time or greater.
func (c *Config) IsPrague(time uint64) bool {
return isForked(c.PragueTime, time)
}
func (c *Config) IsEip1559FeeCollector(num uint64) bool {
return c.Eip1559FeeCollector != nil && isForked(c.Eip1559FeeCollectorTransition, num)
}
@ -660,7 +668,7 @@ type Rules struct {
IsHomestead, IsTangerineWhistle, IsSpuriousDragon bool
IsByzantium, IsConstantinople, IsPetersburg, IsIstanbul bool
IsBerlin, IsLondon, IsShanghai, IsCancun bool
IsSharding bool
IsSharding, IsPrague bool
IsNano, IsMoran, IsGibbs bool
IsEip1559FeeCollector bool
IsParlia, IsAura bool
@ -686,6 +694,8 @@ func (c *Config) Rules(num uint64, time uint64) *Rules {
IsLondon: c.IsLondon(num),
IsShanghai: c.IsShanghai(time),
IsCancun: c.IsCancun(time),
IsSharding: c.IsSharding(time),
IsPrague: c.IsPrague(time),
IsNano: c.IsNano(num),
IsMoran: c.IsMoran(num),
IsEip1559FeeCollector: c.IsEip1559FeeCollector(num),