Merge pull request #108 from gavofyork/executive_fixes

executive gas calculation fixes
This commit is contained in:
Gav Wood 2016-01-14 12:50:31 +01:00
commit 1d524260e9
2 changed files with 6 additions and 6 deletions

View File

@ -418,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(&params, self.substate, BytesRef::Fixed(output)) ex.call(&params, 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> {

View File

@ -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 {