From 4e0daeb3007c322a8a2e242716bd43c7ff4f6550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Garamv=C3=B6lgyi?= Date: Fri, 9 Jun 2023 16:28:40 +0200 Subject: [PATCH] fix(trace): change l1Fee type from uint64 to *big.Int (#360) * fix: change l1Fee type from uint64 to *big.Int * use hexutil.Big --- core/types/l2trace.go | 8 ++++---- eth/tracers/api.go | 1 + eth/tracers/api_blocktrace.go | 6 +----- eth/tracers/api_blocktrace_test.go | 2 ++ eth/tracers/api_test.go | 5 +++++ params/version.go | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/types/l2trace.go b/core/types/l2trace.go index 0235d47e27..88523aff35 100644 --- a/core/types/l2trace.go +++ b/core/types/l2trace.go @@ -44,10 +44,10 @@ type StorageTrace struct { // while replaying a transaction in debug mode as well as transaction // execution status, the amount of gas used and the return value type ExecutionResult struct { - L1Fee uint64 `json:"l1Fee,omitempty"` - Gas uint64 `json:"gas"` - Failed bool `json:"failed"` - ReturnValue string `json:"returnValue"` + L1Fee *hexutil.Big `json:"l1Fee,omitempty"` + Gas uint64 `json:"gas"` + Failed bool `json:"failed"` + ReturnValue string `json:"returnValue"` // Sender's account state (before Tx) From *AccountWrapper `json:"from,omitempty"` // Receiver's account state (before Tx) diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 3b962e28b9..a3705319ea 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -930,6 +930,7 @@ func (api *API) traceTx(ctx context.Context, message core.Message, txctx *Contex Failed: result.Failed(), ReturnValue: returnVal, StructLogs: vm.FormatLogs(tracer.StructLogs()), + L1Fee: (*hexutil.Big)(result.L1Fee), }, nil case Tracer: diff --git a/eth/tracers/api_blocktrace.go b/eth/tracers/api_blocktrace.go index 0a9a1ab441..6b10688030 100644 --- a/eth/tracers/api_blocktrace.go +++ b/eth/tracers/api_blocktrace.go @@ -384,16 +384,12 @@ func (api *API) getTxResult(env *traceEnv, state *state.StateDB, index int, bloc } } - var l1Fee uint64 - if result.L1Fee != nil { - l1Fee = result.L1Fee.Uint64() - } env.executionResults[index] = &types.ExecutionResult{ From: sender, To: receiver, AccountCreated: createdAcc, AccountsAfter: after, - L1Fee: l1Fee, + L1Fee: (*hexutil.Big)(result.L1Fee), Gas: result.UsedGas, Failed: result.Failed(), ReturnValue: fmt.Sprintf("%x", returnVal), diff --git a/eth/tracers/api_blocktrace_test.go b/eth/tracers/api_blocktrace_test.go index c3c5c70eb6..d4d8f02a37 100644 --- a/eth/tracers/api_blocktrace_test.go +++ b/eth/tracers/api_blocktrace_test.go @@ -164,10 +164,12 @@ func checkStructLogs(t *testing.T, expect []*txTraceResult, actual []*types.Exec assert.Equal(t, len(expect), len(actual)) for i, val := range expect { trace1, trace2 := val.Result.(*types.ExecutionResult), actual[i] + assert.Equal(t, trace1.L1Fee, trace2.L1Fee) assert.Equal(t, trace1.Failed, trace2.Failed) assert.Equal(t, trace1.Gas, trace2.Gas) assert.Equal(t, trace1.ReturnValue, trace2.ReturnValue) assert.Equal(t, len(trace1.StructLogs), len(trace2.StructLogs)) + // TODO: compare other fields for i, opcode := range trace1.StructLogs { data1, err := json.Marshal(opcode) diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index fe97805907..c36ecd441d 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -218,6 +218,7 @@ func TestTraceCall(t *testing.T) { config: nil, expectErr: nil, expect: &types.ExecutionResult{ + L1Fee: (*hexutil.Big)(big.NewInt(0)), Gas: params.TxGas, Failed: false, ReturnValue: "", @@ -235,6 +236,7 @@ func TestTraceCall(t *testing.T) { config: nil, expectErr: nil, expect: &types.ExecutionResult{ + L1Fee: (*hexutil.Big)(big.NewInt(0)), Gas: params.TxGas, Failed: false, ReturnValue: "", @@ -264,6 +266,7 @@ func TestTraceCall(t *testing.T) { config: nil, expectErr: nil, expect: &types.ExecutionResult{ + L1Fee: (*hexutil.Big)(big.NewInt(0)), Gas: params.TxGas, Failed: false, ReturnValue: "", @@ -281,6 +284,7 @@ func TestTraceCall(t *testing.T) { config: nil, expectErr: nil, expect: &types.ExecutionResult{ + L1Fee: (*hexutil.Big)(big.NewInt(0)), Gas: params.TxGas, Failed: false, ReturnValue: "", @@ -334,6 +338,7 @@ func TestTraceTransaction(t *testing.T) { t.Errorf("Failed to trace transaction %v", err) } if !reflect.DeepEqual(result, &types.ExecutionResult{ + L1Fee: (*hexutil.Big)(big.NewInt(0)), Gas: params.TxGas, Failed: false, ReturnValue: "", diff --git a/params/version.go b/params/version.go index f61723a51e..cf6c36a0e3 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 4 // Major version component of the current release VersionMinor = 1 // Minor version component of the current release - VersionPatch = 0 // Patch version component of the current release + VersionPatch = 1 // Patch version component of the current release VersionMeta = "sepolia" // Version metadata to append to the version string )