Page MenuHomePhabricator

Modify Rust restore code to avoid fetching latest backup id twice
ClosedPublic

Authored by marcin on May 14 2024, 8:52 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 10, 1:38 AM
Unknown Object (File)
Thu, Oct 31, 3:03 PM
Unknown Object (File)
Oct 17 2024, 11:44 AM
Unknown Object (File)
Oct 17 2024, 7:00 AM
Unknown Object (File)
Oct 17 2024, 12:23 AM
Unknown Object (File)
Oct 15 2024, 4:16 PM
Unknown Object (File)
Oct 15 2024, 4:16 PM
Unknown Object (File)
Oct 15 2024, 4:16 PM
Subscribers

Details

Summary

This differentila modifies the C++ and Rust backup code so that it is possible to restore without querying the backup service for backup id if it is already provided. For SIWE users we will know backup id before we want to restore since we need backup message (that comes with backup id) to prepare backup secret.

Test Plan

For now check that restoration for non-password users work. Next diff in the stack will test SIWE case.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

marcin added inline comments.
native/native_rust_library/src/backup.rs
401–406 ↗(On Diff #40166)

This unrelated change was requested in DM by @bartek to fix his secondary device qr code log in.

Harbormaster returned this revision to the author for changes because remote builds failed.May 14 2024, 9:10 AM
Harbormaster failed remote builds in B28901: Diff 40166!
bartek requested changes to this revision.May 15 2024, 12:19 AM
bartek added inline comments.
native/native_rust_library/src/backup.rs
84

It'd look like this if you applied the suggestion below about using Option

122

Note that you

  • modified download_backup() to optionally retrieve backup ID.
  • modified download_backup_keys() to require backup ID from outside.

So you can't pass an empty string here because this function won't be able to get the ID itself.

This is one of the reasons I prefer Option to distinguish if something is required. It saves us from making such mistakes

266–275

For C++ ↔ Rust communication, relying on empty/non-empty strings is okay.

But for internal Rust functions, we should use Option where possible

400–402

Thanks for adding this!

This revision now requires changes to proceed.May 15 2024, 12:19 AM
  1. Address comment about Optional
  2. Add additional siwe message parsing to avoid having to do it in JS (where we have no tools for that)
This revision is now accepted and ready to land.May 17 2024, 2:11 AM