Fix test and first part of optionality.
This commit is contained in:
parent
bd338a5741
commit
d6f94c4ad7
@ -264,7 +264,7 @@ impl<'a> Executive<'a> {
|
|||||||
trace!("exec: sstore-clears={}\n", unconfirmed_substate.sstore_clears_count);
|
trace!("exec: sstore-clears={}\n", unconfirmed_substate.sstore_clears_count);
|
||||||
trace!("exec: substate={:?}; unconfirmed_substate={:?}\n", substate, unconfirmed_substate);
|
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);
|
trace!("exec: new substate={:?}\n", substate);
|
||||||
res
|
res
|
||||||
} else {
|
} else {
|
||||||
@ -304,7 +304,7 @@ impl<'a> Executive<'a> {
|
|||||||
c.result = res.as_ref().ok().map(|gas_left| (c.gas - *gas_left, created));
|
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
|
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<TraceAction>) {
|
||||||
match *result {
|
match *result {
|
||||||
Err(evm::Error::OutOfGas)
|
Err(evm::Error::OutOfGas)
|
||||||
| Err(evm::Error::BadJumpDestination {..})
|
| Err(evm::Error::BadJumpDestination {..})
|
||||||
@ -378,7 +378,7 @@ impl<'a> Executive<'a> {
|
|||||||
},
|
},
|
||||||
Ok(_) | Err(evm::Error::Internal) => {
|
Ok(_) | Err(evm::Error::Internal) => {
|
||||||
self.state.clear_snapshot();
|
self.state.clear_snapshot();
|
||||||
substate.accrue(un_substate, action)
|
substate.accrue(un_substate, maybe_action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -87,15 +87,17 @@ impl Substate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Merge secondary substate `s` into self, accruing each element correspondingly.
|
/// 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<TraceAction>) {
|
||||||
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.sstore_clears_count = self.sstore_clears_count + s.sstore_clears_count;
|
self.sstore_clears_count = self.sstore_clears_count + s.sstore_clears_count;
|
||||||
self.contracts_created.extend(s.contracts_created.into_iter());
|
self.contracts_created.extend(s.contracts_created.into_iter());
|
||||||
self.trace.push(TraceItem {
|
if let Some(action) = maybe_action {
|
||||||
action: action,
|
self.trace.push(TraceItem {
|
||||||
subs: s.trace,
|
action: action,
|
||||||
});
|
subs: s.trace,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +158,7 @@ mod tests {
|
|||||||
});
|
});
|
||||||
sub_state_2.sstore_clears_count = x!(7);
|
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.contracts_created.len(), 2);
|
||||||
assert_eq!(sub_state.sstore_clears_count, x!(12));
|
assert_eq!(sub_state.sstore_clears_count, x!(12));
|
||||||
assert_eq!(sub_state.suicides.len(), 1);
|
assert_eq!(sub_state.suicides.len(), 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user