Skip to content

Commit

Permalink
fix(trace): Fix l1Fee (ethereum#234)
Browse files Browse the repository at this point in the history
Fix l1Fee
  • Loading branch information
mask-pp authored Feb 24, 2023
1 parent d91c8c7 commit 15f94b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -381,6 +382,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
}

return &ExecutionResult{
L1Fee: st.l1Fee,
UsedGas: st.gasUsed(),
Err: vmerr,
ReturnData: ret,
Expand Down
11 changes: 4 additions & 7 deletions eth/tracers/api_blocktrace.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"errors"
"fmt"
"math/big"
"runtime"
"sync"

Expand All @@ -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"
Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit 15f94b9

Please sign in to comment.