Skip to content

Commit

Permalink
Merge pull request #1673 from rodion-lim-partior/debug_traceCall_on_p…
Browse files Browse the repository at this point in the history
…rivate_txn

Fix bug with private transactions not simulated with debug_traceCall
  • Loading branch information
Krish1979 authored Sep 14, 2023
2 parents 65de7ae + 655889d commit 643b5dc
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"math/big"
"os"
"runtime"
"sync"
Expand Down Expand Up @@ -910,10 +911,21 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHa
Reexec: config.Reexec,
}
}
res, err := api.traceTx(ctx, msg, new(txTraceContext), vmctx, statedb, privateStateDb, privateStateRepo, noTracerConfig) // test private with no config
if exeRes, ok := res.(*ethapi.ExecutionResult); ok && err == nil && len(exeRes.StructLogs) > 0 { // check there is a result

// create a mock private context
emptyTx := types.NewTransaction(
0,
common.Address{},
big.NewInt(0), 0, big.NewInt(0),
nil,
)
emptyTx.SetPrivate()
traceContext := &txTraceContext{tx: emptyTx}

res, err := api.traceTx(ctx, msg, traceContext, vmctx, statedb, privateStateDb, privateStateRepo, noTracerConfig) // test private with no config
if exeRes, ok := res.(*ethapi.ExecutionResult); ok && err == nil && len(exeRes.StructLogs) > 0 { // check there is a result
if config != nil && config.Tracer != nil { // re-run the private call with the custom JS tracer
return api.traceTx(ctx, msg, new(txTraceContext), vmctx, statedb, privateStateDb, privateStateRepo, traceConfig) // re-run with trace
return api.traceTx(ctx, msg, traceContext, vmctx, statedb, privateStateDb, privateStateRepo, traceConfig) // re-run with trace
}
return res, err // return private result with no tracer
} else if err == nil && !ok {
Expand Down

0 comments on commit 643b5dc

Please sign in to comment.