Batch: resolve issues #3266, #3014, #3013, #2978

Resolve #3266 Resolve #3014 Resolve #3013 Resolve #2978 This MR implements the changes described in issues #3266, #3014, #3013, #2978.

Summary

Recovery swaps queued by SlasherImpl.LackSigning after MaxOutboundAttempts got their tx ID from only the inbound hash, the recovery type and the block height. Sibling TxOutItems that share one inbound hash and are recovered in the same block therefore wrote to the same swap-queue key. This covers split outbounds, multi-coin refunds, and Ragnarok payouts with a blank InHash. Each later recovery overwrote the earlier one, yet every original item was still marked handled.

  • Per-item recovery ID: generateRecoveryTxID now mixes in TxOutItem.Hash(), so each failed item gets its own recovery swap.
  • Never overwrite a queued recovery: the derived ID is checked against both the legacy and advanced swap queues. If it is already taken (for example, byte-identical items), a deterministic nonce is mixed in. The search is capped at 100 tries so it cannot loop in EndBlock. After that it returns errRecoveryTxIDExhausted, and LackSigning reschedules the item instead of stranding it. The ID includes the block height, so the retry gets fresh IDs. Reaching this needs 101 byte-identical items recovered in the same block.
  • Exhaustion keeps the refund with the sender: when a failed swap outbound runs out of reverse_swap IDs, sendFailedOutboundToTreasury returns the exhaustion error rather than falling back to treasury recovery, whose separate ID space may still be free. The item is rescheduled and the sender is refunded at a later height. Other reverse-swap errors still fall back to the treasury.
  • Validate before queueing: queueRecoverySwap now runs MsgSwap.ValidateBasic() before writing. Previously the legacy queue stored invalid recovery swaps unchecked; for example, a failed swap refund reverse-swapping into its own asset only failed when it executed. It now falls back to treasury recovery, which is what the advanced queue already did.
  • Tests: unit tests on both queues cover split-outbound, Ragnarok, byte-identical and reverse-swap siblings, plus an end-to-end LackSigning test for a split outbound, a test that fills all 100 nonce slots and checks the next recovery errors without overwriting, and a LackSigning test that recovers 101 identical items over two signing periods. That test runs with and without a valid original swap, and checks that every treasury or reverse-swap recovery reaches the right destination. These tests fail on develop, where only the last recovery swap survives.
  • Regression fixture: treasury-recovery is regenerated for the new recovery IDs (IDs only; no amounts change).

Note: this path is gated on the MaxOutboundAttempts mimir, which defaults to 0. The recovery ID format changes, so this ships with the normal coordinated upgrade.

🤖 Generated with Claude Code

Edited by Huginn Ai

Merge request reports

Loading
Loading