From ec965607cd93dc53332052a939a21faa24c7d876 Mon Sep 17 00:00:00 2001 From: philip-morlier Date: Tue, 15 Feb 2022 16:56:50 -0800 Subject: [PATCH] Cahnges made in service of pretracer type. --- core/plugin_hooks.go | 5 +++++ core/state_transition.go | 3 +++ go.mod | 2 ++ plugins/wrappers/wrappers.go | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/core/plugin_hooks.go b/core/plugin_hooks.go index e1a2544bb..f0c61667c 100644 --- a/core/plugin_hooks.go +++ b/core/plugin_hooks.go @@ -185,6 +185,11 @@ func pluginReorg(commonBlock *types.Block, oldChain, newChain types.Blocks) { PluginReorg(plugins.DefaultPluginLoader, commonBlock, oldChain, newChain) } +type PreTracer interface { + CapturePreStart(from common.Address, to *common.Address, input []byte, gas uint64, value *big.Int) + +} + type metaTracer struct { tracers []core.BlockTracer } diff --git a/core/state_transition.go b/core/state_transition.go index 05d563307..daf45cd0f 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -284,6 +284,9 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { // 6. caller has enough balance to cover asset transfer for **topmost** call // Check clauses 1-3, buy gas if everything is correct + if v, ok := st.evm.Config.Tracer.(PreTracer); ok { + v.CapturePreStart(st.msg.From(), st.msg.To(), st.data, st.gas, st.msg.Value()) + } if err := st.preCheck(); err != nil { return nil, err } diff --git a/go.mod b/go.mod index 62f87601e..3edfa84eb 100644 --- a/go.mod +++ b/go.mod @@ -74,3 +74,5 @@ require ( gotest.tools v2.2.0+incompatible // indirect ) + +replace github.com/openrelayxyz/plugeth-utils v0.0.14 => ../plugeth-utils diff --git a/plugins/wrappers/wrappers.go b/plugins/wrappers/wrappers.go index 0b0389f4a..eada1aaa5 100644 --- a/plugins/wrappers/wrappers.go +++ b/plugins/wrappers/wrappers.go @@ -73,6 +73,10 @@ type WrappedTracer struct { func NewWrappedTracer(r core.TracerResult) *WrappedTracer { return &WrappedTracer{r} } +func (w WrappedTracer) CapturePreStart(from common.Address, to *common.Address, input []byte, gas uint64, value *big.Int) { + if v, ok := w.r.(core.PreTracer); ok { + v.CapturePreStart(core.Address(from), (*core.Address)(to), input, gas, value)} +} func (w WrappedTracer) CaptureStart(env *vm.EVM, from common.Address, to common.Address, create bool, input []byte, gas uint64, value *big.Int) { w.r.CaptureStart(core.Address(from), core.Address(to), create, input, gas, value) }