-
Notifications
You must be signed in to change notification settings - Fork 87
refactor: [4/4] unify get_account_details and get_account_proof[s] into get_account
#1385
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
base: bernhard-partial-storage-map-queries
Are you sure you want to change the base?
refactor: [4/4] unify get_account_details and get_account_proof[s] into get_account
#1385
Conversation
get_account_details and get_account_proof[s]get_account_details and get_account_proof[s]
|
@igamigo could you weigh in on
|
At least a very simple version of replacing |
7e654d4 to
1755724
Compare
69e1952 to
977e30f
Compare
igamigo
left a comment
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 a few comments, mostly nits. There is only one comment related to the functionality of the network monitor that I'm wondering about.
bobbinth
left a comment
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! Mostly what's left is updating some comments and docs (as covered by @igamigo's review).
The fetch_wallet_account function was always returning None since the RPC API only returns commitments, not full account data. This made it completely useless - the code immediately replaced None with the file-based account using .unwrap_or(). Removed the dead code and simplified setup_increment_task to directly use the file-based account, which is what was happening anyway.
The previous commit incorrectly deleted the fetch_wallet_account function. This commit properly implements it to: 1. Request account details from RPC (including the header) 2. Extract the AccountHeader with the latest nonce 3. Reconstruct the wallet account with: - Code, vault, storage from the file-based account - Updated nonce from the chain 4. Fall back to file-based account if RPC fails or account not found This ensures the wallet account nonce stays synced with on-chain state, preventing nonce conflicts in transaction submission.
72d09a5 to
f000d5d
Compare
get_account_details and get_account_proof[s]get_account_details and get_account_proof[s]
get_account_details and get_account_proof[s]get_account_details and get_account_proof[s] into get_account
bobbinth
left a comment
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 some comments inline - most are pretty minor.
proto/proto/rpc.proto
Outdated
| // Returns the latest state of an account with the specified ID. | ||
| rpc GetAccountDetails(account.AccountId) returns (account.AccountDetails) {} |
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 thought we were removing GetAccountDetails as a part of this PR - but maybe I misunderstood?
| // Returns the latest state proof of the specified account. | ||
| rpc GetAccountProof(rpc.AccountProofRequest) returns (rpc.AccountProofResponse) {} | ||
| rpc GetAccount(rpc.AccountRequest) returns (rpc.AccountResponse) {} |
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.
Same question as above.
bin/network-monitor/src/counter.rs
Outdated
| let entries = map_entries.get(&slot.slot_name).cloned().unwrap_or_default(); | ||
| if entries.is_empty() { | ||
| warn!( | ||
| account.id = %account_id, | ||
| slot_name = %slot.slot_name, | ||
| "storage map slot has no entries (not requested or empty)" | ||
| ); | ||
| } | ||
| let storage_map = miden_objects::account::StorageMap::with_entries(entries) | ||
| .context("failed to create storage map")?; | ||
| StorageSlot::with_map(slot_name, storage_map) |
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.
Similar to the above comment: I think we can probably just error out if there are any storage maps in the account.
get_account_details and get_account_proof[s] into get_accountget_account_details and get_account_proof[s] into get_account
…fy-get-details-and-get-proofs
…fy-get-details-and-get-proofs
Unify API calls
The new API is flexible enough to address all needs and avoid loading a lot of data from the DB.
Main changes in:
crates/proto/src/domain/account.rs:AccountProofRequest→AccountRequest,AccountProofResponse→AccountResponseGetAccountDetails*Caveat
Will require client changes!
Part 2
This is part 1 of two pieces. The second piece is in and does the actual DB changes, as well as populate the
SmtForest. This is NOT part of this PR.Open Questions
Do we want compatibility on the RPC level to give the client some more migration time, or is the change bounded enough?
Part of #1349
Part 1 of 2 of the remaining pieces in #1185