Skip to content

Commit

Permalink
feat(txmgr): call CreateAccessList (#9)
Browse files Browse the repository at this point in the history
* feat(txmgr): allow `numConfirmations` to be `0`

* feat(txmgr): improve gas estimation for blob transactions

* feat(txmgr): always use the original gas limit (#6)

* feat(txmgr): always use the original gas limit

* feat(txmgr): always use the original gas limit

* feat(txmgr): introduce `AccessList` in `TxCandidate` (#7)

* feat(txmgr): call CreateAccessList

---------

Co-authored-by: David <[email protected]>
  • Loading branch information
YoGhurt111 and davidtaikocha committed Sep 24, 2024
1 parent b27f4b7 commit 0d45788
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions op-service/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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 @@ -352,18 +354,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 @@ -407,7 +412,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 @@ -422,7 +427,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

0 comments on commit 0d45788

Please sign in to comment.