diff options
| author | Adam Soltys <[email protected]> | 2026-11-23 23:21:58 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-11-23 23:21:58 -0700 |
| commit | f27c49c67ec832db9fa8c99666cb6accd0f2fd57 (patch) | |
| tree | c1d5ab25d7f399798090005d044538da5fa38c8e /names/server.js | |
| parent | e40c5eb1918f41130022f73e3db8a3087837f02f (diff) | |
| download | coinosv3-server-f27c49c67ec832db9fa8c99666cb6accd0f2fd57.tar.gz coinosv3-server-f27c49c67ec832db9fa8c99666cb6accd0f2fd57.zip | |
names: float forwards skip coins at the exit-depth cap and refresh them. "I think there's an issue with the lightning forwarder can you look into it? I've got reports of missing deposits" (Adam, 2026-11-23). From 2026-11-24 00:09Z every forward under 13,661 sat failed: the float's wallet code (the coinosv3 submodule, from 10-16, older than its own cap check) picks the smallest coin that covers a send, and that was a 13,661-sat change chain at exit depth 100, where the ASP refuses every cosign ("refresh the VTXO in a round"). Nine forwards (14,816 sat) sat queued, retried every minute. Float sends now leave coins at the cap out of selection, and upkeep refreshes coins within 8 hops of it right away (2-minute cadence while there are any, dust riding along). Upkeep had not run at all since 2026-10-27: five 1-sat test sends sat 'registered' with a permanently refused mailbox notice, and any open action holds the round. Those are now closed as forwardOnce already closes the ones made for a payment. Checked against the live float state: before, a 381-sat send picked the depth-100 coin; after, every queued amount picks an 81,184-sat coin at depth 12, and the capped coin is still free for the refresh. names tests pass.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VMan6Upic5L6MMJzkTn8zg
Diffstat (limited to 'names/server.js')
| -rw-r--r-- | names/server.js | 64 |
1 files changed, 54 insertions, 10 deletions
diff --git a/names/server.js b/names/server.js index 683702c..a7424f8 100644 --- a/names/server.js +++ b/names/server.js @@ -374,7 +374,23 @@ if (CFG.forwarder?.mnemonic) { // between syncs) lives there, and balance() only counts what state has seen. await fwd.sync().catch(() => {}); log(`forwarder ark wallet ready — float ${fwd.balance().spendableSat} sat, receive ${fwd.address().slice(0, 24)}…`); + // A float send never picks a coin at the server's exit-depth cap. Each + // arkoor hop adds one to a coin's depth and only a round flattens it; at + // the cap the ASP refuses every cosign. The float's wallet code (the + // coinosv3 submodule, from 10-16) predates its own cap check, so the + // smallest coin covering a send — a 13,661-sat change chain at depth 100 — + // was picked for every forward under 13,661 sat and refused, from + // 2026-11-24 00:09Z until this went out ("reports of missing deposits", + // Adam). floatUpkeep refreshes such coins; until that round settles they + // are just left out here. + const select = fwd._selectInputs.bind(fwd), free = fwd._free.bind(fwd); + let selecting = false; + fwd._free = (v, busy) => free(v, busy) && !(selecting && floatCapped(v)); + fwd._selectInputs = (...a) => { selecting = true; try { return select(...a); } finally { selecting = false; } }; } +function floatDepth(v) { try { return fwd._decoded(v).genesis.length; } catch { return 0; } } +const floatDepthCap = () => fwd?.info?.maxVtxoExitDepth || 100; +function floatCapped(v) { return floatDepth(v) >= floatDepthCap(); } // Is this name's wallet on another network than this registrar's node? Then // nothing payable may be minted for it here: a mainnet offer for a mutinynet @@ -963,23 +979,51 @@ async function autoTopupFloat() { // its expiry into a fresh round output. let floatRefreshAt = 0; const REFRESH_MARGIN_BLOCKS = 144; +// A send the server cosigned and registered whose mailbox notice is refused +// for good (status 3, e.g. "invalid a blinded VTXO mailbox identifier") is as +// done as it will ever be: the coins went. forwardOnce closes the ones made +// for a payment; these close the rest (five 1-sat sends from 2026-10-27 sat +// 'registered' for four weeks and held every upkeep and consolidation round). +function closeRefusedSends() { + let n = 0; + for (const a of fwd.state.actions || []) { + if (a.type === 'send' && a.step === 'registered' && /PostArkoorMessage: status 3\b/.test(a.lastError || '')) { + a.step = 'done'; a.undelivered = a.lastError; n++; + } + } + if (n) { fwd._save(); log(`float upkeep: closed ${n} sends whose mailbox notice was refused for good`); } +} + async function floatUpkeep() { - if (!fwd || Date.now() - floatRefreshAt < 30 * 60_000) return; + if (!fwd) return; + closeRefusedSends(); const spendables = (fwd.state?.vtxos || []).filter((v) => v.state === 'spendable'); // never start a round while another action is still in flight if (!spendables.length || (fwd.state.actions || []).some((a) => !['done', 'failed'].includes(a.step))) return; const tip = await fwd.chain.tipHeight(); - // not one already past it: the server's sweeper has taken that coin, and a - // refresh of it never settles — it sat 'submitted' from 2026-09-16 (a large - // coin, swept two blocks after expiry) and blocked every round after it + // not one already past its expiry: the server's sweeper has taken that + // coin, and a refresh of it never settles — it sat 'submitted' from + // 2026-09-16 (a large coin, swept two blocks after expiry) and blocked + // every round after it + const live = (v) => !(v.expiryHeight && v.expiryHeight <= tip); + // coins at or near the depth cap can't be sent (see floatCapped): flatten + // them as soon as they get there, not on the 30-minute expiry cadence. + // Deep dust rides along with a bigger deep coin; alone it can't make a round. + const deep = spendables.filter((v) => live(v) && floatDepth(v) >= floatDepthCap() - 8); + const deepSat = deep.reduce((n, v) => n + v.amountSat, 0); + if (Date.now() - floatRefreshAt < (deepSat >= 330 ? 2 * 60_000 : 30 * 60_000)) return; const expiring = spendables.filter((v) => - v.expiryHeight && v.expiryHeight > tip && v.expiryHeight - tip < REFRESH_MARGIN_BLOCKS && v.amountSat >= 330); - if (!expiring.length) return; + live(v) && v.expiryHeight && v.expiryHeight - tip < REFRESH_MARGIN_BLOCKS && v.amountSat >= 330); + const ids = new Set(expiring.map((v) => v.id)); + if (deepSat >= 330) for (const v of deep) ids.add(v.id); + if (!ids.size) return; floatRefreshAt = Date.now(); - const sat = expiring.reduce((n, v) => n + v.amountSat, 0); - log(`float upkeep: refreshing ${expiring.length} coins (${sat} sat) nearing expiry`); - await fwd.refresh(expiring.map((v) => v.id)); - log(`float upkeep: refresh round complete — float now ${fwd.balance().spendableSat} sat`); + const coins = spendables.filter((v) => ids.has(v.id)); + const sat = coins.reduce((n, v) => n + v.amountSat, 0); + const nDeep = coins.filter((v) => floatDepth(v) >= floatDepthCap() - 8).length; + log(`float upkeep: refreshing ${coins.length} coins (${sat} sat; ${nDeep} at depth ≥ ${floatDepthCap() - 8}, ${expiring.length} nearing expiry)`); + await fwd.refresh([...ids]); + log(`float upkeep: refresh submitted — float now ${fwd.balance().spendableSat} sat`); } // A float fed by many small receives can hold enough sats yet too many coins |
