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): call CreateAccessList #9

Merged
merged 6 commits into from
Jun 26, 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
29 changes: 17 additions & 12 deletions op-service/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ type ETHBackend interface {
// EstimateGas returns an estimate of the amount of gas needed to execute the given
// transaction against the current pending block.
EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)
// CreateAccessList returns an estimate of the AccessList
CreateAccessList(ctx context.Context, msg ethereum.CallMsg) (*types.AccessList, uint64, string, error)
// Close the underlying eth connection
Close()
}
Expand Down Expand Up @@ -264,18 +266,21 @@ func (m *SimpleTxManager) craftTx(ctx context.Context, candidate TxCandidate) (*

gasLimit := candidate.GasLimit

callArgs := ethereum.CallMsg{
From: m.cfg.From,
To: candidate.To,
GasTipCap: gasTipCap,
GasFeeCap: gasFeeCap,
Data: candidate.TxData,
Value: candidate.Value,
}

accessList, _, _, err := m.backend.CreateAccessList(ctx, callArgs)
if err != nil {
return nil, err
}
// If the gas limit is set, we can use that as the gas
if gasLimit == 0 {
callArgs := ethereum.CallMsg{
From: m.cfg.From,
To: candidate.To,
GasTipCap: gasTipCap,
GasFeeCap: gasFeeCap,
Data: candidate.TxData,
Value: candidate.Value,
AccessList: candidate.AccessList,
}

for _, blob := range candidate.Blobs {
commitment, err := blob.ComputeKZGCommitment()
if err != nil {
Expand Down Expand Up @@ -319,7 +324,7 @@ func (m *SimpleTxManager) craftTx(ctx context.Context, candidate TxCandidate) (*
Gas: gasLimit,
BlobHashes: blobHashes,
Sidecar: sidecar,
AccessList: candidate.AccessList,
AccessList: *accessList,
}
if err := finishBlobTx(message, m.chainID, gasTipCap, gasFeeCap, blobFeeCap, candidate.Value); err != nil {
return nil, fmt.Errorf("failed to create blob transaction: %w", err)
Expand All @@ -334,7 +339,7 @@ func (m *SimpleTxManager) craftTx(ctx context.Context, candidate TxCandidate) (*
Value: candidate.Value,
Data: candidate.TxData,
Gas: gasLimit,
AccessList: candidate.AccessList,
AccessList: *accessList,
}
}
return m.signWithNextNonce(ctx, txMessage) // signer sets the nonce field of the tx
Expand Down