Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Support direct input stripping in Tracer
Browse files Browse the repository at this point in the history
  • Loading branch information
sorpaas committed Apr 27, 2018
1 parent 6af682a commit af0f9b3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions ethcore/src/executive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
let default = [];
let data = if let Some(ref d) = params.data { d as &[u8] } else { &default as &[u8] };

let mut trace_info = tracer.prepare_trace_call(&params);
let mut trace_info = tracer.prepare_trace_call(&params, self.depth == 0);

let cost = builtin.cost(data);
if cost <= params.gas {
Expand All @@ -435,10 +435,6 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
}
trace_output
} else {
// Disable recording input and output to avoid possible attacks.
if let Some(trace_info) = trace_info.as_mut() {
trace_info.input = None;
}
None
};

Expand All @@ -465,7 +461,7 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
Err(vm::Error::OutOfGas)
}
} else {
let trace_info = tracer.prepare_trace_call(&params);
let trace_info = tracer.prepare_trace_call(&params, true);
let mut trace_output = tracer.prepare_trace_output();
let mut subtracer = tracer.subtracer();

Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/trace/executive_tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ fn should_prefix_address_properly() {
impl Tracer for ExecutiveTracer {
type Output = FlatTrace;

fn prepare_trace_call(&self, params: &ActionParams) -> Option<Call> {
Some(Call::from_action_params(params, true))
fn prepare_trace_call(&self, params: &ActionParams, record_input: bool) -> Option<Call> {
Some(Call::from_action_params(params, record_input))
}

fn prepare_trace_create(&self, params: &ActionParams) -> Option<Create> {
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/trace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub trait Tracer: Send {
type Output;

/// Prepares call trace for given params. Noop tracer should return None.
fn prepare_trace_call(&self, params: &ActionParams) -> Option<Call>;
fn prepare_trace_call(&self, params: &ActionParams, record_input: bool) -> Option<Call>;

/// Prepares create trace for given params. Noop tracer should return None.
fn prepare_trace_create(&self, params: &ActionParams) -> Option<Create>;
Expand Down
2 changes: 1 addition & 1 deletion ethcore/src/trace/noop_tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct NoopTracer;
impl Tracer for NoopTracer {
type Output = FlatTrace;

fn prepare_trace_call(&self, _: &ActionParams) -> Option<Call> {
fn prepare_trace_call(&self, _: &ActionParams, _: bool) -> Option<Call> {
None
}

Expand Down

0 comments on commit af0f9b3

Please sign in to comment.