-
Notifications
You must be signed in to change notification settings - Fork 36
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: add client specific rpc functions #616
Conversation
22803ea
to
798ac92
Compare
bcbab4d
to
92a8d0e
Compare
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.
Mostly LGTM! Going to review it more deeply soon, so just leaving some comments for now.
// ================================================================================================ | ||
|
||
/// Describes the possible responses from the `GetNotesById` endpoint for a single note. | ||
#[allow(clippy::large_enum_variant)] | ||
pub enum NoteDetails { | ||
/// Details for a private note only include its [NoteMetadata] and [NoteInclusionDetails]. | ||
pub enum NodeNote { |
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 I'd prefer NetworkNote
, what do you think?
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 like it better
crates/rust-client/src/rpc/mod.rs
Outdated
account_ids: &BTreeSet<AccountId>, | ||
code_commitments: &[Digest], | ||
) -> Result<(u32, Vec<FpiAccountData>), RpcError> { | ||
let response = self.get_account_proofs(account_ids, code_commitments, true).await?; |
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.
nit: for readability, we could destructure the response here (let (block_num, account_proofs) =...
)
Also, I believe this closes #511 so I will link it |
4bfcb4c
to
8fd0e1c
Compare
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.
LGTM! Left some minor comments
CHANGELOG.md
Outdated
@@ -19,6 +19,7 @@ | |||
|
|||
### Changes | |||
|
|||
* Refactored rpc functions and structs to improve code quality (#616). |
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.
nit:
* Refactored rpc functions and structs to improve code quality (#616). | |
* Refactored RPC functions and structs to improve code quality (#616). |
crates/rust-client/src/rpc/mod.rs
Outdated
/// Fetches the account data needed to perform a Foreign Procedure Invocation (FPI) on the | ||
/// specified foreign accounts. The `code_commitments` parameter is a list of known code hashes | ||
/// to prevent unnecessary data fetching. Returns the block number and the FPI account data. | ||
/// | ||
/// The default implementation of this method uses [NodeRpcClient::get_account_proofs]. |
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.
We should mention here what the behavior is for non-returned accounts. I believe the endpoint might return an error (but not sure).
crates/rust-client/src/rpc/mod.rs
Outdated
/// The default implementation of this method uses [NodeRpcClient::get_account_update]. | ||
async fn get_updated_public_accounts( | ||
&mut self, | ||
local_accounts: Vec<&AccountHeader>, |
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 this be &[AccountHeader]
? Or maybe an iterator so that it doesn't take ownership of the vector.
crates/rust-client/src/sync/mod.rs
Outdated
@@ -567,30 +535,22 @@ impl<R: FeltRng> Client<R> { | |||
account_updates: &[(AccountId, Digest)], | |||
current_onchain_accounts: &[AccountHeader], |
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.
Not directly related to this PR, but could we rename onchain
to public
? Both in the parameter and function name, to reflect the newer terminology.
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.
Look good! Left some small comments.
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.
Looks good! Thank you! Not a super detailed review from me - but I did leave a few comments inline (mostly nits).
Also, seems like some tests are not passing but I'm assuming these can be solved with a rebase?
The problem is that version of the client that supports the new account ID is still in review. Once it gets merged these CI errors should be fixed. |
closes #573
This PR refactors the functions/structs of the
NodeRpcClient
. It adds some functions that are better suited for the Miden Client and improves its usability. Some of the structs were also changed, specifically theNoteInclusionDetails
was removed and theNoteDetails
was renamed toNodeNote
(I'm not sure about the name here) as we already had a different struct with the same name.Some of the new rpc functions may have too specific of a use. I'm open to removing/changing them if we feel like it would be better.