MCPcopy Create free account
hub / github.com/base/base / bytecode_by_hash

Method bytecode_by_hash

crates/proof/executor/src/test_utils.rs:248–286  ·  view source on GitHub ↗
(&self, hash: B256)

Source from the content-addressed store, hash-verified

246
247impl TrieDBProvider for ExecutorTestFixtureCreator {
248 fn bytecode_by_hash(&self, hash: B256) -> Result<Bytes, Self::Error> {
249 // geth hashdb scheme code hash key prefix
250 const CODE_PREFIX: u8 = b'c';
251
252 // Fetch the preimage from the L2 chain provider.
253 let preimage: Bytes = tokio::task::block_in_place(move || {
254 Handle::current().block_on(async {
255 // Attempt to fetch the code from the L2 chain provider.
256 let code_hash = [&[CODE_PREFIX], hash.as_slice()].concat();
257 let code = self
258 .provider
259 .client()
260 .request::<&[Bytes; 1], Bytes>("debug_dbGet", &[code_hash.into()])
261 .await;
262
263 // Check if the first attempt to fetch the code failed. If it did, try fetching the
264 // code hash preimage without the geth hashdb scheme prefix.
265 let code = match code {
266 Ok(code) => code,
267 Err(_) => self
268 .provider
269 .client()
270 .request::<&[B256; 1], Bytes>("debug_dbGet", &[hash])
271 .await
272 .map_err(|_| TestTrieNodeProviderError::PreimageNotFound)?,
273 };
274
275 self.kv_store
276 .lock()
277 .await
278 .put(hash, code.clone())
279 .map_err(|_| TestTrieNodeProviderError::KVStore)?;
280
281 Ok(code)
282 })
283 })?;
284
285 Ok(preimage)
286 }
287
288 fn header_by_hash(&self, hash: B256) -> Result<Header, Self::Error> {
289 let encoded_header: Bytes = tokio::task::block_in_place(move || {

Callers

nothing calls this directly

Calls 5

block_onMethod · 0.80
lockMethod · 0.80
clientMethod · 0.45
cloneMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected