Skip to content

Commit

Permalink
Merge branch 'v1.1.12-eigenphi' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
cannium committed Sep 23, 2022
2 parents 6f6bbcf + debc046 commit d5e7033
Show file tree
Hide file tree
Showing 7 changed files with 1,576 additions and 2 deletions.
4 changes: 4 additions & 0 deletions core/vm/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ func (evm *EVM) Reset(txCtx TxContext, statedb StateDB) {
evm.StateDB = statedb
}

func (evm *EVM) Depth() int {
return evm.depth
}

// Cancel cancels any running EVM operation. This may be called concurrently and
// it's safe to be called multiple times.
func (evm *EVM) Cancel() {
Expand Down
23 changes: 21 additions & 2 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"bufio"
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io/ioutil"
Expand Down Expand Up @@ -172,6 +173,7 @@ type TraceConfig struct {
Tracer *string
Timeout *string
Reexec *uint64
Plain bool
}

// TraceCallConfig is the config for traceCall API. It holds one more
Expand Down Expand Up @@ -900,12 +902,14 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex
tracer vm.EVMLogger
err error
txContext = core.NewEVMTxContext(message)
plain = false
)
switch {
case config == nil:
tracer = logger.NewStructLogger(nil)
case config.Tracer != nil:
// Define a meaningful timeout of a single transaction trace
plain = config.Plain
timeout := defaultTraceTimeout
if config.Timeout != nil {
if timeout, err = time.ParseDuration(*config.Timeout); err != nil {
Expand Down Expand Up @@ -962,15 +966,30 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex
ReturnValue: returnVal,
StructLogs: ethapi.FormatLogs(tracer.StructLogs()),
}, nil

case Tracer:
return tracer.GetResult()
result, err := tracer.GetResult()
if !plain {
return result, err
}
return PlainTraceByTx{
BlockNumber: vmctx.BlockNumber.Uint64(),
TransactionHash: txctx.TxHash.String(),
TransactionIndex: uint64(txctx.TxIndex),
PlainTraces: result,
}, err

default:
panic(fmt.Sprintf("bad tracer type %T", tracer))
}
}

type PlainTraceByTx struct {
BlockNumber uint64 `json:"blockNumber"`
TransactionHash string `json:"transactionHash"`
TransactionIndex uint64 `json:"transactionIndex"`
PlainTraces json.RawMessage `json:"plainTraces"`
}

// APIs return the collection of RPC services the tracer package offers.
func APIs(backend Backend) []rpc.API {
// Append all the local APIs and return
Expand Down
Loading

0 comments on commit d5e7033

Please sign in to comment.