From 399cbbc8fd3e73a74e1cc39b5815e64c8ff8cf5e Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Tue, 26 Sep 2023 07:26:19 -0700 Subject: [PATCH 01/26] Initial commit of ETC plugin work --- cmd/utils/flags.go | 28 +++++++++ cmd/utils/plugin_hooks.go | 118 ++++++++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 +- 4 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 cmd/utils/plugin_hooks.go diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 8e1d637e8..5e99b9a87 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -95,6 +95,12 @@ var ( Value: flags.DirectoryString(filepath.Join("", "plugins")), Category: flags.EthCategory, } + // ClassicFlag = &cli.BoolFlag{ + // Name: "Classic", + // Usage: "Sepolia network: pre-configured proof-of-work test network", + // Category: flags.EthCategory, + // } + //end PluGeth code injection DataDirFlag = &flags.DirectoryFlag{ Name: "datadir", @@ -965,7 +971,12 @@ func init() { // if none (or the empty string) is specified. If the node is starting a testnet, // then a subdirectory of the specified datadir will be used. func MakeDataDir(ctx *cli.Context) string { + // begin PluGeth injection if path := ctx.String(DataDirFlag.Name); path != "" { + if pluginPath := pluginDefaultDataDir(path); pluginPath != "" { + return pluginPath + } + // end PluGeth injection if ctx.Bool(RinkebyFlag.Name) { return filepath.Join(path, "rinkeby") } @@ -1018,6 +1029,11 @@ func setNodeUserIdent(ctx *cli.Context, cfg *node.Config) { // flags, reverting to pre-configured ones if none have been specified. func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) { urls := params.MainnetBootnodes + // begin PluGeth injection + if pluginUrls := pluginSetBootstrapNodes(); pluginUrls != nil { + urls = pluginUrls + } + // end PluGeth injection switch { case ctx.IsSet(BootnodesFlag.Name): urls = SplitAndTrim(ctx.String(BootnodesFlag.Name)) @@ -1651,6 +1667,18 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { setRequiredBlocks(ctx, cfg) setLes(ctx, cfg) + // beginPluGethInjection + if pluginNetworkId := pluginNetworkId(); pluginNetworkId != nil { + cfg.NetworkId = *pluginNetworkId + } + if pluginETHDiscoveryURLs := pluginETHDiscoveryURLs(); pluginETHDiscoveryURLs != nil { + cfg.EthDiscoveryURLs = pluginETHDiscoveryURLs + } + if pluginSnapDiscoveryURLs := pluginSnapDiscoveryURLs(); pluginSnapDiscoveryURLs != nil { + cfg.SnapDiscoveryURLs = pluginSnapDiscoveryURLs + } + //end PluGeth injection + // Cap the cache allowance and tune the garbage collector mem, err := gopsutil.VirtualMemory() if err == nil { diff --git a/cmd/utils/plugin_hooks.go b/cmd/utils/plugin_hooks.go new file mode 100644 index 000000000..d0fdbff91 --- /dev/null +++ b/cmd/utils/plugin_hooks.go @@ -0,0 +1,118 @@ +package utils + +import ( + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/plugins" +) + +func DefaultDataDir(pl *plugins.PluginLoader, path string) string { + log.Error("inside default data dir hook") + dataDirPath := "" + fnList := pl.Lookup("DefaultDataDir", func(item interface{}) bool { + _, ok := item.(func(string) string) + return ok + }) + for _, fni := range fnList { + if fn, ok := fni.(func(string) string); ok { + dataDirPath = fn(path) + } + } + return dataDirPath +} + +func pluginDefaultDataDir(path string) string { + log.Error("inside default data dir injection") + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting DefaultDataDir, but default PluginLoader has not been initialized") + return "" + } + return DefaultDataDir(plugins.DefaultPluginLoader, path) +} + +func PluginSetBootStrapNodes(pl *plugins.PluginLoader) []string { + var urls []string + fnList := pl.Lookup("SetBootstrapNodes", func(item interface{}) bool { + _, ok := item.(func() []string) + return ok + }) + for _, fni := range fnList { + if fn, ok := fni.(func() []string); ok { + urls = fn() + } + } + return urls +} + +func pluginSetBootstrapNodes() []string { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting pluginSetBootStrapNodes, but default PluginLoader has not been initialized") + return nil + } + return PluginSetBootStrapNodes(plugins.DefaultPluginLoader) +} + +func PluginNetworkId(pl *plugins.PluginLoader) *uint64 { + var networkId *uint64 + fnList := pl.Lookup("SetNetworkId", func(item interface{}) bool { + _, ok := item.(func() *uint64) + return ok + }) + for _, fni := range fnList { + if fn, ok := fni.(func() *uint64); ok { + networkId = fn() + } + } + return networkId +} + +func pluginNetworkId() *uint64 { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting pluginNetworkID, but default PluginLoader has not been initialized") + return nil + } + return PluginNetworkId(plugins.DefaultPluginLoader) +} + +func PluginETHDiscoveryURLs(pl *plugins.PluginLoader) []string { + var ethDiscoveryURLs []string + fnList := pl.Lookup("SetETHDiscoveryURLs", func(item interface{}) bool { + _, ok := item.(func() []string) + return ok + }) + for _, fni := range fnList { + if fn, ok := fni.(func() []string); ok { + ethDiscoveryURLs = fn() + } + } + return ethDiscoveryURLs +} + +func pluginETHDiscoveryURLs() []string { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting pluginETHDiscoveryURLs, but default PluginLoader has not been initialized") + return nil + } + return PluginETHDiscoveryURLs(plugins.DefaultPluginLoader) +} + +func PluginSnapDiscoveryURLs(pl *plugins.PluginLoader) []string { + var snapDiscoveryURLs []string + fnList := pl.Lookup("SetSnapDiscoveryURLs", func(item interface{}) bool { + _, ok := item.(func() []string) + return ok + }) + for _, fni := range fnList { + if fn, ok := fni.(func() []string); ok { + snapDiscoveryURLs = fn() + } + } + return snapDiscoveryURLs +} + +func pluginSnapDiscoveryURLs() []string { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting PluginSnapDiscoveryURLs, but default PluginLoader has not been initialized") + return nil + } + return PluginSnapDiscoveryURLs(plugins.DefaultPluginLoader) +} \ No newline at end of file diff --git a/go.mod b/go.mod index e258e5191..de4055416 100644 --- a/go.mod +++ b/go.mod @@ -38,7 +38,7 @@ require ( github.com/graph-gophers/graphql-go v1.3.0 github.com/hashicorp/go-bexpr v0.1.10 github.com/holiman/bloomfilter/v2 v2.0.3 - github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c + github.com/holiman/uint256 v1.2.3 github.com/huin/goupnp v1.0.3 github.com/influxdata/influxdb-client-go/v2 v2.4.0 github.com/influxdata/influxdb1-client v0.0.0-20220302092344-a9ab5670611c diff --git a/go.sum b/go.sum index 2f95dd941..4189574e2 100644 --- a/go.sum +++ b/go.sum @@ -230,8 +230,8 @@ github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= -github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= -github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= +github.com/holiman/uint256 v1.2.3 h1:K8UWO1HUJpRMXBxbmaY1Y8IAMZC/RsKB+ArEnnK4l5o= +github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= From 5be3014e0bf045822cd1f2c614baf5659b046506 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Thu, 28 Sep 2023 12:34:38 -0700 Subject: [PATCH 02/26] Added first etc hook into test plugin --- cmd/utils/flags.go | 18 +++++++----------- plugins/test-plugin/hooks.go | 16 +++++++++++++--- plugins/test-plugin/main.go | 14 ++++++++------ 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 5e99b9a87..3925bf38d 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -95,12 +95,6 @@ var ( Value: flags.DirectoryString(filepath.Join("", "plugins")), Category: flags.EthCategory, } - // ClassicFlag = &cli.BoolFlag{ - // Name: "Classic", - // Usage: "Sepolia network: pre-configured proof-of-work test network", - // Category: flags.EthCategory, - // } - //end PluGeth code injection DataDirFlag = &flags.DirectoryFlag{ Name: "datadir", @@ -1671,11 +1665,13 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if pluginNetworkId := pluginNetworkId(); pluginNetworkId != nil { cfg.NetworkId = *pluginNetworkId } - if pluginETHDiscoveryURLs := pluginETHDiscoveryURLs(); pluginETHDiscoveryURLs != nil { - cfg.EthDiscoveryURLs = pluginETHDiscoveryURLs - } - if pluginSnapDiscoveryURLs := pluginSnapDiscoveryURLs(); pluginSnapDiscoveryURLs != nil { - cfg.SnapDiscoveryURLs = pluginSnapDiscoveryURLs + if cfg.EthDiscoveryURLs == nil { + var lightMode bool + if cfg.SyncMode == downloader.LightSync { + lightMode = true + } + cfg.EthDiscoveryURLs := pluginETHDiscoveryURLs(lightMode) { + cfg.SnapDiscoveryURLs := pluginSnapDiscoveryURLs() } //end PluGeth injection diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index 7667c616d..950339da8 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -41,6 +41,15 @@ func GetAPIs(stack core.Node, backend core.Backend) []core.API { // this injection is covered by another test in this package. See documentation for details. // } +// cmd/utils/ + +func SetSnapDiscoveryURLs() { + m := map[string]struct{}{ + "SetSnapDiscoveryURLs":struct{}{}, + } + hookChan <- m +} + // core/ @@ -176,12 +185,13 @@ var plugins map[string]struct{} = map[string]struct{}{ "LivePostProcessBlock": struct{}{}, "LiveCaptureStart": struct{}{}, "LiveCaptureState": struct{}{}, + "LiveCaptureEnd": struct{}{}, + "PreTrieCommit": struct{}{}, + "PostTrieCommit": struct{}{}, // "LiveCaptureFault": struct{}{}, // "LiveCaptureEnter": struct{}{}, // "LiveCaptureExit": struct{}{}, // "LiveTracerResult": struct{}{}, - "LiveCaptureEnd": struct{}{}, - "PreTrieCommit": struct{}{}, - "PostTrieCommit": struct{}{}, + "SetSnapDiscoveryURLs": struct{}{}, } diff --git a/plugins/test-plugin/main.go b/plugins/test-plugin/main.go index bd6cd6a06..f78a66fcd 100644 --- a/plugins/test-plugin/main.go +++ b/plugins/test-plugin/main.go @@ -101,6 +101,12 @@ func BlockChain() { delete(plugins, "LiveCaptureStart") case f("LiveCaptureState"): delete(plugins, "LiveCaptureState") + case f("LiveCaptureEnd"): + delete(plugins, "LiveCaptureEnd") + case f("PreTrieCommit"): + delete(plugins, "PreTrieCommit") + case f("PostTrieCommit"): + delete(plugins, "PostTrieCommit") // These methods are not covered by tests at this time // case f("LiveCaptureFault"): // delete(plugins, "LiveCaptureFault") @@ -110,12 +116,8 @@ func BlockChain() { // delete(plugins, "LiveCaptureExit") // case f("LiveTracerResult"): // delete(plugins, "LiveTracerResult") - case f("LiveCaptureEnd"): - delete(plugins, "LiveCaptureEnd") - case f("PreTrieCommit"): - delete(plugins, "PreTrieCommit") - case f("PostTrieCommit"): - delete(plugins, "PostTrieCommit") + case f("SetSnapDiscoveryURLs"): + delete(plugins, "SetSnapDiscoveryURLs") } } } From 38ea6101dec69f108bf0aee019893c8f06b13dc4 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Thu, 28 Sep 2023 21:19:54 -0700 Subject: [PATCH 03/26] Config plugin hooks and injections with test coverage. All config hooks have been written with the exception of writing the genesis. --- cmd/utils/flags.go | 10 +++++-- cmd/utils/plugin_hooks.go | 16 +++++------ plugins/test-plugin/hooks.go | 39 +++++++++++++++++++++++++- plugins/test-plugin/main.go | 10 ++++++- plugins/test-plugin/test/config01.toml | 2 -- 5 files changed, 62 insertions(+), 15 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index a7710eaf7..c70ebe31b 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1510,7 +1510,12 @@ func setSmartCard(ctx *cli.Context, cfg *node.Config) { } func SetDataDir(ctx *cli.Context, cfg *node.Config) { + // begin PluGeth injection + pluginPath := pluginDefaultDataDir(node.DefaultDataDir()) switch { + case pluginPath != "" && cfg.DataDir == node.DefaultDataDir(): + cfg.DataDir = pluginPath + // end PluGeth injection case ctx.IsSet(DataDirFlag.Name): cfg.DataDir = ctx.String(DataDirFlag.Name) case ctx.Bool(DeveloperFlag.Name): @@ -1693,13 +1698,14 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if pluginNetworkId := pluginNetworkId(); pluginNetworkId != nil { cfg.NetworkId = *pluginNetworkId } + if cfg.EthDiscoveryURLs == nil { var lightMode bool if cfg.SyncMode == downloader.LightSync { lightMode = true } - cfg.EthDiscoveryURLs := pluginETHDiscoveryURLs(lightMode) { - cfg.SnapDiscoveryURLs := pluginSnapDiscoveryURLs() + cfg.EthDiscoveryURLs = pluginETHDiscoveryURLs(lightMode) + cfg.SnapDiscoveryURLs = pluginSnapDiscoveryURLs() } //end PluGeth injection diff --git a/cmd/utils/plugin_hooks.go b/cmd/utils/plugin_hooks.go index d0fdbff91..8456c1776 100644 --- a/cmd/utils/plugin_hooks.go +++ b/cmd/utils/plugin_hooks.go @@ -6,9 +6,8 @@ import ( ) func DefaultDataDir(pl *plugins.PluginLoader, path string) string { - log.Error("inside default data dir hook") dataDirPath := "" - fnList := pl.Lookup("DefaultDataDir", func(item interface{}) bool { + fnList := pl.Lookup("SetDefaultDataDir", func(item interface{}) bool { _, ok := item.(func(string) string) return ok }) @@ -21,7 +20,6 @@ func DefaultDataDir(pl *plugins.PluginLoader, path string) string { } func pluginDefaultDataDir(path string) string { - log.Error("inside default data dir injection") if plugins.DefaultPluginLoader == nil { log.Warn("Attempting DefaultDataDir, but default PluginLoader has not been initialized") return "" @@ -73,26 +71,26 @@ func pluginNetworkId() *uint64 { return PluginNetworkId(plugins.DefaultPluginLoader) } -func PluginETHDiscoveryURLs(pl *plugins.PluginLoader) []string { +func PluginETHDiscoveryURLs(pl *plugins.PluginLoader, mode bool) []string { var ethDiscoveryURLs []string fnList := pl.Lookup("SetETHDiscoveryURLs", func(item interface{}) bool { - _, ok := item.(func() []string) + _, ok := item.(func(bool) []string) return ok }) for _, fni := range fnList { - if fn, ok := fni.(func() []string); ok { - ethDiscoveryURLs = fn() + if fn, ok := fni.(func(bool) []string); ok { + ethDiscoveryURLs = fn(mode) } } return ethDiscoveryURLs } -func pluginETHDiscoveryURLs() []string { +func pluginETHDiscoveryURLs(mode bool) []string { if plugins.DefaultPluginLoader == nil { log.Warn("Attempting pluginETHDiscoveryURLs, but default PluginLoader has not been initialized") return nil } - return PluginETHDiscoveryURLs(plugins.DefaultPluginLoader) + return PluginETHDiscoveryURLs(plugins.DefaultPluginLoader, mode) } func PluginSnapDiscoveryURLs(pl *plugins.PluginLoader) []string { diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index 950339da8..72a1c76ae 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -43,11 +43,44 @@ func GetAPIs(stack core.Node, backend core.Backend) []core.API { // cmd/utils/ -func SetSnapDiscoveryURLs() { +func SetDefaultDataDir(arg string) string { + m := map[string]struct{}{ + "SetDefaultDataDir":struct{}{}, + } + hookChan <- m + return "test" +} + +func SetBootstrapNodes() []string { + m := map[string]struct{}{ + "SetBootstrapNodes":struct{}{}, + } + hookChan <- m + return nil +} + +func SetNetworkId() *uint64 { + m := map[string]struct{}{ + "SetNetworkId":struct{}{}, + } + hookChan <- m + return nil +} + +func SetETHDiscoveryURLs(arg bool) []string { + m := map[string]struct{}{ + "SetETHDiscoveryURLs":struct{}{}, + } + hookChan <- m + return nil +} + +func SetSnapDiscoveryURLs() []string { m := map[string]struct{}{ "SetSnapDiscoveryURLs":struct{}{}, } hookChan <- m + return nil } // core/ @@ -192,6 +225,10 @@ var plugins map[string]struct{} = map[string]struct{}{ // "LiveCaptureEnter": struct{}{}, // "LiveCaptureExit": struct{}{}, // "LiveTracerResult": struct{}{}, + "SetDefaultDataDir":struct{}{}, + "SetBootstrapNodes":struct{}{}, + "SetNetworkId":struct{}{}, + "SetETHDiscoveryURLs": struct{}{}, "SetSnapDiscoveryURLs": struct{}{}, } diff --git a/plugins/test-plugin/main.go b/plugins/test-plugin/main.go index 0d52747a7..9acd1b908 100644 --- a/plugins/test-plugin/main.go +++ b/plugins/test-plugin/main.go @@ -116,8 +116,16 @@ func BlockChain() { // delete(plugins, "LiveCaptureExit") // case f("LiveTracerResult"): // delete(plugins, "LiveTracerResult") + case f("SetDefaultDataDir"): + delete(plugins, "SetDefaultDataDir") + case f("SetBootstrapNodes"): + delete(plugins, "SetBootstrapNodes") + case f("SetNetworkId"): + delete(plugins, "SetNetworkId") + case f("SetETHDiscoveryURLs"): + delete(plugins, "SetETHDiscoveryURLs") case f("SetSnapDiscoveryURLs"): - delete(plugins, "SetSnapDiscoveryURLs") + delete(plugins, "SetSnapDiscoveryURLs") } } } diff --git a/plugins/test-plugin/test/config01.toml b/plugins/test-plugin/test/config01.toml index 166c37c3f..31417687c 100644 --- a/plugins/test-plugin/test/config01.toml +++ b/plugins/test-plugin/test/config01.toml @@ -1,8 +1,6 @@ [Eth] NetworkId = 6448 SyncMode = "snap" -EthDiscoveryURLs = [] -SnapDiscoveryURLs = [] NoPruning = false NoPrefetch = false TxLookupLimit = 2350000 From f7ad35eae9b7d2e553b8c6027136b86064ecc717 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Thu, 28 Sep 2023 15:48:25 -0500 Subject: [PATCH 04/26] Add genesis block hook --- cmd/utils/flags.go | 7 + cmd/utils/plugin_hooks.go | 23 + plugins/plugin_loader.go | 20 + plugins/test-plugin/engine.go | 814 +++++++++++++++++++++++++++ plugins/test-plugin/test/run-test.sh | 8 +- 5 files changed, 868 insertions(+), 4 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index c70ebe31b..72a420331 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1933,6 +1933,13 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { SetDNSDiscoveryDefaults(cfg, params.MainnetGenesisHash) } } + + //begin plugeth injection + if genesis := pluginGenesisBlock(); genesis != nil { + cfg.Genesis = genesis + } + //end plugeth injection + // Set any dangling config values if ctx.String(CryptoKZGFlag.Name) != "gokzg" && ctx.String(CryptoKZGFlag.Name) != "ckzg" { Fatalf("--%s flag must be 'gokzg' or 'ckzg'", CryptoKZGFlag.Name) diff --git a/cmd/utils/plugin_hooks.go b/cmd/utils/plugin_hooks.go index 8456c1776..c70defa96 100644 --- a/cmd/utils/plugin_hooks.go +++ b/cmd/utils/plugin_hooks.go @@ -1,6 +1,8 @@ package utils import ( + "encoding/json" + "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/plugins" ) @@ -113,4 +115,25 @@ func pluginSnapDiscoveryURLs() []string { return nil } return PluginSnapDiscoveryURLs(plugins.DefaultPluginLoader) +} + +func PluginGenesisBlock(pl *plugins.PluginLoader) *core.Genesis { + genesisJSON, ok := plugins.LookupOne[func() []byte](pl, "GenesisBlock") + if !ok { + return nil + } + var genesis core.Genesis + if err := json.Unmarshal(genesisJSON(), &genesis); err != nil { + log.Warn("Error unmarshalling genesis", "err", err) + return nil + } + return &genesis +} + +func pluginGenesisBlock() *core.Genesis { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting PluginGenesisBlock, but default PluginLoader has not been initialized") + return nil + } + return PluginGenesisBlock(plugins.DefaultPluginLoader) } \ No newline at end of file diff --git a/plugins/plugin_loader.go b/plugins/plugin_loader.go index dfb4af030..ccd120f06 100644 --- a/plugins/plugin_loader.go +++ b/plugins/plugin_loader.go @@ -157,6 +157,26 @@ func (pl *PluginLoader) ParseFlags(args []string) bool { return len(pl.Flags) > 0 } +func LookupOne[T any](pl *PluginLoader, name string) (T, bool) { + var zero T + if pl == nil { + if DefaultPluginLoader == nil { + log.Warn("Attempting to LookupOne, but default PluginLoader has not been initialized") + return zero, false + } + pl = DefaultPluginLoader + } + items := pl.Lookup(name, func(v interface{}) bool { + _, ok := v.(T) + return ok + }) + if len(items) == 0 { + return zero, false + } + return items[0].(T), true +} + + func ParseFlags(args []string) bool { if DefaultPluginLoader == nil { log.Warn("Attempting to parse flags, but default PluginLoader has not been initialized") diff --git a/plugins/test-plugin/engine.go b/plugins/test-plugin/engine.go index 8a4fe4086..15ef785d5 100644 --- a/plugins/test-plugin/engine.go +++ b/plugins/test-plugin/engine.go @@ -108,4 +108,818 @@ func (e *engine) Close() error { func CreateEngine(chainConfig *params.ChainConfig, db restricted.Database) consensus.Engine { return &engine{} +} + +func GenesisBlock() []byte { + return []byte(`{ + "config": { + "chainId": 6448, + "homesteadBlock": 0, + "eip150Block": 0, + "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "berlinBlock" : 0, + "londonBlock": 0, + "mergeNetsplitBlock": 0, + "shanghaiTime": 0, + "clique": { + "period": 5, + "epoch": 30000 + } + }, + "nonce": "0x0", + "timestamp": "0x603e6caa", + "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f2c207111cb6ef761e439e56b25c7c99ac026a010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "gasLimit": "0x47b760", + "difficulty": "0x1", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "0000000000000000000000000000000000000000": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000001": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000002": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000003": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000004": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000005": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000006": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000007": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000008": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000009": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000010": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000011": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000012": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000013": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000014": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000015": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000016": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000017": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000018": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000019": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000020": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000021": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000022": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000023": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000024": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000025": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000026": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000027": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000028": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000029": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000030": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000031": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000032": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000033": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000034": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000035": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000036": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000037": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000038": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000039": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000040": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000041": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000042": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000043": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000044": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000045": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000046": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000047": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000048": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000049": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000050": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000051": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000052": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000053": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000054": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000055": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000056": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000057": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000058": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000059": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000060": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000061": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000062": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000063": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000064": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000065": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000066": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000067": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000068": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000069": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000070": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000071": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000072": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000073": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000074": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000075": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000076": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000077": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000078": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000079": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000080": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000081": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000082": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000083": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000084": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000085": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000086": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000087": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000088": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000089": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000090": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000091": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000092": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000093": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000094": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000095": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000096": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000097": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000098": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000099": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009f": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000aa": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ab": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ac": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ad": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ae": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000af": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ba": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000bb": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000bc": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000bd": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000be": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000bf": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ca": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000cb": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000cc": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000cd": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ce": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000cf": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000da": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000db": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000dc": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000dd": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000de": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000df": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ea": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000eb": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ec": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ed": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ee": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ef": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fa": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fb": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fc": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fd": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fe": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ff": { + "balance": "0x1" + }, + "2cb2e3bdb066a83a7f1191eef1697da51793f631": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + }, + "4204477bf7fce868e761caaba991ffc607717dbf": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + }, + "f2c207111cb6ef761e439e56b25c7c99ac026a01": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }`) } \ No newline at end of file diff --git a/plugins/test-plugin/test/run-test.sh b/plugins/test-plugin/test/run-test.sh index c7b7cd77a..29552359e 100755 --- a/plugins/test-plugin/test/run-test.sh +++ b/plugins/test-plugin/test/run-test.sh @@ -32,9 +32,9 @@ cp nodekey02 02/geth/nodekey echo -n "supersecretpassword" > passwordfile -$GETH init --datadir=./00 genesis.json -$GETH init --datadir=./01 genesis.json -$GETH init --datadir=./02 genesis.json +# $GETH init --datadir=./00 genesis.json +# $GETH init --datadir=./01 genesis.json +# $GETH init --datadir=./02 genesis.json # miner node $GETH --cache.preimages --config config00.toml --authrpc.port 8552 --port 64480 --verbosity=0 --nodiscover --networkid=6448 --datadir=./00/ --mine --miner.etherbase f2c207111cb6ef761e439e56b25c7c99ac026a01 --unlock f2c207111cb6ef761e439e56b25c7c99ac026a01 --http --http.api eth,debug,net --http.port 9545 --password passwordfile --allow-insecure-unlock & @@ -42,7 +42,7 @@ pid0=$! sleep 1 # passive node -$GETH --cache.preimages --config config01.toml --authrpc.port 8553 --port 64481 --verbosity=3 --syncmode=full --nodiscover --networkid=6448 --datadir=./01/ --unlock 4204477bf7fce868e761caaba991ffc607717dbf --miner.etherbase 4204477bf7fce868e761caaba991ffc607717dbf --password passwordfile --ws --ws.port 8546 --ws.api eth,admin --http --http.api eth,debug,net --http.port 9546 --allow-insecure-unlock & +$GETH --cache.preimages --rpc.allow-unprotected-txs --config config01.toml --authrpc.port 8553 --port 64481 --verbosity=3 --syncmode=full --nodiscover --networkid=6448 --datadir=./01/ --unlock 4204477bf7fce868e761caaba991ffc607717dbf --miner.etherbase 4204477bf7fce868e761caaba991ffc607717dbf --password passwordfile --ws --ws.port 8546 --ws.api eth,admin --http --http.api eth,debug,net --http.port 9546 --allow-insecure-unlock & sleep 1 From 07e97398717b3bf6905c53a93a72a6a04007b911 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 2 Oct 2023 13:18:05 -0500 Subject: [PATCH 05/26] Add genesis block from plugins --- cmd/utils/flags.go | 8 +- cmd/utils/plugin_hooks.go | 6 +- plugins/test-plugin/test/genesis.json | 526 +++++++++--------- .../wrappers/backendwrapper/backendwrapper.go | 4 +- 4 files changed, 274 insertions(+), 270 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 72a420331..8e990844c 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1698,13 +1698,12 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { if pluginNetworkId := pluginNetworkId(); pluginNetworkId != nil { cfg.NetworkId = *pluginNetworkId } - if cfg.EthDiscoveryURLs == nil { var lightMode bool if cfg.SyncMode == downloader.LightSync { lightMode = true } - cfg.EthDiscoveryURLs = pluginETHDiscoveryURLs(lightMode) + cfg.EthDiscoveryURLs = pluginETHDiscoveryURLs(lightMode) cfg.SnapDiscoveryURLs = pluginSnapDiscoveryURLs() } //end PluGeth injection @@ -2204,6 +2203,11 @@ func MakeGenesis(ctx *cli.Context) *core.Genesis { case ctx.Bool(DeveloperFlag.Name): Fatalf("Developer chains are ephemeral") } + //begin plugeth injection + if genesis == nil { + genesis = pluginGenesisBlock() + } + //end plugeth injection return genesis } diff --git a/cmd/utils/plugin_hooks.go b/cmd/utils/plugin_hooks.go index c70defa96..ada6bf2ec 100644 --- a/cmd/utils/plugin_hooks.go +++ b/cmd/utils/plugin_hooks.go @@ -9,7 +9,7 @@ import ( func DefaultDataDir(pl *plugins.PluginLoader, path string) string { dataDirPath := "" - fnList := pl.Lookup("SetDefaultDataDir", func(item interface{}) bool { + fnList := pl.Lookup("DefaultDataDir", func(item interface{}) bool { _, ok := item.(func(string) string) return ok }) @@ -80,7 +80,7 @@ func PluginETHDiscoveryURLs(pl *plugins.PluginLoader, mode bool) []string { return ok }) for _, fni := range fnList { - if fn, ok := fni.(func(bool) []string); ok { + if fn, ok := fni.(func(mode bool) []string); ok { ethDiscoveryURLs = fn(mode) } } @@ -136,4 +136,4 @@ func pluginGenesisBlock() *core.Genesis { return nil } return PluginGenesisBlock(plugins.DefaultPluginLoader) -} \ No newline at end of file +} diff --git a/plugins/test-plugin/test/genesis.json b/plugins/test-plugin/test/genesis.json index ff201c35e..1ac94e795 100644 --- a/plugins/test-plugin/test/genesis.json +++ b/plugins/test-plugin/test/genesis.json @@ -15,797 +15,797 @@ "mergeNetsplitBlock": 0, "shanghaiTime": 0, "clique": { - "period": 5, - "epoch": 30000 + "period": 5, + "epoch": 30000 } }, "nonce": "0x0", "timestamp": "0x603e6caa", "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f2c207111cb6ef761e439e56b25c7c99ac026a010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "gasLimit": "0x47b760", + "gasLimit": "0x1c9c380", "difficulty": "0x1", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "coinbase": "0x0000000000000000000000000000000000000000", "alloc": { "0000000000000000000000000000000000000000": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000001": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000002": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000003": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000004": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000005": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000006": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000007": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000008": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000009": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000000a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000000b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000000c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000000d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000000e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000000f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000010": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000011": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000012": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000013": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000014": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000015": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000016": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000017": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000018": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000019": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000001a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000001b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000001c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000001d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000001e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000001f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000020": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000021": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000022": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000023": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000024": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000025": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000026": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000027": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000028": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000029": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000002a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000002b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000002c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000002d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000002e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000002f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000030": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000031": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000032": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000033": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000034": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000035": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000036": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000037": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000038": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000039": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000003a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000003b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000003c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000003d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000003e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000003f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000040": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000041": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000042": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000043": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000044": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000045": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000046": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000047": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000048": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000049": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000004a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000004b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000004c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000004d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000004e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000004f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000050": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000051": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000052": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000053": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000054": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000055": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000056": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000057": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000058": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000059": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000005a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000005b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000005c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000005d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000005e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000005f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000060": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000061": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000062": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000063": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000064": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000065": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000066": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000067": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000068": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000069": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000006a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000006b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000006c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000006d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000006e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000006f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000070": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000071": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000072": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000073": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000074": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000075": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000076": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000077": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000078": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000079": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000007a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000007b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000007c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000007d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000007e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000007f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000080": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000081": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000082": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000083": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000084": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000085": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000086": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000087": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000088": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000089": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000008a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000008b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000008c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000008d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000008e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000008f": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000090": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000091": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000092": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000093": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000094": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000095": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000096": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000097": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000098": { - "balance": "0x1" + "balance": "0x1" }, "0000000000000000000000000000000000000099": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000009a": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000009b": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000009c": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000009d": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000009e": { - "balance": "0x1" + "balance": "0x1" }, "000000000000000000000000000000000000009f": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a0": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a1": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a2": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a3": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a4": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a5": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a6": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a7": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a8": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000a9": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000aa": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ab": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ac": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ad": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ae": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000af": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b0": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b1": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b2": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b3": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b4": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b5": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b6": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b7": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b8": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000b9": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ba": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000bb": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000bc": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000bd": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000be": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000bf": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c0": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c1": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c2": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c3": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c4": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c5": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c6": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c7": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c8": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000c9": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ca": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000cb": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000cc": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000cd": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ce": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000cf": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d0": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d1": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d2": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d3": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d4": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d5": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d6": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d7": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d8": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000d9": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000da": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000db": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000dc": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000dd": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000de": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000df": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e0": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e1": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e2": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e3": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e4": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e5": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e6": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e7": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e8": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000e9": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ea": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000eb": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ec": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ed": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ee": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ef": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f0": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f1": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f2": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f3": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f4": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f5": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f6": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f7": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f8": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000f9": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000fa": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000fb": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000fc": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000fd": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000fe": { - "balance": "0x1" + "balance": "0x1" }, "00000000000000000000000000000000000000ff": { - "balance": "0x1" + "balance": "0x1" }, "2cb2e3bdb066a83a7f1191eef1697da51793f631": { - "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" }, "4204477bf7fce868e761caaba991ffc607717dbf": { - "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" }, "f2c207111cb6ef761e439e56b25c7c99ac026a01": { - "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" } }, "number": "0x0", "gasUsed": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" -} \ No newline at end of file + } \ No newline at end of file diff --git a/plugins/wrappers/backendwrapper/backendwrapper.go b/plugins/wrappers/backendwrapper/backendwrapper.go index 311402186..a2f681ed9 100644 --- a/plugins/wrappers/backendwrapper/backendwrapper.go +++ b/plugins/wrappers/backendwrapper/backendwrapper.go @@ -482,9 +482,9 @@ func CloneChainConfig(cf *gparams.ChainConfig) *params.ChainConfig { if lv.Kind() != reflect.Invalid { // If core.ChainConfig doesn't have this field, skip it. if v.Type() == lv.Type() && lv.CanSet() { - lv.Set(v) + v.Set(lv) } else { - convertAndSet(lv, v) + convertAndSet(v, lv) } } } From 6781ee2a5caa4eb15bf3dd6a753dd52671d2a781 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 2 Oct 2023 14:45:41 -0500 Subject: [PATCH 06/26] Misc. Fixes from code review --- cmd/utils/plugin_hooks.go | 4 +- plugins/test-plugin/engine.go | 813 -------------------------- plugins/test-plugin/genesis.go | 815 +++++++++++++++++++++++++++ plugins/test-plugin/test/run-test.sh | 8 +- 4 files changed, 821 insertions(+), 819 deletions(-) create mode 100644 plugins/test-plugin/genesis.go diff --git a/cmd/utils/plugin_hooks.go b/cmd/utils/plugin_hooks.go index ada6bf2ec..df28ad8f1 100644 --- a/cmd/utils/plugin_hooks.go +++ b/cmd/utils/plugin_hooks.go @@ -9,7 +9,7 @@ import ( func DefaultDataDir(pl *plugins.PluginLoader, path string) string { dataDirPath := "" - fnList := pl.Lookup("DefaultDataDir", func(item interface{}) bool { + fnList := pl.Lookup("SetDefaultDataDir", func(item interface{}) bool { _, ok := item.(func(string) string) return ok }) @@ -80,7 +80,7 @@ func PluginETHDiscoveryURLs(pl *plugins.PluginLoader, mode bool) []string { return ok }) for _, fni := range fnList { - if fn, ok := fni.(func(mode bool) []string); ok { + if fn, ok := fni.(func(bool) []string); ok { ethDiscoveryURLs = fn(mode) } } diff --git a/plugins/test-plugin/engine.go b/plugins/test-plugin/engine.go index 15ef785d5..76097ba6f 100644 --- a/plugins/test-plugin/engine.go +++ b/plugins/test-plugin/engine.go @@ -110,816 +110,3 @@ func CreateEngine(chainConfig *params.ChainConfig, db restricted.Database) conse return &engine{} } -func GenesisBlock() []byte { - return []byte(`{ - "config": { - "chainId": 6448, - "homesteadBlock": 0, - "eip150Block": 0, - "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "eip155Block": 0, - "eip158Block": 0, - "byzantiumBlock": 0, - "constantinopleBlock": 0, - "petersburgBlock": 0, - "istanbulBlock": 0, - "berlinBlock" : 0, - "londonBlock": 0, - "mergeNetsplitBlock": 0, - "shanghaiTime": 0, - "clique": { - "period": 5, - "epoch": 30000 - } - }, - "nonce": "0x0", - "timestamp": "0x603e6caa", - "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f2c207111cb6ef761e439e56b25c7c99ac026a010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "gasLimit": "0x47b760", - "difficulty": "0x1", - "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", - "coinbase": "0x0000000000000000000000000000000000000000", - "alloc": { - "0000000000000000000000000000000000000000": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000001": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000002": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000003": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000004": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000005": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000006": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000007": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000008": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000009": { - "balance": "0x1" - }, - "000000000000000000000000000000000000000a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000000b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000000c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000000d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000000e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000000f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000010": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000011": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000012": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000013": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000014": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000015": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000016": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000017": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000018": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000019": { - "balance": "0x1" - }, - "000000000000000000000000000000000000001a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000001b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000001c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000001d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000001e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000001f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000020": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000021": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000022": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000023": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000024": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000025": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000026": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000027": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000028": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000029": { - "balance": "0x1" - }, - "000000000000000000000000000000000000002a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000002b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000002c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000002d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000002e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000002f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000030": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000031": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000032": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000033": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000034": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000035": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000036": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000037": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000038": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000039": { - "balance": "0x1" - }, - "000000000000000000000000000000000000003a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000003b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000003c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000003d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000003e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000003f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000040": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000041": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000042": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000043": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000044": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000045": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000046": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000047": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000048": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000049": { - "balance": "0x1" - }, - "000000000000000000000000000000000000004a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000004b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000004c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000004d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000004e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000004f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000050": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000051": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000052": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000053": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000054": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000055": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000056": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000057": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000058": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000059": { - "balance": "0x1" - }, - "000000000000000000000000000000000000005a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000005b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000005c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000005d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000005e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000005f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000060": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000061": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000062": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000063": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000064": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000065": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000066": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000067": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000068": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000069": { - "balance": "0x1" - }, - "000000000000000000000000000000000000006a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000006b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000006c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000006d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000006e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000006f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000070": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000071": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000072": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000073": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000074": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000075": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000076": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000077": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000078": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000079": { - "balance": "0x1" - }, - "000000000000000000000000000000000000007a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000007b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000007c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000007d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000007e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000007f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000080": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000081": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000082": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000083": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000084": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000085": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000086": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000087": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000088": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000089": { - "balance": "0x1" - }, - "000000000000000000000000000000000000008a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000008b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000008c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000008d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000008e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000008f": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000090": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000091": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000092": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000093": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000094": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000095": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000096": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000097": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000098": { - "balance": "0x1" - }, - "0000000000000000000000000000000000000099": { - "balance": "0x1" - }, - "000000000000000000000000000000000000009a": { - "balance": "0x1" - }, - "000000000000000000000000000000000000009b": { - "balance": "0x1" - }, - "000000000000000000000000000000000000009c": { - "balance": "0x1" - }, - "000000000000000000000000000000000000009d": { - "balance": "0x1" - }, - "000000000000000000000000000000000000009e": { - "balance": "0x1" - }, - "000000000000000000000000000000000000009f": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a0": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a1": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a2": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a3": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a4": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a5": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a6": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a7": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a8": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000a9": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000aa": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ab": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ac": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ad": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ae": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000af": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b0": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b1": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b2": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b3": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b4": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b5": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b6": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b7": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b8": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000b9": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ba": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000bb": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000bc": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000bd": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000be": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000bf": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c0": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c1": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c2": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c3": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c4": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c5": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c6": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c7": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c8": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000c9": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ca": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000cb": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000cc": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000cd": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ce": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000cf": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d0": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d1": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d2": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d3": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d4": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d5": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d6": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d7": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d8": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000d9": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000da": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000db": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000dc": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000dd": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000de": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000df": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e0": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e1": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e2": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e3": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e4": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e5": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e6": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e7": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e8": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000e9": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ea": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000eb": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ec": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ed": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ee": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ef": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f0": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f1": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f2": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f3": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f4": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f5": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f6": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f7": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f8": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000f9": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000fa": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000fb": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000fc": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000fd": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000fe": { - "balance": "0x1" - }, - "00000000000000000000000000000000000000ff": { - "balance": "0x1" - }, - "2cb2e3bdb066a83a7f1191eef1697da51793f631": { - "balance": "0x200000000000000000000000000000000000000000000000000000000000000" - }, - "4204477bf7fce868e761caaba991ffc607717dbf": { - "balance": "0x200000000000000000000000000000000000000000000000000000000000000" - }, - "f2c207111cb6ef761e439e56b25c7c99ac026a01": { - "balance": "0x200000000000000000000000000000000000000000000000000000000000000" - } - }, - "number": "0x0", - "gasUsed": "0x0", - "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" - }`) -} \ No newline at end of file diff --git a/plugins/test-plugin/genesis.go b/plugins/test-plugin/genesis.go new file mode 100644 index 000000000..e53eb4274 --- /dev/null +++ b/plugins/test-plugin/genesis.go @@ -0,0 +1,815 @@ +package main + +func GenesisBlock() []byte { + return []byte(`{ + "config": { + "chainId": 6448, + "homesteadBlock": 0, + "eip150Block": 0, + "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "eip155Block": 0, + "eip158Block": 0, + "byzantiumBlock": 0, + "constantinopleBlock": 0, + "petersburgBlock": 0, + "istanbulBlock": 0, + "berlinBlock" : 0, + "londonBlock": 0, + "mergeNetsplitBlock": 0, + "shanghaiTime": 0, + "clique": { + "period": 5, + "epoch": 30000 + } + }, + "nonce": "0x0", + "timestamp": "0x603e6caa", + "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000f2c207111cb6ef761e439e56b25c7c99ac026a010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", + "gasLimit": "0x47b760", + "difficulty": "0x1", + "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", + "coinbase": "0x0000000000000000000000000000000000000000", + "alloc": { + "0000000000000000000000000000000000000000": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000001": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000002": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000003": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000004": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000005": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000006": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000007": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000008": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000009": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000000f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000010": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000011": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000012": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000013": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000014": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000015": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000016": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000017": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000018": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000019": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000001f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000020": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000021": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000022": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000023": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000024": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000025": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000026": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000027": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000028": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000029": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000002f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000030": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000031": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000032": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000033": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000034": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000035": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000036": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000037": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000038": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000039": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000003f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000040": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000041": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000042": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000043": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000044": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000045": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000046": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000047": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000048": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000049": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000004f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000050": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000051": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000052": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000053": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000054": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000055": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000056": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000057": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000058": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000059": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000005f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000060": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000061": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000062": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000063": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000064": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000065": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000066": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000067": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000068": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000069": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000006f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000070": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000071": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000072": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000073": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000074": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000075": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000076": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000077": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000078": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000079": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000007f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000080": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000081": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000082": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000083": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000084": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000085": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000086": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000087": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000088": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000089": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000008f": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000090": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000091": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000092": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000093": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000094": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000095": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000096": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000097": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000098": { + "balance": "0x1" + }, + "0000000000000000000000000000000000000099": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009a": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009b": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009c": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009d": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009e": { + "balance": "0x1" + }, + "000000000000000000000000000000000000009f": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000a9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000aa": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ab": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ac": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ad": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ae": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000af": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000b9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ba": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000bb": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000bc": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000bd": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000be": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000bf": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000c9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ca": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000cb": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000cc": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000cd": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ce": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000cf": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000d9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000da": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000db": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000dc": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000dd": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000de": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000df": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000e9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ea": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000eb": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ec": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ed": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ee": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ef": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f0": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f1": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f2": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f3": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f4": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f5": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f6": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f7": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f8": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000f9": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fa": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fb": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fc": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fd": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000fe": { + "balance": "0x1" + }, + "00000000000000000000000000000000000000ff": { + "balance": "0x1" + }, + "2cb2e3bdb066a83a7f1191eef1697da51793f631": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + }, + "4204477bf7fce868e761caaba991ffc607717dbf": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + }, + "f2c207111cb6ef761e439e56b25c7c99ac026a01": { + "balance": "0x200000000000000000000000000000000000000000000000000000000000000" + } + }, + "number": "0x0", + "gasUsed": "0x0", + "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000" + }`) +} \ No newline at end of file diff --git a/plugins/test-plugin/test/run-test.sh b/plugins/test-plugin/test/run-test.sh index 29552359e..861c6f62f 100755 --- a/plugins/test-plugin/test/run-test.sh +++ b/plugins/test-plugin/test/run-test.sh @@ -9,9 +9,9 @@ mkdir -p test00 test01 test02 00/keystore 01/keystore 02/keystore 00/geth 01/geth 02/geth 00/plugins 01/plugins 02/plugins -cp ../engine.go test00/ -cp ../engine.go ../main.go ../hooks.go ../tracer.go ../live_tracer.go test01/ -cp ../engine.go ../shutdown.go test02/ +cp ../engine.go ../genesis.go test00/ +cp ../engine.go ../genesis.go ../main.go ../hooks.go ../tracer.go ../live_tracer.go test01/ +cp ../engine.go ../genesis.go ../shutdown.go test02/ cd test00/ go build -buildmode=plugin -o ../00/plugins cd ../ @@ -42,7 +42,7 @@ pid0=$! sleep 1 # passive node -$GETH --cache.preimages --rpc.allow-unprotected-txs --config config01.toml --authrpc.port 8553 --port 64481 --verbosity=3 --syncmode=full --nodiscover --networkid=6448 --datadir=./01/ --unlock 4204477bf7fce868e761caaba991ffc607717dbf --miner.etherbase 4204477bf7fce868e761caaba991ffc607717dbf --password passwordfile --ws --ws.port 8546 --ws.api eth,admin --http --http.api eth,debug,net --http.port 9546 --allow-insecure-unlock & +$GETH --cache.preimages --config config01.toml --authrpc.port 8553 --port 64481 --verbosity=3 --syncmode=full --nodiscover --networkid=6448 --datadir=./01/ --unlock 4204477bf7fce868e761caaba991ffc607717dbf --miner.etherbase 4204477bf7fce868e761caaba991ffc607717dbf --password passwordfile --ws --ws.port 8546 --ws.api eth,admin --http --http.api eth,debug,net --http.port 9546 --allow-insecure-unlock & sleep 1 From 052b70563200875a9e4636497814f9e3b73c416a Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Tue, 10 Oct 2023 14:32:52 -0700 Subject: [PATCH 07/26] Added addBalance to wrapped state db --- plugins/wrappers/wrappers.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/wrappers/wrappers.go b/plugins/wrappers/wrappers.go index e49dfb1ea..98bfd93d0 100644 --- a/plugins/wrappers/wrappers.go +++ b/plugins/wrappers/wrappers.go @@ -199,7 +199,10 @@ func (w *WrappedStateDB) SlotInAccessList(addr core.Address, slot core.Hash) (ad func (w *WrappedStateDB) IntermediateRoot(deleteEmptyObjects bool) core.Hash { return core.Hash(w.s.IntermediateRoot(deleteEmptyObjects)) } - + +func (w *WrappedStateDB) AddBalance(addr core.Address, amount *big.Int) { + w.s.AddBalance(common.Address(addr), amount) +} type Node struct { n *node.Node From cb62de132cdef66d1a2f4aadc131a9ba9d96ca46 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Tue, 10 Oct 2023 15:26:47 -0700 Subject: [PATCH 08/26] Added forkIDs plugin hook --- cmd/utils/plugin_hooks.go | 1 + core/forkid/forkid.go | 6 ++++++ core/forkid/plugin_hooks.go | 37 +++++++++++++++++++++++++++++++++++++ go.mod | 4 +++- go.sum | 6 ++---- 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 core/forkid/plugin_hooks.go diff --git a/cmd/utils/plugin_hooks.go b/cmd/utils/plugin_hooks.go index df28ad8f1..12b85b581 100644 --- a/cmd/utils/plugin_hooks.go +++ b/cmd/utils/plugin_hooks.go @@ -22,6 +22,7 @@ func DefaultDataDir(pl *plugins.PluginLoader, path string) string { } func pluginDefaultDataDir(path string) string { + log.Error("public default data dir") if plugins.DefaultPluginLoader == nil { log.Warn("Attempting DefaultDataDir, but default PluginLoader has not been initialized") return "" diff --git a/core/forkid/forkid.go b/core/forkid/forkid.go index 76825d3be..c43c74473 100644 --- a/core/forkid/forkid.go +++ b/core/forkid/forkid.go @@ -240,6 +240,12 @@ func checksumToBytes(hash uint32) [4]byte { // gatherForks gathers all the known forks and creates two sorted lists out of // them, one for the block number based forks and the second for the timestamps. func gatherForks(config *params.ChainConfig, genesis uint64) ([]uint64, []uint64) { + // begin PluGeth injection + if byBlock, byTime, ok := pluginForkIDs(); ok { + return byBlock, byTime + } + // end PluGeth injection + // Gather all the fork block numbers via reflection kind := reflect.TypeOf(params.ChainConfig{}) conf := reflect.ValueOf(config).Elem() diff --git a/core/forkid/plugin_hooks.go b/core/forkid/plugin_hooks.go new file mode 100644 index 000000000..222ef7b2a --- /dev/null +++ b/core/forkid/plugin_hooks.go @@ -0,0 +1,37 @@ +package forkid + +import ( + // "encoding/json" + // "math/big" + // "reflect" + // "time" + // "sync" + + // "github.com/ethereum/go-ethereum/common" + // "github.com/ethereum/go-ethereum/core/state" + // "github.com/ethereum/go-ethereum/core/types" + // "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/plugins" + // "github.com/ethereum/go-ethereum/plugins/wrappers" + // "github.com/ethereum/go-ethereum/rlp" + // "github.com/openrelayxyz/plugeth-utils/core" +) + +func PluginForkIDs(pl *plugins.PluginLoader) ([]uint64, []uint64, bool) { + f, ok := plugins.LookupOne[func() ([]uint64, []uint64)](pl, "ForkIDs") + if !ok { + return nil, nil, false + } + byBlock, byTime := f() + + return byBlock, byTime, ok +} + +func pluginForkIDs() ([]uint64, []uint64, bool) { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting PluginForkIDs, but default PluginLoader has not been initialized") + return nil, nil, false + } + return PluginForkIDs(plugins.DefaultPluginLoader) +} diff --git a/go.mod b/go.mod index 2490cd6e3..e2395b2a4 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/consensys/gnark-crypto v0.10.0 github.com/crate-crypto/go-kzg-4844 v0.3.0 github.com/davecgh/go-spew v1.1.1 - github.com/deckarep/golang-set/v2 v2.1.0 + github.com/deckarep/golang-set/v2 v2.3.1 github.com/docker/docker v24.0.5+incompatible github.com/dop251/goja v0.0.0-20230806174421-c933cf95e127 github.com/ethereum/c-kzg-4844 v0.3.1 @@ -134,3 +134,5 @@ require ( gotest.tools/v3 v3.5.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) + +replace github.com/openrelayxyz/plugeth-utils => /home/philip/src/rivet/plugeth_superspace/plugeth-utils diff --git a/go.sum b/go.sum index 57596642f..fa02d7d76 100644 --- a/go.sum +++ b/go.sum @@ -142,8 +142,8 @@ github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= -github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= +github.com/deckarep/golang-set/v2 v2.3.1 h1:vjmkvJt/IV27WXPyYQpAh4bRyWJc5Y435D17XQ9QU5A= +github.com/deckarep/golang-set/v2 v2.3.1/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc= @@ -458,8 +458,6 @@ github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9k github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/openrelayxyz/plugeth-utils v1.3.0 h1:0goW7zzasytejXJJcWCJiIRXl3X8o/oFtK8zKF//rlE= -github.com/openrelayxyz/plugeth-utils v1.3.0/go.mod h1:p5Jc8deG2yxXI8DzmrH3kHNEwlQqcOQS0pmGulsqg+M= github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsqf19k25Ur8rU= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= From d9de580d7445a1f2714c21919513443e761b4b11 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Mon, 16 Oct 2023 15:33:22 -0700 Subject: [PATCH 09/26] Added IsEIP1559() hook Modifications to genesis injection and datadir injections --- cmd/utils/flags.go | 5 ++++- consensus/misc/eip1559/eip1559.go | 8 ++++++-- params/plugin_hooks.go | 29 +++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 params/plugin_hooks.go diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 8e990844c..ee7e6794a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -990,7 +990,7 @@ func init() { // then a subdirectory of the specified datadir will be used. func MakeDataDir(ctx *cli.Context) string { // begin PluGeth injection - if path := ctx.String(DataDirFlag.Name); path != "" { + if path := ctx.String(DataDirFlag.Name); path == "" { if pluginPath := pluginDefaultDataDir(path); pluginPath != "" { return pluginPath } @@ -1935,7 +1935,10 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) { //begin plugeth injection if genesis := pluginGenesisBlock(); genesis != nil { + chaindb := MakeChainDatabase(ctx, stack, false) cfg.Genesis = genesis + rawdb.WriteChainConfig(chaindb, genesis.ToBlock().Hash(), genesis.Config) + chaindb.Close() } //end plugeth injection diff --git a/consensus/misc/eip1559/eip1559.go b/consensus/misc/eip1559/eip1559.go index 84b82c4c4..9b581fef4 100644 --- a/consensus/misc/eip1559/eip1559.go +++ b/consensus/misc/eip1559/eip1559.go @@ -34,7 +34,9 @@ import ( func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Header) error { // Verify that the gas limit remains within allowed bounds parentGasLimit := parent.GasLimit - if !config.IsLondon(parent.Number) { + // begin PluGeth injection + if !config.Is1559(parent.Number) { + // end PluGeth injection parentGasLimit = parent.GasLimit * config.ElasticityMultiplier() } if err := misc.VerifyGaslimit(parentGasLimit, header.GasLimit); err != nil { @@ -56,7 +58,9 @@ func VerifyEIP1559Header(config *params.ChainConfig, parent, header *types.Heade // CalcBaseFee calculates the basefee of the header. func CalcBaseFee(config *params.ChainConfig, parent *types.Header) *big.Int { // If the current block is the first EIP-1559 block, return the InitialBaseFee. - if !config.IsLondon(parent.Number) { + // begin PluGeth injection + if !config.Is1559(parent.Number) { + // end PluGeth injection return new(big.Int).SetUint64(params.InitialBaseFee) } diff --git a/params/plugin_hooks.go b/params/plugin_hooks.go new file mode 100644 index 000000000..b6b4705ab --- /dev/null +++ b/params/plugin_hooks.go @@ -0,0 +1,29 @@ +package params + +import ( + "math/big" + + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/plugins" +) + +// IsLondon returns whether num is either equal to the London fork block or greater. +func (c *ChainConfig) Is1559(num *big.Int) bool { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting is1559, but default PluginLoader has not been initialized") + return c.IsLondon(num) + } + if active, ok := PluginIs1559(plugins.DefaultPluginLoader, 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") + if !ok { + return false, false + } + return fn(num), ok +} From c0210061c8a52c8f23e7cf8a9ac338ef1e5d02b5 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Tue, 17 Oct 2023 15:00:09 -0700 Subject: [PATCH 10/26] Expanded is1559() further into core/state_transition.go --- core/state_transition.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index cb9287a82..d8d325c0a 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -290,7 +290,9 @@ func (st *StateTransition) preCheck() error { } // Make sure that transaction gasFeeCap is greater than the baseFee (post london) - if st.evm.ChainConfig().IsLondon(st.evm.Context.BlockNumber) { + // begin PluGeth injection + if st.evm.ChainConfig().Is1559(st.evm.Context.BlockNumber) { + // end PluGeth injection // Skip the checks if gas fields are zero and baseFee was explicitly disabled (eth_call) if !st.evm.Config.NoBaseFee || msg.GasFeeCap.BitLen() > 0 || msg.GasTipCap.BitLen() > 0 { if l := msg.GasFeeCap.BitLen(); l > 256 { @@ -433,7 +435,11 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { } effectiveTip := msg.GasPrice if rules.IsLondon { - effectiveTip = cmath.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)) + // begin PluGeth injection + if st.evm.ChainConfig().Is1559(st.evm.Context.BlockNumber) { + // end PluGeth injection + effectiveTip = cmath.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)) + } } if st.evm.Config.NoBaseFee && msg.GasFeeCap.Sign() == 0 && msg.GasTipCap.Sign() == 0 { From 63f8d10434c310ea77eb9630eaa66fda6e1b1e45 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Fri, 20 Oct 2023 09:27:20 -0700 Subject: [PATCH 11/26] OpCode select plugin hook and injection --- core/vm/interpreter.go | 3 +++ core/vm/plugin_hooks.go | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 873337850..8d6270b77 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -95,6 +95,9 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter { } } evm.Config.ExtraEips = extraEips + // begin PluGeth injection + table = pluginOpCodeSelect(table) + // end PluGeth injection return &EVMInterpreter{evm: evm, table: table} } diff --git a/core/vm/plugin_hooks.go b/core/vm/plugin_hooks.go index 728e3c75f..7592dc2cd 100644 --- a/core/vm/plugin_hooks.go +++ b/core/vm/plugin_hooks.go @@ -1,5 +1,39 @@ package vm +import ( + "github.com/ethereum/go-ethereum/log" + "github.com/ethereum/go-ethereum/plugins" +) + func (st *Stack) Len() int { return len(st.data) } + +func PluginOpCodeSelect(pl *plugins.PluginLoader, jt *JumpTable) *JumpTable { + var opCodes []int + fnList := pl.Lookup("OpCodeSelect", func(item interface{}) bool { + _, ok := item.(func() []int) + return ok + }) + for _, fni := range fnList { + if fn, ok := fni.(func() []int); ok { + opCodes = append(opCodes, fn()...) + } + } + if len(opCodes) > 0 { + jt = copyJumpTable(jt) + } + for _, idx := range opCodes { + (*jt)[idx] = nil + } + return jt +} + +func pluginOpCodeSelect(jt *JumpTable) *JumpTable { + if plugins.DefaultPluginLoader == nil { + log.Warn("Attempting PluginOpCodeSelect, but default PluginLoader has not been initialized") + return nil + } + return PluginOpCodeSelect(plugins.DefaultPluginLoader, jt) +} + From a6ee75999b54f7871be6f39bc3b6cf66c2f6ecb4 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 23 Oct 2023 12:34:02 -0500 Subject: [PATCH 12/26] 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 13/26] 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 14/26] 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 15/26] 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 } From e35d5eb3fe2faea7122b45cfc27ddce53ace2c29 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Mon, 23 Oct 2023 13:25:54 -0700 Subject: [PATCH 16/26] Fixed pluginDefaultDataDir --- cmd/utils/flags.go | 8 ++++++-- cmd/utils/plugin_hooks.go | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index ee7e6794a..2b0542084 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -989,9 +989,10 @@ func init() { // if none (or the empty string) is specified. If the node is starting a testnet, // then a subdirectory of the specified datadir will be used. func MakeDataDir(ctx *cli.Context) string { - // begin PluGeth injection if path := ctx.String(DataDirFlag.Name); path == "" { + // begin PluGeth injection if pluginPath := pluginDefaultDataDir(path); pluginPath != "" { + log.Error("Inside datdir injection number one") return pluginPath } // end PluGeth injection @@ -1446,6 +1447,7 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { setGraphQL(ctx, cfg) setWS(ctx, cfg) setNodeUserIdent(ctx, cfg) + log.Error("calling set data dir", "cfg.datadir", cfg.DataDir) SetDataDir(ctx, cfg) setSmartCard(ctx, cfg) @@ -1510,10 +1512,12 @@ func setSmartCard(ctx *cli.Context, cfg *node.Config) { } func SetDataDir(ctx *cli.Context, cfg *node.Config) { + log.Error("Inside of setDataDir", "default", node.DefaultDataDir()) // begin PluGeth injection pluginPath := pluginDefaultDataDir(node.DefaultDataDir()) switch { - case pluginPath != "" && cfg.DataDir == node.DefaultDataDir(): + 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): diff --git a/cmd/utils/plugin_hooks.go b/cmd/utils/plugin_hooks.go index 12b85b581..df28ad8f1 100644 --- a/cmd/utils/plugin_hooks.go +++ b/cmd/utils/plugin_hooks.go @@ -22,7 +22,6 @@ func DefaultDataDir(pl *plugins.PluginLoader, path string) string { } func pluginDefaultDataDir(path string) string { - log.Error("public default data dir") if plugins.DefaultPluginLoader == nil { log.Warn("Attempting DefaultDataDir, but default PluginLoader has not been initialized") return "" From 39b5250f63aa017323d1fc1a271f3171d987067f Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Mon, 23 Oct 2023 17:25:52 -0700 Subject: [PATCH 17/26] ForkIDs() added to test plugin --- cmd/utils/flags.go | 2 -- core/forkid/forkid.go | 10 +++++----- core/forkid/plugin_hooks.go | 38 ++++++++++++++++++------------------ plugins/test-plugin/hooks.go | 23 +++++++++++++++++++--- plugins/test-plugin/main.go | 2 ++ 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2b0542084..083039c2e 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1447,7 +1447,6 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { setGraphQL(ctx, cfg) setWS(ctx, cfg) setNodeUserIdent(ctx, cfg) - log.Error("calling set data dir", "cfg.datadir", cfg.DataDir) SetDataDir(ctx, cfg) setSmartCard(ctx, cfg) @@ -1512,7 +1511,6 @@ func setSmartCard(ctx *cli.Context, cfg *node.Config) { } func SetDataDir(ctx *cli.Context, cfg *node.Config) { - log.Error("Inside of setDataDir", "default", node.DefaultDataDir()) // begin PluGeth injection pluginPath := pluginDefaultDataDir(node.DefaultDataDir()) switch { diff --git a/core/forkid/forkid.go b/core/forkid/forkid.go index c43c74473..1bf81f8dd 100644 --- a/core/forkid/forkid.go +++ b/core/forkid/forkid.go @@ -240,11 +240,6 @@ func checksumToBytes(hash uint32) [4]byte { // gatherForks gathers all the known forks and creates two sorted lists out of // them, one for the block number based forks and the second for the timestamps. func gatherForks(config *params.ChainConfig, genesis uint64) ([]uint64, []uint64) { - // begin PluGeth injection - if byBlock, byTime, ok := pluginForkIDs(); ok { - return byBlock, byTime - } - // end PluGeth injection // Gather all the fork block numbers via reflection kind := reflect.TypeOf(params.ChainConfig{}) @@ -299,5 +294,10 @@ func gatherForks(config *params.ChainConfig, genesis uint64) ([]uint64, []uint64 for len(forksByTime) > 0 && forksByTime[0] <= genesis { forksByTime = forksByTime[1:] } + // begin PluGeth injection + if byBlock, byTime, ok := pluginForkIDs(forksByBlock, forksByTime); ok { + return byBlock, byTime + } + // end PluGeth injection return forksByBlock, forksByTime } diff --git a/core/forkid/plugin_hooks.go b/core/forkid/plugin_hooks.go index 222ef7b2a..b9102c9b8 100644 --- a/core/forkid/plugin_hooks.go +++ b/core/forkid/plugin_hooks.go @@ -1,37 +1,37 @@ package forkid import ( - // "encoding/json" - // "math/big" - // "reflect" - // "time" - // "sync" - - // "github.com/ethereum/go-ethereum/common" - // "github.com/ethereum/go-ethereum/core/state" - // "github.com/ethereum/go-ethereum/core/types" - // "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/plugins" - // "github.com/ethereum/go-ethereum/plugins/wrappers" - // "github.com/ethereum/go-ethereum/rlp" - // "github.com/openrelayxyz/plugeth-utils/core" ) -func PluginForkIDs(pl *plugins.PluginLoader) ([]uint64, []uint64, bool) { - f, ok := plugins.LookupOne[func() ([]uint64, []uint64)](pl, "ForkIDs") +func PluginForkIDs(pl *plugins.PluginLoader, byBlock, byTime []uint64) ([]uint64, []uint64, bool) { + f, ok := plugins.LookupOne[func([]uint64, []uint64) ([]uint64, []uint64)](pl, "ForkIDs") if !ok { return nil, nil, false } - byBlock, byTime := f() + pluginByBlock, pluginByTime := f(byBlock, byTime) - return byBlock, byTime, ok + return pluginByBlock, pluginByTime, ok + + // fnList := pl.Lookup("ForkIDs", func(item interface{}) bool { + // _, ok := item.(func([]uint64, []uint64) ([]uint64, []uint64)) + // return ok + // }) + // for _, fni := range fnList { + // if fn, ok := fni.(func([]uint64, []uint64) ([]uint64, []uint64)); ok { + // pluginByBlock, pluginByTime := fn(byBlock, byTime) + // return pluginByBlock, pluginByTime, true + // } + // } + + // return nil, nil, false } -func pluginForkIDs() ([]uint64, []uint64, bool) { +func pluginForkIDs(byBlock, byTime []uint64) ([]uint64, []uint64, bool) { if plugins.DefaultPluginLoader == nil { log.Warn("Attempting PluginForkIDs, but default PluginLoader has not been initialized") return nil, nil, false } - return PluginForkIDs(plugins.DefaultPluginLoader) + return PluginForkIDs(plugins.DefaultPluginLoader, byBlock, byTime) } diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index 72a1c76ae..1a60266a1 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -141,6 +141,23 @@ func SetTrieFlushIntervalClone(duration time.Duration) time.Duration { return duration } +// core/forkid/ + +var onceZero sync.Once + +func ForkIDs(byBlock, byTime []uint64) ([]uint64, []uint64) { + go func() { + onceZero.Do(func() { + m := map[string]struct{}{ + "ForkIDs":struct{}{}, + } + hookChan <- m + }) + }() + + return byBlock, byTime +} + // core/rawdb/ func ModifyAncients(index uint64, freezerUpdate map[string]struct{}) { @@ -154,7 +171,6 @@ func AppendAncient(number uint64, hash, header, body, receipts, td []byte) { // core/state/ func StateUpdate(blockRoot core.Hash, parentRoot core.Hash, coreDestructs map[core.Hash]struct{}, coreAccounts map[core.Hash][]byte, coreStorage map[core.Hash]map[core.Hash][]byte, coreCode map[core.Hash][]byte) { - // log.Warn("StatueUpdate", "blockRoot", blockRoot, "parentRoot", parentRoot, "coreDestructs", coreDestructs, "coreAccounts", coreAccounts, "coreStorage", coreStorage, "coreCode", coreCode) m := map[string]struct{}{ "StateUpdate":struct{}{}, } @@ -171,11 +187,11 @@ func GetRPCCalls(method string, id string, params string) { hookChan <- m } -var once sync.Once +var onceOne sync.Once func RPCSubscriptionTest() { go func() { - once.Do(func() { + onceOne.Do(func() { m := map[string]struct{}{ "RPCSubscriptionTest":struct{}{}, } @@ -230,5 +246,6 @@ var plugins map[string]struct{} = map[string]struct{}{ "SetNetworkId":struct{}{}, "SetETHDiscoveryURLs": struct{}{}, "SetSnapDiscoveryURLs": struct{}{}, + "ForkIDs": struct{}{}, } diff --git a/plugins/test-plugin/main.go b/plugins/test-plugin/main.go index 9acd1b908..313e87572 100644 --- a/plugins/test-plugin/main.go +++ b/plugins/test-plugin/main.go @@ -126,6 +126,8 @@ func BlockChain() { delete(plugins, "SetETHDiscoveryURLs") case f("SetSnapDiscoveryURLs"): delete(plugins, "SetSnapDiscoveryURLs") + case f("ForkIDs"): + delete(plugins, "ForkIDs") } } } From 771c2e7cc3b139c10218e6cd3ac950895265a48e Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Mon, 23 Oct 2023 17:40:33 -0700 Subject: [PATCH 18/26] Added OpCodeSelect() to test plugin --- plugins/test-plugin/hooks.go | 11 +++++++++++ plugins/test-plugin/main.go | 2 ++ 2 files changed, 13 insertions(+) diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index 1a60266a1..7d83da914 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -177,6 +177,16 @@ func StateUpdate(blockRoot core.Hash, parentRoot core.Hash, coreDestructs map[co hookChan <- m } +// core/vm/ + +func OpCodeSelect() []int { + m := map[string]struct{}{ + "OpCodeSelect":struct{}{}, + } + hookChan <- m + return nil +} + // rpc/ @@ -247,5 +257,6 @@ var plugins map[string]struct{} = map[string]struct{}{ "SetETHDiscoveryURLs": struct{}{}, "SetSnapDiscoveryURLs": struct{}{}, "ForkIDs": struct{}{}, + "OpCodeSelect":struct{}{}, } diff --git a/plugins/test-plugin/main.go b/plugins/test-plugin/main.go index 313e87572..766bc8cc8 100644 --- a/plugins/test-plugin/main.go +++ b/plugins/test-plugin/main.go @@ -128,6 +128,8 @@ func BlockChain() { delete(plugins, "SetSnapDiscoveryURLs") case f("ForkIDs"): delete(plugins, "ForkIDs") + case f("OpCodeSelect"): + delete(plugins, "OpCodeSelect") } } } From ace421d0331b9d6fce554e4bad9c3b94a3be6d3a Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Mon, 23 Oct 2023 18:13:27 -0700 Subject: [PATCH 19/26] Added Is1559() to test plugin --- plugins/test-plugin/hooks.go | 11 +++++++++++ plugins/test-plugin/main.go | 2 ++ 2 files changed, 13 insertions(+) diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index 7d83da914..cea477ab8 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -220,6 +220,16 @@ func RPCSubscriptionTest() { // this injection is covered by another test in this package. See documentation for details. // } +// params/ + +func Is1559(*big.Int) bool { // while this hook resides in params the injections are in consensus/misc/ (2), and core/ (2) + m := map[string]struct{}{ + "Is1559":struct{}{}, + } + hookChan <- m + return true +} + var plugins map[string]struct{} = map[string]struct{}{ "OnShutdown": struct{}{}, "SetTrieFlushIntervalClone":struct{}{}, @@ -258,5 +268,6 @@ var plugins map[string]struct{} = map[string]struct{}{ "SetSnapDiscoveryURLs": struct{}{}, "ForkIDs": struct{}{}, "OpCodeSelect":struct{}{}, + "Is1559":struct{}{}, } diff --git a/plugins/test-plugin/main.go b/plugins/test-plugin/main.go index 766bc8cc8..ac8475bc1 100644 --- a/plugins/test-plugin/main.go +++ b/plugins/test-plugin/main.go @@ -130,6 +130,8 @@ func BlockChain() { delete(plugins, "ForkIDs") case f("OpCodeSelect"): delete(plugins, "OpCodeSelect") + case f("Is1559"): + delete(plugins, "Is1559") } } } From 1dd00d245204ba052bdfa41b3bdb4cf89d5fdc7d Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Mon, 23 Oct 2023 18:41:19 -0700 Subject: [PATCH 20/26] Added PluginEIPCheck to test plugin --- plugins/test-plugin/hooks.go | 9 +++++++++ plugins/test-plugin/main.go | 2 ++ 2 files changed, 11 insertions(+) diff --git a/plugins/test-plugin/hooks.go b/plugins/test-plugin/hooks.go index cea477ab8..b1a11e44a 100644 --- a/plugins/test-plugin/hooks.go +++ b/plugins/test-plugin/hooks.go @@ -230,6 +230,14 @@ func Is1559(*big.Int) bool { // while this hook resides in params the injections return true } +func Is160(num *big.Int) bool { + m := map[string]struct{}{ + "PluginEIPCheck":struct{}{}, + } + hookChan <- m + return true +} + var plugins map[string]struct{} = map[string]struct{}{ "OnShutdown": struct{}{}, "SetTrieFlushIntervalClone":struct{}{}, @@ -269,5 +277,6 @@ var plugins map[string]struct{} = map[string]struct{}{ "ForkIDs": struct{}{}, "OpCodeSelect":struct{}{}, "Is1559":struct{}{}, + "PluginEIPCheck":struct{}{}, } diff --git a/plugins/test-plugin/main.go b/plugins/test-plugin/main.go index ac8475bc1..75cba1eee 100644 --- a/plugins/test-plugin/main.go +++ b/plugins/test-plugin/main.go @@ -132,6 +132,8 @@ func BlockChain() { delete(plugins, "OpCodeSelect") case f("Is1559"): delete(plugins, "Is1559") + case f("PluginEIPCheck"): + delete(plugins, "PluginEIPCheck") } } } From e42a4cb94493611c7b109f3e7a48c7a11c593e46 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Tue, 24 Oct 2023 09:29:09 -0500 Subject: [PATCH 21/26] Use EIP160 case instead of EIP158 --- core/vm/jump_table_export.go | 1 - 1 file changed, 1 deletion(-) diff --git a/core/vm/jump_table_export.go b/core/vm/jump_table_export.go index 5f4a71a6e..78b30c577 100644 --- a/core/vm/jump_table_export.go +++ b/core/vm/jump_table_export.go @@ -49,7 +49,6 @@ func LookupInstructionSet(rules params.Rules) (JumpTable, error) { // Begin plugeth injection case rules.IsEIP160: // End plugeth injection - case rules.IsEIP158: return newSpuriousDragonInstructionSet(), nil case rules.IsEIP150: return newTangerineWhistleInstructionSet(), nil From cd9d109d65aaaa64b24b764a187b2323fcb892cd Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Tue, 24 Oct 2023 10:58:21 -0500 Subject: [PATCH 22/26] Fix interpreter instruction set selection --- core/vm/interpreter.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 8d6270b77..bf1b18971 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -72,7 +72,7 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter { table = &constantinopleInstructionSet case evm.chainRules.IsByzantium: table = &byzantiumInstructionSet - case evm.chainRules.IsEIP158: + case evm.chainRules.IsEIP160: table = &spuriousDragonInstructionSet case evm.chainRules.IsEIP150: table = &tangerineWhistleInstructionSet From 20a51847a8c7b1db5ad61ec266e9c2410c9d73a7 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Tue, 24 Oct 2023 11:06:29 -0500 Subject: [PATCH 23/26] Add plugeth injection comment --- core/vm/interpreter.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index bf1b18971..83f530e0a 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -72,7 +72,9 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter { table = &constantinopleInstructionSet case evm.chainRules.IsByzantium: table = &byzantiumInstructionSet + // begin PluGeth injection case evm.chainRules.IsEIP160: + // end PluGeth injection table = &spuriousDragonInstructionSet case evm.chainRules.IsEIP150: table = &tangerineWhistleInstructionSet From 325fc8351edf7ec75f35be009789985653357be4 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Tue, 24 Oct 2023 09:24:39 -0700 Subject: [PATCH 24/26] Removed comments in core/forkid/plugin_hooks --- core/forkid/plugin_hooks.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/core/forkid/plugin_hooks.go b/core/forkid/plugin_hooks.go index b9102c9b8..a95ee0911 100644 --- a/core/forkid/plugin_hooks.go +++ b/core/forkid/plugin_hooks.go @@ -14,18 +14,6 @@ func PluginForkIDs(pl *plugins.PluginLoader, byBlock, byTime []uint64) ([]uint64 return pluginByBlock, pluginByTime, ok - // fnList := pl.Lookup("ForkIDs", func(item interface{}) bool { - // _, ok := item.(func([]uint64, []uint64) ([]uint64, []uint64)) - // return ok - // }) - // for _, fni := range fnList { - // if fn, ok := fni.(func([]uint64, []uint64) ([]uint64, []uint64)); ok { - // pluginByBlock, pluginByTime := fn(byBlock, byTime) - // return pluginByBlock, pluginByTime, true - // } - // } - - // return nil, nil, false } func pluginForkIDs(byBlock, byTime []uint64) ([]uint64, []uint64, bool) { From 336d39d2381ddf83eed47856fc389069535294d3 Mon Sep 17 00:00:00 2001 From: Austin Roberts Date: Mon, 30 Oct 2023 11:39:14 -0500 Subject: [PATCH 25/26] Update plugeth-utils in go.mod --- go.mod | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e2395b2a4..0a8194ab6 100644 --- a/go.mod +++ b/go.mod @@ -52,7 +52,7 @@ require ( github.com/mattn/go-isatty v0.0.16 github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416 github.com/olekukonko/tablewriter v0.0.5 - github.com/openrelayxyz/plugeth-utils v1.3.0 + github.com/openrelayxyz/plugeth-utils v1.4.0 github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 github.com/protolambda/bls12-381-util v0.0.0-20220416220906-d8552aa452c7 github.com/rs/cors v1.7.0 @@ -134,5 +134,3 @@ require ( gotest.tools/v3 v3.5.0 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) - -replace github.com/openrelayxyz/plugeth-utils => /home/philip/src/rivet/plugeth_superspace/plugeth-utils From 9974ce6f92cc5414596a18417d6246fd31aec2f0 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Mon, 30 Oct 2023 10:43:04 -0700 Subject: [PATCH 26/26] Modified pluginOpCodeSelect injection --- core/vm/interpreter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index 83f530e0a..6dd4b334d 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -98,7 +98,9 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter { } evm.Config.ExtraEips = extraEips // begin PluGeth injection - table = pluginOpCodeSelect(table) + if pluginTable := pluginOpCodeSelect(table); pluginTable != nil { + table = pluginTable + } // end PluGeth injection return &EVMInterpreter{evm: evm, table: table} }