Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with private transactions not simulated with debug_traceCall #1673

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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