-
Notifications
You must be signed in to change notification settings - Fork 115
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
add(scan): Implement DeleteKeys
ScanService
request
#8217
Conversation
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 this looks really good. I left some of comments and questions but i don't think any of those are blockers.
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.
thanks for the changes.
let response_fut = scan_service | ||
.ready() | ||
.await | ||
.map_err(|err| eyre!(err))? | ||
.call(Request::DeleteKeys(vec![zec_pages_sapling_efvk.clone()])); | ||
|
||
let expected_keys = vec![zec_pages_sapling_efvk.clone()]; | ||
let cmd_handler_fut = tokio::task::spawn_blocking(move || { | ||
let Ok(ScanTaskCommand::RemoveKeys { done_tx, keys }) = cmd_receiver.recv() else { | ||
panic!("should successfully receive RemoveKeys message"); | ||
}; | ||
|
||
assert_eq!(keys, expected_keys, "keys should match the request keys"); | ||
|
||
done_tx.send(()).expect("send should succeed"); | ||
}); |
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.
Optional Suggestion
This looks great. I wonder if we could use mocked services from zebra-test
, for example: https://github.com/ZcashFoundation/zebra/blob/main/zebra-test/src/mock_service.rs and https://github.com/ZcashFoundation/zebra/blob/main/zebra-test/src/transcript.rs. I haven't used them yet, but I'll look into it.
) -> JoinHandle<Result<(), Report>> { | ||
scan::spawn_init(config, network, state, chain_tip_change) | ||
/// Sends a message to the scan task to remove the provided viewing keys. | ||
pub fn remove_keys( |
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.
Optional Suggestion
I think it would be good to place this function into a different file since the filename is init.rs
, but let's do that in a different PR?
// TODO: Replace with Arc::unwrap_or_clone() when it stabilises: | ||
// https://github.com/rust-lang/rust/issues/93610 | ||
let mut updated_parsed_keys = | ||
Arc::try_unwrap(parsed_keys).unwrap_or_else(|arc| (*arc).clone()); |
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.
Optional Suggestion
Arc::get_mut
might also have been an option here.
Motivation
This PR implements the
DeleteKeys
request forScanService
to:Closes #8204.
PR Author Checklist
Check before marking the PR as ready for review:
For significant changes:
If a checkbox isn't relevant to the PR, mark it as done.
Solution
scan::start()
for the scan task channel receiverScanTask::remove_keys()
method for sending aRemoveKeys
messageScanTask::process_msgs()
and calls it from the loop inscan::start()
delete_sapling_keys()
method toStorage
remove_keys()
anddelete_sapling_keys()
from theScanService
match arm forRequest::DeleteKeys
Testing
Storage::delete_sapling_results()
method deletes all results for a provided keyScanTask
to remove the keys and that it deletes the results before respondingReview
Anyone can review.
Reviewer Checklist
Check before approving the PR:
PR blockers can be dealt with in new tickets or PRs.
And check the PR Author checklist is complete.
Follow Up Work
ScanTask::process_msgs()