fix: size split coins to match operational requirements#1526
Merged
TheLastCicada merged 1 commit intoMar 12, 2026
Merged
Conversation
COIN_SIZE was hardcoded to 1,000,000 mojos while CADT operations require DEFAULT_COIN_AMOUNT + DEFAULT_FEE (typically 600,000,000 mojos). This caused a perpetual splitting loop where coins were created 600x too small to be usable, wasting fees and temporarily draining spendable balance. Set COIN_SIZE = DEFAULT_COIN_AMOUNT + DEFAULT_FEE so each split coin can independently fund one full DataLayer operation. Add a splitInProgress flag so mirror-check tasks log a warning instead of an error when balance is temporarily reduced during a split.
d0ebc8c
into
fix/parallel-store-creation-retry
20 checks passed
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
COIN_SIZEwas hardcoded to 1,000,000 mojos while CADT operations requireDEFAULT_COIN_AMOUNT + DEFAULT_FEE(typically 600,000,000 mojos on production configs). This caused a perpetual splitting loop where coins were created 600x too small to be "usable" by CADT's own criteria, wasting 300M mojo in fees every 6 hours and temporarily draining spendable balance.COIN_SIZE = MIN_USABLE_COIN_SIZE(DEFAULT_COIN_AMOUNT + DEFAULT_FEE) so each split coin can independently fund one full DataLayer operation (mirror creation, store creation, etc.).splitInProgressflag exported from coin-management socheckWalletBalanceForMirrorin persistance.js logs a warning (not an error) when balance is temporarily reduced during an active coin split, making logs actionable instead of alarming.executeSplit()helper.Root Cause
On a system with
DEFAULT_COIN_AMOUNT=300000000andDEFAULT_FEE=300000000:COIN_SIZEwas 1M mojos butMIN_USABLE_COIN_SIZEwas 600M mojos — split coins were never considered "usable"spendable_balancedropped, causing mirror-check to log "Insufficient funds" errorsTest plan
Note
Medium Risk
Changes coin-splitting amounts and transaction flow in the wallet maintenance task, which can affect spendable balances and DataLayer operation reliability if mis-sized or mis-triggered. The changes are localized but touch on-chain transaction behavior and retry timing.
Overview
Fixes the coin-management task to size split outputs at
DEFAULT_COIN_AMOUNT + DEFAULT_FEE(instead of a hardcoded 1,000,000 mojos) so each resulting coin can independently fund a full DataLayer operation, avoiding repeated under-sized splits and wasted fees.Refactors split logic into a single
executeSplit()path and exportsisSplitInProgress();checkWalletBalanceForMirrornow logs a warning and skips mirror creation when spendable balance is temporarily reduced by an in-flight split. Updates coin-management integration tests to match the new sizing and calculation expectations.Written by Cursor Bugbot for commit 20baea7. This will update automatically on new commits. Configure here.