Skip to content
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

Merged
merged 22 commits into from
Dec 30, 2024
Merged

Conversation

tomyrd
Copy link
Collaborator

@tomyrd tomyrd commented Nov 27, 2024

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 the NoteInclusionDetails was removed and the NoteDetails was renamed to NodeNote (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.

@tomyrd tomyrd force-pushed the tomyrd-rpc-validations branch from 22803ea to 798ac92 Compare November 27, 2024 16:02
@tomyrd tomyrd marked this pull request as ready for review November 27, 2024 18:33
@tomyrd tomyrd force-pushed the tomyrd-rpc-validations branch from bcbab4d to 92a8d0e Compare December 4, 2024 14:19
Copy link
Collaborator

@igamigo igamigo left a 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 {
Copy link
Collaborator

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it better

account_ids: &BTreeSet<AccountId>,
code_commitments: &[Digest],
) -> Result<(u32, Vec<FpiAccountData>), RpcError> {
let response = self.get_account_proofs(account_ids, code_commitments, true).await?;
Copy link
Collaborator

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) =...)

@igamigo
Copy link
Collaborator

igamigo commented Dec 4, 2024

Also, I believe this closes #511 so I will link it

@tomyrd tomyrd force-pushed the tomyrd-rpc-validations branch from 4bfcb4c to 8fd0e1c Compare December 17, 2024 13:42
Copy link
Collaborator

@igamigo igamigo left a 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).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
* Refactored rpc functions and structs to improve code quality (#616).
* Refactored RPC functions and structs to improve code quality (#616).

Comment on lines 156 to 160
/// 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].
Copy link
Collaborator

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).

/// The default implementation of this method uses [NodeRpcClient::get_account_update].
async fn get_updated_public_accounts(
&mut self,
local_accounts: Vec<&AccountHeader>,
Copy link
Collaborator

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.

@@ -567,30 +535,22 @@ impl<R: FeltRng> Client<R> {
account_updates: &[(AccountId, Digest)],
current_onchain_accounts: &[AccountHeader],
Copy link
Collaborator

@igamigo igamigo Dec 19, 2024

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.

Copy link
Collaborator

@SantiagoPittella SantiagoPittella left a 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.

crates/rust-client/src/notes/import.rs Outdated Show resolved Hide resolved
crates/rust-client/src/rpc/domain/notes.rs Outdated Show resolved Hide resolved
crates/rust-client/src/rpc/mod.rs Show resolved Hide resolved
Copy link
Contributor

@bobbinth bobbinth left a 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?

crates/rust-client/src/rpc/mod.rs Outdated Show resolved Hide resolved
crates/rust-client/src/rpc/mod.rs Outdated Show resolved Hide resolved
crates/rust-client/src/rpc/mod.rs Show resolved Hide resolved
crates/rust-client/src/rpc/mod.rs Outdated Show resolved Hide resolved
crates/rust-client/src/rpc/mod.rs Show resolved Hide resolved
@tomyrd
Copy link
Collaborator Author

tomyrd commented Dec 26, 2024

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.

@tomyrd tomyrd merged commit 5f13c47 into next Dec 30, 2024
15 checks passed
@tomyrd tomyrd deleted the tomyrd-rpc-validations branch December 30, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add specific functions to RPC trait Replace NoteInclusionDetails for miden-base's NoteInclusionProof
4 participants