Fix executive.
This commit is contained in:
parent
08b58da107
commit
efdad2ef8e
@ -241,9 +241,6 @@ impl<'a> Executive<'a> {
|
|||||||
|
|
||||||
/// Finalizes the transaction (does refunds and suicides).
|
/// Finalizes the transaction (does refunds and suicides).
|
||||||
fn finalize(&mut self, t: &Transaction, substate: Substate, result: evm::Result) -> ExecutionResult {
|
fn finalize(&mut self, t: &Transaction, substate: Substate, result: evm::Result) -> ExecutionResult {
|
||||||
match result {
|
|
||||||
Err(evm::Error::Internal) => Err(ExecutionError::Internal),
|
|
||||||
Ok(gas_left) => {
|
|
||||||
let schedule = self.engine.schedule(self.info);
|
let schedule = self.engine.schedule(self.info);
|
||||||
|
|
||||||
// refunds from SSTORE nonzero -> zero
|
// refunds from SSTORE nonzero -> zero
|
||||||
@ -252,6 +249,7 @@ impl<'a> Executive<'a> {
|
|||||||
let suicide_refunds = U256::from(schedule.suicide_refund_gas) * U256::from(substate.suicides.len());
|
let suicide_refunds = U256::from(schedule.suicide_refund_gas) * U256::from(substate.suicides.len());
|
||||||
|
|
||||||
// real ammount to refund
|
// real ammount to refund
|
||||||
|
let gas_left = match &result { &Ok(x) => x, _ => x!(0) };
|
||||||
let refund = cmp::min(sstore_refunds + suicide_refunds, (t.gas - gas_left) / U256::from(2)) + gas_left;
|
let refund = cmp::min(sstore_refunds + suicide_refunds, (t.gas - gas_left) / U256::from(2)) + gas_left;
|
||||||
let refund_value = refund * t.gas_price;
|
let refund_value = refund * t.gas_price;
|
||||||
self.state.add_balance(&t.sender().unwrap(), &refund_value);
|
self.state.add_balance(&t.sender().unwrap(), &refund_value);
|
||||||
@ -261,13 +259,19 @@ impl<'a> Executive<'a> {
|
|||||||
let fees_value = fees * t.gas_price;
|
let fees_value = fees * t.gas_price;
|
||||||
let author = &self.info.author;
|
let author = &self.info.author;
|
||||||
self.state.add_balance(author, &fees_value);
|
self.state.add_balance(author, &fees_value);
|
||||||
|
println!("Compensating: fees: {}, fees_value: {}, author: {}", fees, fees_value, author);
|
||||||
|
|
||||||
// perform suicides
|
// perform suicides
|
||||||
for address in substate.suicides.iter() {
|
for address in substate.suicides.iter() {
|
||||||
|
println!("Killing {}", address);
|
||||||
self.state.kill_account(address);
|
self.state.kill_account(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
let gas_used = t.gas - gas_left;
|
let gas_used = t.gas - gas_left;
|
||||||
|
|
||||||
|
match result {
|
||||||
|
Err(evm::Error::Internal) => Err(ExecutionError::Internal),
|
||||||
|
Ok(_) => {
|
||||||
Ok(Executed {
|
Ok(Executed {
|
||||||
gas: t.gas,
|
gas: t.gas,
|
||||||
gas_used: gas_used,
|
gas_used: gas_used,
|
||||||
|
Loading…
Reference in New Issue
Block a user