Skip to content

fix(platform-wallet): stale-islock to chainlock fallback for the L1 invite claim - #4364

Merged
QuantumExplorer merged 4 commits into
v4.2-devfrom
salvage/invite-islock-cl-fallback
Aug 11, 2026
Merged

fix(platform-wallet): stale-islock to chainlock fallback for the L1 invite claim#4364
QuantumExplorer merged 4 commits into
v4.2-devfrom
salvage/invite-islock-cl-fallback

Conversation

@bfoss765

@bfoss765 bfoss765 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Salvaged from #4240 (closed as superseded by #4284): the shared-Rust deltas that were never part of #4284 — the stale-islock → ChainLock fallback on the L1 invitation claim path, plus the doc recording the IS→CL resubmission arm's test-coverage boundary. Two clean cherry-picks onto current v4.2-dev (authorship preserved); the base's only change to this file since (#4332) does not overlap.

Full review history of the original implementation on #4240.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Improved invitation claiming with automatic retries when proof data is outdated.
    • Added fallback handling for eligible InstantSend proofs, with ChainLock-only invitations supported directly.
    • Provides clearer retry guidance when a transaction is not yet chain-locked.
  • Bug Fixes

    • Improved prospective identity identification during invitation claims.
    • Enhanced reliability for claims affected by stale transaction proofs.

