Create VMTracer trait.
This commit is contained in:
parent
c1ed520de0
commit
d4a06b27ed
@ -40,8 +40,7 @@ impl Tracer for ExecutiveTracer {
|
|||||||
Some(vec![])
|
Some(vec![])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trace_call(&mut self, call: Option<Call>, gas_used: U256, output: Option<Bytes>, depth: usize, subs:
|
fn trace_call(&mut self, call: Option<Call>, gas_used: U256, output: Option<Bytes>, depth: usize, subs: Vec<Trace>, delegate_call: bool) {
|
||||||
Vec<Trace>, delegate_call: bool) {
|
|
||||||
// don't trace if it's DELEGATECALL or CALLCODE.
|
// don't trace if it's DELEGATECALL or CALLCODE.
|
||||||
if delegate_call {
|
if delegate_call {
|
||||||
return;
|
return;
|
||||||
|
@ -81,13 +81,25 @@ pub trait Tracer: Send {
|
|||||||
/// Stores failed create trace.
|
/// Stores failed create trace.
|
||||||
fn trace_failed_create(&mut self, create: Option<Create>, depth: usize, subs: Vec<Trace>);
|
fn trace_failed_create(&mut self, create: Option<Create>, depth: usize, subs: Vec<Trace>);
|
||||||
|
|
||||||
/// 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;
|
fn subtracer(&self) -> Self where Self: Sized;
|
||||||
|
|
||||||
/// Consumes self and returns all traces.
|
/// Consumes self and returns all traces.
|
||||||
fn traces(self) -> Vec<Trace>;
|
fn traces(self) -> Vec<Trace>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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<U256>);
|
||||||
|
|
||||||
|
/// 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<VMTrace>;
|
||||||
|
}
|
||||||
|
|
||||||
/// `DbExtras` provides an interface to query extra data which is not stored in tracesdb,
|
/// `DbExtras` provides an interface to query extra data which is not stored in tracesdb,
|
||||||
/// but necessary to work correctly.
|
/// but necessary to work correctly.
|
||||||
pub trait DatabaseExtras {
|
pub trait DatabaseExtras {
|
||||||
|
@ -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<Bytes>,
|
||||||
|
}*/
|
||||||
|
/// Information concerning the execution of the operation.
|
||||||
|
// pub executed: Option<VMExecutedOperation>,
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Binary)]
|
#[derive(Debug, Clone, PartialEq, Binary)]
|
||||||
/// A record of the execution of a single VM operation.
|
/// A record of the execution of a single VM operation.
|
||||||
pub struct VMOperation {
|
pub struct VMOperation {
|
||||||
@ -358,26 +369,17 @@ pub struct VMOperation {
|
|||||||
pub instruction: u8,
|
pub instruction: u8,
|
||||||
/// The gas cost for this instruction.
|
/// The gas cost for this instruction.
|
||||||
pub gas_cost: U256,
|
pub gas_cost: U256,
|
||||||
/// The total gas used.
|
|
||||||
pub gas_used: U256,
|
|
||||||
/// The stack.
|
/// The stack.
|
||||||
pub stack: Vec<U256>,
|
pub stack: Vec<U256>,
|
||||||
/// 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 {
|
impl Encodable for VMOperation {
|
||||||
fn rlp_append(&self, s: &mut RlpStream) {
|
fn rlp_append(&self, s: &mut RlpStream) {
|
||||||
s.begin_list(6);
|
s.begin_list(4);
|
||||||
s.append(&self.pc);
|
s.append(&self.pc);
|
||||||
s.append(&self.instruction);
|
s.append(&self.instruction);
|
||||||
s.append(&self.gas_cost);
|
s.append(&self.gas_cost);
|
||||||
s.append(&self.gas_used);
|
|
||||||
s.append(&self.stack);
|
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)),
|
pc: try!(d.val_at(0)),
|
||||||
instruction: try!(d.val_at(1)),
|
instruction: try!(d.val_at(1)),
|
||||||
gas_cost: try!(d.val_at(2)),
|
gas_cost: try!(d.val_at(2)),
|
||||||
gas_used: try!(d.val_at(3)),
|
stack: 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)),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(res)
|
Ok(res)
|
||||||
|
@ -157,8 +157,6 @@ impl<C, M> Ethcore for EthcoreClient<C, M> where C: BlockChainClient + 'static,
|
|||||||
to_value(&Bytes::new(version))
|
to_value(&Bytes::new(version))
|
||||||
}
|
}
|
||||||
|
|
||||||
//pub type VMTraceFunctionBox = Box<FnMut(usize, u8, U256, U256) + Send>;
|
|
||||||
|
|
||||||
fn vm_trace_call(&self, params: Params) -> Result<Value, Error> {
|
fn vm_trace_call(&self, params: Params) -> Result<Value, Error> {
|
||||||
trace!(target: "jsonrpc", "vm_trace_call: {:?}", params);
|
trace!(target: "jsonrpc", "vm_trace_call: {:?}", params);
|
||||||
from_params(params)
|
from_params(params)
|
||||||
|
Loading…
Reference in New Issue
Block a user