Hashable::sha3 -> fn keccak for ethcore

This commit is contained in:
debris
2017-08-30 19:18:28 +02:00
parent e120c75d17
commit f0e8abb07b
69 changed files with 429 additions and 398 deletions

View File

@@ -11,4 +11,5 @@ common-types = { path = "../types" }
evmjit = { path = "../../evmjit", optional = true }
ethjson = { path = "../../json" }
lazy_static = "0.2"
rlp = { path = "../../util/rlp" }
rlp = { path = "../../util/rlp" }
hash = { path = "../../util/hash" }

View File

@@ -17,7 +17,7 @@
//! Evm input params.
use util::{Address, Bytes, U256};
use util::hash::{H256};
use util::sha3::{Hashable, SHA3_EMPTY};
use hash::{keccak, KECCAK_EMPTY};
use ethjson;
use call_type::CallType;
@@ -87,7 +87,7 @@ impl Default for ActionParams {
fn default() -> ActionParams {
ActionParams {
code_address: Address::new(),
code_hash: Some(SHA3_EMPTY),
code_hash: Some(KECCAK_EMPTY),
address: Address::new(),
sender: Address::new(),
origin: Address::new(),
@@ -106,7 +106,7 @@ impl From<ethjson::vm::Transaction> for ActionParams {
let address: Address = t.address.into();
ActionParams {
code_address: Address::new(),
code_hash: Some((&*t.code).sha3()),
code_hash: Some(keccak(&*t.code)),
address: address,
sender: t.sender.into(),
origin: t.origin.into(),

View File

@@ -18,7 +18,8 @@
use std::cmp;
use std::sync::Arc;
use util::{U256, Address, H256, Hashable};
use hash::keccak;
use util::{U256, Address, H256};
use types::BlockNumber;
use ethjson;
@@ -68,7 +69,7 @@ impl From<ethjson::vm::Env> for EnvInfo {
difficulty: e.difficulty.into(),
gas_limit: e.gas_limit.into(),
timestamp: e.timestamp.into(),
last_hashes: Arc::new((1..cmp::min(number + 1, 257)).map(|i| format!("{}", number - i).as_bytes().sha3()).collect()),
last_hashes: Arc::new((1..cmp::min(number + 1, 257)).map(|i| keccak(format!("{}", number - i).as_bytes())).collect()),
gas_used: U256::default(),
}
}

View File

@@ -20,6 +20,7 @@ extern crate ethcore_util as util;
extern crate common_types as types;
extern crate ethjson;
extern crate rlp;
extern crate hash;
mod action_params;
mod call_type;
@@ -45,4 +46,4 @@ pub trait Vm {
/// It returns either an error, a known amount of gas left, or parameters to be used
/// to compute the final gas left.
fn exec(&mut self, params: ActionParams, ext: &mut Ext) -> Result<GasLeft>;
}
}