fix(forge): Set empty code if the 7702 delegation address is 0x by grandizzy · Pull Request #10481 · foundry-rs/foundry (original) (raw)
For context for other reviewers, as implemented in Revm 19, this skips the unnecessary hash calculation
/// Set code and its hash to the account.
///
/// Note: Assume account is warm and that hash is calculated from code.
#[inline]
pub fn set_code_with_hash(&mut self, address: Address, code: Bytecode, hash: B256) {
let account = self.state.get_mut(&address).unwrap();
Self::touch_account(self.journal.last_mut().unwrap(), &address, account);
self.journal
.last_mut()
.unwrap()
.push(JournalEntry::CodeChange { address });
account.info.code_hash = hash;
account.info.code = Some(code);
}
/// use it only if you know that acc is warm
/// Assume account is warm
#[inline]
pub fn set_code(&mut self, address: Address, code: Bytecode) {
let hash = code.hash_slow();
self.set_code_with_hash(address, code, hash)
}