Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tracer: fix incorrect gasUsed in deposit tx #181

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
return result, err
}

func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
func (st *StateTransition) innerTransitionDb() (_ *ExecutionResult, err error) {
// First check this message satisfies all consensus rules before
// applying the message. The rules include these clauses
//
Expand All @@ -458,24 +458,27 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) {
return nil, err
}

var (
msg = st.msg
sender = vm.AccountRef(msg.From)
rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil, st.evm.Context.Time)
contractCreation = msg.To == nil
)

if tracer := st.evm.Config.Tracer; tracer != nil {
tracer.CaptureTxStart(st.initialGas)
defer func() {
if st.msg.IsDepositTx {
if st.msg.IsDepositTx && !rules.IsOptimismRegolith && err == nil {
if st.msg.IsSystemTx {
tracer.CaptureTxEnd(st.msg.GasLimit)
}
tracer.CaptureTxEnd(0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The else branch is needed here.

} else {
tracer.CaptureTxEnd(st.gasRemaining)
}
}()
}

var (
msg = st.msg
sender = vm.AccountRef(msg.From)
rules = st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil, st.evm.Context.Time)
contractCreation = msg.To == nil
)

// Check clauses 4-5, subtract intrinsic gas if everything is correct
gas, err := IntrinsicGas(msg.Data, msg.AccessList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
if err != nil {
Expand Down