-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
Abstract wallet persistence with external persistence providers #66
Conversation
this is required in order to prevent unsaved changes to the descriptor
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #66 +/- ##
=====================================
Coverage 0.0% 0.0%
=====================================
Files 23 24 +1
Lines 2070 2159 +89
=====================================
- Misses 2070 2159 +89
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
I have mitigated the problem by adding a new trait |
this is required for identifying which data/cache belongs to each wallet, when stored separately using persistence providers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zoedberg and @nicbus please let me know if you need help in updating your repositories - I can work on the PRs there
Thanks, I'll try to do it by myself and ask help if needed.
Right now it seems bp-wallet doesn't compile. You can run cargo test
on this branch https://github.com/zoedberg/rgb-integration-tests/tree/try_store_prs to see the errors, that are:
error[E0599]: no method named `clone` found for type parameter `D` in the current scope
--> bp-wallet/src/wallet.rs:155:39
|
151 | impl<K, D: Descriptor<K>, L2: Layer2Descriptor> CloneNoPersistence for WalletDescr<K, D, L2> {
| - method `clone` not found for this type parameter
...
155 | generator: self.generator.clone(),
| ^^^^^ method not found in `D`
|
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `clone`, perhaps you need to restrict type parameter `D` with it:
|
151 | impl<K, D: Descriptor<K> + Clone, L2: Layer2Descriptor> CloneNoPersistence for WalletDescr<K, D, L2> {
| +++++++
error[E0599]: the method `to_string` exists for reference `&D`, but its trait bounds were not satisfied
--> bp-wallet/src/wallet.rs:278:36
|
278 | descriptor: descriptor.to_string(),
| ^^^^^^^^^ method cannot be called on `&D` due to unsatisfied trait bounds
|
= note: the following trait bounds were not satisfied:
`D: std::fmt::Display`
which is required by `D: ToString`
`&D: std::fmt::Display`
which is required by `&D: ToString`
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `to_string`, perhaps you need to restrict type parameter `D` with it:
|
275 | pub(crate) fn new_nonsync<K, D: Descriptor<K> + ToString>(descriptor: &D) -> Self {
| ++++++++++
All dependencies are the beta 7 ones, except for:
amplify-nonasync
(unreleased, checked outmaster
commitb1bf354
)bp-wallet
(checked outstore
commit5dc38aa
)rgb
(checked outstore
commite4c744f
)rgb-std
(checked outstore
commit10690ef
)rgb-core
(checked outnonce
commit1f6e9823
)rust-amplify
(I've tried both withv4.7.0
andv5.0.0-beta.1
, but the errors don't change)
Can you pls check all the patches I am using in ray-server - the repo I shared with you? BP wallet certainly compiles with all them applied |
By checking out bp-std to the |
Yep, forgot about PR for it |
Done: BP-WG/bp-std#40 |
Here zoedberg/rgb-tests@45932e7 I've updated the integration tests to use the refactored persistence flow. It compiles and all tests pass, but I've noticed an unexpected behavior: if I create the directory for bp-wallet ( P.S. I'm seeing also some lint warnings:
|
About the warning: the system reports via log, and to have that reporting you have to use I have pushed commit to |
Code should be linted regardless all features being enabled. Warnings will disappear by changing: if let Err(e) = self.store() {
#[cfg(feature = "log")]
log::error!(
"impossible to automatically-save wallet cache during the Drop operation: {e}"
);
} to: if let Err(_e) = self.store() {
#[cfg(feature = "log")]
log::error!(
"impossible to automatically-save wallet cache during the Drop operation: {_e}"
);
}
I've tried the updated code and confirm this now works as expected. |
we just need to add |
Closes #11, #54, #56
Addresses RGB-WG/RFC#11
I have tried all possible approaches and this is the only one which was possible to actually implement in practice. Unfortunately it took some tall on the API: now all Wallet objects became no-Clone, due to adding
Box<dyn PersistenceProvider>
: if thePersistenceProvider: Clone
than it can't be made into an object and can't be used in that way. UPD: I have mitigated the problem by adding a new traitCloneNoPersistence
and implementing it for all wallet structures. Such clones will not "remember" how to persist the data, but the persistence can be restored on them by usingmake_persistent
API.Adding persistence provider as a generic field also doesn't work: the scale of changes becomes so dramatic that everything using BP wallet would have to be literally rewritten.
The recommended way of using the APIs for the non-blocking I/O: RGB-WG/RFC#12
Asking @will-bitlight and @Matrix-Zhang to provide a feedback on the changes.
@zoedberg and @nicbus please let me know if you need help in updating your repositories - I can work on the PRs there
In the meanwhile I will be updatingrgb-std
andrgb
repos to match the changes here.Two other related PRs: