Skip to content

Suppress false insufficient-balance errors while syncing#203

Draft
piatoss3612 wants to merge 7 commits into
mainfrom
rowan/vzr-42
Draft

Suppress false insufficient-balance errors while syncing#203
piatoss3612 wants to merge 7 commits into
mainfrom
rowan/vzr-42

Conversation

@piatoss3612

@piatoss3612 piatoss3612 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Problem

While the wallet is still scanning, the local spendable balance can be transiently lower than the eventual spendable balance. Send and ZEC swap paths treated those mid-sync shortfalls as final insufficient-funds errors, which could block Review or surface misleading balance copy even though retrying after sync would succeed.

Approach

Keep the fix small and avoid a separate readiness state:

  • Rust send proposal builders prefix proposal-building failures with stable failure codes only when the error is actionable for UI classification: sync_in_progress, scan_required, or insufficient_funds.
  • Rust treats active sync as non-final for shortfall classification, even if the wallet DB summary still appears synced to its last stored tip.
  • Dart adds a lightweight SendFailureKind parser for those coded Rust errors.
  • SyncState.isSyncedToTip is a computed getter from the existing sync fields; it is used only to decide when a local spendable shortfall is final.
  • Desktop and mobile send no longer block on local spendable shortfall until sync is actually at tip.
  • Desktop send re-reads spendable balance after async fee estimates before deciding whether amount + fee is insufficient.
  • Mobile send rechecks the current synced spendable balance before moving from amount entry to review, so a stale mid-sync valid amount becomes blocked once sync reaches tip.
  • ZEC swap composer no longer treats the current spendable balance as an authority for quote review; it lets a valid quote reach review.
  • ZEC swap MAX maps zero estimates and coded syncing failures to the existing “Still syncing” copy while sync is incomplete.
  • ZEC swap review keeps the local balance block only when sync is at tip, then lets ZEC send preflight make the authoritative call.
  • ZEC swap preflight maps coded syncing errors to the existing “Still syncing” copy instead of a generic wallet-preflight failure.

Scope

This PR covers send and the ZEC-send side of swap. It does not change non-ZEC deposit flows or broaden generic swap failure handling.

Behavior

  • Mid-sync shortfall: Review/preflight is allowed to reach Rust, and coded syncing failures ask the user to wait.
  • Active-sync shortfall: Rust keeps insufficient-funds proposal failures classified as sync_in_progress until sync has stopped and the DB is synced to tip.
  • Desktop send in-flight fee estimate: if sync updates spendable balance while fee estimation is pending, the final amount + fee comparison uses the latest spendable balance.
  • Mobile send stale amount: if sync reaches tip before the user taps Review, the amount screen rechecks the final balance and restores “Not enough ZEC” instead of navigating to review.
  • Mid-sync ZEC swap MAX: zero estimates and coded syncing failures ask the user to wait instead of showing insufficient-balance or generic max-unavailable copy.
  • Fully synced send shortfall: the existing insufficient-balance behavior remains final and blocking.
  • Fully synced ZEC swap composer shortfall: quote review is still allowed, but the review/start path can block on the live quote amount.
  • Unknown proposal errors still follow the existing generic failure paths.

Testing

Latest targeted validation after the desktop fee-estimate recheck:

  • fvm flutter test test/features/send/send_screen_test.dart
  • fvm flutter analyze
  • git diff --check

Targeted validation after the mobile review recheck:

  • fvm flutter test test/features/send/mobile_send_screen_test.dart --tags mobile --run-skipped --dart-define=VIZOR_FORM_FACTOR=mobile
  • fvm flutter analyze
  • git diff --check

Validation after rebasing onto origin/main (f18df5ef):

  • fvm flutter test test/features/send/mobile_send_screen_test.dart --tags mobile --run-skipped --dart-define=VIZOR_FORM_FACTOR=mobile
  • fvm flutter test test/features/send/send_screen_test.dart test/features/send/send_failure_test.dart test/features/swap/swap_screen_test.dart
  • fvm flutter test test/features/swap/mobile_swap_modal_route_test.dart --tags mobile --run-skipped --dart-define=VIZOR_FORM_FACTOR=mobile
  • fvm flutter analyze
  • cd rust && cargo test wallet::sync::send::tests
  • git diff --check

Earlier validation before the latest main rebase:

  • fvm flutter test → 1388 passed / 47 skipped
  • cd rust && cargo test --lib → 179 passed / 1 ignored

@piatoss3612 piatoss3612 changed the title Hold back transient insufficient-balance state during sync (VZR-42) Suppress false insufficient-balance errors while syncing Jun 8, 2026
@piatoss3612 piatoss3612 force-pushed the rowan/vzr-42 branch 2 times, most recently from 82fbb8f to b04acad Compare June 22, 2026 04:42
@piatoss3612 piatoss3612 reopened this Jun 22, 2026
@piatoss3612 piatoss3612 force-pushed the rowan/vzr-42 branch 6 times, most recently from 9917514 to 0ebb26a Compare June 22, 2026 08:41
@piatoss3612 piatoss3612 marked this pull request as ready for review June 22, 2026 08:50

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0ebb26ac1b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread rust/src/wallet/sync/send.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1db4a88083

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/src/features/send/screens/mobile/mobile_send_screen.dart

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2a308c6be6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/src/features/send/screens/send_screen.dart Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7379523e27

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/src/features/send/screens/mobile/mobile_send_screen.dart Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2064d5300b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/src/features/send/screens/send_screen.dart Outdated
@piatoss3612 piatoss3612 self-assigned this Jun 23, 2026
Replace the fabricated "InsufficientFunds" unit-test input with the real
zcash_client_backend 0.23.0 Display string, and add classifier_matches_real_
librustzcash_display: a canary that constructs the actual Error::InsufficientFunds
/ Error::ScanRequired variants and runs their Display through send_build_error_code,
so a future crate bump that renames those strings breaks CI instead of silently
reintroducing the VZR-42 false "insufficient" symptom. Also pin the send-max
"Insufficient shielded balance to cover fee" custom string, guard the Dart
classifySendFailure AnyhowException(.message) branch (the real FRB runtime type),
and document the Display/custom-string coupling on send_build_error_code.

VZR-42 review follow-up.
@piatoss3612 piatoss3612 marked this pull request as draft June 25, 2026 13:48
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.

1 participant