Hashable::sha3 -> fn keccak for ethcore
This commit is contained in:
@@ -26,6 +26,7 @@ mod shared_cache;
|
||||
use std::marker::PhantomData;
|
||||
use std::{cmp, mem};
|
||||
use std::sync::Arc;
|
||||
use hash::keccak;
|
||||
|
||||
use vm::{
|
||||
self, ActionParams, ActionValue, CallType, MessageCallResult,
|
||||
@@ -180,7 +181,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(|| code.sha3());
|
||||
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));
|
||||
}
|
||||
let jump_destinations = valid_jump_destinations.as_ref().expect("jump_destinations are initialized on first jump; qed");
|
||||
@@ -464,8 +465,8 @@ impl<Cost: CostType> Interpreter<Cost> {
|
||||
instructions::SHA3 => {
|
||||
let offset = stack.pop_back();
|
||||
let size = stack.pop_back();
|
||||
let sha3 = self.mem.read_slice(offset, size).sha3();
|
||||
stack.push(U256::from(&*sha3));
|
||||
let k = keccak(self.mem.read_slice(offset, size));
|
||||
stack.push(U256::from(&*k));
|
||||
},
|
||||
instructions::SLOAD => {
|
||||
let key = H256::from(&stack.pop_back());
|
||||
@@ -880,7 +881,7 @@ mod tests {
|
||||
use rustc_hex::FromHex;
|
||||
use vmtype::VMType;
|
||||
use factory::Factory;
|
||||
use vm::{self, ActionParams, ActionValue};
|
||||
use vm::{ActionParams, ActionValue};
|
||||
use vm::tests::{FakeExt, test_finalize};
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use std::sync::Arc;
|
||||
use hash::KECCAK_EMPTY;
|
||||
use util::{H256, HeapSizeOf, Mutex};
|
||||
use util::sha3::*;
|
||||
use util::cache::MemoryLruCache;
|
||||
use bit_set::BitSet;
|
||||
use super::super::instructions;
|
||||
@@ -49,7 +49,7 @@ impl SharedCache {
|
||||
|
||||
/// Get jump destinations bitmap for a contract.
|
||||
pub fn jump_destinations(&self, code_hash: &H256, code: &[u8]) -> Arc<BitSet> {
|
||||
if code_hash == &SHA3_EMPTY {
|
||||
if code_hash == &KECCAK_EMPTY {
|
||||
return Self::find_jump_destinations(code);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ extern crate parity_wasm;
|
||||
extern crate wasm_utils;
|
||||
extern crate ethcore_logger;
|
||||
extern crate vm;
|
||||
extern crate hash;
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
Reference in New Issue
Block a user