From a448086780a070f5c46fa62c9bf399c42dd75a68 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Tue, 2 Jan 2024 13:29:42 -0800 Subject: [PATCH 1/5] removed unnecessary logging from cmd/utils/flags.go --- cmd/utils/flags.go | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 59be56fb1..3e8557c2b 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1499,7 +1499,6 @@ func SetDataDir(ctx *cli.Context, cfg *node.Config) { pluginPath := pluginDefaultDataDir(node.DefaultDataDir()) switch { case pluginPath != "" && ctx.String(DataDirFlag.Name) == node.DefaultDataDir(): - log.Error("Inside datdir injection number two") cfg.DataDir = pluginPath // end PluGeth injection case ctx.IsSet(DataDirFlag.Name): From 3a2484e12d79a20e72dc6276a43698ab65fd70d8 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Fri, 26 Jan 2024 13:09:03 -0800 Subject: [PATCH 2/5] 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 From 7c47123898ba00e7d74adb7c266460a3de5f7932 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Wed, 14 Feb 2024 16:30:05 -0600 Subject: [PATCH 3/5] Don't include base fee on non-1559 chains --- miner/worker.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/miner/worker.go b/miner/worker.go index 2ed91cc18..fc706601e 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -940,9 +940,12 @@ func (w *worker) prepareWork(genParams *generateParams) (*environment, error) { header.MixDigest = genParams.random } // Set baseFee and GasLimit if we are on an EIP-1559 chain - if w.chainConfig.IsLondon(header.Number) { + + // begin PluGeth injection + if w.chainConfig.Is1559(header.Number) { header.BaseFee = eip1559.CalcBaseFee(w.chainConfig, parent) - if !w.chainConfig.IsLondon(parent.Number) { + if !w.chainConfig.Is1559(parent.Number) { + // end PluGeth injection parentGasLimit := parent.GasLimit * w.chainConfig.ElasticityMultiplier() header.GasLimit = core.CalcGasLimit(parentGasLimit, w.config.GasCeil) } From fd7b4068cd062a187fbf084a0352a92fc07342e4 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Thu, 15 Feb 2024 13:07:06 -0800 Subject: [PATCH 4/5] Updated comment in test plugin --- plugins/test-plugin/hooks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index 47f8249ed..c2ffd64cf 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -243,7 +243,7 @@ func RPCSubscriptionTest() { // params/ -func Is1559(*big.Int) bool { // while this hook resides in params the injections are in consensus/misc/ (2), and core/ (2) +func Is1559(*big.Int) bool { // while this hook resides in params the injections are in consensus/misc/ (2), and core/ (2) and miner/ (1) m := map[string]struct{}{ "Is1559":struct{}{}, } From 3c9d3b52b06c8e588269edb0001f4e45cb4f8391 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Tue, 20 Feb 2024 13:17:11 -0800 Subject: [PATCH 5/5] Added IsShanghai to test, increased size of hookChan in test to occomodate. --- plugins/test-plugin/hooks.go | 18 +++++++++++++++--- plugins/test-plugin/main.go | 8 +++++--- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index c2ffd64cf..02878fbdc 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -243,7 +243,8 @@ func RPCSubscriptionTest() { // params/ -func Is1559(*big.Int) bool { // while this hook resides in params the injections are in consensus/misc/ (2), and core/ (2) and miner/ (1) +// Is1559 is written in params/ the injections are in: consensus/misc/ (2), and core/ (2) and miner/ (1) +func Is1559(*big.Int) bool { m := map[string]struct{}{ "Is1559":struct{}{}, } @@ -251,9 +252,19 @@ func Is1559(*big.Int) bool { // while this hook resides in params the injections return true } +// the following two hooks are both testing the PluginEIPCheck() hook + func Is160(num *big.Int) bool { m := map[string]struct{}{ - "PluginEIPCheck":struct{}{}, + "Is160":struct{}{}, + } + hookChan <- m + return true +} + +func IsShanghai(num *big.Int) bool { + m := map[string]struct{}{ + "IsShanghai":struct{}{}, } hookChan <- m return true @@ -300,6 +311,7 @@ var plugins map[string]struct{} = map[string]struct{}{ "ForkIDs": struct{}{}, "OpCodeSelect":struct{}{}, "Is1559":struct{}{}, - "PluginEIPCheck":struct{}{}, + "Is160":struct{}{}, + "IsShanghai":struct{}{}, } diff --git a/plugins/test-plugin/main.go b/plugins/test-plugin/main.go index 30f272606..70b813932 100644 --- a/plugins/test-plugin/main.go +++ b/plugins/test-plugin/main.go @@ -12,7 +12,7 @@ import ( "github.com/openrelayxyz/plugeth-utils/restricted/crypto" ) -var hookChan chan map[string]struct{} = make(chan map[string]struct{}, 10) +var hookChan chan map[string]struct{} = make(chan map[string]struct{}, 20) var quit chan string = make(chan string) func (service *engineService) CaptureShutdown(ctx context.Context) { @@ -136,8 +136,10 @@ func BlockChain() { delete(plugins, "OpCodeSelect") case f("Is1559"): delete(plugins, "Is1559") - case f("PluginEIPCheck"): - delete(plugins, "PluginEIPCheck") + case f("Is160"): + delete(plugins, "Is160") + case f("IsShanghai"): + delete(plugins, "IsShanghai") } } }