Skip to content

Commit 643b5dc

Browse files
authored
Merge pull request #1673 from rodion-lim-partior/debug_traceCall_on_private_txn
Fix bug with private transactions not simulated with debug_traceCall
2 parents 65de7ae + 655889d commit 643b5dc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

eth/tracers/api.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"errors"
2424
"fmt"
2525
"io/ioutil"
26+
"math/big"
2627
"os"
2728
"runtime"
2829
"sync"
@@ -910,10 +911,21 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.CallArgs, blockNrOrHa
910911
Reexec: config.Reexec,
911912
}
912913
}
913-
res, err := api.traceTx(ctx, msg, new(txTraceContext), vmctx, statedb, privateStateDb, privateStateRepo, noTracerConfig) // test private with no config
914-
if exeRes, ok := res.(*ethapi.ExecutionResult); ok && err == nil && len(exeRes.StructLogs) > 0 { // check there is a result
914+
915+
// create a mock private context
916+
emptyTx := types.NewTransaction(
917+
0,
918+
common.Address{},
919+
big.NewInt(0), 0, big.NewInt(0),
920+
nil,
921+
)
922+
emptyTx.SetPrivate()
923+
traceContext := &txTraceContext{tx: emptyTx}
924+
925+
res, err := api.traceTx(ctx, msg, traceContext, vmctx, statedb, privateStateDb, privateStateRepo, noTracerConfig) // test private with no config
926+
if exeRes, ok := res.(*ethapi.ExecutionResult); ok && err == nil && len(exeRes.StructLogs) > 0 { // check there is a result
915927
if config != nil && config.Tracer != nil { // re-run the private call with the custom JS tracer
916-
return api.traceTx(ctx, msg, new(txTraceContext), vmctx, statedb, privateStateDb, privateStateRepo, traceConfig) // re-run with trace
928+
return api.traceTx(ctx, msg, traceContext, vmctx, statedb, privateStateDb, privateStateRepo, traceConfig) // re-run with trace
917929
}
918930
return res, err // return private result with no tracer
919931
} else if err == nil && !ok {

0 commit comments

Comments
 (0)