feat(bifrost): hold refunds until their inbound is finalised + owned (parity C4a)

🔎 Visual review of f5efe1e6: explainer, review flags and prompts to ask an AI about the change

Public-develop parity cluster C4a

Faithful port of the shipped-3.21.1 refund-funding guard from tag 7061c98d01b, non-EVM part. Stacked on C3; review that first. No milestone (targets public develop / next minor).

Before signing a REFUND outbound, the signer validates against a fresh inbound voter that the refund's inbound is finalised, not reverted, and actually owns this refund action; otherwise it holds (defers) and retries on a later block. This stops a node funding a refund whose inbound was reorged, reverted, or never observed.

Commits

  1. signer storage — TxOutStoreItem.RefundFundingRetryHeight + DeferRefundFunding / UpdateRefundFundingRetry; Set/Batch serialized under one mutex, Batch never replaces existing signing/recovery evidence.
  2. refund-funding guard — validateRefundFunding (fresh voter: finalised/not-reverted/action-owned), wired into the signer pipeline (pre-lock + pre-broadcast checks, a retry loop, ready/defer in the store list), the UTXO signer path, the fresh inbound-voter query, and shared helpers.

Scope split

The EVM refund-funding path (shared/evm/refund_funding.go, ethereum/evm) is intentionally not here: it needs the direct_erc20_transfer gate change, whose consistency fix lives in the EVM-occurrence rework (C6). It lands as C4b-EVM after C6.

Review asks (@huginn-bot @zlyzol)

  • validateRefundFunding runs twice (pre-lock and pre-broadcast) — confirm the second check is needed (vault state can change while the lock is held) and that a hold defers rather than drops.
  • Storage: confirm Batch skipping existing keys cannot drop a legitimately-updated item.

Notes

  • Builds mainnet+mocknet; signer/thorclient/shared-types/utxo tests green.
  • mr-overlap-check: priv!191 / !4838 touch shared files (inherited via the C3 stack) for unrelated problems — rebase-risk only.
Edited by Huginn Ai

Merge request reports

Loading
Loading