Skip to content

A missing birthday means the tip minus 100, so a restore with no birthday would miss older notes #36

Backlog

Description

@danielgorgonha

When birthday_height is None, the account starts 100 blocks below the chain tip. The docs say otherwise. I ran this at the head of #27 (9ad0a58) and read the same code on main (317d790).

How I ran it. A native harness calls the inner Rust Wallet methods that the wasm bindings wrap, over native tonic, against a public mainnet lightwalletd, at #27's head (it pins zcash_client_backend 0.25.0; main requires 0.24.0-rc.1). The key is a throwaway key that holds no funds. The bindings and the browser transport were not exercised. The program and its output are in https://github.com/deegalabs/WebZjs/tree/409ce5a294db0a196a24e446f7687621bc9f3677/repro/birthday-lock-stall. Note 4 is the run. Notes 1, 2 and 5 to 7 are read from the code.

  1. import_account_ufvk reads the tip with get_latest_block and uses chain_tip - 100 (wallet.rs:232-244).
  2. create_account, create_account_ufvk and create_account_view_ufvk pass their Option<u32> straight to it (bindgen/wallet.rs:175, :208, :247), so all three do this.
  3. A restored seed or an imported key given no birthday scans from 100 blocks below the tip. Notes received earlier are not found. The balance leaves them out and no error is raised. It reads 0 when every note is older. That older notes are missed follows from the scan start. I did not run that case, because it needs a wallet with funded notes.
  4. Measured. import_ufvk and create_account with None store a birthday of tip minus 100 (3,617,626 at a tip of 3,617,726), read back from the account. The UFVK path and the seed path give the same result.
  5. The docs say two other things. The Rust doc says "optionally None and the current height is used" (wallet.rs:178). The WebWallet doc says a missing birthday means the wallet "will need to scan the entire blockchain" (bindgen/wallet.rs:51). The birthday_height docs of the three functions do not say what None does (:167).
  6. The web wallet creates its account with the tip as birthday (useWebzjsActions.ts:250-254). Full Resync passes undefined when it has no custom birthday and no stored webWalletSyncStartBlock (:417-419, :453), so it takes this path too.
  7. There is no call that changes an account's birthday after import. A wallet created this way is repaired only by building a new one.

Fix to consider. Make birthday_height a required u32 in the three JS functions, so every caller chooses one.

If that is too strict, two other ways.

  • Return an Error when it is None, with a message that names the problem.
  • Keep the default, document it in all three functions, and correct the two docs above.

🤖 Generated with Claude Code

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions