Conversation
…close them in minutes An open, lease-less deployment holds the minimum escrow deposit until the cleanup sweep closes it. Bids expire about five minutes after a deployment is created, so one with no lease after ten minutes can never become active — but the sweep only ran at 10:30 and 22:30, so a trial user could wait half a day to get their credits back. The sweep could not simply run more often. It paged through every managed wallet and asked the chain database whether that one owner had orphans, so a run cost a query per wallet and grew with the wallet table rather than with the handful of real orphans. It now asks about a batch of owners at a time: one query screens five thousand wallets and comes back with only the orphans worth closing, which is a couple of dozen queries per run instead of tens of thousands. Closing is unchanged — still one transaction per owner, with the same already-closed drop, fee-grant refill and unsettleable handling. Two things the ten-minute cadence made worth guarding. The sweep now refuses to run when the indexer trails the chain far enough that a leased deployment would read as lease-less, because the staleness cutoff is derived from the last indexed height. And one owner's orphans are split across transactions, so a wallet holding many of them cannot build a close the chain rejects for gas on every run forever. The command also takes --dry-run, which reports what it would close and broadcasts nothing, so the new query can be watched in production before it is trusted to act.
|
Warning Review paused — included plan limit reachedKeep your review moving with free on-demand reviews.
On-demand reviews are free for the next 2 days.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Promotion and pricing detailsOn-demand reviews are free for the next 2 days. After that, they cost $0.25 per reviewed file. Review limit detailsOr wait 24 minutes for your next included review. Limit details: You’ve used all 2 included reviews currently available. Review configuration: ⚙️ Run configurationConfiguration used: Repository: akash-network/console/.coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (4)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: akash-network/console/.coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (12)
Included review availability: Your plan provides up to 5 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughChangesStale deployment cleanup
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~45 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to No actionable defect remains; cleanup failures are surfaced correctly and the safety predicates are preserved. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3980 +/- ##
==========================================
- Coverage 83.91% 83.47% -0.44%
==========================================
Files 1307 1207 -100
Lines 36242 33678 -2564
Branches 8725 8210 -515
==========================================
- Hits 30411 28112 -2299
+ Misses 5152 4904 -248
+ Partials 679 662 -17
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
… from spreading Three things the review caught in the inverted sweep. Screening a batch of owners ran unguarded, so a transient chain-database error on one batch threw out of the sweep loop and skipped every remaining batch for that run. Before the inversion each owner's query ran inside the error handler, so one failure was logged and the rest carried on. The batch query is now handled the same way. Chunking an owner's closes across transactions also reset the already-closed drop cap on every chunk, so an owner with a hundred orphans could drop and re-broadcast fifteen times in a run instead of three. The budget is now spent across all of an owner's transactions. The new JSDoc blocks ran to several lines, which the repo's comment rule does not allow.
Why
Fixes CON-752.
An open, lease-less deployment holds the $0.50 minimum escrow deposit until the cleanup sweep closes it. Bids expire ~5 minutes after a deployment is created, so one with no lease after 10 minutes can never become active — yet the sweep ran only at 10:30 and 22:30 UTC. A trial user stranded by an orphan waited up to ~12 hours to get their credits back; on a $1.00 trial that is the entire balance gone for half a day.
The sweep could not simply be scheduled more often. It paged through every managed wallet and asked the chain DB whether that one owner had orphans, so a run cost a query per wallet and grew with the wallet table rather than with the handful of real orphans.
What
The sweep is inverted.
findStaleDeploymentsnow takes a batch of owners instead of one, so a single query screens 5,000 wallets and returns only the orphans worth closing — roughly a couple of dozen queries per run instead of tens of thousands. The predicate is unchanged; it moved from SequelizeGROUP BY/HAVINGto raw SQL withunnest($1::text[]), the shapefindClosureStatesalready uses. All seven existing repository cases were ported verbatim as a parity suite.Scoping by owner rather than by a time window is deliberate.
deploymentis chain-wide, and an open lease-less deployment is the normal end state of every abandoned self-custody deployment on Akash — no lease means no spend, so the escrow never drains and the row stays open forever. A chain-wide query with a row cap would hand back those rows first and never close any of them, so the owner set is the only bound that keeps every returned row actionable.Closing is untouched — still one transaction per owner, with the same already-closed drop/re-broadcast, fee-grant refill retry and unsettleable handling.
Two guards the 10-minute cadence made worth adding:
Schedule moves to
4,14,24,34,44,54 * * * *withconcurrencyPolicy: ForbidandactiveDeadlineSeconds: 540, so runs cannot overlap. Minutes are offset off every other sweep,mint-act's*/10included. Staging sandbox moves off its weekly schedule to the same one.--dry-runwas added to the command (house convention for every other sweep), which reports what would close and broadcasts nothing.Verification
npm run test:unit— 3694 passed (236 files)npm run test:integration— 666 passed; the 4markAsActive/markAsUsedthrottle failures are pre-existing on native PG and reproduce identically atorigin/mainwith these changes stashednpm run test:functional— 546 passednpx tsc --noEmitandnpm run lint -- --quietcleanRollout note
Worth one run with
--dry-runon the tightened schedule first, to see the real candidate counts in theDEPLOYMENT_CLEAN_UP_SWEEP_ENDlog before it is trusted to broadcast.Summary by CodeRabbit
New Features
Bug Fixes
Chores