Fix up the VM trace.

This commit is contained in:
Gav Wood
2016-08-03 20:07:30 +02:00
parent 40a304b177
commit 52355855fc
3 changed files with 18 additions and 5 deletions

View File

@@ -160,11 +160,24 @@ impl Tracer for ExecutiveTracer {
}
/// Simple VM tracer. Traces all operations.
#[derive(Default)]
pub struct ExecutiveVMTracer {
data: VMTrace,
}
impl ExecutiveVMTracer {
/// Create a new top-level instance.
pub fn toplevel() -> Self {
ExecutiveVMTracer {
data: VMTrace {
parent_step: 0,
code: vec![],
operations: vec![Default::default()], // prefill with a single entry so that prepare_subtrace can get the parent_step
subs: vec![],
}
}
}
}
impl VMTracer for ExecutiveVMTracer {
fn trace_prepare_execute(&mut self, pc: usize, instruction: u8, gas_cost: &U256) -> bool {
self.data.operations.push(VMOperation {
@@ -188,7 +201,7 @@ impl VMTracer for ExecutiveVMTracer {
fn prepare_subtrace(&self, code: &[u8]) -> Self {
ExecutiveVMTracer { data: VMTrace {
parent_step: self.data.operations.len(),
parent_step: self.data.operations.len() - 1, // won't overflow since we must already have pushed an operation in trace_prepare_execute.
code: code.to_vec(),
operations: vec![],
subs: vec![],