Merge pull request #104 from gavofyork/tx_gas

transact substracts tx_gas
This commit is contained in:
Gav Wood 2016-01-14 01:30:09 +01:00
commit 36e8be0e0b
2 changed files with 8 additions and 3 deletions

View File

@ -135,13 +135,16 @@ impl<'a> Executive<'a> {
let mut substate = Substate::new();
let backup = self.state.clone();
let schedule = self.engine.schedule(self.info);
let init_gas = t.gas - U256::from(schedule.tx_gas);
let res = match t.action() {
&Action::Create => {
let params = ActionParams {
address: contract_address(&sender, &nonce),
sender: sender.clone(),
origin: sender.clone(),
gas: t.gas,
gas: init_gas,
gas_price: t.gas_price,
value: t.value,
code: t.data.clone(),
@ -154,7 +157,7 @@ impl<'a> Executive<'a> {
address: address.clone(),
sender: sender.clone(),
origin: sender.clone(),
gas: t.gas,
gas: init_gas,
gas_price: t.gas_price,
value: t.value,
code: self.state.code(address).unwrap_or(vec![]),

View File

@ -53,9 +53,11 @@ fn do_json_test(json_data: &[u8]) -> Vec<String> {
let mut s = State::new_temp();
s.populate_from(pre);
Executive::new(&mut s, &env, engine.deref()).transact(&t).unwrap();
let e = Executive::new(&mut s, &env, engine.deref()).transact(&t).unwrap();
println!("executed: {:?}", e);
let our_post = s.to_pod_map();
s.commit();
if fail_unless(s.root() == &post_state_root) {
println!("FAILED {}. Diff:\n{}", name, pod_map_diff(&post, &our_post));
}