Fixing evmbin compilation (#2652)

This commit is contained in:
Tomasz Drwięga 2016-10-17 11:55:47 +02:00 committed by Gav Wood
parent b5c65e3df5
commit 238840d74e
3 changed files with 473 additions and 322 deletions

772
evmbin/Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
//! Externalities implementation. //! Externalities implementation.
use std::sync::Arc;
use std::collections::HashMap; use std::collections::HashMap;
use util::{U256, H256, Address, Bytes, FixedHash}; use util::{U256, H256, Address, Bytes, FixedHash};
use ethcore::client::EnvInfo; use ethcore::client::EnvInfo;
@ -24,6 +25,7 @@ use ethcore::evm::{self, Ext, ContractCreateResult, MessageCallResult, Schedule,
pub struct FakeExt { pub struct FakeExt {
schedule: Schedule, schedule: Schedule,
store: HashMap<H256, H256>, store: HashMap<H256, H256>,
depth: usize,
} }
impl Default for FakeExt { impl Default for FakeExt {
@ -31,6 +33,7 @@ impl Default for FakeExt {
FakeExt { FakeExt {
schedule: Schedule::new_homestead(), schedule: Schedule::new_homestead(),
store: HashMap::new(), store: HashMap::new(),
depth: 1,
} }
} }
} }
@ -72,7 +75,11 @@ impl Ext for FakeExt {
unimplemented!(); unimplemented!();
} }
fn extcode(&self, _address: &Address) -> Bytes { fn extcode(&self, _address: &Address) -> Arc<Bytes> {
unimplemented!();
}
fn extcodesize(&self, _address: &Address) -> usize {
unimplemented!(); unimplemented!();
} }
@ -97,8 +104,7 @@ impl Ext for FakeExt {
} }
fn depth(&self) -> usize { fn depth(&self) -> usize {
unimplemented!(); self.depth
// self.depth
} }
fn inc_sstore_clears(&mut self) { fn inc_sstore_clears(&mut self) {

View File

@ -26,6 +26,7 @@ extern crate ethcore_util as util;
mod ext; mod ext;
use std::sync::Arc;
use std::time::{Instant, Duration}; use std::time::{Instant, Duration};
use std::str::FromStr; use std::str::FromStr;
use docopt::Docopt; use docopt::Docopt;
@ -42,9 +43,9 @@ Usage:
evmbin [-h | --help] evmbin [-h | --help]
Transaction options: Transaction options:
--code CODE Contract code. --code CODE Contract code as hex (without 0x)
--input DATA Input data. --input DATA Input data as hex (without 0x)
--gas GAS Supplied gas. --gas GAS Supplied gas as hex (without 0x)
General options: General options:
-h, --help Display this message and exit. -h, --help Display this message and exit.
@ -56,7 +57,7 @@ fn main() {
let mut params = ActionParams::default(); let mut params = ActionParams::default();
params.gas = args.gas(); params.gas = args.gas();
params.code = Some(args.code()); params.code = Some(Arc::new(args.code()));
params.data = args.data(); params.data = args.data();
let result = run_vm(params); let result = run_vm(params);
@ -68,7 +69,7 @@ fn main() {
/// Execute VM with given `ActionParams` /// Execute VM with given `ActionParams`
pub fn run_vm(params: ActionParams) -> ExecutionResults { pub fn run_vm(params: ActionParams) -> ExecutionResults {
let initial_gas = params.gas; let initial_gas = params.gas;
let factory = Factory::new(VMType::Interpreter); let factory = Factory::new(VMType::Interpreter, 1024);
let mut vm = factory.create(params.gas); let mut vm = factory.create(params.gas);
let mut ext = ext::FakeExt::default(); let mut ext = ext::FakeExt::default();