From 9900158c8e30a20ce802f59a65cf9320a9b771f6 Mon Sep 17 00:00:00 2001 From: Tomusdrw Date: Thu, 14 Jan 2016 01:40:55 +0100 Subject: [PATCH] MaxDepth param --- src/evm/schedule.rs | 2 ++ src/executive.rs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/evm/schedule.rs b/src/evm/schedule.rs index a8807735e..f820f85e7 100644 --- a/src/evm/schedule.rs +++ b/src/evm/schedule.rs @@ -5,6 +5,7 @@ pub struct Schedule { pub exceptional_failed_code_deposit: bool, pub have_delegate_call: bool, pub stack_limit: usize, + pub max_depth: usize, pub tier_step_gas: [usize; 8], pub exp_gas: usize, pub exp_byte_gas: usize, @@ -50,6 +51,7 @@ impl Schedule { exceptional_failed_code_deposit: efcd, have_delegate_call: hdc, stack_limit: 1024, + max_depth: 1024, tier_step_gas: [0, 2, 3, 5, 8, 10, 20, 0], exp_gas: 10, exp_byte_gas: 10, diff --git a/src/executive.rs b/src/executive.rs index ea135194f..d3f313cce 100644 --- a/src/executive.rs +++ b/src/executive.rs @@ -300,7 +300,7 @@ impl<'a> Externalities<'a> { pub fn new(state: &'a mut State, info: &'a EnvInfo, engine: &'a Engine, - depth: usize, + depth: usize, params: &'a ActionParams, substate: &'a mut Substate, output: OutputPolicy<'a>) -> Self { @@ -351,7 +351,7 @@ impl<'a> Ext for Externalities<'a> { fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> Result<(U256, Option
), evm::Error> { // 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)); } @@ -397,7 +397,7 @@ impl<'a> Ext for Externalities<'a> { let gas = *gas - gas_cost; // 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) } @@ -489,14 +489,14 @@ mod tests { struct TestEngine { spec: Spec, - stack_limit: usize + max_depth: usize } impl TestEngine { - fn new(stack_limit: usize) -> TestEngine { + fn new(max_depth: usize) -> TestEngine { TestEngine { spec: ethereum::new_frontier_test(), - stack_limit: stack_limit + max_depth: max_depth } } } @@ -506,7 +506,7 @@ mod tests { fn spec(&self) -> &Spec { &self.spec } fn schedule(&self, _env_info: &EnvInfo) -> Schedule { let mut schedule = Schedule::new_frontier(); - schedule.stack_limit = self.stack_limit; + schedule.max_depth = self.max_depth; schedule } } @@ -656,7 +656,7 @@ mod tests { } #[test] - fn test_create_contract_without_stack_limit() { + fn test_create_contract_without_max_depth() { // code: // // 7c 601080600c6000396000f3006000355415600957005b60203560003555 - push 29 bytes?