Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor/wallet async signing #1846

Open
wants to merge 3 commits into
base: refactor/wallet-generic-signer
Choose a base branch
from

Conversation

OBorce
Copy link
Contributor

@OBorce OBorce commented Nov 28, 2024

  • Make the Signer trait use async functions to enable future support for the Ledger wallet integration.
  • Change to use a local object that stores any new changes in memory instead of a DB transaction so it can used more easily in async contexts than a reference

wallet/wallet-controller/src/synced_controller.rs Outdated Show resolved Hide resolved
wallet/src/wallet/mod.rs Outdated Show resolved Hide resolved
@@ -221,6 +223,13 @@ pub trait WalletStorageEncryptionWrite {
fn encrypt_seed_phrase(&mut self, new_encryption_key: &Option<SymmetricKey>) -> Result<()>;
}

pub trait WalletStorageReadWriteLocked: WalletStorageReadLocked + WalletStorageWriteLocked {}
Copy link
Member

Choose a reason for hiding this comment

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

This change to the hierarchy is confusing. If I understand correctly you needed new storage type without a reference to an actual storage. But why introducing new traits if you could implement previous for a new type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

wallet/wallet-rpc-lib/src/rpc/mod.rs Outdated Show resolved Hide resolved
Comment on lines 1079 to 1081
// In case of an error reload the keys in case the operation issued new ones and
// are saved in the cache but not in the DB
Copy link
Contributor

Choose a reason for hiding this comment

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

The grammar is broken in this sentence and the meaning is not super clear.
Also, since it's a copy-paste, the original should be updated too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated, hopefully it is more clear now

Comment on lines +1225 to +1234
let acc = accounts
.remove(&account_index)
.ok_or(WalletError::NoAccountFoundWithIndex(account_index))?;

let (acc, res) = f(acc).await;

accounts.insert(account_index, acc);
Ok(res)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose this is a workaround for that weird lifetime-related issue you posted in the chat recently.
But I thought you've managed to solve it by boxing some futures. So it didn't work after all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The boxed future is used in the Synced Controller, this was a prior workaround for the lifetimes to not pass the account as a reference but as a value. I have not tried if a boxed future will solve this as well or not, but also not sure how expensive boxed futures are?

@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch 3 times, most recently from b3bd09f to fd48654 Compare December 9, 2024 16:06
@OBorce OBorce force-pushed the refactor/wallet-async-signing branch from b05ce60 to dcefb1f Compare December 9, 2024 17:13
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from fd48654 to 511bba3 Compare December 10, 2024 16:56
@OBorce OBorce force-pushed the refactor/wallet-async-signing branch 3 times, most recently from f0dcbbc to 6c8ab7c Compare December 11, 2024 09:07
@OBorce OBorce force-pushed the refactor/wallet-generic-signer branch from 3b76519 to 46cf688 Compare December 11, 2024 10:35
@OBorce OBorce force-pushed the refactor/wallet-async-signing branch from 6c8ab7c to 8d21f6a Compare December 11, 2024 10:35
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