Skip to content

Support NU7 recovery after Sprout removal - #302

Merged
zmanian merged 4 commits into
mainfrom
feat/nu7-supported-recovery
Nov 6, 2026
Merged

zmanian merged 4 commits into
mainfrom
feat/nu7-supported-recovery

Conversation

@zmanian

@zmanian zmanian commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

After #301 removes Sprout recovery, Argos still needs the coordinated NU7 SDK and submission rules for supported pools. This carries the non-Sprout work from #291 onto current main, preserving the newer dependency fixes and private-workspace protections.

  • Upgrade the wallet/crypto SDK family together and move builds to Rust 1.89, retaining legacy key identities and testing old-wallet database migration.
  • Bind reviews to the consensus branch; revalidate fresh network tip, signed branch/version, expiry and padded shielded limits before submission and exact-byte retry.
  • Split large send-max sweeps into bounded transactions while preserving inputs, aggregate fees, payment metadata and partial-success evidence. Account for donations already submitted when a later batch stops.
  • Make birthday estimation network-aware and conservative across the spacing change; reject late GUI responses after network/endpoint changes.
  • Add independent NU7 block/proxy CI and retain an explicit funded recovery qualification gate. Sprout availability UI, spending, journals and P2P are not restored.

Validation of runtime commit e3bf129 (later commits change CI annotations only):

  • Rust 1.89 all-feature workspace: 1,120 passed, zero failures, 40 harness/network cases ignored, including the two live NU7 cases delegated to CI.
  • GUI: 189 Node tests, 26 Chromium and 26 WebKit layout tests passed.
  • Strict all-target/all-feature Clippy, formatting, cargo-deny, locked cargo-vet, actionlint and harness/fixture checks passed.
  • Independent Astra runtime review found partial-batch donation underreporting; the fix passes a regression that demonstrably fails when the original error ordering is restored. Actual Orchard, Ironwood and mixed-pool proposal tests cover padding, input preservation and fee accounting.

Local Docker/node infrastructure was unavailable. The live NU7 block/proxy CI job passed on final head d6858f3; remaining platform/full-suite CI is still running. Funded full-height supported sweeps and signed imported-Sapling PCZT rehearsal remain an unexecuted release gate. Empty fixtures and coinbase/proxy tests do not establish funded recovery acceptance. Exact-version exemptions carried from #291 remain exemptions, not new source-audit claims; newer uncovered aes/ctutils patches were avoided.

Qualification record. This supersedes the supported-recovery scope of #291; it does not merge or close that PR.

@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
zec-wallet-rescue Ready Ready Preview Nov 6, 2026 8:28pm UTC

Request Review

Comment thread .github/workflows/ci.yml Outdated
permissions:
contents: read
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
Comment thread .github/workflows/ci.yml Fixed
A donation split comes from propose_transfer, whose change strategy
emits a zero-valued change output when the transaction balances
exactly. bound_send_max refused any proposal with change, so after NU7
every sweep too large for one transaction failed outright whenever a
donation was set (the default). The donation-free fallback runs before
batching, so it never caught this.

Zero-valued change holds no value and the batches are built without
change, so it is now dropped. Real change is still refused. The
existing donation test built its proposal by hand with no change, which
is why it missed the shape the SDK actually produces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zmanian
zmanian merged commit 102f584 into main Nov 6, 2026
20 checks passed
@zmanian zmanian mentioned this pull request Nov 6, 2026

@poldsam poldsam 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.

Post-merge review of the NU7 carry-forward. This is now most of the code in v2.0.0, and the v2.0.0 release run is signing.

Checked and sound:

  • Tip and branch checks. nu7.rs checks the server's branch against the tip height and refuses signed bytes whose branch or version is wrong for the next block, or whose encoded expiry has passed. Exact-byte retry runs the same check through validate_retry_at_tip, and nothing is rebuilt or rewritten. Prior-branch V5/V6 transactions and V4 are refused after activation, and the tests cover this on both networks.
  • Reviews are bound to the branch. canonical_proposal now hashes the branch id, so a review made under NU6.3 cannot authorize a V6 transaction under NU7.
  • Batching keeps every note. bound_send_max assigns every selected note to exactly one batch, drops no pool, and refuses anything other than an independent shielded send-max (transparent inputs, chained steps or real change are all refused). Each batch's fee comes from the SDK's own padded action counts. The donation stays in payment 0 in every batch, with the destination taking the rounding remainder, matching build_donation_split_proposal.
  • Partial donations are counted correctly. Each batch's donation is tied to its txid before submission. Mined and unknown results count; unsent, rejected and expired ones don't.
  • Imported Sapling batches go through independent_step, which refuses chained steps. The whole account's fee is authorized against --max-fee before the first batch is signed, and each batch is checked again for size and branch after extraction.
  • Confirmation waits don't threaten expiry. Batches are proved up front with a 120-block expiry (about 50 min at 25 s), and the wait per batch is bounded at 24 × 5 s, so later batches can't expire waiting behind earlier ones.
  • Key identities are unchanged. The secp256k1/sapling-crypto API moves keep the same derivations, derive_internal / master failures now return errors instead of being assumed infallible, and LegacyTransparentAddress keeps wallet provenance restricted to P2PKH/P2SH.
  • I checked the zcash_client_backend 0.25.0 source: the SDK does not enforce the ZIP 218 budgets itself (its only size gate is TransactionTooLarge against MAX_BLOCK_BYTES), so Argos has to enforce them, and does.
  • CI is green on 0d08052 and on the merge commit.

