Conversation
…cleTopUpsStorage; reset officialCyclesBalance in postupgrade; add cycle-balance and PAUSED guards to pullNextChallenge
Port the previously off-chain daily cleanup job directly into the canister. The challenge queue is now automatically reset if it reaches the length threshold or if all entries are older than 24 hours, ensuring stale work is cleared before pulling new challenges.
Add documentation for deploying the pre-built WASM to `mainer_ctrlb_canister_0` and include references to the `smoketest` Makefile target for both the controller and the main service.
… more forensic history; still a strict bound)
…ieval Wrap cross-canister calls and timer operations in try-catch blocks to prevent silent failures and log cycle balances on error. Inlining the GameState call avoids unnecessary Motoko self-calls that can fail when the canister balance is near the freezing reserve.
patnorris
approved these changes
Apr 23, 2026
Contributor
|
looks good. Just one comment on the Summary above: it should be "Cap submittedResponses at 100" (MAX_SUBMITTED_RESPONSES : Nat = 100;) |
Compensate for the IC's upfront instruction-cost deduction during install_code by adding a 1T cycle buffer to the official balance tracking. This prevents false triggers of the unofficial-topup penalty immediately after installation or upgrade. The minimum balance threshold is also increased to ensure the canister stays above the freezing reserve during the prepay/refund cycle. Includes a new diagnostic query and extensive logging to trace cycle balance drift.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements Required Actions 1–6 (item 5 skipped per source) from
funnAI/scripts/logs-mainer-analysis/mAIner-memory-remediation-plan.mdto halt the mAIner freeze wave.submittedResponsesat 5.putSubmittedResponsenowList.takes after every push (mirrorschallengeQueuecap pattern). Stops the primary unbounded-growth source.generatedResponsesentirely. Declaration + 4 accessors + theputGeneratedResponsecall site are gone —get/getAll/removewere never called anywhere;putproduced a write-only sink. Pure dead code.officialCycleTopUpsStorageentirely. Write-only dead code (no reader anywhere in PoAIW).officialCyclesBalanceaccounting inaddCycles()is preserved — still needed for unofficial-topup detection.officialCyclesBalance := Cycles.balance()inpostupgrade(). Treats cycles delivered during upgrade (dfx wallet send) as official, fixing the 9× penalty that immediately froze 36 mAIners after the last upgrade. Reinstall path already correct via the line-108 initializer.pullNextChallengeentry withPAUSED_DUE_TO_LOW_CYCLE_BALANCEearly-return +Cycles.balance() < CYCLE_BALANCE_MINIMUMearly-return. Prevents the wasteful GameState call when the canister has already paused itself.Diffstat: 2 files, 135 insertions, 143 deletions.
Test plan
moc --checkclean (only pre-existing warnings)make smoketest— 116 passed, 4 skipped (the 4 are GameState integration tests)test__getSubmittedResponsesAdminextended withentry_count <= 5invariant assertionlocalviascripts/upgrade_mainers.sh --reinstall --mainer <id>(companion PR in funnAI repo) and confirm memory drops to baselinescripts/check_mAIner_status.py