From 7a0271e4d1338ab393f10b775152a4f1f0fa048f Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Mon, 11 Mar 2024 10:58:47 +0800 Subject: [PATCH] temp dump traces --- eth/tracers/api_blocktrace.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/eth/tracers/api_blocktrace.go b/eth/tracers/api_blocktrace.go index 3fc08e849f3e..b9821f1fd66e 100644 --- a/eth/tracers/api_blocktrace.go +++ b/eth/tracers/api_blocktrace.go @@ -2,7 +2,10 @@ package tracers import ( "context" + "encoding/json" "errors" + "fmt" + "os" "github.com/scroll-tech/go-ethereum/consensus" "github.com/scroll-tech/go-ethereum/core" @@ -107,5 +110,19 @@ func (api *API) createTraceEnvAndGetBlockTrace(ctx context.Context, config *Trac } chaindb := api.backend.ChainDb() - return api.scrollTracerWrapper.CreateTraceEnvAndGetBlockTrace(api.backend.ChainConfig(), api.chainContext(ctx), api.backend.Engine(), chaindb, statedb, parent, block, true) + + traces, err := api.scrollTracerWrapper.CreateTraceEnvAndGetBlockTrace(api.backend.ChainConfig(), api.chainContext(ctx), api.backend.Engine(), chaindb, statedb, parent, block, true) + if err != nil { + return nil, err + } + tracesByt, err := json.Marshal(traces) + if err != nil { + return nil, err + } + fileName := fmt.Sprintf("/l2geth/data/%s.json", block.Transactions()[0].Hash().Hex()) + err = os.WriteFile(fileName, tracesByt, 0644) + if err != nil { + return nil, err + } + return nil, nil }