Skip to content

fix(watch-only): make AddressCache::new fallible#931

Open
Sandipmandal25 wants to merge 1 commit intogetfloresta:masterfrom
Sandipmandal25:fix/watch-only-new-fallible
Open

fix(watch-only): make AddressCache::new fallible#931
Sandipmandal25 wants to merge 1 commit intogetfloresta:masterfrom
Sandipmandal25:fix/watch-only-new-fallible

Conversation

@Sandipmandal25
Copy link
Copy Markdown

@Sandipmandal25 Sandipmandal25 commented Apr 3, 2026

Description and Notes

Closes part of #463 and Competency Test for sob 2026 to be submitted along with proposal
image

AddressCache::new and AddressCacheInner::new previously panicked on database failures at startup.
This change makes both return Result<Self, WatchOnlyError<D::Error>>, allowing callers to handle errors instead of crashing.

changes

Replaced three production panics:

  • database.load().expect("Could not load database")

    • propagated with ?
  • database.save_stats(...).expect("Could not save stats")

    • propagated with ?
  • self.database.get_stats().unwrap() (in maybe_derive_addresses)

    • let Ok(...) else { return }

Updated florestad.rs::load_wallet to propagate via
FlorestadError::CouldNotInitializeWallet.

verification

cargo test -p floresta-watch-only
  • All 10 tests pass

  • Includes new_returns_err_when_database_load_fails:

    • uses a FailingDatabase stub
    • load() returns Err
    • asserts AddressCache::new returns Err(WatchOnlyError::DatabaseError(_))
    • confirms no panic on startup path

checklist

@Davidson-Souza Davidson-Souza added the reliability Related to runtime reliability, stability and production readiness label Apr 7, 2026
@github-project-automation github-project-automation bot moved this to Backlog in Floresta Apr 7, 2026
@Davidson-Souza Davidson-Souza moved this from Backlog to Needs review in Floresta Apr 7, 2026
@Davidson-Souza Davidson-Souza added this to the Q2/2026 milestone Apr 7, 2026
@Sandipmandal25 Sandipmandal25 force-pushed the fix/watch-only-new-fallible branch 3 times, most recently from 1938768 to d3b758a Compare April 7, 2026 21:37
@Sandipmandal25 Sandipmandal25 force-pushed the fix/watch-only-new-fallible branch from d3b758a to ac22dcc Compare April 8, 2026 04:16
@jaoleal
Copy link
Copy Markdown
Member

jaoleal commented Apr 13, 2026

Closes part of #463 and Competency Test for sob 2026 to be submitted along with proposal

Just to be clear that was my mistake, a competency test ideally should not be a PR. Thats what i wrote on our discord channel: https://discord.com/channels/1185232004506198056/1488947854612365353/1489335077769838685

@jaoleal
Copy link
Copy Markdown
Member

jaoleal commented Apr 13, 2026

When i started reading the code here i noticed that this is partially addressed on #804 but i have the intuition that it will be discarded, AFAIK the approach there was already reviewed and validated, maybe you could steal the code there and implement it here ? (That is, the error handling for the watch only interface)

@Sandipmandal25
Copy link
Copy Markdown
Author

When i started reading the code here i noticed that this is partially addressed on #804 but i have the intuition that it will be discarded, AFAIK the approach there was already reviewed and validated, maybe you could steal the code there and implement it here ? (That is, the error handling for the watch only interface)

hey @jaoleal when you say "it will be discarded" do you mean pr #804 ? also by "steal the code from #804" and should i just take the full lib.rs error handling changes from there?

@Sandipmandal25
Copy link
Copy Markdown
Author

Closes part of #463 and Competency Test for sob 2026 to be submitted along with proposal

Just to be clear that was my mistake, a competency test ideally should not be a PR. Thats what i wrote on our discord channel: https://discord.com/channels/1185232004506198056/1488947854612365353/1489335077769838685

i missed this acknowledging my mistake.

@jaoleal
Copy link
Copy Markdown
Member

jaoleal commented Apr 13, 2026

hey @jaoleal when you say "it will be discarded" do you mean pr #804 ?

Yes, Im not certain what will be discarded but for sure the error handling for the AddressCache is desirable.

also by "steal the code from #804" and should i just take the full lib.rs error handling changes from there?

Yes, but only if you think its proper.

@Sandipmandal25
Copy link
Copy Markdown
Author

hey @jaoleal when you say "it will be discarded" do you mean pr #804 ?

Yes, Im not certain what will be discarded but for sure the error handling for the AddressCache is desirable.

also by "steal the code from #804" and should i just take the full lib.rs error handling changes from there?

Yes, but only if you think its proper.

i willl expand this with the full lib.rs error handling changes.

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

Labels

reliability Related to runtime reliability, stability and production readiness

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

4 participants