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

txmgr: call EstimateGas correctly for blob tx #12086

Merged
merged 1 commit into from
Sep 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
31 changes: 18 additions & 13 deletions op-service/txmgr/txmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,34 +349,39 @@ func (m *SimpleTxManager) craftTx(ctx context.Context, candidate TxCandidate) (*

gasLimit := candidate.GasLimit

var sidecar *types.BlobTxSidecar
var blobHashes []common.Hash
if len(candidate.Blobs) > 0 {
if candidate.To == nil {
return nil, errors.New("blob txs cannot deploy contracts")
}
if sidecar, blobHashes, err = MakeSidecar(candidate.Blobs); err != nil {
return nil, fmt.Errorf("failed to make sidecar: %w", err)
}
}

// If the gas limit is set, we can use that as the gas
if gasLimit == 0 {
// Calculate the intrinsic gas for the transaction
gas, err := m.backend.EstimateGas(ctx, ethereum.CallMsg{
callMsg := ethereum.CallMsg{
From: m.cfg.From,
To: candidate.To,
GasTipCap: gasTipCap,
GasFeeCap: gasFeeCap,
Data: candidate.TxData,
Value: candidate.Value,
})
}
if len(blobHashes) > 0 {
callMsg.BlobGasFeeCap = blobBaseFee
callMsg.BlobHashes = blobHashes
}
gas, err := m.backend.EstimateGas(ctx, callMsg)
if err != nil {
return nil, fmt.Errorf("failed to estimate gas: %w", errutil.TryAddRevertReason(err))
}
gasLimit = gas
}

var sidecar *types.BlobTxSidecar
var blobHashes []common.Hash
if len(candidate.Blobs) > 0 {
if candidate.To == nil {
return nil, errors.New("blob txs cannot deploy contracts")
}
if sidecar, blobHashes, err = MakeSidecar(candidate.Blobs); err != nil {
return nil, fmt.Errorf("failed to make sidecar: %w", err)
}
}

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