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

Fix json tracer overflow #9873

Merged
merged 5 commits into from
Nov 7, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Replace trace_executed with a direct trace push
  • Loading branch information
sorpaas committed Nov 7, 2018
commit cad06ec4edaea9488214815cdf564c6371db571b
20 changes: 19 additions & 1 deletion evmbin/src/display/json.rs
Original file line number Diff line number Diff line change
@@ -194,7 +194,25 @@ impl trace::VMTracer for Informant {
// print last line with final state:
self.gas_cost = 0.into();
let gas_used = self.gas_used;
self.trace_executed(gas_used, &[], &[]);
let subdepth = self.subdepth;

Self::with_informant_in_depth(&mut self, subdepth, |informant: &mut Informant| {
let store_diff = informant.store_written.clone();
let info = ::evm::Instruction::from_u8(informant.instruction).map(|i| i.info());

let trace = json!({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way we could get rid of this duplication? It's not strongly typed and having two places where this is generated is imho error prone in the long term.

"pc": informant.pc,
"op": informant.instruction,
"opName": info.map(|i| i.name).unwrap_or(""),
"gas": format!("{:#x}", gas_used.saturating_add(informant.gas_cost)),
"gasCost": format!("{:#x}", informant.gas_cost),
"memory": format!("0x{}", informant.memory.to_hex()),
"stack": informant.stack,
"storage": informant.storage,
"depth": informant.depth,
});
informant.traces.push(trace.to_string());
});
} else if !self.subtraces.is_empty() {
self.traces.extend(mem::replace(&mut self.subtraces, vec![]));
}