From 52852c0850e6e39ef6a43b3656cb4f24dd836726 Mon Sep 17 00:00:00 2001 From: ledgerwatch Date: Wed, 16 Mar 2022 16:21:40 +0000 Subject: [PATCH] rpcdaemon: fix TxContext in traceBlock (#3716) (#3718) Previously `txCtx` is not updated for every tx, which leads to wrong tracing results. Co-authored-by: can --- cmd/rpcdaemon/commands/tracing.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/rpcdaemon/commands/tracing.go b/cmd/rpcdaemon/commands/tracing.go index eb1acc9af..23e21137b 100644 --- a/cmd/rpcdaemon/commands/tracing.go +++ b/cmd/rpcdaemon/commands/tracing.go @@ -11,6 +11,7 @@ import ( "github.com/ledgerwatch/erigon/core/rawdb" "github.com/ledgerwatch/erigon/core/state" "github.com/ledgerwatch/erigon/core/types" + "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/eth/tracers" "github.com/ledgerwatch/erigon/ethdb" "github.com/ledgerwatch/erigon/internal/ethapi" @@ -65,7 +66,7 @@ func (api *PrivateDebugAPIImpl) traceBlock(ctx context.Context, blockNrOrHash rp return rawdb.ReadHeader(tx, hash, number) } - _, blockCtx, txCtx, ibs, reader, err := transactions.ComputeTxEnv(ctx, block, chainConfig, getHeader, contractHasTEVM, ethash.NewFaker(), tx, block.Hash(), 0) + _, blockCtx, _, ibs, reader, err := transactions.ComputeTxEnv(ctx, block, chainConfig, getHeader, contractHasTEVM, ethash.NewFaker(), tx, block.Hash(), 0) if err != nil { stream.WriteNil() return err @@ -82,6 +83,11 @@ func (api *PrivateDebugAPIImpl) traceBlock(ctx context.Context, blockNrOrHash rp } ibs.Prepare(tx.Hash(), block.Hash(), idx) msg, _ := tx.AsMessage(*signer, block.BaseFee()) + txCtx := vm.TxContext{ + TxHash: tx.Hash(), + Origin: msg.From(), + GasPrice: msg.GasPrice().ToBig(), + } transactions.TraceTx(ctx, msg, blockCtx, txCtx, ibs, config, chainConfig, stream) _ = ibs.FinalizeTx(chainConfig.Rules(blockCtx.BlockNumber), reader)