-
Notifications
You must be signed in to change notification settings - Fork 33
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
[Submitter] Do Not Bump if Out of Gas #1837
Comments
trajan0x
changed the title
[Submitter] Do Not Resubmit if Out of Gas
[Submitter] Do Not Bump if Out of Gas
Jan 11, 2024
To address the issue of not resubmitting transactions if out of gas, modify the
func (c *chainQueue) bumpTX(parentCtx context.Context, ogTx db.TX) (err error) {
if !c.isBumpIntervalElapsed(ogTx) {
c.addToReprocessQueue(ogTx)
return nil
}
gasBalance, err := c.client.BalanceAt(parentCtx, c.signer.Address(), nil)
if err != nil {
return fmt.Errorf("could not get gas balance: %w", err)
}
if ogTx.Cost().Cmp(gasBalance) > 0 {
c.metrics.Tracer().Start(parentCtx, "chainPendingQueue.bumpTX").AddEvent("tx out of gas", trace.WithAttributes(txToAttributes(ogTx.Transaction, ogTx.UUID)...))
return nil
}
// existing logic for copying and bumping the transaction
tx, err := util.CopyTX(ogTx.Transaction, util.WithTxType(c.txTypeForChain(c.chainID)))
if err != nil {
return fmt.Errorf("could not copy tx: %w", err)
}
ctx, span := c.metrics.Tracer().Start(parentCtx, "chainPendingQueue.bumpTX", trace.WithAttributes(attribute.Stringer(metrics.TxHash, tx.Hash())))
defer func() {
metrics.EndSpanWithErr(span, err)
}()
newGasEstimate, err := c.getGasEstimate(ctx, c.client, c.chainIDInt(), tx)
if err != nil {
return fmt.Errorf("could not get gas estimate: %w", err)
}
transactor, err := c.signer.GetTransactor(ctx, c.chainID)
if err != nil {
return fmt.Errorf("could not get transactor: %w", err)
}
transactor.NoSend = true
transactor.Nonce = new(big.Int).SetUint64(tx.Nonce())
transactor.GasLimit = newGasEstimate
err = c.setGasPrice(ctx, c.client, transactor, c.chainID, ogTx.Transaction)
if err != nil {
return fmt.Errorf("could not set gas price: %w", err)
}
switch tx.Type() {
case types.LegacyTxType:
tx = types.NewTx(&types.LegacyTx{
Nonce: tx.Nonce(),
GasPrice: transactor.GasPrice,
Gas: transactor.GasLimit,
To: tx.To(),
Value: tx.Value(),
Data: tx.Data(),
})
case types.DynamicFeeTxType:
tx = types.NewTx(&types.DynamicFeeTx{
ChainID: tx.ChainId(),
Nonce: tx.Nonce(),
GasTipCap: core.CopyBigInt(transactor.GasTipCap),
GasFeeCap: core.CopyBigInt(transactor.GasFeeCap),
Gas: transactor.GasLimit,
To: tx.To(),
Value: tx.Value(),
Data: tx.Data(),
})
default:
return fmt.Errorf("unknown tx type: %v", ogTx.Type())
}
tx, err = transactor.Signer(transactor.From, tx)
if err != nil {
return fmt.Errorf("could not sign tx: %w", err)
}
span.AddEvent("add to reprocess queue")
span.SetAttributes(txToAttributes(tx, ogTx.UUID)...)
c.addToReprocessQueue(db.TX{
UUID: ogTx.UUID,
Transaction: tx,
Status: db.Stored,
})
registerErr := c.registerBumpTx(ctx, tx)
if registerErr != nil {
span.AddEvent("could not register bump tx", trace.WithAttributes(attribute.String("error", registerErr.Error())))
}
return nil
} References |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't resubmit if out of gas
The text was updated successfully, but these errors were encountered: