diff --git a/core/blockchain_hooks_test.go b/core/blockchain_hooks_test.go index 27c9253b8..09df94e62 100644 --- a/core/blockchain_hooks_test.go +++ b/core/blockchain_hooks_test.go @@ -1,22 +1,29 @@ package core import ( - "testing" - "github.com/ethereum/go-ethereum/plugins" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/common" + "testing" + + "github.com/ethereum/go-ethereum/plugins" + "github.com/openrelayxyz/plugeth-utils/core" ) - func TestReorgLongHeadersHook(t *testing.T) { - invoked := false - done := plugins.HookTester("NewHead", func(b *types.Block, h common.Hash, logs []*types.Log) { - // invoked = true - if b == nil { t.Errorf("Expected block to be non-nil") } - if h == (common.Hash{}) { t.Errorf("Expected hash to be non-empty") } - if len(logs) > 0 { t.Errorf("Expected some logs") } - }) - defer done() - testReorgLong(t, true) - if !invoked { t.Errorf("Expected plugin invocation")} + invoked := false + done := plugins.HookTester("NewHead", func(b []byte, h core.Hash, logs [][]byte) { + invoked = true + if b == nil { + t.Errorf("Expected block to be non-nil") + } + if h == (core.Hash{}) { + t.Errorf("Expected hash to be non-empty") + } + if len(logs) > 0 { + t.Errorf("Expected some logs") + } + }) + defer done() + testReorgLong(t, true) + if !invoked { + t.Errorf("Expected plugin invocation") + } } diff --git a/core/state/plugin_hooks.go b/core/state/plugin_hooks.go index 46933901b..926fa8f5c 100644 --- a/core/state/plugin_hooks.go +++ b/core/state/plugin_hooks.go @@ -7,8 +7,6 @@ import ( "github.com/openrelayxyz/plugeth-utils/core" ) -// TODO (philip): change common.Hash to core.Hash, - func PluginStateUpdate(pl *plugins.PluginLoader, blockRoot, parentRoot common.Hash, destructs map[common.Hash]struct{}, accounts map[common.Hash][]byte, storage map[common.Hash]map[common.Hash][]byte) { fnList := pl.Lookup("StateUpdate", func(item interface{}) bool { _, ok := item.(func(core.Hash, core.Hash, map[core.Hash]struct{}, map[core.Hash][]byte, map[core.Hash]map[core.Hash][]byte)) diff --git a/eth/plugin_hooks.go b/eth/plugin_hooks.go index 14946cd5a..ce660c491 100644 --- a/eth/plugin_hooks.go +++ b/eth/plugin_hooks.go @@ -13,28 +13,6 @@ import ( "github.com/openrelayxyz/plugeth-utils/core" ) -// func PluginCreateConsensusEngine(pl *plugins.PluginLoader, stack *node.Node, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine { -// fnList := pl.Lookup("CreateConsensusEngine", func(item interface{}) bool { -// _, ok := item.(func(*node.Node, *params.ChainConfig, *ethash.Config, []string, bool, ethdb.Database) consensus.Engine) -// return ok -// }) -// for _, fni := range fnList { -// if fn, ok := fni.(func(*node.Node, *params.ChainConfig, *ethash.Config, []string, bool, ethdb.Database) consensus.Engine); ok { -// return fn(stack, chainConfig, config, notify, noverify, db) -// } -// } -// return ethconfig.CreateConsensusEngine(stack, chainConfig, config, notify, noverify, db) -// } -// -// func pluginCreateConsensusEngine(stack *node.Node, chainConfig *params.ChainConfig, config *ethash.Config, notify []string, noverify bool, db ethdb.Database) consensus.Engine { -// if plugins.DefaultPluginLoader == nil { -// log.Warn("Attempting CreateConsensusEngine, but default PluginLoader has not been initialized") -// return ethconfig.CreateConsensusEngine(stack, chainConfig, config, notify, noverify, db) -// } -// return PluginCreateConsensusEngine(plugins.DefaultPluginLoader, stack, chainConfig, config, notify, noverify, db) -// } - -// TODO (philip): Translate to core.TracerResult instead of vm.Tracer, with appropriate type adjustments (let me know if this one is too hard) type metaTracer struct { tracers []core.TracerResult } @@ -77,21 +55,11 @@ func PluginUpdateBlockchainVMConfig(pl *plugins.PluginLoader, cfg *vm.Config) { } } cfg.Debug = true - cfg.Tracer = mt //I think this means we will need a vm.config wrapper although confugure doesnt sound very passive + cfg.Tracer = mt } else { log.Warn("Module is not tracer") } - fnList := plugins.Lookup("UpdateBlockchainVMConfig", func(item interface{}) bool { - _, ok := item.(func(*vm.Config)) - return ok - }) - for _, fni := range fnList { - if fn, ok := fni.(func(*vm.Config)); ok { - fn(cfg) - return - } - } } func pluginUpdateBlockchainVMConfig(cfg *vm.Config) {