Modified hooks for plugeth-utils functionality
This commit is contained in:
parent
8291edc416
commit
f615e3813d
@ -2,25 +2,26 @@ package state
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/opoenrelayxyz/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) {
|
||||
func PluginStateUpdate(pl *plugins.PluginLoader, blockRoot, parentRoot core.Hash, destructs map[core.Hash]struct{}, accounts map[core.Hash][]byte, storage map[core.Hash]map[core.Hash][]byte) {
|
||||
fnList := pl.Lookup("StateUpdate", func(item interface{}) bool {
|
||||
_, ok := item.(func(common.Hash, common.Hash, map[common.Hash]struct{}, map[common.Hash][]byte, map[common.Hash]map[common.Hash][]byte))
|
||||
_, ok := item.(func(core.Hash, core.Hash, map[core.Hash]struct{}, map[core.Hash][]byte, map[core.Hash]map[core.Hash][]byte))
|
||||
return ok
|
||||
})
|
||||
for _, fni := range fnList {
|
||||
if fn, ok := fni.(func(common.Hash, common.Hash, map[common.Hash]struct{}, map[common.Hash][]byte, map[common.Hash]map[common.Hash][]byte)); ok {
|
||||
if fn, ok := fni.(func(core.Hash, core.Hash, map[core.Hash]struct{}, map[core.Hash][]byte, map[core.Hash]map[core.Hash][]byte)); ok {
|
||||
fn(blockRoot, parentRoot, destructs, accounts, storage)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func pluginStateUpdate(blockRoot, parentRoot common.Hash, destructs map[common.Hash]struct{}, accounts map[common.Hash][]byte, storage map[common.Hash]map[common.Hash][]byte) {
|
||||
func pluginStateUpdate(blockRoot, parentRoot core.Hash, destructs map[core.Hash]struct{}, accounts map[core.Hash][]byte, storage map[core.Hash]map[core.Hash][]byte) {
|
||||
if plugins.DefaultPluginLoader == nil {
|
||||
log.Warn("Attempting StateUpdate, but default PluginLoader has not been initialized")
|
||||
return
|
||||
|
@ -1,17 +1,18 @@
|
||||
package eth
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/consensus/ethash"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||
"github.com/ethereum/go-ethereum/ethdb"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/node"
|
||||
"github.com/ethereum/go-ethereum/params"
|
||||
"github.com/ethereum/go-ethereum/plugins"
|
||||
"github.com/opoenrelayxyz/plugeth-utils/core"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"time"
|
||||
)
|
||||
@ -37,9 +38,9 @@ import (
|
||||
// return PluginCreateConsensusEngine(plugins.DefaultPluginLoader, stack, chainConfig, config, notify, noverify, db)
|
||||
// }
|
||||
|
||||
// TODO (philip): Translate to core.Tracer instead of vm.Tracer, with appropriate type adjustments (let me know if this one is too hard)
|
||||
// TODO (philip): Translate to core.Tracer instead of core.Tracer, with appropriate type adjustments (let me know if this one is too hard)
|
||||
type metaTracer struct {
|
||||
tracers []vm.Tracer
|
||||
tracers []core.Tracer
|
||||
}
|
||||
|
||||
func (mt *metaTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) {
|
||||
@ -65,14 +66,14 @@ func (mt *metaTracer) CaptureEnd(output []byte, gasUsed uint64, t time.Duration,
|
||||
|
||||
func PluginUpdateBlockchainVMConfig(pl *plugins.PluginLoader, cfg *vm.Config) {
|
||||
tracerList := plugins.Lookup("LiveTracer", func(item interface{}) bool {
|
||||
_, ok := item.(*vm.Tracer)
|
||||
_, ok := item.(*core.Tracer)
|
||||
log.Info("Item is LiveTracer", "ok", ok, "type", reflect.TypeOf(item))
|
||||
return ok
|
||||
})
|
||||
if len(tracerList) > 0 {
|
||||
mt := &metaTracer{tracers: []vm.Tracer{}}
|
||||
for _, tracer := range(tracerList) {
|
||||
if v, ok := tracer.(*vm.Tracer); ok {
|
||||
mt := &metaTracer{tracers: []core.Tracer{}}
|
||||
for _, tracer := range tracerList {
|
||||
if v, ok := tracer.(*core.Tracer); ok {
|
||||
log.Info("LiveTracer registered")
|
||||
mt.tracers = append(mt.tracers, *v)
|
||||
} else {
|
||||
@ -97,7 +98,6 @@ func PluginUpdateBlockchainVMConfig(pl *plugins.PluginLoader, cfg *vm.Config) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func pluginUpdateBlockchainVMConfig(cfg *vm.Config) {
|
||||
if plugins.DefaultPluginLoader == nil {
|
||||
log.Warn("Attempting CreateConsensusEngine, but default PluginLoader has not been initialized")
|
||||
|
Loading…
Reference in New Issue
Block a user