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

Commit

Permalink
Don't hash the init_code of CREATE. (#9688)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomusdrw authored and andresilva committed Oct 9, 2018
1 parent 2e4cbec commit 964bd33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 1 addition & 2 deletions ethcore/evm/src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ impl<Cost: CostType> vm::Vm for Interpreter<Cost> {
match result {
InstructionResult::JumpToPosition(position) => {
if valid_jump_destinations.is_none() {
let code_hash = params.code_hash.clone().unwrap_or_else(|| keccak(code.as_ref()));
valid_jump_destinations = Some(self.cache.jump_destinations(&code_hash, code));
valid_jump_destinations = Some(self.cache.jump_destinations(&params.code_hash, code));
}
let jump_destinations = valid_jump_destinations.as_ref().expect("jump_destinations are initialized on first jump; qed");
let pos = self.verify_jump(position, jump_destinations)?;
Expand Down
19 changes: 12 additions & 7 deletions ethcore/evm/src/interpreter/shared_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,22 @@ impl SharedCache {
}

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

if let Some(d) = self.jump_destinations.lock().get_mut(code_hash) {
return d.0.clone();
if let Some(d) = self.jump_destinations.lock().get_mut(code_hash) {
return d.0.clone();
}
}

let d = Self::find_jump_destinations(code);
self.jump_destinations.lock().insert(code_hash.clone(), Bits(d.clone()));

if let Some(ref code_hash) = code_hash {
self.jump_destinations.lock().insert(*code_hash, Bits(d.clone()));
}

d
}
Expand Down

0 comments on commit 964bd33

Please sign in to comment.