Skip to content

feat: transactions with retry#5464

Draft
sbackend123 wants to merge 7 commits into
masterfrom
feat/new-gas-estimation
Draft

feat: transactions with retry#5464
sbackend123 wants to merge 7 commits into
masterfrom
feat/new-gas-estimation

Conversation

@sbackend123
Copy link
Copy Markdown
Contributor

Checklist

  • I have read the coding guide.
  • My change requires a documentation update, and I have done it.
  • I have added tests to cover my changes.
  • I have filled out the description and linked the related issues.

Description

Add automatic gas-fee retry for Ethereum transactions in Bee. Transactions that stay unconfirmed are re-broadcast with the same nonce and an escalated priority fee, using dynamic fees from eth_feeHistory. Retry behaviour is configurable, survives node restarts, and is used for redistribution and postage operations.

What changed

  1. Transaction retry (pkg/transaction)
    New SendWithRetry on the transaction service: EIP-1559 txs with fee estimation via eth_feeHistory (initial tip = market / 50th percentile), then +20% tip per retry step (configurable). Replacement transactions reuse the same nonce; maxFeePerGas is derived as 2 × baseFee + tip. Persists RetryState in the state store and resumes in-flight retries after restart. Stops on non-retryable errors (revert, insufficient funds, sign failure, redistribution contract errors, nonce too low, etc.).

  2. Structured logging: Info on each broadcast, Debug on fee suggestion / state updates, Error on critical failures and when all attempts are exhausted.

  3. Configuration (cmd/bee, pkg/node)
    CLI flags (defaults: 5 attempts, 1 min delay, 20% increase):

--transaction-retry-max-retries
--transaction-retry-delay
--transaction-retry-gas-increase-percent
--transaction-retry-max-tx-price-wei

Call sites

  • Redistribution (pkg/storageincentives/redistribution): commit / reveal / claim use SendWithRetry via sendAndWait.
  • Postage (pkg/postage/postagecontract): batch create, top-up, dilute, approve, and expire use SendWithRetry when retry is not disabled.

API
New HTTP header Disable-Retry (parsed in gasConfigMiddleware together with Gas-Price / Gas-Limit).
When Disable-Retry: true, postage falls back to the existing Send + WaitForReceipt path.
Header is included in CORS allow-list.

Open API Spec Version Changes (if applicable)

Motivation and Context (Optional)

Related Issue (Optional)

#5114

Screenshots (if appropriate):

AI Disclosure

  • This PR contains code that has been generated by an LLM.
  • I have reviewed the AI generated code thoroughly.
Send txs with retry - [ ] I possess the technical expertise to responsibly review the code generated in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant