From 3a2484e12d79a20e72dc6276a43698ab65fd70d8 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Fri, 26 Jan 2024 13:09:03 -0800 Subject: [PATCH] Shanghai activation --- params/config.go | 10 +++++++--- params/plugin_hooks.go | 13 +++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/params/config.go b/params/config.go index 386ce7e23..bb49169db 100644 --- a/params/config.go +++ b/params/config.go @@ -524,10 +524,14 @@ func (c *ChainConfig) IsTerminalPoWBlock(parentTotalDiff *big.Int, totalDiff *bi return parentTotalDiff.Cmp(c.TerminalTotalDifficulty) < 0 && totalDiff.Cmp(c.TerminalTotalDifficulty) >= 0 } +// begin Plugeth injection -- the following code is being commented to enable network plugins to initiate the shanghai fork + // IsShanghai returns whether time is either equal to the Shanghai fork time or greater. -func (c *ChainConfig) IsShanghai(num *big.Int, time uint64) bool { - return c.IsLondon(num) && isTimestampForked(c.ShanghaiTime, time) -} +// func (c *ChainConfig) IsShanghai(num *big.Int, time uint64) bool { +// return c.IsLondon(num) && isTimestampForked(c.ShanghaiTime, time) +// } + +// end PluGeth injection // IsCancun returns whether num is either equal to the Cancun fork time or greater. func (c *ChainConfig) IsCancun(num *big.Int, time uint64) bool { diff --git a/params/plugin_hooks.go b/params/plugin_hooks.go index 23e7cbbe9..913fb5a8d 100644 --- a/params/plugin_hooks.go +++ b/params/plugin_hooks.go @@ -39,3 +39,16 @@ func (c *ChainConfig) IsEIP160(num *big.Int) bool { } return c.IsEIP158(num) } + +// IsShanghai is modified here to return whether num is either equal to the Shanghai fork block or greater, if the chain supports Shanghai +// the foundation implementation has been commented out +func (c *ChainConfig) IsShanghai(num *big.Int, time uint64) bool { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting isPluginShanghai, but default PluginLoader has not been initialized") + return c.IsLondon(num) && isTimestampForked(c.ShanghaiTime, time) + } + if active, ok := PluginEIPCheck(plugins.DefaultPluginLoader, "IsShanghai", num); ok { + return active + } + return c.IsLondon(num) && isTimestampForked(c.ShanghaiTime, time) +} \ No newline at end of file