Merge remote-tracking branch 'origin/master' into gav
This commit is contained in:
commit
bf4669eaff
@ -12,7 +12,7 @@ env_logger = "0.3"
|
|||||||
ethcore-util = { path = "../ethcore-util" }
|
ethcore-util = { path = "../ethcore-util" }
|
||||||
rustc-serialize = "0.3"
|
rustc-serialize = "0.3"
|
||||||
flate2 = "0.2"
|
flate2 = "0.2"
|
||||||
rocksdb = "0.2"
|
rocksdb = "0.3"
|
||||||
heapsize = "0.2.0"
|
heapsize = "0.2.0"
|
||||||
rust-crypto = "0.2.34"
|
rust-crypto = "0.2.34"
|
||||||
time = "0.1"
|
time = "0.1"
|
||||||
|
@ -22,7 +22,7 @@ pub struct Substate {
|
|||||||
/// Refund counter of SSTORE nonzero->zero.
|
/// Refund counter of SSTORE nonzero->zero.
|
||||||
refunds_count: U256,
|
refunds_count: U256,
|
||||||
/// True if transaction, or one of its subcalls runs out of gas.
|
/// True if transaction, or one of its subcalls runs out of gas.
|
||||||
out_of_gas: bool,
|
excepted: bool,
|
||||||
/// Created contracts.
|
/// Created contracts.
|
||||||
contracts_created: Vec<Address>
|
contracts_created: Vec<Address>
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ impl Substate {
|
|||||||
suicides: HashSet::new(),
|
suicides: HashSet::new(),
|
||||||
logs: vec![],
|
logs: vec![],
|
||||||
refunds_count: U256::zero(),
|
refunds_count: U256::zero(),
|
||||||
out_of_gas: false,
|
excepted: false,
|
||||||
contracts_created: vec![]
|
contracts_created: vec![]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,11 +43,11 @@ impl Substate {
|
|||||||
self.suicides.extend(s.suicides.into_iter());
|
self.suicides.extend(s.suicides.into_iter());
|
||||||
self.logs.extend(s.logs.into_iter());
|
self.logs.extend(s.logs.into_iter());
|
||||||
self.refunds_count = self.refunds_count + s.refunds_count;
|
self.refunds_count = self.refunds_count + s.refunds_count;
|
||||||
self.out_of_gas |= s.out_of_gas;
|
self.excepted |= s.excepted;
|
||||||
self.contracts_created.extend(s.contracts_created.into_iter());
|
self.contracts_created.extend(s.contracts_created.into_iter());
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn out_of_gas(&self) -> bool { self.out_of_gas }
|
pub fn excepted(&self) -> bool { self.excepted }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transaction execution receipt.
|
/// Transaction execution receipt.
|
||||||
@ -69,7 +69,7 @@ pub struct Executed {
|
|||||||
/// Vector of logs generated by transaction.
|
/// Vector of logs generated by transaction.
|
||||||
pub logs: Vec<LogEntry>,
|
pub logs: Vec<LogEntry>,
|
||||||
/// Execution ended running out of gas.
|
/// Execution ended running out of gas.
|
||||||
pub out_of_gas: bool,
|
pub excepted: bool,
|
||||||
/// Addresses of contracts created during execution of transaction.
|
/// Addresses of contracts created during execution of transaction.
|
||||||
/// Ordered from earliest creation.
|
/// Ordered from earliest creation.
|
||||||
///
|
///
|
||||||
@ -207,7 +207,10 @@ impl<'a> Executive<'a> {
|
|||||||
Ok(params.gas - cost)
|
Ok(params.gas - cost)
|
||||||
},
|
},
|
||||||
// just drain the whole gas
|
// just drain the whole gas
|
||||||
false => Ok(U256::zero())
|
false => {
|
||||||
|
substate.excepted = true;
|
||||||
|
Ok(U256::zero())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if params.code.len() > 0 {
|
} else if params.code.len() > 0 {
|
||||||
// if destination is a contract, do normal message call
|
// if destination is a contract, do normal message call
|
||||||
@ -293,7 +296,7 @@ impl<'a> Executive<'a> {
|
|||||||
refunded: refund,
|
refunded: refund,
|
||||||
cumulative_gas_used: self.info.gas_used + gas_used,
|
cumulative_gas_used: self.info.gas_used + gas_used,
|
||||||
logs: substate.logs,
|
logs: substate.logs,
|
||||||
out_of_gas: substate.out_of_gas,
|
excepted: substate.excepted,
|
||||||
contracts_created: substate.contracts_created
|
contracts_created: substate.contracts_created
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@ -304,7 +307,7 @@ impl<'a> Executive<'a> {
|
|||||||
refunded: U256::zero(),
|
refunded: U256::zero(),
|
||||||
cumulative_gas_used: self.info.gas_used + t.gas,
|
cumulative_gas_used: self.info.gas_used + t.gas,
|
||||||
logs: vec![],
|
logs: vec![],
|
||||||
out_of_gas: true,
|
excepted: true,
|
||||||
contracts_created: vec![]
|
contracts_created: vec![]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -315,7 +318,7 @@ impl<'a> Executive<'a> {
|
|||||||
// TODO: handle other evm::Errors same as OutOfGas once they are implemented
|
// TODO: handle other evm::Errors same as OutOfGas once they are implemented
|
||||||
match result {
|
match result {
|
||||||
&Err(evm::Error::OutOfGas) => {
|
&Err(evm::Error::OutOfGas) => {
|
||||||
substate.out_of_gas = true;
|
substate.excepted = true;
|
||||||
self.state.revert(backup);
|
self.state.revert(backup);
|
||||||
},
|
},
|
||||||
&Ok(_) | &Err(evm::Error::Internal) => substate.accrue(un_substate)
|
&Ok(_) | &Err(evm::Error::Internal) => substate.accrue(un_substate)
|
||||||
@ -899,7 +902,7 @@ mod tests {
|
|||||||
assert_eq!(executed.refunded, U256::from(58_699));
|
assert_eq!(executed.refunded, U256::from(58_699));
|
||||||
assert_eq!(executed.cumulative_gas_used, U256::from(41_301));
|
assert_eq!(executed.cumulative_gas_used, U256::from(41_301));
|
||||||
assert_eq!(executed.logs.len(), 0);
|
assert_eq!(executed.logs.len(), 0);
|
||||||
assert_eq!(executed.out_of_gas, false);
|
assert_eq!(executed.excepted, false);
|
||||||
assert_eq!(executed.contracts_created.len(), 0);
|
assert_eq!(executed.contracts_created.len(), 0);
|
||||||
assert_eq!(state.balance(&sender), U256::from(1));
|
assert_eq!(state.balance(&sender), U256::from(1));
|
||||||
assert_eq!(state.balance(&contract), U256::from(17));
|
assert_eq!(state.balance(&contract), U256::from(17));
|
||||||
|
Loading…
Reference in New Issue
Block a user