Findings (details inline):

  1. Should fix: batches are sized at the per-block budget, so they compete with every other shielded transaction for space. ZIP 218's limits are per block, and a 298-note Sapling batch fills the whole Sapling budget. See nu7_limits.rs:197.
  2. Coverage gap: no end-to-end test spends under NU7 rules. regtest_local_network leaves nu7: None, and the only live NU7 CI job mines coinbase and parses compact blocks. That is the gate waived for 2.0.0; the ZIP 218 constants and the 25 s spacing have never met a node with a spend.
  3. Low: the 5-minute future-timestamp tolerance can refuse legitimate tips. See nu7.rs:26.
  4. Nit: a stale birthday-estimate response leaves the hint stuck. See main.js:1240.

Untested (also listed in #303): migration of an imported-key 1.x workspace has no test; pre_nu7_database_migrates_without_losing_account_or_scan_work covers only a seed-only database.

// A batch with 298 notes plus the mandatory two Sapling outputs fits the
// Sapling budget. Other pools' padded outputs still fit the global budget.
// Balance batch lengths to avoid leaving an uneconomic one-note tail.
let batch_count = notes.len().div_ceil(SAPLING_IO_LIMIT - 2);

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.

ZIP 218's limits are per block, not per transaction: "The total number of Sapling inputs and outputs across all transactions in the block MUST NOT exceed 300", and the same for the 330 global budget. Sizing batches at 298 notes + 2 outputs makes each one consume the block's entire Sapling budget. It can only be mined in a block that contains no other Sapling component, and in a block whose other shielded components total at most about 30.

Whether that is a problem depends on how block templates are selected. If a template adds transactions in weighted-random order and skips any that no longer fit the budget, a full-budget batch only lands when it happens to be picked before any other shielded transaction. Under real shielded traffic it can sit in the mempool until its 120-block expiry. The sweep then reports Expired, the notes come back and the user has to re-run, so no funds are lost, but this is exactly the case batching exists for (large wallets).

Suggest sizing batches well below the block budget, e.g. a quarter of it (~75 Sapling components / ~80 actions per transaction). The extra fee is small: ZIP 317 charges per logical action, so splitting the same notes across more transactions adds only the 2-output padding per batch. The module comment on line 3 ("a transaction must fit by itself") also reads as if the limit were per transaction; it would help to say that it is per block and how much headroom is left.

nu6_1: h,
nu6_2: h,
nu6_3: h,
nu7: None,

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.

With nu7: None here, every regtest sweep (regtest_integration, transparent_only_wallet_sweeps_to_a_shielded_destination and the rest) still runs under NU6.3 rules. The nu7-node-tests CI job mines and parses blocks across activation but never submits a spend. So nothing has checked against a node that a V6/NU7-branch sweep, an imported-Sapling PCZT, or a near-budget batch is accepted and mined. That is the rehearsal the qualification doc waives for 2.0.0. Even one funded NU7 sweep on the nu7-fast profile, including a batch near the size from the previous comment, would close most of it.

pub const TESTNET_ACTIVATION_HEIGHT: u32 = 4_465_026;
const QUERY_TIMEOUT: Duration = Duration::from_secs(15);
const MAX_TIP_AGE: u64 = 30 * 60;
const MAX_FUTURE_TIME: u64 = 5 * 60;

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.

A tip whose timestamp is more than 5 minutes ahead of the local clock is treated as invalid evidence and blocks submission. Two things can trigger that besides a bad server: the local clock running slow (the #303 known gap), and miners' timestamps running ahead. Consensus accepts block times well beyond 5 minutes in the future, so a legitimately mined tip can trip this. With 25 s blocks it usually clears within a block or two, but the error ("tip timestamp is stale or in the future") doesn't tell the user to retry or check their clock. Suggest a wider future tolerance (the staleness bound is what protects against a stale server), or at least wording that names both causes and says to retry.

Comment thread gui/src/main.js
lightwalletdUrl: $("lightwalletd-url").value.trim(),
});
const height = await invoke("estimate_birthday_from_date", request);
if (!isCurrent()) return;

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.

Nit: when the response is discarded because the date, network or endpoint changed, this returns without touching the hint, so "Looking up block height for that date…" stays on screen until the user clicks again. The auto-detect path prints "result discarded: …" in the same situation. Doing the same here would match.

This branch was successfully deployed

1 active deployment
Preview — 0d080524 Deployed Nov 6, 2026 by vercel[bot]
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