From d6f94c4ad7f1e47a854fb47951c1da53259f9636 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sat, 19 Mar 2016 08:31:19 +0100 Subject: [PATCH] Fix test and first part of optionality. --- ethcore/src/executive.rs | 8 ++++---- ethcore/src/substate.rs | 14 ++++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index 9c42f1716..d16bc94d9 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -264,7 +264,7 @@ impl<'a> Executive<'a> { trace!("exec: sstore-clears={}\n", unconfirmed_substate.sstore_clears_count); trace!("exec: substate={:?}; unconfirmed_substate={:?}\n", substate, unconfirmed_substate); - self.enact_result(&res, substate, unconfirmed_substate, action); + self.enact_result(&res, substate, unconfirmed_substate, Some(action)); trace!("exec: new substate={:?}\n", substate); res } else { @@ -304,7 +304,7 @@ impl<'a> Executive<'a> { c.result = res.as_ref().ok().map(|gas_left| (c.gas - *gas_left, created)); } - self.enact_result(&res, substate, unconfirmed_substate, action); + self.enact_result(&res, substate, unconfirmed_substate, Some(action)); res } @@ -367,7 +367,7 @@ impl<'a> Executive<'a> { } } - fn enact_result(&mut self, result: &evm::Result, substate: &mut Substate, un_substate: Substate, action: TraceAction) { + fn enact_result(&mut self, result: &evm::Result, substate: &mut Substate, un_substate: Substate, maybe_action: Option) { match *result { Err(evm::Error::OutOfGas) | Err(evm::Error::BadJumpDestination {..}) @@ -378,7 +378,7 @@ impl<'a> Executive<'a> { }, Ok(_) | Err(evm::Error::Internal) => { self.state.clear_snapshot(); - substate.accrue(un_substate, action) + substate.accrue(un_substate, maybe_action) } } } diff --git a/ethcore/src/substate.rs b/ethcore/src/substate.rs index 08905ac1a..9880fcd16 100644 --- a/ethcore/src/substate.rs +++ b/ethcore/src/substate.rs @@ -87,15 +87,17 @@ impl Substate { } /// Merge secondary substate `s` into self, accruing each element correspondingly. - pub fn accrue(&mut self, s: Substate, action: TraceAction) { + pub fn accrue(&mut self, s: Substate, maybe_action: Option) { self.suicides.extend(s.suicides.into_iter()); self.logs.extend(s.logs.into_iter()); self.sstore_clears_count = self.sstore_clears_count + s.sstore_clears_count; self.contracts_created.extend(s.contracts_created.into_iter()); - self.trace.push(TraceItem { - action: action, - subs: s.trace, - }); + if let Some(action) = maybe_action { + self.trace.push(TraceItem { + action: action, + subs: s.trace, + }); + } } } @@ -156,7 +158,7 @@ mod tests { }); sub_state_2.sstore_clears_count = x!(7); - sub_state.accrue(sub_state_2); + sub_state.accrue(sub_state_2, None); assert_eq!(sub_state.contracts_created.len(), 2); assert_eq!(sub_state.sstore_clears_count, x!(12)); assert_eq!(sub_state.suicides.len(), 1);