bfoss765 and others added 2 commits August 10, 2026 17:16
…e claim (#4240)

A voucher islock is signed at creation, so by claim time (minutes-to-hours
later, possibly across a testnet platform-4.1 quorum rotation) Drive may reject
it with InvalidInstantAssetLockProofSignatureError ("try chain asset lock proof
instead"). claim_invitation now recovers exactly as the register/top-up paths do:

  - reconstruct_asset_lock_proof / assemble_asset_lock_proof return a
    ReconstructedProof { primary, chain_fallback }. When the link carried an
    islock AND the funding tx is already chain-locked, a ChainLock proof over the
    SAME credit output is built as chain_fallback.
  - The primary proof is submitted through submit_with_cl_height_retry. If it is
    an IS proof rejected with is_instant_lock_proof_invalid(), the ChainLock
    fallback is resubmitted over the same outpoint. If no fallback exists (tx not
    yet chain-locked), AssetLockNotChainLocked surfaces a clear retry signal.

Adds unit tests for the three assemble outcomes (chainlock-only,
islock+chainlocked→fallback, islock+not-chainlocked→no-fallback).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…L resubmission arm

The unit tests pin proof assembly (IS primary + optional CL fallback)
but not the resubmission arm itself, which needs an injectable
submission seam to be unit-testable; note that at the arm so the gap
raised in review is visible in the code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 27230105-26d4-4a85-9185-127d593bad89

📥 Commits

Reviewing files that changed from the base of the PR and between 232794f and df7c0a0.

📒 Files selected for processing (1)
  • packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs

📝 Walkthrough

Walkthrough

Invitation proof reconstruction now returns a primary proof and an optional ChainLock fallback. Claims retry stale InstantSend submissions with the fallback. ChainLock-only invitations use a ChainLock primary proof, and identity derivation uses the primary proof.

Changes

Invitation proof flow

Layer / File(s) Summary
Proof reconstruction and fallback assembly
packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs
Proof reconstruction returns primary and optional ChainLock proofs. ChainLock-only and unconfirmed funding states follow distinct proof paths. Tests cover fallback availability.
Claim submission retry flow
packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs
Claim submission retries by chain height and resubmits with ChainLock after stale InstantSend rejection. It returns a retry-specific error when no fallback is available.
Primary-proof identity derivation and validation
packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs
Prospective identity derivation and tests now use ReconstructedProof.primary.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant InvitationClaim
  participant ProofReconstruction
  participant Platform
  InvitationClaim->>ProofReconstruction: reconstruct primary and fallback proofs
  ProofReconstruction-->>InvitationClaim: return ReconstructedProof
  InvitationClaim->>Platform: submit primary proof with chain-height retry
  Platform-->>InvitationClaim: reject stale InstantSend proof
  InvitationClaim->>Platform: submit ChainLock fallback proof
  Platform-->>InvitationClaim: return claim result
Loading

Possibly related PRs

  • dashpay/platform#4332: Updates invitation proof reconstruction and prospective identity ID derivation logic used by this change.

Suggested reviewers: lklimek, llbartekll, shumkov

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: ChainLock fallback handling for stale InstantLock proofs in the L1 invitation claim.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch salvage/invite-islock-cl-fallback

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added this to the v4.2.0 milestone Aug 10, 2026
@thepastaclaw

thepastaclaw commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — next in queue (commit df7c0a0)
Queue position: 1/1
ETA: start ~09:00 UTC · complete ~09:11 UTC (median 11m across 30 recent reviews; 2 slots)
Queued 2m ago · Last checked: 2026-08-11 09:00 UTC

…d path

The salvaged fallback changes reconstruct/assemble to return a
ReconstructedProof carrying the optional ChainLock fallback; #4332's
prospective-identity-id caller and its two tests derive the id from the
PRIMARY proof (both proofs cover the same credit output, so the id is
identical either way). 619 tests green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final validation — Codex/Sol only (Phase 2 disabled)

The invitation proof reconstruction and stale-InstantSend-to-ChainLock fallback are internally consistent, and no blocking correctness issue was found. The central resubmission control flow remains untested, so this review requests direct coverage before regressions can surface only in live invitation claims.
Source: codex general reviewer (gpt-5.6-sol), codex rust-quality reviewer (gpt-5.6-sol), and final codex verifier (gpt-5.6-sol); openclaw-agent/cliproxy/gpt-5.6-sol is orchestration-only and not reviewer evidence.

Validated zero-blocker Codex/Sol precheck evidence was promoted to final because Phase 2 (Sonnet/Opus) is temporarily disabled. This is Codex/Sol-only final validation, not Codex + Sonnet/Opus coverage.

Review provenance

  • Codex reviewers: gpt-5.6-sol — general (completed), gpt-5.6-sol — rust-quality (completed)
  • Verifier: gpt-5.6-sol — verifier
  • Sonnet/Opus: not run (Phase 2 disabled — temporary Codex/Sol-only final)
  • Secondary pass: disabled (temporary_phase2_sonnet_disable)

🟡 1 suggestion(s)

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/wallet/identity/network/invitation.rs:539-584: Add direct coverage for the stale-islock resubmission branch
  The new tests verify proof assembly, including when a ChainLock fallback is available, but they never execute this two-attempt submission flow. They would therefore continue passing if a stale InstantSend rejection stopped submitting the fallback, an unrelated SDK error incorrectly triggered a second submission, a successful primary submission invoked the fallback, or the no-fallback path stopped returning `AssetLockNotChainLocked`. Extract this orchestration behind an injectable async submission seam, similar to `fetch_funding_tx_with_retry`, and cover those four outcomes so the PR's principal behavior does not depend exclusively on live claims.

Comment on lines +539 to +584
let identity = match submit_with_cl_height_retry(settings, |s| {
placeholder.put_to_platform_and_wait_for_response_with_private_key(
&self.sdk,
asset_lock,
primary.clone(),
&voucher_priv.0,
identity_signer,
settings,
s,
)
.await
.map_err(PlatformWalletError::Sdk)?;
})
.await
{
Ok(identity) => identity,
// Coverage note (#4240 review): the unit tests pin proof assembly
// (IS primary + optional CL fallback) but not this resubmission arm
// itself — exercising it needs an injectable submission seam, so
// until one exists regressions here surface only in live claims.
Err(e) if is_instant_lock_proof_invalid(&e) => {
let Some(chain_proof) = chain_fallback else {
// The islock was rejected but the funding tx is not yet
// chain-locked, so no ChainLock proof can be built. Surface a
// clear retry signal rather than the raw consensus error.
return Err(PlatformWalletError::AssetLockNotChainLocked(
"invitation islock proof was rejected by Platform (stale — quorum \
rotated or no longer recent) and the funding transaction is not yet \
chain-locked, so no ChainLock fallback is possible; retry once the \
funding block is chain-locked"
.to_string(),
));
};
tracing::warn!(
"invitation IS-lock proof rejected by Platform on claim; retrying with a \
ChainLock proof over the same funding outpoint"
);
submit_with_cl_height_retry(settings, |s| {
placeholder.put_to_platform_and_wait_for_response_with_private_key(
&self.sdk,
chain_proof.clone(),
&voucher_priv.0,
identity_signer,
s,
)
})
.await
.map_err(PlatformWalletError::Sdk)?
}
Err(e) => return Err(PlatformWalletError::Sdk(e)),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Suggestion: Add direct coverage for the stale-islock resubmission branch

The new tests verify proof assembly, including when a ChainLock fallback is available, but they never execute this two-attempt submission flow. They would therefore continue passing if a stale InstantSend rejection stopped submitting the fallback, an unrelated SDK error incorrectly triggered a second submission, a successful primary submission invoked the fallback, or the no-fallback path stopped returning AssetLockNotChainLocked. Extract this orchestration behind an injectable async submission seam, similar to fetch_funding_tx_with_retry, and cover those four outcomes so the PR's principal behavior does not depend exclusively on live claims.

source: ['codex']

… injectable seam

The claim's two-attempt submission flow (primary proof, then the ChainLock
fallback on Platform's stale-islock rejection) was pinned only by proof-assembly
tests, so a regression in the orchestration itself — submitting the fallback for
an unrelated error, skipping it for a stale islock, or losing the
AssetLockNotChainLocked retry signal — would surface only in live claims.

Extract the orchestration into submit_claim_with_stale_islock_fallback, generic
over the submit future (mirroring fetch_funding_tx_with_retry's seam), and
script it directly:

  - a successful primary never touches the fallback
  - a stale-islock rejection resubmits the ChainLock fallback
  - a stale-islock rejection with no fallback surfaces AssetLockNotChainLocked
  - an unrelated SDK error propagates without a second submission
  - the recovery runs exactly once (a rejected fallback is not re-recovered)

claim_invitation now routes through the seam unchanged in behavior; the
coverage-boundary note recorded on the arm is superseded and removed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@QuantumExplorer
QuantumExplorer merged commit b10256c into v4.2-dev Aug 11, 2026
17 checks passed
@QuantumExplorer
QuantumExplorer deleted the salvage/invite-islock-cl-fallback branch August 11, 2026 09:00
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.63%. Comparing base (86f3878) to head (df7c0a0).
⚠️ Report is 5 commits behind head on v4.2-dev.

Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4364      +/-   ##
============================================
- Coverage     87.80%   87.63%   -0.18%     
============================================
  Files          2641     2670      +29     
  Lines        336510   339447    +2937     
============================================
+ Hits         295468   297464    +1996     
- Misses        41042    41983     +941     
Components Coverage Δ
dpp 88.86% <ø> (ø)
drive 86.25% <ø> (ø)
drive-abci 89.66% <ø> (-0.01%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.88% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 48.02% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants