Skip to content

Commit

Permalink
support EXTCODEHASH (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
Raz0r authored Jun 21, 2024
1 parent 8683ce2 commit 9ab8f5c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/evm/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,11 +1229,11 @@ where
}
}

fn code_hash(&mut self, _address: EVMAddress) -> Option<(B256, bool)> {
Some((
B256::from_str("0x0000000000000000000000000000000000000000000000000000000000000000").unwrap(),
true,
))
fn code_hash(&mut self, address: EVMAddress) -> Option<(B256, bool)> {
match self.code.get(&address) {
Some(code) => Some((code.hash(), true)),
None => Some((B256::zero(), true)),
}
}

fn sload(&mut self, address: EVMAddress, index: EVMU256) -> Option<(EVMU256, bool)> {
Expand Down
6 changes: 3 additions & 3 deletions src/evm/onchain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ where
0x46 => {
host.env.tx.chain_id = Some(self.endpoint.chain_id as u64);
}
// CALL | CALLCODE | DELEGATECALL | STATICCALL | EXTCODESIZE | EXTCODECOPY
0xf1 | 0xf2 | 0xf4 | 0xfa | 0x3b | 0x3c => {
// CALL | CALLCODE | DELEGATECALL | STATICCALL | EXTCODESIZE | EXTCODECOPY | EXTCODEHASH
0xf1 | 0xf2 | 0xf4 | 0xfa | 0x3b | 0x3c | 0x3f => {
let caller = interp.contract.address;
let address = match *interp.instruction_pointer {
0xf1 | 0xf2 => {
Expand All @@ -275,7 +275,7 @@ where
interp.stack.peek(1).unwrap()
}
0xf4 | 0xfa => interp.stack.peek(1).unwrap(),
0x3b | 0x3c => interp.stack.peek(0).unwrap(),
0x3b | 0x3c | 0x3f => interp.stack.peek(0).unwrap(),
_ => unreachable!(),
};

Expand Down

0 comments on commit 9ab8f5c

Please sign in to comment.