@@ -178,13 +178,6 @@ type StdTraceConfig struct {
178178 TxHash common.Hash
179179}
180180
181- // txTraceContext is the contextual infos about a transaction before it gets run.
182- type txTraceContext struct {
183- index int // Index of the transaction within the block
184- hash common.Hash // Hash of the transaction
185- block common.Hash // Hash of the block containing the transaction
186- }
187-
188181// txTraceResult is the result of a single transaction trace.
189182type txTraceResult struct {
190183 Result interface {} `json:"result,omitempty"` // Trace results produced by the tracer
@@ -272,10 +265,10 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config
272265 // Trace all the transactions contained within
273266 for i , tx := range task .block .Transactions () {
274267 msg , _ := tx .AsMessage (signer , task .block .BaseFee ())
275- txctx := & txTraceContext {
276- index : i ,
277- hash : tx . Hash () ,
278- block : task . block .Hash (),
268+ txctx := & Context {
269+ BlockHash : task . block . Hash () ,
270+ TxIndex : i ,
271+ TxHash : tx .Hash (),
279272 }
280273 res , err := api .traceTx (localctx , msg , txctx , blockCtx , task .statedb , config )
281274 if err != nil {
@@ -524,10 +517,10 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
524517 // Fetch and execute the next transaction trace tasks
525518 for task := range jobs {
526519 msg , _ := txs [task .index ].AsMessage (signer , block .BaseFee ())
527- txctx := & txTraceContext {
528- index : task . index ,
529- hash : txs [ task .index ]. Hash () ,
530- block : blockHash ,
520+ txctx := & Context {
521+ BlockHash : blockHash ,
522+ TxIndex : task .index ,
523+ TxHash : txs [ task . index ]. Hash () ,
531524 }
532525 res , err := api .traceTx (ctx , msg , txctx , blockCtx , task .statedb , config )
533526 if err != nil {
@@ -718,10 +711,10 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
718711 if err != nil {
719712 return nil , err
720713 }
721- txctx := & txTraceContext {
722- index : int ( index ) ,
723- hash : hash ,
724- block : blockHash ,
714+ txctx := & Context {
715+ BlockHash : blockHash ,
716+ TxIndex : int ( index ) ,
717+ TxHash : hash ,
725718 }
726719 return api .traceTx (ctx , msg , txctx , vmctx , statedb , config )
727720}
@@ -777,13 +770,13 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
777770 Reexec : config .Reexec ,
778771 }
779772 }
780- return api .traceTx (ctx , msg , new (txTraceContext ), vmctx , statedb , traceConfig )
773+ return api .traceTx (ctx , msg , new (Context ), vmctx , statedb , traceConfig )
781774}
782775
783776// traceTx configures a new tracer according to the provided configuration, and
784777// executes the given message in the provided environment. The return value will
785778// be tracer dependent.
786- func (api * API ) traceTx (ctx context.Context , message core.Message , txctx * txTraceContext , vmctx vm.BlockContext , statedb * state.StateDB , config * TraceConfig ) (interface {}, error ) {
779+ func (api * API ) traceTx (ctx context.Context , message core.Message , txctx * Context , vmctx vm.BlockContext , statedb * state.StateDB , config * TraceConfig ) (interface {}, error ) {
787780 // Assemble the structured logger or the JavaScript tracer
788781 var (
789782 tracer vm.Tracer
@@ -800,7 +793,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *txTrac
800793 }
801794 }
802795 // Constuct the JavaScript tracer to execute with
803- if tracer , err = New (* config .Tracer , txContext ); err != nil {
796+ if tracer , err = New (* config .Tracer , txctx ); err != nil {
804797 return nil , err
805798 }
806799 // Handle timeouts and RPC cancellations
@@ -823,7 +816,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *txTrac
823816 vmenv := vm .NewEVM (vmctx , txContext , statedb , api .backend .ChainConfig (), vm.Config {Debug : true , Tracer : tracer , NoBaseFee : true })
824817
825818 // Call Prepare to clear out the statedb access list
826- statedb .Prepare (txctx .hash , txctx .block , txctx .index )
819+ statedb .Prepare (txctx .TxHash , txctx .BlockHash , txctx .TxIndex )
827820
828821 result , err := core .ApplyMessage (vmenv , message , new (core.GasPool ).AddGas (message .Gas ()))
829822 if err != nil {
0 commit comments