[fix] Retain stale migrate pending txouts

Summary

This MR fixes stale migrate pending accounting for retiring vaults and adds a bounded recovery path for dead migrate txouts.

Previously, migrate scheduling treated SigningTransactionPeriod as the visibility window for pending migration txouts. That was unsafe because migrate observations clear the exact MIGRATE:<height> pending marker only when the outbound is observed. If the marker or txout aged out first, thornode could forget that an older migration was still unresolved and schedule another migrate from stale vault balances.

The fix keeps unresolved migrate pending heights durable for normal accounting, explicitly scans stale pending migrate heights from retiring vaults, and only retries a dead migrate after a conservative timeout.

Mocknet Incident

In the failing mocknet run, the effective constants were:

SigningTransactionPeriod = 30
FundMigrationInterval    = 30
ChurnMigrateRounds       = 2

An XRP retiring vault had:

XRP balance = 248542067700

At height 3234, thornode scheduled the first migration round:

248542067700 / 2 = 124271033850
rounded            = 124271033800
minus gas 1500     = 124271032300

So the first migrate txout was:

memo   = MIGRATE:3234
amount = 124271032300 XRP.XRP

That tx was broadcast and later observed/accounted, but not before the later migration scheduling pass aged past SigningTransactionPeriod.

At height 3294, the rolling scan started at:

3294 - 30 = 3264

So the 3234 pending txout was no longer visible. The previous pending height had also been pruned from the vault pending-height list. migrateFunds therefore treated the vault as if no XRP migration was pending and recomputed from the stale full vault balance.

Because this was now the final migration round for XRP, it scheduled almost the full balance:

stale full balance = 248542067700
minus gas 1500     = 248542066200
minus XRP reserve  = 248442066200

That second migrate tx was not a duplicate L1 tx. It had a different amount and memo height, so it produced a distinct outbound and overcommitted the retiring vault.

Changes

  • Stop pruning Vault.PendingTxBlockHeights by SigningTransactionPeriod.
  • Preserve pending migrate heights until the matching migrate observation removes them.
  • In migrateFunds, scan stale pending migrate heights from retiring vaults even when they are older than the normal rolling txout window.
  • Deduct stale pending txouts from available vault coins.
  • Mark vaults with pending migrate txouts so new migrations are not scheduled prematurely.
  • Add a bounded fallback for dead migrate txouts: after 4 * SigningTransactionPeriod, mark expired unobserved migrate txouts as replaced and allow a fresh migrate to be scheduled.
  • Handle duplicate same-height migrate entries by removing one pending-height marker per expired migrate txout.
  • Process cached stale txout heights deterministically in height order.
  • Validate SigningTransactionPeriod > 0 before using it for stale-migrate accounting.
  • Increase mocknet cluster SIGNING_TRANSACTION_PERIOD from 30 to 120.

Mocknet Configuration

The mocknet cluster previously had:

SIGNING_TRANSACTION_PERIOD=30

This made the signing period equal to a single migration interval. A delayed observation only had to miss one later scheduling window before the pending migrate txout could become invisible.

This MR changes mocknet to:

SIGNING_TRANSACTION_PERIOD=120

That gives mocknet four migration intervals of pending outbound visibility, which better tolerates delayed observations in multi-chain simulations while still keeping churn tests fast.

This configuration change is a mitigation for compressed mocknet timing. The protocol correctness fix is retaining and explicitly scanning unresolved migrate pending heights until observation removes them, with a conservative bounded retry for migrate txouts that never get broadcast or observed.

Edited by ZlyDevMaya

Merge request reports

Loading
Loading