-
Notifications
You must be signed in to change notification settings - Fork 137
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
Full Lifecycle API Support #184
Full Lifecycle API Support #184
Conversation
…ecycle provider, remove password + open_with_credentials from WalletBackend + impl
|
Ready for any review now, paves the way for changes in the associated RFC without actually changing anything external for users or wallet developers. Note there's an internal change whereby the seed is now kept in memory instead of the password as before when the wallet is listening. This won't be the case at the next release, where we'd be expecting to replace this with an XORed token value (see current proposal of security model in RFC) |
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.
didn't take a look at impls/src/lifecycle/default.rs
yet, obviously that is where the meat and potatoes is
The new type is really quite unfortunate and verbose, not sure there is any way around that
overall this is an absolutely massive PR that has a few different refactors in it, hopefully no one else is working in these files but I suppose they're not
I'm not sure that changes to the wallet cli are unit tested but that functionality has been changed due to refactor, would be worth testing out. There should probably be a smoke test suite that tests functionality via CLI (maybe there already is?)
@@ -462,11 +471,23 @@ macro_rules! doctest_helper_setup_doc_env_foreign { | |||
.unwrap(); | |||
let mut wallet_config = WalletConfig::default(); | |||
wallet_config.data_file_dir = dir.to_owned(); | |||
let pw = ""; | |||
let pw = ZeroingString::from(""); |
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.
it would be cool to see a lazy static for this. C# for example has string.Empty
etc
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.
Think this is okay, it's just test setup
@@ -1338,7 +1340,8 @@ pub fn run_doctest_owner( | |||
) -> Result<Option<serde_json::Value>, String> { |
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.
this function has a lot of unwrap
. I understand that it is a test helper but even so, it seems un-necessary not sure how difficult the refactor of this return type would be
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.
I think unwraps in tests are okay for now, happy to see a PR later that removes them (a lot of these tests were written before you could return a Result from main or from a test).
// Use config file if current directory if it exists, .grin home otherwise | ||
if let Some(p) = check_config_current_dir(WALLET_CONFIG_FILE_NAME) { | ||
GlobalWalletConfig::new(p.to_str().unwrap()) | ||
} else { | ||
// Check if grin dir exists | ||
let grin_path = get_grin_path(chain_type)?; | ||
let grin_path = match data_path { |
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.
could probably use unwrap_or
, it's a style question
config/src/config.rs
Outdated
|
||
// Get path to default config file | ||
let mut config_path = grin_path.clone(); | ||
config_path.push(WALLET_CONFIG_FILE_NAME); | ||
|
||
// Spit it out if it doesn't exist | ||
println!("CONFIG PATH: {}", config_path.to_str().unwrap()); |
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.
should this be info!
?
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.
Leftover debug println, thanks for catching!
@@ -131,35 +135,36 @@ where | |||
|
|||
// If so configured, add the foreign API to the same port | |||
if owner_api_include_foreign.unwrap_or(false) { | |||
info!("Starting HTTP Foreign API on Owner server at {}.", addr); | |||
let foreign_api_handler_v2 = ForeignAPIHandlerV2::new(wallet.clone()); | |||
warn!("Starting HTTP Foreign API on Owner server at {}.", addr); |
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.
why info
->warn
? if we want to see the messages we can set the log level, these don't look like warnings to me
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.
Changed this for consistency with how it's done in other places. The default in grin.toml is warn
, and I think we want to make sure something like that is definitely printed to the console by default.
pub fn foreign_listener<T: ?Sized, C, K>( | ||
wallet: Arc<Mutex<T>>, | ||
pub fn foreign_listener<L, C, K>( | ||
wallet: Arc<Mutex<Box<dyn WalletInst<'static, L, C, K> + 'static>>>, |
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.
this type is unfortunate but i understand how it came to be
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.
Indeed... the joys of rust. At least it works how you think it's going to work once you're done fighting with the compiler
Thanks for review, wallet APIs are definitely exercised extensively by tests, the CLI is as well but a bit less so. I've manually tested that all of the init/recover/restore operations work exactly as they did before these changes. More tests are definitely needed, however I'm planning to replace most of the CLI code with the CLI code borrowed from wallet713, to make the whole thing more cohesive. Will definitely be adding to the test suite at that stage to ensure all operations are tested at the CLI/listener level as well. |
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.
So many changes. Overall direction looks good, but I'm hoping now that you've finished laying the groundwork for the full lifecycle, we can start having smaller, more incremental reviews? I suggest for the new APIs we're going to be adding, there should probably be a review per API. It's a bit slower with more overhead, but it's probably the best way to get real input from wallet devs about what the APIs should look like. It would also be a natural way of splitting up the work to let other devs get their feet wet.
Yes, next bits of functionality to go in related the the current RFC are much more easily split-up. I don't think there will be a need for another refactor of this size (in the foreseeable future, anyhow). |
* version bump for next potential release * Merge master into milestone/2.1.0 (#182) * Derive --version output dynamically from cargo package version (#174) * add --txid to the `wallet txs` command (#176) * add --txid to the `wallet txs` command * add test for `wallet txs` command with `--txid` parameter * Refactor - Split WalletCommAdapter into multiple traits (#180) * Derive --version output dynamically from cargo package version (#174) * add server auth argument to http client * Revert "add server auth argument to http client" This reverts commit f52a8d2. * modify WalletCommAdapter, moving dest argument into fields on implementors, visiting havok on automated tests, at least one of which is now out of date and failing * Split WalletCommAdapter into four traits, one for each of its intended behaviors. * Remove two vestigals 1. args, a stringly typed argument to put_tx 2. NullAdapter, which is no longer used * Remove unused "params" argument from listen method. * Re-add previously existing TODO comment * Fix non-test build * completely Fix non-test build * Full Lifecycle API Support (#184) * refactoring wallet lib traits * rustfmt * rustfmt * add new files * explicit lifetime specifiers on all wallet traits * rustfmt * modify apis to use new walletinst * rustfmt * converting controller crate * rustfmt * controller crate compiling * rustfmt * compilation * rustfmt * Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl * rustfmt * full compilation, changing recovery + init to new model * rustfmt * wallet initialisation working, init command output and flow identical to v2.0.0 wallet * rustfmt * fix listener and owner api startup * rustfmt * rustfmt * move encryption test * rustfmt * fix api doctests * rustfmt * fix for most tests in controller crate * rustfmt * fix for check tests in controller crate * fix main wallet tests * rustfmt * add explicit functions to handle mnemonic recovery, fix CLI recovery workflow * rustfmt * update keybase adapter to use new wallet format * rustfmt * test fix * remove debug output
* version bump for next potential release * Merge master into milestone/2.1.0 (mimblewimble#182) * Derive --version output dynamically from cargo package version (mimblewimble#174) * add --txid to the `wallet txs` command (mimblewimble#176) * add --txid to the `wallet txs` command * add test for `wallet txs` command with `--txid` parameter * Refactor - Split WalletCommAdapter into multiple traits (mimblewimble#180) * Derive --version output dynamically from cargo package version (mimblewimble#174) * add server auth argument to http client * Revert "add server auth argument to http client" This reverts commit f52a8d2. * modify WalletCommAdapter, moving dest argument into fields on implementors, visiting havok on automated tests, at least one of which is now out of date and failing * Split WalletCommAdapter into four traits, one for each of its intended behaviors. * Remove two vestigals 1. args, a stringly typed argument to put_tx 2. NullAdapter, which is no longer used * Remove unused "params" argument from listen method. * Re-add previously existing TODO comment * Fix non-test build * completely Fix non-test build * Full Lifecycle API Support (mimblewimble#184) * refactoring wallet lib traits * rustfmt * rustfmt * add new files * explicit lifetime specifiers on all wallet traits * rustfmt * modify apis to use new walletinst * rustfmt * converting controller crate * rustfmt * controller crate compiling * rustfmt * compilation * rustfmt * Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl * rustfmt * full compilation, changing recovery + init to new model * rustfmt * wallet initialisation working, init command output and flow identical to v2.0.0 wallet * rustfmt * fix listener and owner api startup * rustfmt * rustfmt * move encryption test * rustfmt * fix api doctests * rustfmt * fix for most tests in controller crate * rustfmt * fix for check tests in controller crate * fix main wallet tests * rustfmt * add explicit functions to handle mnemonic recovery, fix CLI recovery workflow * rustfmt * update keybase adapter to use new wallet format * rustfmt * test fix * remove debug output
* version bump for next potential release * Merge master into milestone/2.1.0 (mimblewimble#182) * Derive --version output dynamically from cargo package version (mimblewimble#174) * add --txid to the `wallet txs` command (mimblewimble#176) * add --txid to the `wallet txs` command * add test for `wallet txs` command with `--txid` parameter * Refactor - Split WalletCommAdapter into multiple traits (mimblewimble#180) * Derive --version output dynamically from cargo package version (mimblewimble#174) * add server auth argument to http client * Revert "add server auth argument to http client" This reverts commit f52a8d2. * modify WalletCommAdapter, moving dest argument into fields on implementors, visiting havok on automated tests, at least one of which is now out of date and failing * Split WalletCommAdapter into four traits, one for each of its intended behaviors. * Remove two vestigals 1. args, a stringly typed argument to put_tx 2. NullAdapter, which is no longer used * Remove unused "params" argument from listen method. * Re-add previously existing TODO comment * Fix non-test build * completely Fix non-test build * Full Lifecycle API Support (mimblewimble#184) * refactoring wallet lib traits * rustfmt * rustfmt * add new files * explicit lifetime specifiers on all wallet traits * rustfmt * modify apis to use new walletinst * rustfmt * converting controller crate * rustfmt * controller crate compiling * rustfmt * compilation * rustfmt * Remove config from wallet, implement open_wallet, close_wallet in lifecycle provider, remove password + open_with_credentials from WalletBackend + impl * rustfmt * full compilation, changing recovery + init to new model * rustfmt * wallet initialisation working, init command output and flow identical to v2.0.0 wallet * rustfmt * fix listener and owner api startup * rustfmt * rustfmt * move encryption test * rustfmt * fix api doctests * rustfmt * fix for most tests in controller crate * rustfmt * fix for check tests in controller crate * fix main wallet tests * rustfmt * add explicit functions to handle mnemonic recovery, fix CLI recovery workflow * rustfmt * update keybase adapter to use new wallet format * rustfmt * test fix * remove debug output
Exploratory PR being developed in tandem with: mimblewimble/grin-rfcs#11
Thus far, this:
'static
lifetime requirementsAlso, this is an all-out war with the Rust compiler, but getting there.