all: tie timestamp based forks to the passage of London (#27279)

This commit is contained in:
Péter Szilágyi
2023-05-19 11:27:19 +03:00
committed by GitHub
parent 6a6318b1d2
commit 85a4b82b33
14 changed files with 31 additions and 29 deletions
+9 -9
View File
@@ -492,18 +492,18 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi
}
// IsShanghai returns whether time is either equal to the Shanghai fork time or greater.
func (c *ChainConfig) IsShanghai(time uint64) bool {
return isTimestampForked(c.ShanghaiTime, time)
func (c *ChainConfig) IsShanghai(num *big.Int, time uint64) bool {
return c.IsLondon(num) && isTimestampForked(c.ShanghaiTime, time)
}
// IsCancun returns whether num is either equal to the Cancun fork time or greater.
func (c *ChainConfig) IsCancun(time uint64) bool {
return isTimestampForked(c.CancunTime, time)
func (c *ChainConfig) IsCancun(num *big.Int, time uint64) bool {
return c.IsLondon(num) && isTimestampForked(c.CancunTime, time)
}
// IsPrague returns whether num is either equal to the Prague fork time or greater.
func (c *ChainConfig) IsPrague(time uint64) bool {
return isTimestampForked(c.PragueTime, time)
func (c *ChainConfig) IsPrague(num *big.Int, time uint64) bool {
return c.IsLondon(num) && isTimestampForked(c.PragueTime, time)
}
// CheckCompatible checks whether scheduled fork transitions have been imported
@@ -829,8 +829,8 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
IsBerlin: c.IsBerlin(num),
IsLondon: c.IsLondon(num),
IsMerge: isMerge,
IsShanghai: c.IsShanghai(timestamp),
IsCancun: c.IsCancun(timestamp),
IsPrague: c.IsPrague(timestamp),
IsShanghai: c.IsShanghai(num, timestamp),
IsCancun: c.IsCancun(num, timestamp),
IsPrague: c.IsPrague(num, timestamp),
}
}
+1
View File
@@ -121,6 +121,7 @@ func TestCheckCompatible(t *testing.T) {
func TestConfigRules(t *testing.T) {
c := &ChainConfig{
LondonBlock: new(big.Int),
ShanghaiTime: newUint64(500),
}
var stamp uint64