Cahnges made in service of pretracer type.

This commit is contained in:
philip-morlier 2022-02-15 16:56:50 -08:00
parent 4549968e8e
commit ec965607cd
4 changed files with 14 additions and 0 deletions

View File

@ -185,6 +185,11 @@ func pluginReorg(commonBlock *types.Block, oldChain, newChain types.Blocks) {
PluginReorg(plugins.DefaultPluginLoader, commonBlock, oldChain, newChain) 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 { type metaTracer struct {
tracers []core.BlockTracer tracers []core.BlockTracer
} }

View File

@ -284,6 +284,9 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
// 6. caller has enough balance to cover asset transfer for **topmost** call // 6. caller has enough balance to cover asset transfer for **topmost** call
// Check clauses 1-3, buy gas if everything is correct // 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 { if err := st.preCheck(); err != nil {
return nil, err return nil, err
} }

2
go.mod
View File

@ -74,3 +74,5 @@ require (
gotest.tools v2.2.0+incompatible // indirect gotest.tools v2.2.0+incompatible // indirect
) )
replace github.com/openrelayxyz/plugeth-utils v0.0.14 => ../plugeth-utils

View File

@ -73,6 +73,10 @@ type WrappedTracer struct {
func NewWrappedTracer(r core.TracerResult) *WrappedTracer { func NewWrappedTracer(r core.TracerResult) *WrappedTracer {
return &WrappedTracer{r} 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) { 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) w.r.CaptureStart(core.Address(from), core.Address(to), create, input, gas, value)
} }