Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 5061017

Browse files
tomusdrwandresilva
authored andcommitted
Don't hash the init_code of CREATE. (#9688)
1 parent c898463 commit 5061017

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

ethcore/evm/src/interpreter/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ impl<Cost: CostType> vm::Vm for Interpreter<Cost> {
186186
match result {
187187
InstructionResult::JumpToPosition(position) => {
188188
if valid_jump_destinations.is_none() {
189-
let code_hash = params.code_hash.clone().unwrap_or_else(|| keccak(code.as_ref()));
190-
valid_jump_destinations = Some(self.cache.jump_destinations(&code_hash, code));
189+
valid_jump_destinations = Some(self.cache.jump_destinations(&params.code_hash, code));
191190
}
192191
let jump_destinations = valid_jump_destinations.as_ref().expect("jump_destinations are initialized on first jump; qed");
193192
let pos = self.verify_jump(position, jump_destinations)?;

ethcore/evm/src/interpreter/shared_cache.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,22 @@ impl SharedCache {
5050
}
5151

5252
/// Get jump destinations bitmap for a contract.
53-
pub fn jump_destinations(&self, code_hash: &H256, code: &[u8]) -> Arc<BitSet> {
54-
if code_hash == &KECCAK_EMPTY {
55-
return Self::find_jump_destinations(code);
56-
}
53+
pub fn jump_destinations(&self, code_hash: &Option<H256>, code: &[u8]) -> Arc<BitSet> {
54+
if let Some(ref code_hash) = code_hash {
55+
if code_hash == &KECCAK_EMPTY {
56+
return Self::find_jump_destinations(code);
57+
}
5758

58-
if let Some(d) = self.jump_destinations.lock().get_mut(code_hash) {
59-
return d.0.clone();
59+
if let Some(d) = self.jump_destinations.lock().get_mut(code_hash) {
60+
return d.0.clone();
61+
}
6062
}
6163

6264
let d = Self::find_jump_destinations(code);
63-
self.jump_destinations.lock().insert(code_hash.clone(), Bits(d.clone()));
65+
66+
if let Some(ref code_hash) = code_hash {
67+
self.jump_destinations.lock().insert(*code_hash, Bits(d.clone()));
68+
}
6469

6570
d
6671
}

0 commit comments

Comments
 (0)