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

Method with_account_code

crates/execution/txpool/src/validator.rs:261–288  ·  view source on GitHub ↗
(
        &mut self,
        address: Address,
        f: &mut dyn FnMut(&Bytecode),
    )

Source from the content-addressed store, hash-verified

259 }
260
261 fn with_account_code(
262 &mut self,
263 address: Address,
264 f: &mut dyn FnMut(&Bytecode),
265 ) -> Result<(), BasePrecompileError> {
266 let expected_hash = self
267 .state
268 .basic_account(&address)
269 .map_err(Self::provider_error)?
270 .and_then(|account| account.bytecode_hash)
271 .unwrap_or(B256::ZERO);
272 let code = if expected_hash == B256::ZERO || expected_hash == KECCAK_EMPTY {
273 Bytecode::default()
274 } else {
275 self.state
276 .bytecode_by_hash(&expected_hash)
277 .map_err(Self::provider_error)?
278 .ok_or_else(|| {
279 BasePrecompileError::Fatal(
280 "account code unavailable for non-empty code hash".into(),
281 )
282 })?
283 .0
284 };
285 validate_loaded_code_presence(expected_hash, &code)?;
286 f(&code);
287 Ok(())
288 }
289
290 fn sload(&mut self, address: Address, key: U256) -> Result<U256, BasePrecompileError> {
291 self.state

Callers 1

installMethod · 0.45

Calls 4

basic_accountMethod · 0.45
bytecode_by_hashMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected