Merge branch 'executive_max_depth' into evm

This commit is contained in:
Tomusdrw 2016-01-14 01:59:11 +01:00
commit 0dc1055af2
2 changed files with 10 additions and 8 deletions

View File

@ -5,6 +5,7 @@ pub struct Schedule {
pub exceptional_failed_code_deposit: bool, pub exceptional_failed_code_deposit: bool,
pub have_delegate_call: bool, pub have_delegate_call: bool,
pub stack_limit: usize, pub stack_limit: usize,
pub max_depth: usize,
pub tier_step_gas: [usize; 8], pub tier_step_gas: [usize; 8],
pub exp_gas: usize, pub exp_gas: usize,
pub exp_byte_gas: usize, pub exp_byte_gas: usize,
@ -50,6 +51,7 @@ impl Schedule {
exceptional_failed_code_deposit: efcd, exceptional_failed_code_deposit: efcd,
have_delegate_call: hdc, have_delegate_call: hdc,
stack_limit: 1024, stack_limit: 1024,
max_depth: 1024,
tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0], tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0],
exp_gas: 10, exp_gas: 10,
exp_byte_gas: 10, exp_byte_gas: 10,

View File

@ -356,7 +356,7 @@ impl<'a> Ext for Externalities<'a> {
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option<Address>), evm::Error> { fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option<Address>), evm::Error> {
// if balance is insufficient or we are to deep, return // if balance is insufficient or we are to deep, return
if self.state.balance(&self.params.address) < *value || self.depth >= self.schedule.stack_limit { if self.state.balance(&self.params.address) < *value || self.depth >= self.schedule.max_depth {
return Ok((*gas, None)); return Ok((*gas, None));
} }
@ -402,7 +402,7 @@ impl<'a> Ext for Externalities<'a> {
let gas = *gas - gas_cost; let gas = *gas - gas_cost;
// if balance is insufficient or we are to deep, return // if balance is insufficient or we are to deep, return
if self.state.balance(&self.params.address) < *value || self.depth >= self.schedule.stack_limit { if self.state.balance(&self.params.address) < *value || self.depth >= self.schedule.max_depth {
return Ok(gas + call_gas) return Ok(gas + call_gas)
} }
@ -494,14 +494,14 @@ mod tests {
struct TestEngine { struct TestEngine {
spec: Spec, spec: Spec,
stack_limit: usize max_depth: usize
} }
impl TestEngine { impl TestEngine {
fn new(stack_limit: usize) -> TestEngine { fn new(max_depth: usize) -> TestEngine {
TestEngine { TestEngine {
spec: ethereum::new_frontier_test(), spec: ethereum::new_frontier_test(),
stack_limit: stack_limit max_depth: max_depth
} }
} }
} }
@ -511,7 +511,7 @@ mod tests {
fn spec(&self) -> &Spec { &self.spec } fn spec(&self) -> &Spec { &self.spec }
fn schedule(&self, _env_info: &EnvInfo) -> Schedule { fn schedule(&self, _env_info: &EnvInfo) -> Schedule {
let mut schedule = Schedule::new_frontier(); let mut schedule = Schedule::new_frontier();
schedule.stack_limit = self.stack_limit; schedule.max_depth = self.max_depth;
schedule schedule
} }
} }
@ -661,7 +661,7 @@ mod tests {
} }
#[test] #[test]
fn test_create_contract_without_stack_limit() { fn test_create_contract_without_max_depth() {
// code: // code:
// //
// 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes? // 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes?