[wallet] loadwallet RPC - load wallet at runtime#10740
[wallet] loadwallet RPC - load wallet at runtime#10740laanwj merged 7 commits intobitcoin:masterfrom
loadwallet RPC - load wallet at runtime#10740Conversation
f12b3f6 to
72c3745
Compare
src/init.cpp
Outdated
There was a problem hiding this comment.
It'd probably call this deallocWallets()
There was a problem hiding this comment.
Yes, DeleteWallets() is a bad name. DeallocWallets() is good, or perhaps DetachWallets()
src/wallet/db.cpp
Outdated
There was a problem hiding this comment.
What's the reasons for keeping this function (that now always returns true)?
There was a problem hiding this comment.
You're right. This (and CWalletDB::VerifyEnvironment()) are now entirely vestigial and are not called. Both can be removed.
src/wallet/wallet.cpp
Outdated
There was a problem hiding this comment.
I guess this belongs to walletinit.h now?
There was a problem hiding this comment.
Why? vpwallets is accessed by functions in several of the wallet source files.
There was a problem hiding this comment.
I had the idea that walletinit.h/.c is kind of the multiwallet interface (wallet manager). The functions we have there (DeleteWallets(), VerifyWallets(), ShutdownWallets();, etc.) sounded for me after vpwallets belongs there...
IMO, the multiwallet map should ideally not sit within the objects (CWallet) implementation.
There was a problem hiding this comment.
Tend to agree with @jonasschnelli here, though I agree the barrier isn't exactly clear (yet). Ideally we'd move more towards clarifying the interface here - making CWallet less and less aware of all the things around it (including other wallets). @sipa thoughts here?
|
This overlaps significantly with #10762. Not sure how I should ask for review. Perhaps find out which one people think is the priority? Or I could split the |
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
On further thought, I think I prefer the names attachwallet and detachwallet. That gives a bit more distinction from the dump/import RPCs and makes a stronger implication that the new .dat file is being loaded and attached as a separate wallet.
|
@jnewbery IMO this one should rebase on the other. |
Makes logical sense. Downside is that the other is a more significant change, so may take longer to get merged. |
|
If this really depends on that work then there's no other way than waiting. The other downside is that the other commits will show up here too. |
72c3745 to
3f80aae
Compare
3f80aae to
f258768
Compare
…terface 5d2a399 [trivial] fixup comment for VerifyWallets() (John Newbery) 43b0e81 [wallet] Add StartWallets() function to wallet/init.cpp (John Newbery) 290f3c5 [wallet] Add RegisterWalletRPC() function to wallet/init.cpp (John Newbery) 062d631 [wallet] Add CloseWallets() function to wallet/init.cpp (John Newbery) 77fe07c [wallet] Add StopWallets() function to wallet/init.cpp (John Newbery) 2da5eaf [wallet] Add FlushWallets() function to wallet/init.cpp (John Newbery) 1b9cee6 [wallet] Rename WalletVerify() to VerifyWallets() (John Newbery) 9c76ba1 [wallet] Rename InitLoadWallet() to OpenWallets() (John Newbery) Pull request description: Apologies for the mostly code move only PR. This is a pre-req for both #10740 and #10762 All wallet component initialization/destruction functions are now in their own `wallet/init.cpp` translation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet. There should be no changes in behavior from this PR. Tree-SHA512: 7c260eb094f2fa1a88d803769ba60935810968a7309f731135e4b17623b97f18c03bbcd293c942093d1efce62c6c978f9ff484d54dc9a60bc2fcb5af2d160fcd
f258768 to
91aea7e
Compare
|
Rebased now that #10767 is merged. Still a work in progress. PR text updated. |
9baf566 to
15705f4
Compare
15705f4 to
6c5b841
Compare
|
Bad automatic merge of the testcase. Re-merged manually. |
|
Manual rebase fixed the test bug. Travis now passes. This is ready for initial review. |
promag
left a comment
There was a problem hiding this comment.
Quick review. All touched code could be updated as per dev notes.
Most importantly, With the LOCK(cs_wallets) it will be impossible to have concurrent RPC to different wallets, not to mention to the same wallet. Is this expected behavior? - I'm assuming there is a thread pool for RPC.
src/qt/bitcoin.cpp
Outdated
src/qt/bitcoin.cpp
Outdated
src/wallet/init.cpp
Outdated
There was a problem hiding this comment.
Throw an error if -salvagewallet and there are multiple wallets?
There was a problem hiding this comment.
Sounds like a sensible change in behaviour. I think it's beyond the scope of this PR.
There was a problem hiding this comment.
In commit "Allow single wallet to be verified"
It looks like WalletParameterInteraction is already throwing an error in this case. I think it would be better to drop the comment and wallet_files check here. If you'd prefer to keep the check, I think the comment should be something clearer like "// parameter interaction code should have thrown an error if -salvagewallet was enabled with more than wallet file, so the wallet_files size check here should have no effect."
There was a problem hiding this comment.
Updated comment as suggested by @ryanofsky .
There was a problem hiding this comment.
Appears this comment update was lost somewhere?
src/wallet/rpcwallet.cpp
Outdated
There was a problem hiding this comment.
Why not just LOCK(cs_wallets) too?
There was a problem hiding this comment.
Because I'd prefer to avoid recursive locking if possible.
There was a problem hiding this comment.
Yes, definitely. cs_wallets is locked before cs_main in global lock order, so putting it too many places is just asking for trouble, IMO.
|
Thanks for the review @promag! Regarding the locking: Yes, I've implemented this as a mutex for now, which as you point out would limit wallet RPCs to be single-threaded. I'd like to update this to be something a bit better before v0.16. Suggestions are either a shared mutex or (suggested by @theuni) a version of the decay pointers in #10738. The problem with using a shared mutex is that C++ doesn't have a standard library shared mutex until C++14 (std::shared_timed_mutex) so I'd either have to use boost::shared_mutex or roll my own. (apologies - I thought I'd already written a note in this PR explaining this, but I must have failed to hit send!) For now, I think review of this PR with the mutex is helpful, and I'll change it around to use a shared_mutex later. |
|
This seems to ignore the whole issue of long-term wallet references, and probably locks |
…tion interface 5d2a399 [trivial] fixup comment for VerifyWallets() (John Newbery) 43b0e81 [wallet] Add StartWallets() function to wallet/init.cpp (John Newbery) 290f3c5 [wallet] Add RegisterWalletRPC() function to wallet/init.cpp (John Newbery) 062d631 [wallet] Add CloseWallets() function to wallet/init.cpp (John Newbery) 77fe07c [wallet] Add StopWallets() function to wallet/init.cpp (John Newbery) 2da5eaf [wallet] Add FlushWallets() function to wallet/init.cpp (John Newbery) 1b9cee6 [wallet] Rename WalletVerify() to VerifyWallets() (John Newbery) 9c76ba1 [wallet] Rename InitLoadWallet() to OpenWallets() (John Newbery) Pull request description: Apologies for the mostly code move only PR. This is a pre-req for both bitcoin#10740 and bitcoin#10762 All wallet component initialization/destruction functions are now in their own `wallet/init.cpp` translation unit and are no longer static functions on the CWallet class. The bitcoin_server also no longer has any knowledge that there are multiple wallets in vpwallet. There should be no changes in behavior from this PR. Tree-SHA512: 7c260eb094f2fa1a88d803769ba60935810968a7309f731135e4b17623b97f18c03bbcd293c942093d1efce62c6c978f9ff484d54dc9a60bc2fcb5af2d160fcd
Adds a
loadwalletRPCs. This allows wallets to be loaded dynamically during runtime without having to stop-start the node with new-walletparams.Includes functional tests and release notes.
Limitations: