@@ -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