Move EvmSchedule -> evm::Schedule
This commit is contained in:
@@ -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;
|
||||
|
||||
80
src/evm/schedule.rs
Normal file
80
src/evm/schedule.rs
Normal file
@@ -0,0 +1,80 @@
|
||||
/// Definition of the cost schedule and other parameterisations for the EVM.
|
||||
pub struct Schedule {
|
||||
pub exceptional_failed_code_deposit: bool,
|
||||
pub have_delegate_call: bool,
|
||||
pub stack_limit: usize,
|
||||
pub tier_step_gas: [usize; 8],
|
||||
pub exp_gas: usize,
|
||||
pub exp_byte_gas: usize,
|
||||
pub sha3_gas: usize,
|
||||
pub sha3_word_gas: usize,
|
||||
pub sload_gas: usize,
|
||||
pub sstore_set_gas: usize,
|
||||
pub sstore_reset_gas: usize,
|
||||
pub sstore_refund_gas: usize,
|
||||
pub jumpdest_gas: usize,
|
||||
pub log_gas: usize,
|
||||
pub log_data_gas: usize,
|
||||
pub log_topic_gas: usize,
|
||||
pub create_gas: usize,
|
||||
pub call_gas: usize,
|
||||
pub call_stipend: usize,
|
||||
pub call_value_transfer_gas: usize,
|
||||
pub call_new_account_gas: usize,
|
||||
pub suicide_refund_gas: usize,
|
||||
pub memory_gas: usize,
|
||||
pub quad_coeff_div: usize,
|
||||
pub create_data_gas: usize,
|
||||
pub tx_gas: usize,
|
||||
pub tx_create_gas: usize,
|
||||
pub tx_data_zero_gas: usize,
|
||||
pub tx_data_non_zero_gas: usize,
|
||||
pub copy_gas: usize,
|
||||
}
|
||||
|
||||
impl Schedule {
|
||||
/// Schedule for the Frontier-era of the Ethereum main net.
|
||||
pub fn new_frontier() -> Schedule {
|
||||
Self::new(false, false, 21000)
|
||||
}
|
||||
|
||||
/// Schedule for the Homestead-era of the Ethereum main net.
|
||||
pub fn new_homestead() -> Schedule {
|
||||
Self::new(true, true, 53000)
|
||||
}
|
||||
|
||||
fn new(efcd: bool, hdc: bool, tcg: usize) -> Schedule {
|
||||
Schedule{
|
||||
exceptional_failed_code_deposit: efcd,
|
||||
have_delegate_call: hdc,
|
||||
stack_limit: 1024,
|
||||
tier_step_gas: [0usize, 2, 3, 4, 5, 6, 10, 20],
|
||||
exp_gas: 10,
|
||||
exp_byte_gas: 10,
|
||||
sha3_gas: 30,
|
||||
sha3_word_gas: 6,
|
||||
sload_gas: 50,
|
||||
sstore_set_gas: 20000,
|
||||
sstore_reset_gas: 5000,
|
||||
sstore_refund_gas: 15000,
|
||||
jumpdest_gas: 1,
|
||||
log_gas: 375,
|
||||
log_data_gas: 8,
|
||||
log_topic_gas: 375,
|
||||
create_gas: 32000,
|
||||
call_gas: 40,
|
||||
call_stipend: 2300,
|
||||
call_value_transfer_gas: 9000,
|
||||
call_new_account_gas: 25000,
|
||||
suicide_refund_gas: 24000,
|
||||
memory_gas: 3,
|
||||
quad_coeff_div: 512,
|
||||
create_data_gas: 200,
|
||||
tx_gas: 21000,
|
||||
tx_create_gas: tcg,
|
||||
tx_data_zero_gas: 4,
|
||||
tx_data_non_zero_gas: 68,
|
||||
copy_gas: 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user