Merge remote-tracking branch 'origin/master' into gav
This commit is contained in:
commit
c6a1d1a286
@ -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,
|
||||||
|
@ -104,6 +104,8 @@ impl<'a> Executive<'a> {
|
|||||||
let sender = try!(t.sender());
|
let sender = try!(t.sender());
|
||||||
let nonce = self.state.nonce(&sender);
|
let nonce = self.state.nonce(&sender);
|
||||||
|
|
||||||
|
// TODO: error on base gas required
|
||||||
|
|
||||||
// validate transaction nonce
|
// validate transaction nonce
|
||||||
if t.nonce != nonce {
|
if t.nonce != nonce {
|
||||||
return Err(From::from(ExecutionError::InvalidNonce { expected: nonce, is: t.nonce }));
|
return Err(From::from(ExecutionError::InvalidNonce { expected: nonce, is: t.nonce }));
|
||||||
@ -136,7 +138,7 @@ impl<'a> Executive<'a> {
|
|||||||
let backup = self.state.clone();
|
let backup = self.state.clone();
|
||||||
|
|
||||||
let schedule = self.engine.schedule(self.info);
|
let schedule = self.engine.schedule(self.info);
|
||||||
let init_gas = t.gas - U256::from(schedule.tx_gas);
|
let init_gas = t.gas - U256::from(t.gas_required(&schedule));
|
||||||
|
|
||||||
let res = match t.action() {
|
let res = match t.action() {
|
||||||
&Action::Create => {
|
&Action::Create => {
|
||||||
@ -303,7 +305,7 @@ impl<'a> Externalities<'a> {
|
|||||||
pub fn new(state: &'a mut State,
|
pub fn new(state: &'a mut State,
|
||||||
info: &'a EnvInfo,
|
info: &'a EnvInfo,
|
||||||
engine: &'a Engine,
|
engine: &'a Engine,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
params: &'a ActionParams,
|
params: &'a ActionParams,
|
||||||
substate: &'a mut Substate,
|
substate: &'a mut Substate,
|
||||||
output: OutputPolicy<'a>) -> Self {
|
output: OutputPolicy<'a>) -> Self {
|
||||||
@ -354,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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +418,7 @@ impl<'a> Ext for Externalities<'a> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut ex = Executive::from_parent(self.state, self.info, self.engine, self.depth);
|
let mut ex = Executive::from_parent(self.state, self.info, self.engine, self.depth);
|
||||||
ex.call(¶ms, self.substate, BytesRef::Fixed(output))
|
ex.call(¶ms, self.substate, BytesRef::Fixed(output)).map(|gas_left| gas + gas_left)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extcode(&self, address: &Address) -> Vec<u8> {
|
fn extcode(&self, address: &Address) -> Vec<u8> {
|
||||||
@ -492,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -509,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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -659,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?
|
||||||
|
@ -9,14 +9,14 @@ use ethereum;
|
|||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ impl Engine for TestEngine {
|
|||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,7 +87,7 @@ impl<'a> Ext for TestExt<'a> {
|
|||||||
});
|
});
|
||||||
Ok((gas_left, Some(address)))
|
Ok((gas_left, Some(address)))
|
||||||
},
|
},
|
||||||
// creation failed only due to reaching stack_limit
|
// creation failed only due to reaching max_depth
|
||||||
Ok((gas_left, None)) if ext.state.balance(&ext.params.address) >= *value => {
|
Ok((gas_left, None)) if ext.state.balance(&ext.params.address) >= *value => {
|
||||||
let address = contract_address(&ext.params.address, &ext.state.nonce(&ext.params.address));
|
let address = contract_address(&ext.params.address, &ext.state.nonce(&ext.params.address));
|
||||||
self.callcreates.push(CallCreate {
|
self.callcreates.push(CallCreate {
|
||||||
|
Loading…
Reference in New Issue
Block a user