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

Grab bag of cleanup #11504

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions ethcore/db/src/cache_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ impl<T> CacheManager<T> where T: Eq + Hash {
/// 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 {
CacheManager {
pref_cache_size: pref_cache_size,
max_cache_size: max_cache_size,
bytes_per_cache_entry: bytes_per_cache_entry,
pref_cache_size,
max_cache_size,
bytes_per_cache_entry,
cache_usage: (0..COLLECTION_QUEUE_SIZE).into_iter().map(|_| Default::default()).collect(),
}
}
Expand Down
15 changes: 6 additions & 9 deletions ethcore/executive-state/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,12 @@ pub trait ExecutiveState {

/// Execute a given transaction with given tracer and VM tracer producing a receipt and an optional trace.
/// This will change the state accordingly.
fn apply_with_tracing<V, T>(
fn apply_with_tracing<T, V>(
&mut self,
env_info: &EnvInfo,
machine: &Machine,
t: &SignedTransaction,
tracer: T,
vm_tracer: V,
options: TransactOptions<T, V>,
) -> ApplyResult<T::Output, V::Output>
where
T: trace::Tracer,
Expand All @@ -179,28 +178,26 @@ impl<B: Backend> ExecutiveState for State<B> {
) -> ApplyResult<FlatTrace, VMTrace> {
if 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 {
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.
/// This will change the state accordingly.
fn apply_with_tracing<V, T>(
fn apply_with_tracing<T, V>(
&mut self,
env_info: &EnvInfo,
machine: &Machine,
t: &SignedTransaction,
tracer: T,
vm_tracer: V,
options: TransactOptions<T, V>
) -> ApplyResult<T::Output, V::Output>
where
T: trace::Tracer,
V: trace::VMTracer,
{
let options = TransactOptions::new(tracer, vm_tracer);
let e = execute(self, env_info, machine, t, options, false)?;
let params = machine.params();

Expand Down
3 changes: 2 additions & 1 deletion ethcore/src/test_helpers/evm_test_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ impl<'a> EvmTestClient<'a> {
}

// 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;

// Touch the coinbase at the end of the test to simulate
Expand Down
4 changes: 2 additions & 2 deletions ethcore/trace/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ pub struct Config {
/// Indicates if tracing should be enabled or not.
/// If it's None, it will be automatically configured.
pub enabled: bool,
/// Preferred cache-size.
/// Preferred cache-size (default: 15Mb).
pub pref_cache_size: usize,
/// Max cache-size.
/// Max cache-size (default: 20Mb).
pub max_cache_size: usize,
}

Expand Down
39 changes: 21 additions & 18 deletions ethcore/trace/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,15 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras {
let enacted_blooms: Vec<_> = request.enacted
.iter()
// 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.
.map(|block_hash| if block_hash == &request.block_hash {
request.traces.bloom()
} else {
self.traces(block_hash).expect("Traces database is incomplete.").bloom()
})
.map(|block_hash|
if block_hash == &request.block_hash {
request.traces.bloom()
} else {
self.traces(block_hash).expect("Traces database is incomplete.").bloom()
}
)
.collect();

self.db.trace_blooms()
Expand Down Expand Up @@ -298,18 +300,19 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras {
let tx_hash = self.extras.transaction_hash(block_number, tx_position)
.expect("Expected to find transaction hash. Database is probably corrupted");

traces.into_iter()
.map(|trace| LocalizedTrace {
action: trace.action,
result: trace.result,
subtraces: trace.subtraces,
trace_address: trace.trace_address.into_iter().collect(),
transaction_number: Some(tx_position),
transaction_hash: Some(tx_hash.clone()),
block_number,
block_hash,
})
.collect()
traces
.into_iter()
.map(|trace| LocalizedTrace {
action: trace.action,
result: trace.result,
subtraces: trace.subtraces,
trace_address: trace.trace_address.into_iter().collect(),
transaction_number: Some(tx_position),
transaction_hash: Some(tx_hash.clone()),
block_number,
block_hash,
})
.collect()
})
)
}
Expand Down