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

feat(txmgr): compare gasUsed and estimateGas #11

Merged
merged 1 commit into from
Jun 27, 2024
Merged
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
13 changes: 11 additions & 2 deletions op-service/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ func (m *SimpleTxManager) craftTx(ctx context.Context, candidate TxCandidate) (*
Data: candidate.TxData,
Value: candidate.Value,
}

accessList, _, _, err := m.backend.CreateAccessList(ctx, callArgs)
// Set includeAccessList as default
includeAccessList := true
providedAccessList, gasUsed, _, err := m.backend.CreateAccessList(ctx, callArgs)
if err != nil {
return nil, err
}
Expand All @@ -298,6 +299,9 @@ func (m *SimpleTxManager) craftTx(ctx context.Context, candidate TxCandidate) (*
if err != nil {
return nil, fmt.Errorf("failed to estimate gas: %w", errutil.TryAddRevertReason(err))
}
if gasUsed >= gas {
includeAccessList = false
}
gasLimit = gas
}

Expand All @@ -312,6 +316,11 @@ func (m *SimpleTxManager) craftTx(ctx context.Context, candidate TxCandidate) (*
}
}

accessList := &types.AccessList{}
if includeAccessList {
accessList = providedAccessList
}

var txMessage types.TxData
if sidecar != nil {
if blobBaseFee == nil {
Expand Down