Merge pull request #777 from ethcore/call

added output to execution result
This commit is contained in:
Marek Kotewicz 2016-03-20 10:28:28 +01:00
commit 6feb503c67

View File

@ -66,7 +66,8 @@ pub struct Executed {
/// ///
/// B creation ends first, and it will be the first element of the vector. /// B creation ends first, and it will be the first element of the vector.
pub contracts_created: Vec<Address>, pub contracts_created: Vec<Address>,
/// Transaction output.
pub output: Bytes,
/// The trace of this transaction. /// The trace of this transaction.
pub trace: Option<Trace>, pub trace: Option<Trace>,
} }
@ -152,7 +153,7 @@ impl<'a> Executive<'a> {
let mut substate = Substate::new(tracing); let mut substate = Substate::new(tracing);
let res = match t.action { let (gas_left, output) = match t.action {
Action::Create => { Action::Create => {
let new_address = contract_address(&sender, &nonce); let new_address = contract_address(&sender, &nonce);
let params = ActionParams { let params = ActionParams {
@ -166,7 +167,7 @@ impl<'a> Executive<'a> {
code: Some(t.data.clone()), code: Some(t.data.clone()),
data: None, data: None,
}; };
self.create(params, &mut substate) (self.create(params, &mut substate), vec![])
}, },
Action::Call(ref address) => { Action::Call(ref address) => {
let params = ActionParams { let params = ActionParams {
@ -182,12 +183,12 @@ impl<'a> Executive<'a> {
}; };
// TODO: move output upstream // TODO: move output upstream
let mut out = vec![]; let mut out = vec![];
self.call(params, &mut substate, BytesRef::Flexible(&mut out)) (self.call(params, &mut substate, BytesRef::Flexible(&mut out)), out)
} }
}; };
// finalize here! // finalize here!
Ok(try!(self.finalize(t, substate, res))) Ok(try!(self.finalize(t, substate, gas_left, output)))
} }
fn exec_vm(&mut self, params: ActionParams, unconfirmed_substate: &mut Substate, output_policy: OutputPolicy) -> evm::Result { fn exec_vm(&mut self, params: ActionParams, unconfirmed_substate: &mut Substate, output_policy: OutputPolicy) -> evm::Result {
@ -316,7 +317,7 @@ impl<'a> Executive<'a> {
} }
/// Finalizes the transaction (does refunds and suicides). /// Finalizes the transaction (does refunds and suicides).
fn finalize(&mut self, t: &SignedTransaction, substate: Substate, result: evm::Result) -> ExecutionResult { fn finalize(&mut self, t: &SignedTransaction, substate: Substate, result: evm::Result, output: Bytes) -> ExecutionResult {
let schedule = self.engine.schedule(self.info); let schedule = self.engine.schedule(self.info);
// refunds from SSTORE nonzero -> zero // refunds from SSTORE nonzero -> zero
@ -357,6 +358,7 @@ impl<'a> Executive<'a> {
cumulative_gas_used: self.info.gas_used + t.gas, cumulative_gas_used: self.info.gas_used + t.gas,
logs: vec![], logs: vec![],
contracts_created: vec![], contracts_created: vec![],
output: output,
trace: None, trace: None,
}) })
}, },
@ -368,6 +370,7 @@ impl<'a> Executive<'a> {
cumulative_gas_used: self.info.gas_used + gas_used, cumulative_gas_used: self.info.gas_used + gas_used,
logs: substate.logs, logs: substate.logs,
contracts_created: substate.contracts_created, contracts_created: substate.contracts_created,
output: output,
trace: substate.subtraces.and_then(|mut v| v.pop()), trace: substate.subtraces.and_then(|mut v| v.pop()),
}) })
}, },