Move EvmSchedule -> evm::Schedule
This commit is contained in:
parent
f19a6e54bf
commit
85ac9af832
@ -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::*;
|
||||
|
@ -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()) }
|
||||
|
@ -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<String, String> { 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).
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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]
|
||||
|
@ -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;
|
||||
|
@ -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,
|
@ -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;
|
||||
|
@ -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() }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user