0xMiden / 0xMiden/node

Optimize `GetAccount` all-entries storage map fallback for partial reverse-key cache misses

未關閉
#2,183 1 則留言 1 個 reaction 已指派 0 人 在 GitHub 檢視
store
主要語言
Rust
星號
104
分支
138
平均合併
1 天 13 小時
30 天內合併 PR
56

描述

Follow-up from PR comment: https://github.com/0xMiden/node/pull/2012#pullrequestreview-4396515696

When `GetAccount` handles an `AllEntries` storage-map request, it first tries to read entries from the account state forest. This works only if every `hashed_key -> raw_key` mapping is present in the forest reverse-key LRU cache. If any mapping is missing, the current code falls back to `reconstruct_storage_map_details_from_db()`, which reconstructs the full storage map from the DB and then backfills the cache.

There may be a more targeted fallback here. Instead of reading full map details from the DB when only some reverse-key cache entries are missing, we could fetch or reconstruct only the missing key mappings.

Potential approaches:

- Add a DB helper such as `get_storage_map_key_mapping(account_id, slot_name, block_num, hashed_keys)` that returns raw keys for the missing hashed keys.
- Store hashed keys in `account_storage_map_values`, for example as an additional column, so missing mappings can be queried directly.
- Alternatively, since all-entries responses are bounded by `AccountStorageMapDetails::MAX_RETURN_ENTRIES` currently 1000, read the raw keys for the map and hash them locally to recover only the missing mappings.

The main tradeoff is complexity and storage overhead versus avoiding full DB reconstruction on partial cache misses. This issue should explore whether the optimization is worthwhile and, if so, what API/schema shape would be appropriate.

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。