Decouple virtual machines (#6184)
* work in progress for splitting vms * evm working * Evm -> Vm * wasm converted * ethcore working * test fixes
This commit is contained in:
@@ -25,7 +25,7 @@ use util::{Bytes, Address, Hashable, U256, H256, ordered_trie_root, SHA3_NULL_RL
|
||||
use util::error::{Mismatch, OutOfBounds};
|
||||
|
||||
use basic_types::{LogBloom, Seal};
|
||||
use evm::env_info::{EnvInfo, LastHashes};
|
||||
use vm::{EnvInfo, LastHashes};
|
||||
use engines::Engine;
|
||||
use error::{Error, BlockError, TransactionError};
|
||||
use factory::Factories;
|
||||
@@ -667,7 +667,7 @@ mod tests {
|
||||
use tests::helpers::*;
|
||||
use super::*;
|
||||
use engines::Engine;
|
||||
use evm::env_info::LastHashes;
|
||||
use vm::LastHashes;
|
||||
use error::Error;
|
||||
use header::Header;
|
||||
use factory::Factories;
|
||||
|
||||
@@ -36,9 +36,9 @@ impl From<&'static str> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl Into<::evm::Error> for Error {
|
||||
fn into(self) -> ::evm::Error {
|
||||
::evm::Error::BuiltIn(self.0)
|
||||
impl Into<::vm::Error> for Error {
|
||||
fn into(self) -> ::vm::Error {
|
||||
::vm::Error::BuiltIn(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,9 +42,8 @@ use client::{
|
||||
};
|
||||
use encoded;
|
||||
use engines::{Engine, EpochTransition};
|
||||
use evm::env_info::EnvInfo;
|
||||
use evm::env_info::LastHashes;
|
||||
use error::{ImportError, ExecutionError, CallError, BlockError, ImportResult, Error as EthcoreError};
|
||||
use vm::{EnvInfo, LastHashes};
|
||||
use evm::{Factory as EvmFactory, Schedule};
|
||||
use executive::{Executive, Executed, TransactOptions, contract_address};
|
||||
use factory::Factories;
|
||||
|
||||
@@ -23,7 +23,7 @@ use util::kvdb::{self, KeyValueDB};
|
||||
use {state, state_db, client, executive, trace, db, spec};
|
||||
use factory::Factories;
|
||||
use evm::{self, VMType};
|
||||
use evm::action_params::ActionParams;
|
||||
use vm::{self, ActionParams};
|
||||
|
||||
/// EVM test Error.
|
||||
#[derive(Debug)]
|
||||
@@ -31,7 +31,7 @@ pub enum EvmTestError {
|
||||
/// Trie integrity error.
|
||||
Trie(util::TrieError),
|
||||
/// EVM error.
|
||||
Evm(evm::Error),
|
||||
Evm(vm::Error),
|
||||
/// Initialization error.
|
||||
Initialization(::error::Error),
|
||||
/// Low-level database error.
|
||||
|
||||
@@ -40,7 +40,7 @@ pub use types::pruning_info::PruningInfo;
|
||||
pub use types::call_analytics::CallAnalytics;
|
||||
|
||||
pub use executive::{Executed, Executive, TransactOptions};
|
||||
pub use evm::env_info::{LastHashes, EnvInfo};
|
||||
pub use vm::{LastHashes, EnvInfo};
|
||||
|
||||
pub use error::{BlockImportError, TransactionImportError, TransactionImportResult};
|
||||
pub use verification::VerifierType;
|
||||
|
||||
@@ -36,7 +36,8 @@ use log_entry::LocalizedLogEntry;
|
||||
use receipt::{Receipt, LocalizedReceipt};
|
||||
use blockchain::extras::BlockReceipts;
|
||||
use error::{ImportResult, Error as EthcoreError};
|
||||
use evm::{Factory as EvmFactory, VMType, Schedule};
|
||||
use evm::{Factory as EvmFactory, VMType};
|
||||
use vm::Schedule;
|
||||
use miner::{Miner, MinerService, TransactionImportResult};
|
||||
use spec::Spec;
|
||||
use types::basic_account::BasicAccount;
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::collections::BTreeMap;
|
||||
use block::{OpenBlock, SealedBlock, ClosedBlock};
|
||||
use blockchain::TreeRoute;
|
||||
use encoded;
|
||||
use evm::env_info::LastHashes;
|
||||
use vm::LastHashes;
|
||||
use error::{ImportResult, CallError, Error as EthcoreError};
|
||||
use error::{TransactionImportResult, BlockImportError};
|
||||
use evm::{Factory as EvmFactory, Schedule};
|
||||
|
||||
@@ -514,7 +514,7 @@ impl Engine for AuthorityRound {
|
||||
fn on_new_block(
|
||||
&self,
|
||||
block: &mut ExecutedBlock,
|
||||
last_hashes: Arc<::evm::env_info::LastHashes>,
|
||||
last_hashes: Arc<::vm::LastHashes>,
|
||||
epoch_begin: bool,
|
||||
) -> Result<(), Error> {
|
||||
let parent_hash = block.fields().header.parent_hash().clone();
|
||||
|
||||
@@ -43,15 +43,13 @@ use account_provider::AccountProvider;
|
||||
use block::ExecutedBlock;
|
||||
use builtin::Builtin;
|
||||
use client::Client;
|
||||
use evm::env_info::{EnvInfo, LastHashes};
|
||||
use vm::{EnvInfo, LastHashes, Schedule, CreateContractAddress};
|
||||
use error::Error;
|
||||
use evm::Schedule;
|
||||
use header::{Header, BlockNumber};
|
||||
use receipt::Receipt;
|
||||
use snapshot::SnapshotComponents;
|
||||
use spec::CommonParams;
|
||||
use transaction::{UnverifiedTransaction, SignedTransaction};
|
||||
use evm::CreateContractAddress;
|
||||
|
||||
use ethkey::Signature;
|
||||
use util::*;
|
||||
@@ -394,12 +392,10 @@ pub trait Engine : Sync + Send {
|
||||
/// Common engine utilities
|
||||
pub mod common {
|
||||
use block::ExecutedBlock;
|
||||
use evm::env_info::{EnvInfo, LastHashes};
|
||||
use error::Error;
|
||||
use transaction::SYSTEM_ADDRESS;
|
||||
use executive::Executive;
|
||||
use evm::CallType;
|
||||
use evm::action_params::{ActionParams, ActionValue};
|
||||
use vm::{CallType, ActionParams, ActionValue, EnvInfo, LastHashes};
|
||||
use trace::{NoopTracer, NoopVMTracer};
|
||||
use state::Substate;
|
||||
|
||||
|
||||
@@ -299,7 +299,7 @@ impl ValidatorSet for ValidatorSafeContract {
|
||||
let (old_header, state_items) = decode_first_proof(&rlp)?;
|
||||
let old_hash = old_header.hash();
|
||||
|
||||
let env_info = ::evm::env_info::EnvInfo {
|
||||
let env_info = ::vm::EnvInfo {
|
||||
number: old_header.number(),
|
||||
author: *old_header.author(),
|
||||
difficulty: *old_header.difficulty(),
|
||||
|
||||
@@ -19,7 +19,7 @@ use ethash::{quick_get_difficulty, slow_get_seedhash, EthashManager};
|
||||
use util::*;
|
||||
use block::*;
|
||||
use builtin::Builtin;
|
||||
use evm::env_info::EnvInfo;
|
||||
use vm::EnvInfo;
|
||||
use error::{BlockError, Error, TransactionError};
|
||||
use header::{Header, BlockNumber};
|
||||
use state::CleanupMode;
|
||||
@@ -29,7 +29,7 @@ use engines::{self, Engine};
|
||||
use evm::Schedule;
|
||||
use ethjson;
|
||||
use rlp::{self, UntrustedRlp};
|
||||
use evm::env_info::LastHashes;
|
||||
use vm::LastHashes;
|
||||
|
||||
/// Parity tries to round block.gas_limit to multiple of this constant
|
||||
pub const PARITY_GAS_LIMIT_DETERMINANT: U256 = U256([37, 0, 0, 0]);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Transaction execution format module.
|
||||
|
||||
use util::{Bytes, U256, Address, U512, trie};
|
||||
use evm;
|
||||
use vm;
|
||||
use trace::{VMTrace, FlatTrace};
|
||||
use log_entry::LogEntry;
|
||||
use state_diff::StateDiff;
|
||||
@@ -28,7 +28,7 @@ use std::fmt;
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub struct Executed {
|
||||
/// True if the outer call/create resulted in an exceptional exit.
|
||||
pub exception: Option<evm::Error>,
|
||||
pub exception: Option<vm::Error>,
|
||||
|
||||
/// Gas paid up front for execution of transaction.
|
||||
pub gas: U256,
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
//! Transaction Execution environment.
|
||||
use util::*;
|
||||
use evm::action_params::{ActionParams, ActionValue};
|
||||
use state::{Backend as StateBackend, State, Substate, CleanupMode};
|
||||
use engines::Engine;
|
||||
use evm::CallType;
|
||||
use evm::env_info::EnvInfo;
|
||||
use vm::EnvInfo;
|
||||
use error::ExecutionError;
|
||||
use evm::{self, wasm, Factory, Ext, Finalize, CreateContractAddress, FinalizationResult, ReturnData, CleanDustMode};
|
||||
use evm::{CallType, Factory, Finalize, FinalizationResult};
|
||||
use vm::{self, Ext, CreateContractAddress, ReturnData, CleanDustMode, ActionParams, ActionValue};
|
||||
use wasm;
|
||||
use externalities::*;
|
||||
use trace::{FlatTrace, Tracer, NoopTracer, ExecutiveTracer, VMTrace, VMTracer, ExecutiveVMTracer, NoopVMTracer};
|
||||
use transaction::{Action, SignedTransaction};
|
||||
@@ -74,8 +74,8 @@ pub struct TransactOptions {
|
||||
pub check_nonce: bool,
|
||||
}
|
||||
|
||||
pub fn executor<E>(engine: &E, vm_factory: &Factory, params: &ActionParams)
|
||||
-> Box<evm::Evm> where E: Engine + ?Sized
|
||||
pub fn executor<E>(engine: &E, vm_factory: &Factory, params: &ActionParams)
|
||||
-> Box<vm::Vm> where E: Engine + ?Sized
|
||||
{
|
||||
if engine.supports_wasm() && params.code.as_ref().map_or(false, |code| code.len() > 4 && &code[0..4] == WASM_MAGIC_NUMBER) {
|
||||
Box::new(
|
||||
@@ -269,7 +269,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
output_policy: OutputPolicy,
|
||||
tracer: &mut T,
|
||||
vm_tracer: &mut V
|
||||
) -> evm::Result<FinalizationResult> where T: Tracer, V: VMTracer {
|
||||
) -> vm::Result<FinalizationResult> where T: Tracer, V: VMTracer {
|
||||
|
||||
let depth_threshold = ::io::LOCAL_STACK_SIZE.with(|sz| sz.get() / STACK_SIZE_PER_DEPTH);
|
||||
let static_call = params.call_type == CallType::StaticCall;
|
||||
@@ -299,7 +299,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
/// Calls contract function with given contract params.
|
||||
/// NOTE. It does not finalize the transaction (doesn't do refunds, nor suicides).
|
||||
/// Modifies the substate and the output.
|
||||
/// Returns either gas_left or `evm::Error`.
|
||||
/// Returns either gas_left or `vm::Error`.
|
||||
pub fn call<T, V>(
|
||||
&mut self,
|
||||
params: ActionParams,
|
||||
@@ -307,14 +307,14 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
mut output: BytesRef,
|
||||
tracer: &mut T,
|
||||
vm_tracer: &mut V
|
||||
) -> evm::Result<(U256, ReturnData)> where T: Tracer, V: VMTracer {
|
||||
) -> vm::Result<(U256, ReturnData)> where T: Tracer, V: VMTracer {
|
||||
|
||||
trace!("Executive::call(params={:?}) self.env_info={:?}", params, self.info);
|
||||
if (params.call_type == CallType::StaticCall ||
|
||||
((params.call_type == CallType::Call || params.call_type == CallType::DelegateCall) &&
|
||||
self.static_flag))
|
||||
&& params.value.value() > 0.into() {
|
||||
return Err(evm::Error::MutableCallInStaticContext);
|
||||
return Err(vm::Error::MutableCallInStaticContext);
|
||||
}
|
||||
|
||||
// backup used in case of running out of gas
|
||||
@@ -344,7 +344,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
if cost <= params.gas {
|
||||
if let Err(e) = builtin.execute(data, &mut output) {
|
||||
self.state.revert_to_checkpoint();
|
||||
let evm_err: evm::evm::Error = e.into();
|
||||
let evm_err: vm::Error = e.into();
|
||||
tracer.trace_failed_call(trace_info, vec![], evm_err.clone().into());
|
||||
Err(evm_err)
|
||||
} else {
|
||||
@@ -371,9 +371,9 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
// just drain the whole gas
|
||||
self.state.revert_to_checkpoint();
|
||||
|
||||
tracer.trace_failed_call(trace_info, vec![], evm::Error::OutOfGas.into());
|
||||
tracer.trace_failed_call(trace_info, vec![], vm::Error::OutOfGas.into());
|
||||
|
||||
Err(evm::Error::OutOfGas)
|
||||
Err(vm::Error::OutOfGas)
|
||||
}
|
||||
} else {
|
||||
let trace_info = tracer.prepare_trace_call(¶ms);
|
||||
@@ -432,17 +432,17 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
substate: &mut Substate,
|
||||
tracer: &mut T,
|
||||
vm_tracer: &mut V,
|
||||
) -> evm::Result<(U256, ReturnData)> where T: Tracer, V: VMTracer {
|
||||
) -> vm::Result<(U256, ReturnData)> where T: Tracer, V: VMTracer {
|
||||
|
||||
let scheme = self.engine.create_address_scheme(self.info.number);
|
||||
if scheme != CreateContractAddress::FromSenderAndNonce && self.state.exists_and_has_code(¶ms.address)? {
|
||||
return Err(evm::Error::OutOfGas);
|
||||
return Err(vm::Error::OutOfGas);
|
||||
}
|
||||
|
||||
if params.call_type == CallType::StaticCall || self.static_flag {
|
||||
let trace_info = tracer.prepare_trace_create(¶ms);
|
||||
tracer.trace_failed_create(trace_info, vec![], evm::Error::MutableCallInStaticContext.into());
|
||||
return Err(evm::Error::MutableCallInStaticContext);
|
||||
tracer.trace_failed_create(trace_info, vec![], vm::Error::MutableCallInStaticContext.into());
|
||||
return Err(vm::Error::MutableCallInStaticContext);
|
||||
}
|
||||
|
||||
// backup used in case of running out of gas
|
||||
@@ -496,7 +496,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
&mut self,
|
||||
t: &SignedTransaction,
|
||||
mut substate: Substate,
|
||||
result: evm::Result<(U256, ReturnData)>,
|
||||
result: vm::Result<(U256, ReturnData)>,
|
||||
output: Bytes,
|
||||
trace: Vec<FlatTrace>,
|
||||
vm_trace: Option<VMTrace>
|
||||
@@ -538,7 +538,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
self.state.kill_garbage(&substate.touched, schedule.kill_empty, &min_balance, schedule.kill_dust == CleanDustMode::WithCodeAndStorage)?;
|
||||
|
||||
match result {
|
||||
Err(evm::Error::Internal(msg)) => Err(ExecutionError::Internal(msg)),
|
||||
Err(vm::Error::Internal(msg)) => Err(ExecutionError::Internal(msg)),
|
||||
Err(exception) => {
|
||||
Ok(Executed {
|
||||
exception: Some(exception),
|
||||
@@ -572,20 +572,20 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> {
|
||||
}
|
||||
}
|
||||
|
||||
fn enact_result(&mut self, result: &evm::Result<FinalizationResult>, substate: &mut Substate, un_substate: Substate) {
|
||||
fn enact_result(&mut self, result: &vm::Result<FinalizationResult>, substate: &mut Substate, un_substate: Substate) {
|
||||
match *result {
|
||||
Err(evm::Error::OutOfGas)
|
||||
| Err(evm::Error::BadJumpDestination {..})
|
||||
| Err(evm::Error::BadInstruction {.. })
|
||||
| Err(evm::Error::StackUnderflow {..})
|
||||
| Err(evm::Error::BuiltIn {..})
|
||||
| Err(evm::Error::Wasm {..})
|
||||
| Err(evm::Error::OutOfStack {..})
|
||||
| Err(evm::Error::MutableCallInStaticContext)
|
||||
Err(vm::Error::OutOfGas)
|
||||
| Err(vm::Error::BadJumpDestination {..})
|
||||
| Err(vm::Error::BadInstruction {.. })
|
||||
| Err(vm::Error::StackUnderflow {..})
|
||||
| Err(vm::Error::BuiltIn {..})
|
||||
| Err(vm::Error::Wasm {..})
|
||||
| Err(vm::Error::OutOfStack {..})
|
||||
| Err(vm::Error::MutableCallInStaticContext)
|
||||
| Ok(FinalizationResult { apply_state: false, .. }) => {
|
||||
self.state.revert_to_checkpoint();
|
||||
},
|
||||
Ok(_) | Err(evm::Error::Internal(_)) => {
|
||||
Ok(_) | Err(vm::Error::Internal(_)) => {
|
||||
self.state.discard_checkpoint();
|
||||
substate.accrue(un_substate);
|
||||
}
|
||||
@@ -602,9 +602,8 @@ mod tests {
|
||||
use super::*;
|
||||
use util::{H256, U256, U512, Address, FromStr};
|
||||
use util::bytes::BytesRef;
|
||||
use evm::action_params::{ActionParams, ActionValue};
|
||||
use evm::env_info::EnvInfo;
|
||||
use evm::{Factory, VMType, CreateContractAddress};
|
||||
use vm::{ActionParams, ActionValue, CallType, EnvInfo, CreateContractAddress};
|
||||
use evm::{Factory, VMType};
|
||||
use error::ExecutionError;
|
||||
use state::{Substate, CleanupMode};
|
||||
use tests::helpers::*;
|
||||
@@ -613,8 +612,6 @@ mod tests {
|
||||
use trace::{VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, VMTracer, NoopVMTracer, ExecutiveVMTracer};
|
||||
use transaction::{Action, Transaction};
|
||||
|
||||
use evm::CallType;
|
||||
|
||||
#[test]
|
||||
fn test_contract_address() {
|
||||
let address = Address::from_str("0f572e5295c57f15886f9b263e2f6d2d6c7b5ec6").unwrap();
|
||||
|
||||
@@ -16,13 +16,14 @@
|
||||
|
||||
//! Transaction Execution environment.
|
||||
use util::*;
|
||||
use evm::action_params::{ActionParams, ActionValue};
|
||||
use state::{Backend as StateBackend, State, Substate, CleanupMode};
|
||||
use engines::Engine;
|
||||
use evm::env_info::EnvInfo;
|
||||
use executive::*;
|
||||
use evm::{self, Schedule, Ext, ContractCreateResult, MessageCallResult, CreateContractAddress, ReturnData};
|
||||
use evm::CallType;
|
||||
use vm::{
|
||||
self, ActionParams, ActionValue, EnvInfo, CallType, Schedule,
|
||||
Ext, ContractCreateResult, MessageCallResult, CreateContractAddress,
|
||||
ReturnData
|
||||
};
|
||||
use transaction::UNSIGNED_SENDER;
|
||||
use trace::{Tracer, VMTracer};
|
||||
|
||||
@@ -109,31 +110,31 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Externalities<'a, T, V, B, E>
|
||||
impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for Externalities<'a, T, V, B, E>
|
||||
where T: Tracer, V: VMTracer, B: StateBackend, E: Engine + ?Sized
|
||||
{
|
||||
fn storage_at(&self, key: &H256) -> evm::Result<H256> {
|
||||
fn storage_at(&self, key: &H256) -> vm::Result<H256> {
|
||||
self.state.storage_at(&self.origin_info.address, key).map_err(Into::into)
|
||||
}
|
||||
|
||||
fn set_storage(&mut self, key: H256, value: H256) -> evm::Result<()> {
|
||||
fn set_storage(&mut self, key: H256, value: H256) -> vm::Result<()> {
|
||||
if self.static_flag {
|
||||
Err(evm::Error::MutableCallInStaticContext)
|
||||
Err(vm::Error::MutableCallInStaticContext)
|
||||
} else {
|
||||
self.state.set_storage(&self.origin_info.address, key, value).map_err(Into::into)
|
||||
}
|
||||
}
|
||||
|
||||
fn exists(&self, address: &Address) -> evm::Result<bool> {
|
||||
fn exists(&self, address: &Address) -> vm::Result<bool> {
|
||||
self.state.exists(address).map_err(Into::into)
|
||||
}
|
||||
|
||||
fn exists_and_not_null(&self, address: &Address) -> evm::Result<bool> {
|
||||
fn exists_and_not_null(&self, address: &Address) -> vm::Result<bool> {
|
||||
self.state.exists_and_not_null(address).map_err(Into::into)
|
||||
}
|
||||
|
||||
fn origin_balance(&self) -> evm::Result<U256> {
|
||||
fn origin_balance(&self) -> vm::Result<U256> {
|
||||
self.balance(&self.origin_info.address).map_err(Into::into)
|
||||
}
|
||||
|
||||
fn balance(&self, address: &Address) -> evm::Result<U256> {
|
||||
fn balance(&self, address: &Address) -> vm::Result<U256> {
|
||||
self.state.balance(address).map_err(Into::into)
|
||||
}
|
||||
|
||||
@@ -274,16 +275,16 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for Externalities<'a, T, V, B, E>
|
||||
}
|
||||
}
|
||||
|
||||
fn extcode(&self, address: &Address) -> evm::Result<Arc<Bytes>> {
|
||||
fn extcode(&self, address: &Address) -> vm::Result<Arc<Bytes>> {
|
||||
Ok(self.state.code(address)?.unwrap_or_else(|| Arc::new(vec![])))
|
||||
}
|
||||
|
||||
fn extcodesize(&self, address: &Address) -> evm::Result<usize> {
|
||||
fn extcodesize(&self, address: &Address) -> vm::Result<usize> {
|
||||
Ok(self.state.code_size(address)?.unwrap_or(0))
|
||||
}
|
||||
|
||||
#[cfg_attr(feature="dev", allow(match_ref_pats))]
|
||||
fn ret(mut self, gas: &U256, data: &ReturnData) -> evm::Result<U256>
|
||||
fn ret(mut self, gas: &U256, data: &ReturnData) -> vm::Result<U256>
|
||||
where Self: Sized {
|
||||
let handle_copy = |to: &mut Option<&mut Bytes>| {
|
||||
to.as_mut().map(|b| **b = data.to_vec());
|
||||
@@ -307,7 +308,7 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for Externalities<'a, T, V, B, E>
|
||||
let return_cost = U256::from(data.len()) * U256::from(self.schedule.create_data_gas);
|
||||
if return_cost > *gas || data.len() > self.schedule.create_data_limit {
|
||||
return match self.schedule.exceptional_failed_code_deposit {
|
||||
true => Err(evm::Error::OutOfGas),
|
||||
true => Err(vm::Error::OutOfGas),
|
||||
false => Ok(*gas)
|
||||
}
|
||||
}
|
||||
@@ -320,11 +321,11 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for Externalities<'a, T, V, B, E>
|
||||
}
|
||||
}
|
||||
|
||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> evm::Result<()> {
|
||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> vm::Result<()> {
|
||||
use log_entry::LogEntry;
|
||||
|
||||
if self.static_flag {
|
||||
return Err(evm::Error::MutableCallInStaticContext);
|
||||
return Err(vm::Error::MutableCallInStaticContext);
|
||||
}
|
||||
|
||||
let address = self.origin_info.address.clone();
|
||||
@@ -337,9 +338,9 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for Externalities<'a, T, V, B, E>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn suicide(&mut self, refund_address: &Address) -> evm::Result<()> {
|
||||
fn suicide(&mut self, refund_address: &Address) -> vm::Result<()> {
|
||||
if self.static_flag {
|
||||
return Err(evm::Error::MutableCallInStaticContext);
|
||||
return Err(vm::Error::MutableCallInStaticContext);
|
||||
}
|
||||
|
||||
let address = self.origin_info.address.clone();
|
||||
@@ -396,13 +397,11 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for Externalities<'a, T, V, B, E>
|
||||
mod tests {
|
||||
use util::*;
|
||||
use engines::Engine;
|
||||
use evm::env_info::EnvInfo;
|
||||
use evm::Ext;
|
||||
use evm::{EnvInfo, Ext, CallType};
|
||||
use state::{State, Substate};
|
||||
use tests::helpers::*;
|
||||
use super::*;
|
||||
use trace::{NoopTracer, NoopVMTracer};
|
||||
use evm::CallType;
|
||||
|
||||
fn get_test_origin() -> OriginInfo {
|
||||
OriginInfo {
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use super::test_common::*;
|
||||
use evm::action_params::ActionParams;
|
||||
use state::{Backend as StateBackend, State, Substate};
|
||||
use executive::*;
|
||||
use engines::Engine;
|
||||
use evm::env_info::EnvInfo;
|
||||
use evm;
|
||||
use evm::{Schedule, Ext, Finalize, VMType, ContractCreateResult, MessageCallResult, CreateContractAddress, ReturnData};
|
||||
use evm::{VMType, Finalize};
|
||||
use vm::{
|
||||
self, ActionParams, CallType, Schedule, Ext,
|
||||
ContractCreateResult, EnvInfo, MessageCallResult,
|
||||
CreateContractAddress, ReturnData,
|
||||
};
|
||||
use externalities::*;
|
||||
use evm::CallType;
|
||||
use tests::helpers::*;
|
||||
use ethjson;
|
||||
use trace::{Tracer, NoopTracer};
|
||||
@@ -88,27 +89,27 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> TestExt<'a, T, V, B, E>
|
||||
impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for TestExt<'a, T, V, B, E>
|
||||
where T: Tracer, V: VMTracer, B: StateBackend, E: Engine + ?Sized
|
||||
{
|
||||
fn storage_at(&self, key: &H256) -> evm::Result<H256> {
|
||||
fn storage_at(&self, key: &H256) -> vm::Result<H256> {
|
||||
self.ext.storage_at(key)
|
||||
}
|
||||
|
||||
fn set_storage(&mut self, key: H256, value: H256) -> evm::Result<()> {
|
||||
fn set_storage(&mut self, key: H256, value: H256) -> vm::Result<()> {
|
||||
self.ext.set_storage(key, value)
|
||||
}
|
||||
|
||||
fn exists(&self, address: &Address) -> evm::Result<bool> {
|
||||
fn exists(&self, address: &Address) -> vm::Result<bool> {
|
||||
self.ext.exists(address)
|
||||
}
|
||||
|
||||
fn exists_and_not_null(&self, address: &Address) -> evm::Result<bool> {
|
||||
fn exists_and_not_null(&self, address: &Address) -> vm::Result<bool> {
|
||||
self.ext.exists_and_not_null(address)
|
||||
}
|
||||
|
||||
fn balance(&self, address: &Address) -> evm::Result<U256> {
|
||||
fn balance(&self, address: &Address) -> vm::Result<U256> {
|
||||
self.ext.balance(address)
|
||||
}
|
||||
|
||||
fn origin_balance(&self) -> evm::Result<U256> {
|
||||
fn origin_balance(&self) -> vm::Result<U256> {
|
||||
self.ext.origin_balance()
|
||||
}
|
||||
|
||||
@@ -146,23 +147,23 @@ impl<'a, T: 'a, V: 'a, B: 'a, E: 'a> Ext for TestExt<'a, T, V, B, E>
|
||||
MessageCallResult::Success(*gas, ReturnData::empty())
|
||||
}
|
||||
|
||||
fn extcode(&self, address: &Address) -> evm::Result<Arc<Bytes>> {
|
||||
fn extcode(&self, address: &Address) -> vm::Result<Arc<Bytes>> {
|
||||
self.ext.extcode(address)
|
||||
}
|
||||
|
||||
fn extcodesize(&self, address: &Address) -> evm::Result<usize> {
|
||||
fn extcodesize(&self, address: &Address) -> vm::Result<usize> {
|
||||
self.ext.extcodesize(address)
|
||||
}
|
||||
|
||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> evm::Result<()> {
|
||||
fn log(&mut self, topics: Vec<H256>, data: &[u8]) -> vm::Result<()> {
|
||||
self.ext.log(topics, data)
|
||||
}
|
||||
|
||||
fn ret(self, gas: &U256, data: &ReturnData) -> Result<U256, evm::Error> {
|
||||
fn ret(self, gas: &U256, data: &ReturnData) -> Result<U256, vm::Error> {
|
||||
self.ext.ret(gas, data)
|
||||
}
|
||||
|
||||
fn suicide(&mut self, refund_address: &Address) -> evm::Result<()> {
|
||||
fn suicide(&mut self, refund_address: &Address) -> vm::Result<()> {
|
||||
self.ext.suicide(refund_address)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ use spec::Spec;
|
||||
use ethjson;
|
||||
use ethjson::state::test::ForkSpec;
|
||||
use transaction::SignedTransaction;
|
||||
use evm::env_info::EnvInfo;
|
||||
use vm::EnvInfo;
|
||||
|
||||
lazy_static! {
|
||||
pub static ref FRONTIER: Spec = ethereum::new_frontier_test();
|
||||
|
||||
@@ -106,6 +106,8 @@ extern crate semver;
|
||||
extern crate stats;
|
||||
extern crate time;
|
||||
extern crate transient_hashmap;
|
||||
extern crate vm;
|
||||
extern crate wasm;
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
@@ -20,10 +20,9 @@ use rustc_hex::FromHex;
|
||||
use super::genesis::Genesis;
|
||||
use super::seal::Generic as GenericSeal;
|
||||
|
||||
use evm::action_params::{ActionValue, ActionParams};
|
||||
use builtin::Builtin;
|
||||
use engines::{Engine, NullEngine, InstantSeal, BasicAuthority, AuthorityRound, Tendermint, DEFAULT_BLOCKHASH_CONTRACT};
|
||||
use evm::env_info::EnvInfo;
|
||||
use vm::{EnvInfo, CallType, ActionValue, ActionParams};
|
||||
use error::Error;
|
||||
use ethereum;
|
||||
use ethjson;
|
||||
@@ -36,7 +35,6 @@ use state_db::StateDB;
|
||||
use state::{Backend, State, Substate};
|
||||
use state::backend::Basic as BasicBackend;
|
||||
use trace::{NoopTracer, NoopVMTracer};
|
||||
use evm::CallType;
|
||||
use util::*;
|
||||
|
||||
/// Parameters common to ethereum-like blockchains.
|
||||
@@ -102,14 +100,14 @@ pub struct CommonParams {
|
||||
|
||||
impl CommonParams {
|
||||
/// Schedule for an EVM in the post-EIP-150-era of the Ethereum main net.
|
||||
pub fn schedule(&self, block_number: u64) -> ::evm::Schedule {
|
||||
let mut schedule = ::evm::Schedule::new_post_eip150(usize::max_value(), true, true, true);
|
||||
pub fn schedule(&self, block_number: u64) -> ::vm::Schedule {
|
||||
let mut schedule = ::vm::Schedule::new_post_eip150(usize::max_value(), true, true, true);
|
||||
self.update_schedule(block_number, &mut schedule);
|
||||
schedule
|
||||
}
|
||||
|
||||
/// Apply common spec config parameters to the schedule.
|
||||
pub fn update_schedule(&self, block_number: u64, schedule: &mut ::evm::Schedule) {
|
||||
pub fn update_schedule(&self, block_number: u64, schedule: &mut ::vm::Schedule) {
|
||||
schedule.have_create2 = block_number >= self.eip86_transition;
|
||||
schedule.have_revert = block_number >= self.eip140_transition;
|
||||
schedule.have_static_call = block_number >= self.eip214_transition;
|
||||
@@ -119,8 +117,8 @@ impl CommonParams {
|
||||
}
|
||||
if block_number >= self.dust_protection_transition {
|
||||
schedule.kill_dust = match self.remove_dust_contracts {
|
||||
true => ::evm::CleanDustMode::WithCodeAndStorage,
|
||||
false => ::evm::CleanDustMode::BasicOnly,
|
||||
true => ::vm::CleanDustMode::WithCodeAndStorage,
|
||||
false => ::vm::CleanDustMode::BasicOnly,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ use std::collections::hash_map::Entry;
|
||||
|
||||
use receipt::Receipt;
|
||||
use engines::Engine;
|
||||
use evm::env_info::EnvInfo;
|
||||
use vm::EnvInfo;
|
||||
use error::Error;
|
||||
use executive::{Executive, TransactOptions};
|
||||
use factory::Factories;
|
||||
@@ -982,7 +982,7 @@ mod tests {
|
||||
use ethkey::Secret;
|
||||
use util::{U256, H256, Address, Hashable};
|
||||
use tests::helpers::*;
|
||||
use evm::env_info::EnvInfo;
|
||||
use vm::EnvInfo;
|
||||
use spec::*;
|
||||
use transaction::*;
|
||||
use ethcore_logger::init_log;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
//! Tests of EVM integration with transaction execution.
|
||||
|
||||
use evm::action_params::{ActionParams, ActionValue};
|
||||
use evm::env_info::EnvInfo;
|
||||
use vm::{EnvInfo, ActionParams, ActionValue, CallType};
|
||||
use evm::{Factory, VMType};
|
||||
use evm::call_type::CallType;
|
||||
use executive::Executive;
|
||||
use state::Substate;
|
||||
use tests::helpers::*;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Simple executive tracer.
|
||||
|
||||
use util::{Bytes, Address, U256};
|
||||
use evm::action_params::ActionParams;
|
||||
use vm::ActionParams;
|
||||
use trace::trace::{Call, Create, Action, Res, CreateResult, CallResult, VMTrace, VMOperation, VMExecutedOperation, MemoryDiff, StorageDiff, Suicide};
|
||||
use trace::{Tracer, VMTracer, FlatTrace, TraceError};
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ pub use self::types::filter::{Filter, AddressesFilter};
|
||||
|
||||
use util::{Bytes, Address, U256, H256, DBTransaction};
|
||||
use self::trace::{Call, Create};
|
||||
use evm::action_params::ActionParams;
|
||||
use vm::ActionParams;
|
||||
use header::BlockNumber;
|
||||
|
||||
/// This trait is used by executive to build traces.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Nonoperative tracer.
|
||||
|
||||
use util::{Bytes, Address, U256};
|
||||
use evm::action_params::ActionParams;
|
||||
use vm::ActionParams;
|
||||
use trace::{Tracer, VMTracer, FlatTrace, TraceError};
|
||||
use trace::trace::{Call, Create, VMTrace};
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use std::fmt;
|
||||
use rlp::{Encodable, RlpStream, Decodable, DecoderError, UntrustedRlp};
|
||||
use evm::Error as EvmError;
|
||||
use vm::Error as VmError;
|
||||
|
||||
/// Trace evm errors.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
@@ -45,24 +45,24 @@ pub enum Error {
|
||||
Wasm,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a EvmError> for Error {
|
||||
fn from(e: &'a EvmError) -> Self {
|
||||
impl<'a> From<&'a VmError> for Error {
|
||||
fn from(e: &'a VmError) -> Self {
|
||||
match *e {
|
||||
EvmError::OutOfGas => Error::OutOfGas,
|
||||
EvmError::BadJumpDestination { .. } => Error::BadJumpDestination,
|
||||
EvmError::BadInstruction { .. } => Error::BadInstruction,
|
||||
EvmError::StackUnderflow { .. } => Error::StackUnderflow,
|
||||
EvmError::OutOfStack { .. } => Error::OutOfStack,
|
||||
EvmError::BuiltIn { .. } => Error::BuiltIn,
|
||||
EvmError::Wasm { .. } => Error::Wasm,
|
||||
EvmError::Internal(_) => Error::Internal,
|
||||
EvmError::MutableCallInStaticContext => Error::MutableCallInStaticContext,
|
||||
VmError::OutOfGas => Error::OutOfGas,
|
||||
VmError::BadJumpDestination { .. } => Error::BadJumpDestination,
|
||||
VmError::BadInstruction { .. } => Error::BadInstruction,
|
||||
VmError::StackUnderflow { .. } => Error::StackUnderflow,
|
||||
VmError::OutOfStack { .. } => Error::OutOfStack,
|
||||
VmError::BuiltIn { .. } => Error::BuiltIn,
|
||||
VmError::Wasm { .. } => Error::Wasm,
|
||||
VmError::Internal(_) => Error::Internal,
|
||||
VmError::MutableCallInStaticContext => Error::MutableCallInStaticContext,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EvmError> for Error {
|
||||
fn from(e: EvmError) -> Self {
|
||||
impl From<VmError> for Error {
|
||||
fn from(e: VmError) -> Self {
|
||||
Error::from(&e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ use util::sha3::Hashable;
|
||||
use util::bloom::Bloomable;
|
||||
use rlp::*;
|
||||
|
||||
use evm::action_params::ActionParams;
|
||||
use vm::ActionParams;
|
||||
use basic_types::LogBloom;
|
||||
use evm::CallType;
|
||||
use super::error::Error;
|
||||
|
||||
Reference in New Issue
Block a user