Skip to content

Commit b1afbb1

Browse files
authored
Revert "eth/tracers: add txHash field on txTraceResult (ethereum#27183)"
This reverts commit c2057f0.
1 parent 4e0c675 commit b1afbb1

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

eth/tracers/api.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ type StdTraceConfig struct {
176176

177177
// txTraceResult is the result of a single transaction trace.
178178
type txTraceResult struct {
179-
TxHash common.Hash `json:"txHash"` // transaction hash
180179
Result interface{} `json:"result,omitempty"` // Trace results produced by the tracer
181180
Error string `json:"error,omitempty"` // Trace failure produced by the tracer
182181
}
@@ -279,13 +278,13 @@ func (api *API) traceChain(start, end *types.Block, config *TraceConfig, closed
279278
}
280279
res, err := api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config)
281280
if err != nil {
282-
task.results[i] = &txTraceResult{TxHash: tx.Hash(), Error: err.Error()}
281+
task.results[i] = &txTraceResult{Error: err.Error()}
283282
log.Warn("Tracing failed", "hash", tx.Hash(), "block", task.block.NumberU64(), "err", err)
284283
break
285284
}
286285
// Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect
287286
task.statedb.Finalise(api.backend.ChainConfig().IsEIP158(task.block.Number()))
288-
task.results[i] = &txTraceResult{TxHash: tx.Hash(), Result: res}
287+
task.results[i] = &txTraceResult{Result: res}
289288
}
290289
// Tracing state is used up, queue it for de-referencing. Note the
291290
// state is the parent state of trace block, use block.number-1 as
@@ -616,7 +615,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
616615
if err != nil {
617616
return nil, err
618617
}
619-
results[i] = &txTraceResult{TxHash: tx.Hash(), Result: res}
618+
results[i] = &txTraceResult{Result: res}
620619
// Finalize the state so any modifications are written to the trie
621620
// Only delete empty objects if EIP158/161 (a.k.a Spurious Dragon) is in effect
622621
statedb.Finalise(is158)
@@ -657,10 +656,10 @@ func (api *API) traceBlockParallel(ctx context.Context, block *types.Block, stat
657656
}
658657
res, err := api.traceTx(ctx, msg, txctx, blockCtx, task.statedb, config)
659658
if err != nil {
660-
results[task.index] = &txTraceResult{TxHash: txs[task.index].Hash(), Error: err.Error()}
659+
results[task.index] = &txTraceResult{Error: err.Error()}
661660
continue
662661
}
663-
results[task.index] = &txTraceResult{TxHash: txs[task.index].Hash(), Result: res}
662+
results[task.index] = &txTraceResult{Result: res}
664663
}
665664
}()
666665
}

eth/tracers/api_test.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,12 @@ func TestTraceBlock(t *testing.T) {
384384
}
385385
genBlocks := 10
386386
signer := types.HomesteadSigner{}
387-
var txHash common.Hash
388387
backend := newTestBackend(t, genBlocks, genesis, func(i int, b *core.BlockGen) {
389388
// Transfer from account[0] to account[1]
390389
// value: 1000 wei
391390
// fee: 0 wei
392391
tx, _ := types.SignTx(types.NewTransaction(uint64(i), accounts[1].addr, big.NewInt(1000), params.TxGas, b.BaseFee(), nil), signer, accounts[0].key)
393392
b.AddTx(tx)
394-
txHash = tx.Hash()
395393
})
396394
defer backend.chain.Stop()
397395
api := NewAPI(backend)
@@ -410,7 +408,7 @@ func TestTraceBlock(t *testing.T) {
410408
// Trace head block
411409
{
412410
blockNumber: rpc.BlockNumber(genBlocks),
413-
want: fmt.Sprintf(`[{"txHash":"%v","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]`, txHash),
411+
want: `[{"result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]`,
414412
},
415413
// Trace non-existent block
416414
{
@@ -420,12 +418,12 @@ func TestTraceBlock(t *testing.T) {
420418
// Trace latest block
421419
{
422420
blockNumber: rpc.LatestBlockNumber,
423-
want: fmt.Sprintf(`[{"txHash":"%v","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]`, txHash),
421+
want: `[{"result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]`,
424422
},
425423
// Trace pending block
426424
{
427425
blockNumber: rpc.PendingBlockNumber,
428-
want: fmt.Sprintf(`[{"txHash":"%v","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]`, txHash),
426+
want: `[{"result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}]`,
429427
},
430428
}
431429
for i, tc := range testSuite {
@@ -855,7 +853,7 @@ func TestTraceChain(t *testing.T) {
855853
backend.relHook = func() { rel.Add(1) }
856854
api := NewAPI(backend)
857855

858-
single := `{"txHash":"0x0000000000000000000000000000000000000000000000000000000000000000","result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}`
856+
single := `{"result":{"gas":21000,"failed":false,"returnValue":"","structLogs":[]}}`
859857
var cases = []struct {
860858
start uint64
861859
end uint64
@@ -874,17 +872,16 @@ func TestTraceChain(t *testing.T) {
874872

875873
next := c.start + 1
876874
for result := range resCh {
877-
if have, want := uint64(result.Block), next; have != want {
878-
t.Fatalf("unexpected tracing block, have %d want %d", have, want)
875+
if next != uint64(result.Block) {
876+
t.Error("Unexpected tracing block")
879877
}
880-
if have, want := len(result.Traces), int(next); have != want {
881-
t.Fatalf("unexpected result length, have %d want %d", have, want)
878+
if len(result.Traces) != int(next) {
879+
t.Error("Unexpected tracing result")
882880
}
883881
for _, trace := range result.Traces {
884-
trace.TxHash = common.Hash{}
885882
blob, _ := json.Marshal(trace)
886-
if have, want := string(blob), single; have != want {
887-
t.Fatalf("unexpected tracing result, have\n%v\nwant:\n%v", have, want)
883+
if string(blob) != single {
884+
t.Error("Unexpected tracing result")
888885
}
889886
}
890887
next += 1

0 commit comments

Comments
 (0)