Fix tracer loading

This commit is contained in:
Austin Roberts
2021-06-25 23:27:09 -05:00
parent b821bd9948
commit 4dd3527541
6 changed files with 24 additions and 141 deletions
+2 -1
View File
@@ -40,6 +40,7 @@ import (
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/plugins/interfaces"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
)
@@ -850,7 +851,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *txTrac
StructLogs: ethapi.FormatLogs(tracer.StructLogs()),
}, nil
case TracerResult:
case interfaces.TracerResult:
return tracer.GetResult()
case *Tracer:
+9 -12
View File
@@ -2,33 +2,30 @@ package tracers
import (
"github.com/ethereum/go-ethereum/plugins"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/plugins/interfaces"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/log"
"reflect"
)
type TracerResult interface {
vm.Tracer
GetResult() (interface{}, error)
}
func GetPluginTracer(pl *plugins.PluginLoader, name string) (func(*state.StateDB)TracerResult, bool) {
func GetPluginTracer(pl *plugins.PluginLoader, name string) (func(*state.StateDB)interfaces.TracerResult, bool) {
tracers := pl.Lookup("Tracers", func(item interface{}) bool {
_, ok := item.(map[string]func(*state.StateDB)TracerResult)
_, ok := item.(*map[string]func(*state.StateDB)interfaces.TracerResult)
if !ok { log.Warn("Found tracer that did not match type", "tracer", reflect.TypeOf(item) ) }
return ok
})
for _, tmap := range tracers {
if tracerMap, ok := tmap.(map[string]func(*state.StateDB)TracerResult); ok {
if tracer, ok := tracerMap[name]; ok {
if tracerMap, ok := tmap.(*map[string]func(*state.StateDB)interfaces.TracerResult); ok {
if tracer, ok := (*tracerMap)[name]; ok {
return tracer, true
}
}
}
log.Info("Tracer not found", "name", name, "tracers", len(tracers))
return nil, false
}
func getPluginTracer(name string) (func(*state.StateDB)TracerResult, bool) {
func getPluginTracer(name string) (func(*state.StateDB)interfaces.TracerResult, bool) {
if plugins.DefaultPluginLoader == nil {
log.Warn("Attempting GetPluginTracer, but default PluginLoader has not been initialized")
return nil, false