diff --git a/core/state_transition.go b/core/state_transition.go index ca059ff36e..e3fb4689ad 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -89,6 +89,7 @@ type Message interface { // ExecutionResult includes all output after executing given evm // message no matter the execution itself is successful or not. type ExecutionResult struct { + L1Fee *big.Int UsedGas uint64 // Total used gas but include the refunded gas Err error // Any error encountered during the execution(listed in core/vm/errors.go) ReturnData []byte // Returned data from evm(function result or data supplied with revert opcode) @@ -381,6 +382,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { } return &ExecutionResult{ + L1Fee: st.l1Fee, UsedGas: st.gasUsed(), Err: vmerr, ReturnData: ret, diff --git a/eth/tracers/api_blocktrace.go b/eth/tracers/api_blocktrace.go index 0e12074e16..c01d4acd63 100644 --- a/eth/tracers/api_blocktrace.go +++ b/eth/tracers/api_blocktrace.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "math/big" "runtime" "sync" @@ -15,7 +14,6 @@ import ( "github.com/scroll-tech/go-ethereum/core/types" "github.com/scroll-tech/go-ethereum/core/vm" "github.com/scroll-tech/go-ethereum/log" - "github.com/scroll-tech/go-ethereum/rollup/fees" "github.com/scroll-tech/go-ethereum/rollup/rcfg" "github.com/scroll-tech/go-ethereum/rollup/withdrawtrie" "github.com/scroll-tech/go-ethereum/rpc" @@ -330,17 +328,16 @@ func (api *API) getTxResult(env *traceEnv, state *state.StateDB, index int, bloc } } - l1Fee := big.NewInt(0) - if vmenv.ChainConfig().UsingScroll { - l1Fee, _ = fees.CalculateL1MsgFee(msg, vmenv.StateDB) + 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.Uint64(), + L1Fee: l1Fee, Gas: result.UsedGas, Failed: result.Failed(), ReturnValue: fmt.Sprintf("%x", returnVal),