Skip to content

Retry admin-wallet balance scan and recover from an empty funded-wallet list - #586

Closed
sirpy with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-empty-admin-wallet-pool
Closed

sirpy with Copilot wants to merge 2 commits into
masterfrom
copilot/fix-empty-admin-wallet-pool

Conversation

Copilot AI commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

After a successful topAdmins tx on Celo, the immediate balance scan read pre-top-up balances, so filledAddresses was cached as []. Every later send then timed out on the tx lock until restart. This PR adds a bounded retry to the scan, and a rescan before sends when the list is empty.

  • Scan with retry (Web3Wallet.js)
    • The inline startup scan is now scanFilledAddresses(). It still requires a verified admin with a balance above the minimum.
    • scanFilledAddressesWithRetry() retries when the result is empty or the RPC throws. It makes up to 4 attempts, with exponential backoff starting at 1s.
    • It only reads balances and never sends another top-up.
  • Recovery before sends
    • sendTransaction (when from is unset) and sendNative call ensureFilledAddresses() before taking the tx lock.
    • refreshEmptyFilledAddresses() rescans only when the list is empty.
    • Concurrent callers share one in-flight rescan, and a 30s cooldown follows each rescan.
    • If the list is still empty, the send throws no admin wallet with funds available after balance rescan, not a lock timeout.
  • Config knobs: balanceScanMaxAttempts, balanceScanRetryDelayMs and balanceRefreshCooldownMs are read from the wallet conf. They have defaults.
// before: lock([]) → timeout
await this.txManager.lock(this.filledAddresses)
// after: rescan if empty, else fail clearly
await this.txManager.lock(await this.ensureFilledAddresses())

Review notes

  • I did not implement the issue's other suggestion, reading balances at the top-up receipt block. The retry covers the stale-read case without it.
  • No tests are added yet for the scenarios in the issue: delayed recovery, retries exhausted, and concurrent sends sharing one refresh.
  • jest could not run in my environment because dependencies were missing, so none of this has been run.

Co-authored-by: sirpy <671095+sirpy@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix empty admin-wallet pool after successful Celo top-up Retry admin-wallet balance scan and recover from an empty funded-wallet list Nov 1, 2026
Copilot AI requested a review from sirpy November 1, 2026 09:51
@sirpy

sirpy commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

not required

@sirpy sirpy closed this Nov 1, 2026
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.

Fix empty admin-wallet pool after successful Celo top-up

2 participants