-
Notifications
You must be signed in to change notification settings - Fork 40
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
feat: Return code for FPI #521
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.
Thank you! Looks good! I left a few comments inline. The main one is about returning account code only if include_headers
is set to true.
crates/store/src/state.rs
Outdated
@@ -691,7 +693,7 @@ impl State { | |||
let inner_state = self.inner.read().await; | |||
|
|||
let state_headers = if !include_headers { | |||
BTreeMap::<AccountId, AccountStateHeader>::default() | |||
BTreeMap::<u64, AccountStateHeader>::new() |
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 was this change necessary?
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 wasn't, I thought I was rolling it back correctly but I wasn't (AccountId
here is a newtype for u64
)
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! I left a couple more comments inline. Once they are addressed, we should be good to merge.
// Account code commitments corresponding to the last-known `AccountCode` for requested | ||
// accounts. Responses will include only the ones that are not known to the caller. | ||
repeated digest.Digest code_commitments = 2; | ||
// Optional flag to include header in the response. `false` by default. | ||
optional bool include_headers = 2; | ||
optional bool include_headers = 3; |
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: I would move include_headers
above code_commitments
.
Also, we should update comments to make it clear that account code only is included if include_headers
is true, and also that it is not associated with a specific account ID (i.e., we check code roots against all accounts).
crates/store/src/server/api.rs
Outdated
@@ -485,13 +485,25 @@ impl api_server::Api for StoreApi { | |||
request: Request<GetAccountProofsRequest>, | |||
) -> Result<Response<GetAccountProofsResponse>, Status> { | |||
let request = request.into_inner(); | |||
if request.account_ids.len() >= request.code_commitments.len() { | |||
return Err(Status::invalid_argument( | |||
"Amount of code commitments should not be larger than amount of requested accounts.", |
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: I would use "number" instead of "amount" here.
Closes #520