diff --git a/runtime/runtime/src/prefetch.rs b/runtime/runtime/src/prefetch.rs index 9db9624349b..e75e51f83ce 100644 --- a/runtime/runtime/src/prefetch.rs +++ b/runtime/runtime/src/prefetch.rs @@ -41,6 +41,7 @@ //! in the prefetcher. Implementation details for most limits are in //! `core/store/src/trie/prefetching_trie_storage.rs` +use borsh::BorshSerialize as _; use near_o11y::metrics::prometheus; use near_o11y::metrics::prometheus::core::GenericCounter; use near_primitives::receipt::{Receipt, ReceiptEnum}; @@ -306,16 +307,14 @@ impl TriePrefetcher { return Ok(()); }; for tuple in list.iter() { - let Some(tuple) = tuple.as_array() else { - continue; - }; - let Some(user_account) = tuple.first().and_then(|a| a.as_str()) else { - continue; - }; - // Unique prefix of underlying data structure. - let mut key = vec![0, 64, 0, 0, 0]; - key.extend(user_account.as_bytes()); - let trie_key = TrieKey::ContractData { account_id: account_id.clone(), key }; + let Some(tuple) = tuple.as_array() else { continue }; + let Some(user_account) = tuple.first().and_then(|a| a.as_str()) else { continue }; + let mut account_data_key = Vec::with_capacity(4 + 8 + user_account.len()); + // (branch v2) StorageKey::Accounts = 4u8 + let Ok(()) = 4u8.serialize(&mut account_data_key) else { continue }; + let Ok(()) = user_account.serialize(&mut account_data_key) else { continue }; + let trie_key = + TrieKey::ContractData { account_id: account_id.clone(), key: account_data_key }; near_o11y::io_trace!(count: "prefetch"); self.prefetch_trie_key(trie_key)?; }