diff --git a/src/common.rs b/src/common.rs index 061d0748a..33f0651dc 100644 --- a/src/common.rs +++ b/src/common.rs @@ -2,7 +2,6 @@ pub use util::*; pub use basic_types::*; pub use error::*; pub use env_info::*; -pub use evm_schedule::*; pub use views::*; pub use builtin::*; pub use header::*; diff --git a/src/engine.rs b/src/engine.rs index aed9fe2f3..59888d12a 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -1,6 +1,7 @@ use common::*; use block::Block; use spec::Spec; +use evm::Schedule; /// A consensus mechanism for the chain. Generally either proof-of-work or proof-of-stake-based. /// Provides hooks into each of the major parts of block import. @@ -22,7 +23,7 @@ pub trait Engine : Sync + Send { fn spec(&self) -> &Spec; /// Get the EVM schedule for the given `env_info`. - fn evm_schedule(&self, env_info: &EnvInfo) -> EvmSchedule; + fn schedule(&self, env_info: &EnvInfo) -> Schedule; /// Some intrinsic operation parameters; by default they take their value from the `spec()`'s `engine_params`. fn maximum_extra_data_size(&self) -> usize { decode(&self.spec().engine_params.get("maximumExtraDataSize").unwrap()) } diff --git a/src/ethereum/ethash.rs b/src/ethereum/ethash.rs index c30a855a0..6b253d79f 100644 --- a/src/ethereum/ethash.rs +++ b/src/ethereum/ethash.rs @@ -2,6 +2,7 @@ use common::*; use block::*; use spec::*; use engine::*; +use evm::*; /// Engine using Ethash proof-of-work consensus algorithm, suitable for Ethereum /// mainnet chains in the Olympic, Frontier and Homestead eras. @@ -26,7 +27,7 @@ impl Engine for Ethash { /// Additional engine-specific information for the user/developer concerning `header`. fn extra_info(&self, _header: &Header) -> HashMap { HashMap::new() } fn spec(&self) -> &Spec { &self.spec } - fn evm_schedule(&self, _env_info: &EnvInfo) -> EvmSchedule { EvmSchedule::new_frontier() } + fn schedule(&self, _env_info: &EnvInfo) -> Schedule { Schedule::new_frontier() } /// Apply the block reward on finalisation of the block. /// This assumes that all uncles are valid uncles (i.e. of at least one generation before the current). diff --git a/src/evm/executive.rs b/src/evm/executive.rs index f39273870..d89bce000 100644 --- a/src/evm/executive.rs +++ b/src/evm/executive.rs @@ -9,11 +9,10 @@ use util::sha3::*; use util::bytes::*; use state::*; use env_info::*; -use evm_schedule::*; use engine::*; use transaction::*; use log_entry::*; -use evm::{VmFactory, Ext, EvmParams, EvmResult, EvmError}; +use evm::{Schedule, VmFactory, Ext, EvmParams, EvmResult, EvmError}; /// Returns new address created from address and given nonce. pub fn contract_address(address: &Address, nonce: &U256) -> Address { @@ -242,7 +241,7 @@ impl<'a> Executive<'a> { Err(ExecutionError::OutOfGas) }, Ok(gas_left) => { - let schedule = self.engine.evm_schedule(self.info); + let schedule = self.engine.schedule(self.info); // refunds from SSTORE nonzero -> zero let sstore_refunds = U256::from(schedule.sstore_refund_gas) * substate.refunds_count; @@ -294,7 +293,7 @@ pub struct Externalities<'a> { depth: usize, params: &'a EvmParams, substate: &'a mut Substate, - schedule: EvmSchedule, + schedule: Schedule, output: OutputPolicy<'a> } @@ -314,7 +313,7 @@ impl<'a> Externalities<'a> { depth: depth, params: params, substate: substate, - schedule: engine.evm_schedule(info), + schedule: engine.schedule(info), output: output } } @@ -459,7 +458,7 @@ impl<'a> Ext for Externalities<'a> { self.substate.suicides.insert(address); } - fn schedule(&self) -> &EvmSchedule { + fn schedule(&self) -> &Schedule { &self.schedule } } diff --git a/src/evm/ext.rs b/src/evm/ext.rs index e2680ea71..36add41b6 100644 --- a/src/evm/ext.rs +++ b/src/evm/ext.rs @@ -3,7 +3,7 @@ use util::hash::*; use util::uint::*; use util::bytes::*; -use evm_schedule::*; +use evm::Schedule; use evm::EvmError; // TODO: replace all u64 with u256 @@ -54,5 +54,5 @@ pub trait Ext { fn suicide(&mut self); /// Returns schedule. - fn schedule(&self) -> &EvmSchedule; + fn schedule(&self) -> &Schedule; } diff --git a/src/evm/jit.rs b/src/evm/jit.rs index d5268b78c..1e00a93d9 100644 --- a/src/evm/jit.rs +++ b/src/evm/jit.rs @@ -375,7 +375,7 @@ mod tests { use state::*; use env_info::*; use engine::*; - use evm_schedule::*; + use schedule::*; use spec::*; struct TestEngine; @@ -387,7 +387,7 @@ mod tests { impl Engine for TestEngine { fn name(&self) -> &str { "TestEngine" } fn spec(&self) -> &Spec { unimplemented!() } - fn evm_schedule(&self, _env_info: &EnvInfo) -> EvmSchedule { EvmSchedule::new_frontier() } + fn schedule(&self, _env_info: &EnvInfo) -> Schedule { Schedule::new_frontier() } } #[test] diff --git a/src/evm/mod.rs b/src/evm/mod.rs index 8bb817ac5..bb9b822ec 100644 --- a/src/evm/mod.rs +++ b/src/evm/mod.rs @@ -6,6 +6,7 @@ pub mod vmfactory; //pub mod logentry; pub mod executive; pub mod params; +pub mod schedule; #[cfg(feature = "jit" )] mod jit; @@ -16,3 +17,4 @@ pub use self::vmfactory::VmFactory; // TODO: reduce this to absolutely necessary things pub use self::executive::{Executive, ExecutionResult, Externalities, Substate, OutputPolicy}; pub use self::params::EvmParams; +pub use self::schedule::Schedule; diff --git a/src/evm_schedule.rs b/src/evm/schedule.rs similarity index 90% rename from src/evm_schedule.rs rename to src/evm/schedule.rs index dbe2fc670..552c2a576 100644 --- a/src/evm_schedule.rs +++ b/src/evm/schedule.rs @@ -1,5 +1,5 @@ /// Definition of the cost schedule and other parameterisations for the EVM. -pub struct EvmSchedule { +pub struct Schedule { pub exceptional_failed_code_deposit: bool, pub have_delegate_call: bool, pub stack_limit: usize, @@ -32,19 +32,19 @@ pub struct EvmSchedule { pub copy_gas: usize, } -impl EvmSchedule { +impl Schedule { /// Schedule for the Frontier-era of the Ethereum main net. - pub fn new_frontier() -> EvmSchedule { + pub fn new_frontier() -> Schedule { Self::new(false, false, 21000) } /// Schedule for the Homestead-era of the Ethereum main net. - pub fn new_homestead() -> EvmSchedule { + pub fn new_homestead() -> Schedule { Self::new(true, true, 53000) } - fn new(efcd: bool, hdc: bool, tcg: usize) -> EvmSchedule { - EvmSchedule{ + fn new(efcd: bool, hdc: bool, tcg: usize) -> Schedule { + Schedule{ exceptional_failed_code_deposit: efcd, have_delegate_call: hdc, stack_limit: 1024, diff --git a/src/lib.rs b/src/lib.rs index 47132ee6c..7788c107f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -98,7 +98,6 @@ pub mod header; pub mod transaction; pub mod receipt; pub mod null_engine; -pub mod evm_schedule; pub mod builtin; pub mod spec; pub mod views; diff --git a/src/null_engine.rs b/src/null_engine.rs index da6334839..bd745365c 100644 --- a/src/null_engine.rs +++ b/src/null_engine.rs @@ -1,6 +1,6 @@ use engine::Engine; use spec::Spec; -use evm_schedule::EvmSchedule; +use evm::Schedule; use env_info::EnvInfo; /// An engine which does not provide any consensus mechanism. @@ -17,5 +17,5 @@ impl NullEngine { impl Engine for NullEngine { fn name(&self) -> &str { "NullEngine" } fn spec(&self) -> &Spec { &self.spec } - fn evm_schedule(&self, _env_info: &EnvInfo) -> EvmSchedule { EvmSchedule::new_frontier() } + fn schedule(&self, _env_info: &EnvInfo) -> Schedule { Schedule::new_frontier() } }