@@ -4,72 +4,32 @@ import (
44 "encoding/json"
55 "fmt"
66
7- "github.com/ethereum/go-ethereum/core/types "
7+ "github.com/ethereum/go-ethereum/common "
88 "github.com/ethereum/go-ethereum/eth/tracers"
9-
10- "github.com/iotaledger/wasp/packages/evm/evmutil"
119)
1210
13- type Tracer struct {
14- * tracers.Tracer
15- TraceFakeTx func (tx * types.Transaction ) (json.RawMessage , error )
16- }
17-
18- type tracerFactory func (traceCtx * tracers.Context , cfg json.RawMessage , traceBlock bool , initValue any ) (* Tracer , error )
11+ type tracerFactory func (traceCtx * tracers.Context , cfg json.RawMessage ) (* tracers.Tracer , error )
1912
2013var allTracers = map [string ]tracerFactory {}
2114
2215func registerTracer (tracerType string , fn tracerFactory ) {
2316 allTracers [tracerType ] = fn
2417}
2518
26- func newTracer (tracerType string , ctx * tracers.Context , cfg json.RawMessage , traceBlock bool , initValue any ) (* Tracer , error ) {
19+ func newTracer (
20+ tracerType string ,
21+ ctx * tracers.Context ,
22+ cfg json.RawMessage ,
23+ ) (* tracers.Tracer , error ) {
2724 fn := allTracers [tracerType ]
2825 if fn == nil {
2926 return nil , fmt .Errorf ("unsupported tracer type: %s" , tracerType )
3027 }
31- return fn (ctx , cfg , traceBlock , initValue )
28+ return fn (ctx , cfg )
3229}
3330
34- func GetTraceResults (
35- blockTxs []* types.Transaction ,
36- traceBlock bool ,
37- getFakeTxTrace func (tx * types.Transaction ) (json.RawMessage , error ),
38- getTxTrace func (tx * types.Transaction ) (json.RawMessage , error ),
39- getSingleTxTrace func () (json.RawMessage , error ),
40- reason error ,
41- ) (json.RawMessage , error ) {
42- var traceResult []byte
43- var err error
44- if traceBlock {
45- results := make ([]TxTraceResult , 0 , len (blockTxs ))
46- var jsResult json.RawMessage
47- for _ , tx := range blockTxs {
48- if evmutil .IsFakeTransaction (tx ) {
49- jsResult , err = getFakeTxTrace (tx )
50- if err != nil {
51- return nil , err
52- }
53- } else {
54- jsResult , err = getTxTrace (tx )
55- if err != nil {
56- return nil , err
57- }
58- }
59-
60- results = append (results , TxTraceResult {TxHash : tx .Hash (), Result : jsResult })
61- }
62-
63- traceResult , err = json .Marshal (results )
64- if err != nil {
65- return nil , err
66- }
67- } else {
68- traceResult , err = getSingleTxTrace ()
69- if err != nil {
70- return nil , err
71- }
72- }
73-
74- return traceResult , reason
31+ type TxTraceResult struct {
32+ TxHash common.Hash `json:"txHash"` // transaction hash
33+ Result json.RawMessage `json:"result,omitempty"` // Trace results produced by the tracer
34+ Error string `json:"error,omitempty"` // Trace failure produced by the tracer
7535}
0 commit comments