Add separate EIP160 check

This commit is contained in:
Austin Roberts 2023-10-23 12:34:02 -05:00
parent 63f8d10434
commit a6ee75999b
3 changed files with 26 additions and 3 deletions

View File

@ -46,6 +46,9 @@ func LookupInstructionSet(rules params.Rules) (JumpTable, error) {
return newConstantinopleInstructionSet(), nil
case rules.IsByzantium:
return newByzantiumInstructionSet(), nil
// Begin plugeth injection
case rules.IsEIP160:
// End plugeth injection
case rules.IsEIP158:
return newSpuriousDragonInstructionSet(), nil
case rules.IsEIP150:

View File

@ -852,6 +852,10 @@ type Rules struct {
IsBerlin, IsLondon bool
IsMerge, IsShanghai, IsCancun, IsPrague bool
IsVerkle bool
// begin plugeth injection
IsEIP160 bool
// end plugeth injection
}
// Rules ensures c's ChainID is not nil.
@ -877,5 +881,10 @@ func (c *ChainConfig) Rules(num *big.Int, isMerge bool, timestamp uint64) Rules
IsCancun: c.IsCancun(num, timestamp),
IsPrague: c.IsPrague(num, timestamp),
IsVerkle: c.IsVerkle(num, timestamp),
// Begin plugeth injection
IsEIP160: c.IsEIP160(num),
// End plugeth injection
}
}

View File

@ -13,17 +13,28 @@ func (c *ChainConfig) Is1559(num *big.Int) bool {
log.Warn("Attempting is1559, but default PluginLoader has not been initialized")
return c.IsLondon(num)
}
if active, ok := PluginIs1559(plugins.DefaultPluginLoader, num); ok {
if active, ok := PluginEIPCheck(plugins.DefaultPluginLoader, "Is1559" num); ok {
return active
}
return c.IsLondon(num)
}
func PluginIs1559(pl *plugins.PluginLoader, num *big.Int) (bool, bool) {
fn, ok := plugins.LookupOne[func(*big.Int) bool](pl, "Is1559")
func PluginEIPCheck(pl *plugins.PluginLoader, eipHookName string, num *big.Int) (bool, bool) {
fn, ok := plugins.LookupOne[func(*big.Int) bool](pl, eipHookName)
if !ok {
return false, false
}
return fn(num), ok
}
// IsLondon returns whether num is either equal to the London fork block or greater.
func (c *ChainConfig) IsEIP160(num *big.Int) bool {
if plugins.DefaultPluginLoader == nil {
log.Warn("Attempting is160, but default PluginLoader has not been initialized")
return c.IsEIP158(num)
}
if active, ok := PluginEIPCheck(plugins.DefaultPluginLoader, "Is160", num); ok {
return active
}
return c.IsEIP158(num)
}