MaxDepth param

This commit is contained in:
Tomusdrw 2016-01-14 01:40:55 +01:00
parent 5b52b19bb3
commit 9900158c8e
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 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,

View File

@ -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<Address>), 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?