Grab bag of cleanup (#11504)
Formatting, docs, pass TransactOptions instead of tracers.
This commit is contained in:
parent
06df521eff
commit
fa0c1efb8d
@ -33,9 +33,9 @@ impl<T> CacheManager<T> where T: Eq + Hash {
|
|||||||
/// Create new cache manager with preferred (heap) sizes.
|
/// Create new cache manager with preferred (heap) sizes.
|
||||||
pub fn new(pref_cache_size: usize, max_cache_size: usize, bytes_per_cache_entry: usize) -> Self {
|
pub fn new(pref_cache_size: usize, max_cache_size: usize, bytes_per_cache_entry: usize) -> Self {
|
||||||
CacheManager {
|
CacheManager {
|
||||||
pref_cache_size: pref_cache_size,
|
pref_cache_size,
|
||||||
max_cache_size: max_cache_size,
|
max_cache_size,
|
||||||
bytes_per_cache_entry: bytes_per_cache_entry,
|
bytes_per_cache_entry,
|
||||||
cache_usage: (0..COLLECTION_QUEUE_SIZE).into_iter().map(|_| Default::default()).collect(),
|
cache_usage: (0..COLLECTION_QUEUE_SIZE).into_iter().map(|_| Default::default()).collect(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,13 +154,12 @@ pub trait ExecutiveState {
|
|||||||
|
|
||||||
/// Execute a given transaction with given tracer and VM tracer producing a receipt and an optional trace.
|
/// Execute a given transaction with given tracer and VM tracer producing a receipt and an optional trace.
|
||||||
/// This will change the state accordingly.
|
/// This will change the state accordingly.
|
||||||
fn apply_with_tracing<V, T>(
|
fn apply_with_tracing<T, V>(
|
||||||
&mut self,
|
&mut self,
|
||||||
env_info: &EnvInfo,
|
env_info: &EnvInfo,
|
||||||
machine: &Machine,
|
machine: &Machine,
|
||||||
t: &SignedTransaction,
|
t: &SignedTransaction,
|
||||||
tracer: T,
|
options: TransactOptions<T, V>,
|
||||||
vm_tracer: V,
|
|
||||||
) -> ApplyResult<T::Output, V::Output>
|
) -> ApplyResult<T::Output, V::Output>
|
||||||
where
|
where
|
||||||
T: trace::Tracer,
|
T: trace::Tracer,
|
||||||
@ -179,28 +178,26 @@ impl<B: Backend> ExecutiveState for State<B> {
|
|||||||
) -> ApplyResult<FlatTrace, VMTrace> {
|
) -> ApplyResult<FlatTrace, VMTrace> {
|
||||||
if tracing {
|
if tracing {
|
||||||
let options = TransactOptions::with_tracing();
|
let options = TransactOptions::with_tracing();
|
||||||
self.apply_with_tracing(env_info, machine, t, options.tracer, options.vm_tracer)
|
self.apply_with_tracing(env_info, machine, t, options)
|
||||||
} else {
|
} else {
|
||||||
let options = TransactOptions::with_no_tracing();
|
let options = TransactOptions::with_no_tracing();
|
||||||
self.apply_with_tracing(env_info, machine, t, options.tracer, options.vm_tracer)
|
self.apply_with_tracing(env_info, machine, t, options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Execute a given transaction with given tracer and VM tracer producing a receipt and an optional trace.
|
/// Execute a given transaction with given tracer and VM tracer producing a receipt and an optional trace.
|
||||||
/// This will change the state accordingly.
|
/// This will change the state accordingly.
|
||||||
fn apply_with_tracing<V, T>(
|
fn apply_with_tracing<T, V>(
|
||||||
&mut self,
|
&mut self,
|
||||||
env_info: &EnvInfo,
|
env_info: &EnvInfo,
|
||||||
machine: &Machine,
|
machine: &Machine,
|
||||||
t: &SignedTransaction,
|
t: &SignedTransaction,
|
||||||
tracer: T,
|
options: TransactOptions<T, V>
|
||||||
vm_tracer: V,
|
|
||||||
) -> ApplyResult<T::Output, V::Output>
|
) -> ApplyResult<T::Output, V::Output>
|
||||||
where
|
where
|
||||||
T: trace::Tracer,
|
T: trace::Tracer,
|
||||||
V: trace::VMTracer,
|
V: trace::VMTracer,
|
||||||
{
|
{
|
||||||
let options = TransactOptions::new(tracer, vm_tracer);
|
|
||||||
let e = execute(self, env_info, machine, t, options, false)?;
|
let e = execute(self, env_info, machine, t, options, false)?;
|
||||||
let params = machine.params();
|
let params = machine.params();
|
||||||
|
|
||||||
|
@ -271,7 +271,8 @@ impl<'a> EvmTestClient<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply transaction
|
// Apply transaction
|
||||||
let result = self.state.apply_with_tracing(&env_info, self.spec.engine.machine(), &transaction, tracer, vm_tracer);
|
let trace_opts = executive::TransactOptions::new(tracer, vm_tracer);
|
||||||
|
let result = self.state.apply_with_tracing(&env_info, self.spec.engine.machine(), &transaction, trace_opts);
|
||||||
let scheme = CreateContractAddress::FromSenderAndNonce;
|
let scheme = CreateContractAddress::FromSenderAndNonce;
|
||||||
|
|
||||||
// Touch the coinbase at the end of the test to simulate
|
// Touch the coinbase at the end of the test to simulate
|
||||||
|
@ -22,9 +22,9 @@ pub struct Config {
|
|||||||
/// Indicates if tracing should be enabled or not.
|
/// Indicates if tracing should be enabled or not.
|
||||||
/// If it's None, it will be automatically configured.
|
/// If it's None, it will be automatically configured.
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
/// Preferred cache-size.
|
/// Preferred cache-size (default: 15Mb).
|
||||||
pub pref_cache_size: usize,
|
pub pref_cache_size: usize,
|
||||||
/// Max cache-size.
|
/// Max cache-size (default: 20Mb).
|
||||||
pub max_cache_size: usize,
|
pub max_cache_size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,13 +239,15 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras {
|
|||||||
let enacted_blooms: Vec<_> = request.enacted
|
let enacted_blooms: Vec<_> = request.enacted
|
||||||
.iter()
|
.iter()
|
||||||
// all traces are expected to be found here. That's why `expect` has been used
|
// all traces are expected to be found here. That's why `expect` has been used
|
||||||
// instead of `filter_map`. If some traces haven't been found, it meens that
|
// instead of `filter_map`. If some traces haven't been found, it means that
|
||||||
// traces database is corrupted or incomplete.
|
// traces database is corrupted or incomplete.
|
||||||
.map(|block_hash| if block_hash == &request.block_hash {
|
.map(|block_hash|
|
||||||
|
if block_hash == &request.block_hash {
|
||||||
request.traces.bloom()
|
request.traces.bloom()
|
||||||
} else {
|
} else {
|
||||||
self.traces(block_hash).expect("Traces database is incomplete.").bloom()
|
self.traces(block_hash).expect("Traces database is incomplete.").bloom()
|
||||||
})
|
}
|
||||||
|
)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
self.db.trace_blooms()
|
self.db.trace_blooms()
|
||||||
@ -298,7 +300,8 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras {
|
|||||||
let tx_hash = self.extras.transaction_hash(block_number, tx_position)
|
let tx_hash = self.extras.transaction_hash(block_number, tx_position)
|
||||||
.expect("Expected to find transaction hash. Database is probably corrupted");
|
.expect("Expected to find transaction hash. Database is probably corrupted");
|
||||||
|
|
||||||
traces.into_iter()
|
traces
|
||||||
|
.into_iter()
|
||||||
.map(|trace| LocalizedTrace {
|
.map(|trace| LocalizedTrace {
|
||||||
action: trace.action,
|
action: trace.action,
|
||||||
result: trace.result,
|
result: trace.result,
|
||||||
|
Loading…
Reference in New Issue
Block a user