v2.5.8-stable (#11041)
* add more tx tests (#11038) * Fix parallel transactions race-condition (#10995) * Add blake2_f precompile (#11017) * [trace] introduce trace failed to Ext (#11019) * Edit publish-onchain.sh to use https (#11016) * Fix deadlock in network-devp2p (#11013) * EIP 1108: Reduce alt_bn128 precompile gas costs (#11008) * xDai chain support and nodes list update (#10989) * EIP 2028: transaction gas lowered from 68 to 16 (#10987) * EIP-1344 Add CHAINID op-code (#10983) * manual publish jobs for releases, no changes for nightlies (#10977) * [blooms-db] Fix benchmarks (#10974) * Verify transaction against its block during import (#10954) * Better error message for rpc gas price errors (#10931) * tx-pool: accept local tx with higher gas price when pool full (#10901) * Fix fork choice (#10837) * Cleanup unused vm dependencies (#10787) * Fix compilation on recent nightlies (#10991)
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
//! Simple executive tracer.
|
||||
|
||||
use std::cmp::min;
|
||||
use ethereum_types::{U256, Address};
|
||||
use vm::{Error as VmError, ActionParams};
|
||||
use log::{debug, warn};
|
||||
@@ -194,12 +195,16 @@ impl Tracer for ExecutiveTracer {
|
||||
}
|
||||
}
|
||||
|
||||
struct TraceData {
|
||||
mem_written: Option<(usize, usize)>,
|
||||
store_written: Option<(U256, U256)>,
|
||||
}
|
||||
|
||||
/// Simple VM tracer. Traces all operations.
|
||||
pub struct ExecutiveVMTracer {
|
||||
data: VMTrace,
|
||||
depth: usize,
|
||||
last_mem_written: Option<(usize, usize)>,
|
||||
last_store_written: Option<(U256, U256)>,
|
||||
trace_stack: Vec<TraceData>,
|
||||
}
|
||||
|
||||
impl ExecutiveVMTracer {
|
||||
@@ -213,8 +218,7 @@ impl ExecutiveVMTracer {
|
||||
subs: vec![],
|
||||
},
|
||||
depth: 0,
|
||||
last_mem_written: None,
|
||||
last_store_written: None,
|
||||
trace_stack: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,30 +245,27 @@ impl VMTracer for ExecutiveVMTracer {
|
||||
executed: None,
|
||||
});
|
||||
});
|
||||
self.last_mem_written = mem_written;
|
||||
self.last_store_written = store_written;
|
||||
self.trace_stack.push(TraceData { mem_written, store_written });
|
||||
}
|
||||
|
||||
fn trace_failed(&mut self) {
|
||||
let _ = self.trace_stack.pop().expect("pushed in trace_prepare_execute; qed");
|
||||
}
|
||||
|
||||
fn trace_executed(&mut self, gas_used: U256, stack_push: &[U256], mem: &[u8]) {
|
||||
let mem_diff = self.last_mem_written.take().map(|(o, s)| {
|
||||
let TraceData { mem_written, store_written } = self.trace_stack.pop().expect("pushed in trace_prepare_execute; qed");
|
||||
let mem_diff = mem_written.map(|(o, s)| {
|
||||
if o + s > mem.len() {
|
||||
warn!(
|
||||
target: "trace",
|
||||
"Last mem written is out of bounds {} (mem is {})",
|
||||
o + s,
|
||||
mem.len(),
|
||||
);
|
||||
(o, &[][..])
|
||||
} else {
|
||||
(o, &(mem[o..o+s]))
|
||||
warn!(target: "trace", "mem_written is out of bounds");
|
||||
}
|
||||
(o, &mem[min(mem.len(), o)..min(o + s, mem.len())])
|
||||
});
|
||||
let store_diff = self.last_store_written.take();
|
||||
let store_diff = store_written;
|
||||
Self::with_trace_in_depth(&mut self.data, self.depth, move |trace| {
|
||||
let ex = VMExecutedOperation {
|
||||
gas_used: gas_used,
|
||||
stack_push: stack_push.iter().cloned().collect(),
|
||||
mem_diff: mem_diff.map(|(s, r)| MemoryDiff { offset: s, data: r.iter().cloned().collect() }),
|
||||
stack_push: stack_push.to_vec(),
|
||||
mem_diff: mem_diff.map(|(s, r)| MemoryDiff { offset: s, data: r.to_vec() }),
|
||||
store_diff: store_diff.map(|(l, v)| StorageDiff { location: l, value: v }),
|
||||
};
|
||||
trace.operations.last_mut().expect("trace_executed is always called after a trace_prepare_execute; trace.operations cannot be empty; qed").executed = Some(ex);
|
||||
|
||||
@@ -85,6 +85,9 @@ pub trait VMTracer: Send {
|
||||
/// Trace the preparation to execute a single valid instruction.
|
||||
fn trace_prepare_execute(&mut self, _pc: usize, _instruction: u8, _gas_cost: U256, _mem_written: Option<(usize, usize)>, _store_written: Option<(U256, U256)>) {}
|
||||
|
||||
/// Trace the execution failure of a single instruction.
|
||||
fn trace_failed(&mut self) {}
|
||||
|
||||
/// Trace the finalised execution of a single valid instruction.
|
||||
fn trace_executed(&mut self, _gas_used: U256, _stack_push: &[U256], _mem: &[u8]) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user