feat(rpc/proto): GetAccount can now return all storage maps#2153
feat(rpc/proto): GetAccount can now return all storage maps#2153kkovaacs wants to merge 5 commits into
GetAccount can now return all storage maps#2153Conversation
| 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, | ||
| }, | ||
| }; |
There was a problem hiding this comment.
This feels like a large clone?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I don't really have a better suggestion, unless we track this in the database itself somehow..
| accepted_map_details.push(candidate_details); | ||
| } else { | ||
| budget_exceeded = true; | ||
| accepted_map_details.push(AccountStorageMapDetails::limit_exceeded(slot_name)); |
There was a problem hiding this comment.
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.
SantiagoPittella
left a comment
There was a problem hiding this comment.
Besides the existing comments, LGTM
Implements GitHub issue #2121 by extending
GetAccountso clients can request either explicit storage maps or all storage maps for a public account. The request shape now uses theAccountDetailRequeststorage selector pattern, includingall_storage_maps, and the store expands that into per-map detail requests.Adds response-size accounting for the
all_storage_mapscase using Protobufencoded_len(). When the response would exceedMAX_RESPONSE_PAYLOAD_BYTES, the current and remaining maps are returned withLimitExceededinstead 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.rsintocrates/store/src/state/account.rs.Closes #2121