From a6ee75999b54f7871be6f39bc3b6cf66c2f6ecb4 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 23 Oct 2023 12:34:02 -0500 Subject: [PATCH 1/4] Add separate EIP160 check --- core/vm/jump_table_export.go | 3 +++ params/config.go | 9 +++++++++ params/plugin_hooks.go | 17 ++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/vm/jump_table_export.go b/core/vm/jump_table_export.go index 6ea47d63a..5f4a71a6e 100644 --- a/core/vm/jump_table_export.go +++ b/core/vm/jump_table_export.go @@ -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: diff --git a/params/config.go b/params/config.go index ac55d3771..cb5f31585 100644 --- a/params/config.go +++ b/params/config.go @@ -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 } } diff --git a/params/plugin_hooks.go b/params/plugin_hooks.go index b6b4705ab..6d94e42af 100644 --- a/params/plugin_hooks.go +++ b/params/plugin_hooks.go @@ -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) +} From e43bc1774da618451c3ed5a91b6b6ba586fdc556 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 23 Oct 2023 12:36:16 -0500 Subject: [PATCH 2/4] Fix comments --- params/plugin_hooks.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/params/plugin_hooks.go b/params/plugin_hooks.go index 6d94e42af..b46881455 100644 --- a/params/plugin_hooks.go +++ b/params/plugin_hooks.go @@ -7,7 +7,7 @@ import ( "github.com/ethereum/go-ethereum/plugins" ) -// IsLondon returns whether num is either equal to the London fork block or greater. +// Is1559 returns whether num is either equal to the London fork block or greater, if the chain supports EIP1559 func (c *ChainConfig) Is1559(num *big.Int) bool { if plugins.DefaultPluginLoader == nil { log.Warn("Attempting is1559, but default PluginLoader has not been initialized") @@ -27,7 +27,8 @@ func PluginEIPCheck(pl *plugins.PluginLoader, eipHookName string, num *big.Int) } return fn(num), ok } -// IsLondon returns whether num is either equal to the London fork block or greater. +// IsEIP160 returns whether num is either equal to the EIP160 block or greater. +// This defaults to same as 158, but some chains do it at a different block func (c *ChainConfig) IsEIP160(num *big.Int) bool { if plugins.DefaultPluginLoader == nil { log.Warn("Attempting is160, but default PluginLoader has not been initialized") From 3184027a2ca96d3d9b1f18e2948a22fd97f6195f Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 23 Oct 2023 12:38:48 -0500 Subject: [PATCH 3/4] Syntax fix --- params/plugin_hooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/params/plugin_hooks.go b/params/plugin_hooks.go index b46881455..23e7cbbe9 100644 --- a/params/plugin_hooks.go +++ b/params/plugin_hooks.go @@ -13,7 +13,7 @@ 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 := PluginEIPCheck(plugins.DefaultPluginLoader, "Is1559" num); ok { + if active, ok := PluginEIPCheck(plugins.DefaultPluginLoader, "Is1559", num); ok { return active } return c.IsLondon(num) From 0bb80e6be1d6b467b94119acffd7de01003ac273 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 23 Oct 2023 14:31:50 -0500 Subject: [PATCH 4/4] Set undefined operations instead of nil --- core/vm/plugin_hooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vm/plugin_hooks.go b/core/vm/plugin_hooks.go index 7592dc2cd..d00a6aa3b 100644 --- a/core/vm/plugin_hooks.go +++ b/core/vm/plugin_hooks.go @@ -24,7 +24,7 @@ func PluginOpCodeSelect(pl *plugins.PluginLoader, jt *JumpTable) *JumpTable { jt = copyJumpTable(jt) } for _, idx := range opCodes { - (*jt)[idx] = nil + (*jt)[idx] = &operation{execute: opUndefined, maxStack: maxStack(0, 0)} } return jt }