Skip to content

feat(rpc/proto): GetAccount can now return all storage maps#2153

Open
kkovaacs wants to merge 5 commits into
nextfrom
krisztian/get-account-return-all-storage-maps
Open

feat(rpc/proto): GetAccount can now return all storage maps#2153
kkovaacs wants to merge 5 commits into
nextfrom
krisztian/get-account-return-all-storage-maps

Conversation

@kkovaacs
Copy link
Copy Markdown
Contributor

Implements GitHub issue #2121 by extending GetAccount so clients can request either explicit storage maps or all storage maps for a public account. The request shape now uses the AccountDetailRequest storage selector pattern, including all_storage_maps, and the store expands that into per-map detail requests.

Adds response-size accounting for the all_storage_maps case using Protobuf encoded_len(). When the response would exceed MAX_RESPONSE_PAYLOAD_BYTES, the current and remaining maps are returned with LimitExceeded instead of entries. The response-size accounting can be removed once 0xMiden/protocol#2996 is implemented.

Also moves account-related store logic out of crates/store/src/state/mod.rs into crates/store/src/state/account.rs.

Closes #2121

@kkovaacs kkovaacs marked this pull request as ready for review May 28, 2026 11:06
Comment on lines +89 to +97
let candidate_response_details = AccountDetails {
account_header: account_header.clone(),
account_code: account_code.clone(),
vault_details: vault_details.clone(),
storage_details: AccountStorageDetails {
header: storage_header.clone(),
map_details: candidate_map_details,
},
};
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This feels like a large clone?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this response size accounting code is pretty bad...

Maybe we could make it a bit less precise and instead of properly getting the length of the full Protobuf message we could get away by just getting the base size and deriving an approximate size for the complete message purely by using the number of key-value pairs in the map?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't really have a better suggestion, unless we track this in the database itself somehow..

Comment thread proto/proto/rpc.proto Outdated
accepted_map_details.push(candidate_details);
} else {
budget_exceeded = true;
accepted_map_details.push(AccountStorageMapDetails::limit_exceeded(slot_name));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What if we're just a few bytes below the budget when we flip budget_exceeded = true, and then we have a lot of remaining slots? We'd keep appending limit_exceeded(slot_name) markers without checking they fit.

Copy link
Copy Markdown
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.

Besides the existing comments, LGTM

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.

Allow GetAccount endpoint to return all storage map entries

4 participants