Skip to content

Conversation

@drahnr
Copy link
Contributor

@drahnr drahnr commented Nov 27, 2025

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:

  • Renamed domain structs: AccountProofRequestAccountRequest, AccountProofResponseAccountResponse
  • Dropped GetAccountDetails*

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

@drahnr drahnr changed the title refacotr: unify get_account_details and get_account_proof[s] refactor: unify get_account_details and get_account_proof[s] Nov 27, 2025
@drahnr drahnr marked this pull request as ready for review November 27, 2025 20:46
@Mirko-von-Leipzig
Copy link
Collaborator

@igamigo could you weigh in on

Do we want compatibility on the RPC level to give the client some more migration time, or is the change bounded enough?

@igamigo
Copy link
Collaborator

igamigo commented Nov 28, 2025

@igamigo could you weigh in on

Do we want compatibility on the RPC level to give the client some more migration time, or is the change bounded enough?

At least a very simple version of replacing get_account_details should be very quick to write (we already have the syncing endpoints implemented), so I wouldn't spend time providing a replacement here

@drahnr drahnr force-pushed the bernhard-unify-get-details-and-get-proofs branch from 7e654d4 to 1755724 Compare November 29, 2025 14:03
@bobbinth bobbinth requested a review from igamigo December 1, 2025 18:30
@drahnr drahnr force-pushed the bernhard-unify-get-details-and-get-proofs branch from 69e1952 to 977e30f Compare December 2, 2025 14:15
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 a few comments, mostly nits. There is only one comment related to the functionality of the network monitor that I'm wondering about.

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! 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.
@drahnr drahnr force-pushed the bernhard-unify-get-details-and-get-proofs branch from 72d09a5 to f000d5d Compare December 23, 2025 19:59
@drahnr drahnr changed the title refactor: unify get_account_details and get_account_proof[s] refactor: [3/3] unify get_account_details and get_account_proof[s] Dec 23, 2025
@drahnr drahnr changed the base branch from next to bernhard-partial-storage-map-queries December 23, 2025 20:03
@drahnr drahnr changed the title refactor: [3/3] unify get_account_details and get_account_proof[s] refactor: [3/3] unify get_account_details and get_account_proof[s] into get_account Dec 23, 2025
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! I left some comments inline - most are pretty minor.

Comment on lines 33 to 34
// Returns the latest state of an account with the specified ID.
rpc GetAccountDetails(account.AccountId) returns (account.AccountDetails) {}
Copy link
Contributor

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?

Comment on lines 37 to +38
// Returns the latest state proof of the specified account.
rpc GetAccountProof(rpc.AccountProofRequest) returns (rpc.AccountProofResponse) {}
rpc GetAccount(rpc.AccountRequest) returns (rpc.AccountResponse) {}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question as above.

Comment on lines 295 to 305
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)
Copy link
Contributor

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.

@drahnr drahnr changed the title refactor: [3/3] unify get_account_details and get_account_proof[s] into get_account refactor: [4/4] unify get_account_details and get_account_proof[s] into get_account Dec 30, 2025
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.

5 participants