Skip to content

platform-wallet: the InstantSend wait ignores a ChainLock proof that is already available, so asset-lock funding waits the full 300 s #5946

Open

Description

@romchornyi

Expected Behavior

A funding call that waits for an asset-lock proof (shielded fund-from-asset-lock, platform-address top-up, identity registration and top-up) returns as soon as any usable proof exists: the InstantSend lock, or a ChainLock proof once the funding transaction is in a ChainLocked block. The 300 s InstantSend timeout should only matter when neither proof is available.

Current Behavior

The IS phase waits for the InstantSend lock only. When the IS-lock does not arrive, the call keeps waiting for the full 300 s even after the transaction is mined and ChainLocked and a ChainLock proof could be built. Only after the timeout does the fallback build that proof, and then it is ready immediately.

From a testnet reproduction (shielded fund-from-asset-lock, iOS app; identifiers replaced):

13:02:53 platform_wallet::broadcaster: SPV broadcast accepted by the network txid=<txid>
13:02:53 asset_lock::sync::proof: wait_for_proof: entered outpoint=<txid>:0 timeout=Some(300s)
13:04:28 asset_lock::sync::reconstruction: attaching chain proof to tracked asset lock from finalized scan record outpoint=<txid>:0
13:07:53 shielded::fund_from_asset_lock: IS-lock did not propagate within 300s for shielded fund-from-asset-lock (tx <txid>), falling back to ChainLock proof
13:07:53 asset_lock::sync::proof: ChainLock proof height <height> for tx <txid> taken from a mined-height lookup verified against the SPV header chain
13:07:56 shielded::fund_from_asset_lock: Shielded fund-from-asset-lock succeeded

The ChainLock proof was available at 13:04:28; the call returned at 13:07:56, about 3.5 minutes later. For the app this is a send screen blocked for five minutes instead of about one and a half. The same send moments earlier, when the IS-lock did arrive, took a few seconds.

Possible Solution

resolve_funding_with_is_timeout_fallback runs the first wait through wait_for_proof, which uses MinedHeightLookup::Off: while the funding record has no InstantSend or ChainLocked-block context, it never looks up the mined height, and a ChainLock proof that reconstruction attaches to the tracked lock does not end the wait. Only resolve_chain_proof_after_is_timeout (called by each funding path after FundingResolution::IsTimeout, e.g. shielded) builds the ChainLock proof.

Direction: let the IS phase finish with whichever proof comes first — run it with MinedHeightLookup::WhenRecordCannotProve (the mode wait_for_proof_with already has), and/or wake the waiter (lock_notify) when reconstruction attaches a ChainLock proof to the tracked lock. The 300 s bound then only applies while the transaction is neither IS-locked nor ChainLocked. The fallback path stays for that case.

All four funding paths share the orchestration, so the change helps identity registration, identity top-up and platform-address top-up as well.

Steps to Reproduce

Natural reproduction needs an asset lock whose IS-lock does not reach the wallet, which happens now and then on testnet but cannot be forced from the app.

  1. Testnet wallet with Core funds; dashwallet-ios qa/external-send-receive (SDK test/external-send-qa), or any host calling shielded fund-from-asset-lock.
  2. Send Core → a Shielded address.
  3. When the IS-lock does not arrive, watch the platform_wallet log: the ChainLock proof is attached within ~1–2 minutes, the call returns only after the 300 s timeout.

A unit test can drive it: a funding record that gets a mined height under a ChainLock while no IS-lock is ever delivered; resolve_funding_with_is_timeout_fallback should resolve with a ChainLock proof without waiting for the timeout.

Context

Users of the new Send in Dash Wallet iOS see Confirm spinning for five minutes on Core → Shielded (and the other asset-lock routes) whenever an IS-lock is late. Related: #4238 (ChainLock wait not promoted per record, no cancellation), #5518 (shield guard held through the ChainLock wait).

Your Environment

dashpay/platform v5.2-dev f465de2 (same code on v5.1-dev adfa029); app build on a local integration of #5860, #5863, #5865 (test/external-send-qa 2edc3bd); testnet; iOS simulator.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions