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

Submitter: don't bump transactions without sufficient gas #2664

Merged
merged 6 commits into from
Jun 8, 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
15 changes: 13 additions & 2 deletions ethergo/submitter/chain_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,14 @@ func (t *txSubmitterImpl) chainPendingQueue(parentCtx context.Context, chainID *
// so now, we have a list of transactions that need to be resubmitted.
// these are already ordered by nonce and we should have at most one per nonce, so we can just iterate through them.
// we need to figure out which ones are still valid, and which ones need to be bumped.
// once this is done, we'll be ready to submit them
// we're going to handle this by updating txes in place
// once this is done, we'll be ready to submit them.
// we're going to handle this by updating txes in place.
// note that if we do not have sufficient gas on this chain, no txes will be bumped.
gasBalance, err := chainClient.BalanceAt(ctx, t.signer.Address(), nil)
if err != nil {
return fmt.Errorf("could not get gas balance: %w", err)
}
span.SetAttributes(attribute.String("gas_balance", gasBalance.String()))
for i := range txes {
tx := txes[i]

Expand All @@ -94,6 +100,11 @@ func (t *txSubmitterImpl) chainPendingQueue(parentCtx context.Context, chainID *
continue
}

if tx.Cost().Cmp(gasBalance) > 0 {
span.SetAttributes(attribute.Bool("out_of_gas", true))
span.AddEvent("tx out of gas", trace.WithAttributes(txToAttributes(tx.Transaction, tx.UUID)...))
break
}
cq.bumpTX(gCtx, tx)
}
cq.updateOldTxStatuses(gCtx)
Expand Down
Loading