diff --git a/ethcore/src/trace/executive_tracer.rs b/ethcore/src/trace/executive_tracer.rs index a0bff1c72..41d8c2389 100644 --- a/ethcore/src/trace/executive_tracer.rs +++ b/ethcore/src/trace/executive_tracer.rs @@ -40,8 +40,7 @@ impl Tracer for ExecutiveTracer { Some(vec![]) } - fn trace_call(&mut self, call: Option, gas_used: U256, output: Option, depth: usize, subs: - Vec, delegate_call: bool) { + fn trace_call(&mut self, call: Option, gas_used: U256, output: Option, depth: usize, subs: Vec, delegate_call: bool) { // don't trace if it's DELEGATECALL or CALLCODE. if delegate_call { return; diff --git a/ethcore/src/trace/mod.rs b/ethcore/src/trace/mod.rs index dd8cd4d20..21827dd58 100644 --- a/ethcore/src/trace/mod.rs +++ b/ethcore/src/trace/mod.rs @@ -81,13 +81,25 @@ pub trait Tracer: Send { /// Stores failed create trace. fn trace_failed_create(&mut self, create: Option, depth: usize, subs: Vec); - /// Spawn subracer which will be used to trace deeper levels of execution. + /// Spawn subtracer which will be used to trace deeper levels of execution. fn subtracer(&self) -> Self where Self: Sized; /// Consumes self and returns all traces. fn traces(self) -> Vec; } +/// Used by executive to build VM traces. +pub trait VMTracer: Send { + /// Trace the preparation to execute a single instruction. + fn trace_prepare_execute(pc: usize, instruction: u8, gas_cost: &U256, stack: &Vec); + + /// Spawn subtracer which will be used to trace deeper levels of execution. + fn subtracer(&self) -> Self where Self: Sized; + + /// Consumes self and returns all VM traces. + fn traces(self) -> Vec; +} + /// `DbExtras` provides an interface to query extra data which is not stored in tracesdb, /// but necessary to work correctly. pub trait DatabaseExtras { diff --git a/ethcore/src/types/trace_types/trace.rs b/ethcore/src/types/trace_types/trace.rs index da58f3253..5b5132643 100644 --- a/ethcore/src/types/trace_types/trace.rs +++ b/ethcore/src/types/trace_types/trace.rs @@ -349,6 +349,17 @@ impl Trace { } } +/*pub struct VMExecutedOperation { + /// The total gas used. + pub gas_used: U256, + /// Altered storage value. + pub storage_diff: Option<(U256, U256)>, + /// If altered, the new memory image. + pub new_memory: Option, +}*/ + /// Information concerning the execution of the operation. +// pub executed: Option, + #[derive(Debug, Clone, PartialEq, Binary)] /// A record of the execution of a single VM operation. pub struct VMOperation { @@ -358,26 +369,17 @@ pub struct VMOperation { pub instruction: u8, /// The gas cost for this instruction. pub gas_cost: U256, - /// The total gas used. - pub gas_used: U256, /// The stack. pub stack: Vec, - /// Altered storage value. TODO: should be option. -// pub storage_diff: Option<(U256, U256)>, - /// If altered, the new memory image. - pub new_memory: Bytes, } impl Encodable for VMOperation { fn rlp_append(&self, s: &mut RlpStream) { - s.begin_list(6); + s.begin_list(4); s.append(&self.pc); s.append(&self.instruction); s.append(&self.gas_cost); - s.append(&self.gas_used); s.append(&self.stack); -// s.append(&self.storage_diff); - s.append(&self.new_memory); } } @@ -388,10 +390,7 @@ impl Decodable for VMOperation { pc: try!(d.val_at(0)), instruction: try!(d.val_at(1)), gas_cost: try!(d.val_at(2)), - gas_used: try!(d.val_at(3)), - stack: try!(d.val_at(4)), -// storage_diff: try!(d.val_at(5)), - new_memory: try!(d.val_at(6)), + stack: try!(d.val_at(3)), }; Ok(res) diff --git a/rpc/src/v1/impls/ethcore.rs b/rpc/src/v1/impls/ethcore.rs index d34c6d62e..4412cdac6 100644 --- a/rpc/src/v1/impls/ethcore.rs +++ b/rpc/src/v1/impls/ethcore.rs @@ -157,8 +157,6 @@ impl Ethcore for EthcoreClient where C: BlockChainClient + 'static, to_value(&Bytes::new(version)) } - //pub type VMTraceFunctionBox = Box; - fn vm_trace_call(&self, params: Params) -> Result { trace!(target: "jsonrpc", "vm_trace_call: {:?}", params); from_params(params)