Batch: resolve issues #2947, #3070, #3069, #3071

Resolve #2947 Resolve #3070 Resolve #3069 Resolve #3071 This MR implements the changes described in issues #2947, #3070, #3069, #3071.

Summary

All four fixes are solvency-accounting gaps where in-flight/pending outbound liabilities were omitted from the vault vs. wallet comparison, letting a solvent vault look insolvent (false halt) or an already-committed liability look like excess vault funds (over-solvency treasury swaps).

  • #2947 excludePendingOutboundFromVault (insolvencyCheck path): the pending-outbound lookback used only the base SigningTransactionPeriod, so an unsigned XMR FROST outbound older than that window but still in-flight was not deducted and a solvent XMR vault could be flagged insolvent and halt the chain. The scan now reaches back the longest signing window of any chain (MaxSigningPeriodMultiplier × base), and each item is filtered back to its own chain's window inside deductVaultBlockPendingOutbound, so chains on the standard window are unaffected by the wider scan.
  • #3070 calculateNetworkSolvency forward scan: only read scheduled txouts through +MaxTxOutOffset, but CalcTxOutHeight can place congested outbounds up to TxOutDelayMax. Now scans through TxOutDelayMax, breaking only once past MaxTxOutOffset on an empty txout height (mirroring the GetPendingOutbounds keeper helper).
  • #3069 calculateNetworkSolvency streaming-swap liability: trade/secured swap targets were skipped alongside synths, but only synths are minted without reducing the L1 pool balance; trade/secured DO reduce pool.BalanceAsset while their depth is credited only at settlement. Now only synth targets are skipped (in both the legacy and current streaming branches), so in-flight trade/secured output is subtracted until settlement.
  • #3071 calculateNetworkSolvency backward scan: used only the base SigningTransactionPeriod for all chains, missing unsigned XMR outbounds still in the extended window. Now scans back the widest signing window and filters each item against its own chain's window.

The GetPendingOutbounds keeper helper is also corrected in the same spirit: it now reads the Mimir-overridable configured SigningTransactionPeriod (via GetConfigInt64, matching LackSigning) instead of the bare default constant, and scans back its asset's own chain signing window (SigningTransactionPeriod × asset.GetChain().SigningPeriodMultiplier()) instead of a bare SigningTransactionPeriod, so a raised signing period widens this scan too and still-legitimately-pending XMR outbounds are not dropped and their committed funds don't appear available for reassignment.

Also included is a refactor that moves the XMR signing-period exception behind a chain abstraction: the xmrSigningPeriodMultiplier constant and its scattered chain.Equals(common.XMRChain) checks are replaced by Chain.SigningPeriodMultiplier(), plus common.SigningPeriodMultipliers() (distinct windows, ascending) and common.MaxSigningPeriodMultiplier(). staleOutboundObservationSigningPeriod now derives its window from chain.SigningPeriodMultiplier(); SlasherImpl.LackSigning runs one reschedule pass per distinct window (each pass processing only items whose chain uses that window) instead of a hardcoded standard/XMR pair; and the outbound-matching lookbacks in handler_common_outbound.go and findOriginalMemoForOutbound derive their search period from the chain rather than special-casing XMR. Behaviour is unchanged (XMR still 3×, everything else 1×), but a future long-signing chain only needs to declare its multiplier in one place.

All changes are deterministic (constants + on-chain state only; no float/map-iteration/rand/time). Added unit tests for each fix plus coverage of the new chain helpers; the full x/thorchain suite passes and gofumpt/analyze are clean.

🤖 Generated with Claude Code

Edited by Huginn Ai

Merge request reports

Loading
Loading