Merge branch 'master' into move_hash

This commit is contained in:
debris 2016-08-04 14:22:16 +02:00
commit efca92b766
5 changed files with 57 additions and 14 deletions

View File

@ -99,11 +99,11 @@ impl<'a> Executive<'a> {
let check = options.check_nonce;
match options.tracing {
true => match options.vm_tracing {
true => self.transact_with_tracer(t, check, ExecutiveTracer::default(), ExecutiveVMTracer::default()),
true => self.transact_with_tracer(t, check, ExecutiveTracer::default(), ExecutiveVMTracer::toplevel()),
false => self.transact_with_tracer(t, check, ExecutiveTracer::default(), NoopVMTracer),
},
false => match options.vm_tracing {
true => self.transact_with_tracer(t, check, NoopTracer, ExecutiveVMTracer::default()),
true => self.transact_with_tracer(t, check, NoopTracer, ExecutiveVMTracer::toplevel()),
false => self.transact_with_tracer(t, check, NoopTracer, NoopVMTracer),
},
}
@ -634,7 +634,7 @@ mod tests {
let engine = TestEngine::new(5);
let mut substate = Substate::new();
let mut tracer = ExecutiveTracer::default();
let mut vm_tracer = ExecutiveVMTracer::default();
let mut vm_tracer = ExecutiveVMTracer::toplevel();
let gas_left = {
let mut ex = Executive::new(&mut state, &info, &engine, &factory);
@ -693,7 +693,7 @@ mod tests {
],
subs: vec![
VMTrace {
parent_step: 7,
parent_step: 6,
code: vec![96, 16, 128, 96, 12, 96, 0, 57, 96, 0, 243, 0, 96, 0, 53, 84, 21, 96, 9, 87, 0, 91, 96, 32, 53, 96, 0, 53, 85],
operations: vec![
VMOperation { pc: 0, instruction: 96, gas_cost: 3.into(), executed: Some(VMExecutedOperation { gas_used: 67976.into(), stack_push: vec_into![16], mem_diff: None, store_diff: None }) },
@ -743,7 +743,7 @@ mod tests {
let engine = TestEngine::new(5);
let mut substate = Substate::new();
let mut tracer = ExecutiveTracer::default();
let mut vm_tracer = ExecutiveVMTracer::default();
let mut vm_tracer = ExecutiveVMTracer::toplevel();
let gas_left = {
let mut ex = Executive::new(&mut state, &info, &engine, &factory);

View File

@ -294,10 +294,11 @@ impl<T> TraceDatabase for TraceDB<T> where T: DatabaseExtras {
.map(|p| (From::from(p.0), From::from(p.1)))
.collect::<HashMap<TraceGroupPosition, blooms::BloomGroup>>();
let mut blooms = self.blooms.write();
// note_used must be called before locking blooms to avoid cache/traces deadlock on garbage collection
for key in blooms_to_insert.keys() {
self.note_used(CacheID::Bloom(key.clone()));
}
let mut blooms = self.blooms.write();
batch.extend_with_cache(DB_COL_TRACE, blooms.deref_mut(), blooms_to_insert, CacheUpdatePolicy::Remove);
}
}

View File

@ -160,11 +160,24 @@ impl Tracer for ExecutiveTracer {
}
/// Simple VM tracer. Traces all operations.
#[derive(Default)]
pub struct ExecutiveVMTracer {
data: VMTrace,
}
impl ExecutiveVMTracer {
/// Create a new top-level instance.
pub fn toplevel() -> Self {
ExecutiveVMTracer {
data: VMTrace {
parent_step: 0,
code: vec![],
operations: vec![Default::default()], // prefill with a single entry so that prepare_subtrace can get the parent_step
subs: vec![],
}
}
}
}
impl VMTracer for ExecutiveVMTracer {
fn trace_prepare_execute(&mut self, pc: usize, instruction: u8, gas_cost: &U256) -> bool {
self.data.operations.push(VMOperation {
@ -188,7 +201,7 @@ impl VMTracer for ExecutiveVMTracer {
fn prepare_subtrace(&self, code: &[u8]) -> Self {
ExecutiveVMTracer { data: VMTrace {
parent_step: self.data.operations.len(),
parent_step: self.data.operations.len() - 1, // won't overflow since we must already have pushed an operation in trace_prepare_execute.
code: code.to_vec(),
operations: vec![],
subs: vec![],

View File

@ -473,7 +473,7 @@ impl Decodable for VMExecutedOperation {
}
}
#[derive(Debug, Clone, PartialEq, Binary)]
#[derive(Debug, Clone, PartialEq, Binary, Default)]
/// A record of the execution of a single VM operation.
pub struct VMOperation {
/// The program counter.

View File

@ -37,7 +37,7 @@ use dir::Directories;
use dapps::Configuration as DappsConfiguration;
use signer::Configuration as SignerConfiguration;
use run::RunCmd;
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain};
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, DataFormat};
use presale::ImportWallet;
use account::{AccountCmd, NewAccount, ImportAccounts};
@ -88,6 +88,7 @@ impl Configuration {
let signer_port = self.signer_port();
let dapps_conf = self.dapps_config();
let signer_conf = self.signer_config();
let format = try!(self.format());
let cmd = if self.args.flag_version {
Cmd::Version
@ -128,7 +129,7 @@ impl Configuration {
cache_config: cache_config,
dirs: dirs,
file_path: self.args.arg_file.clone(),
format: None,
format: format,
pruning: pruning,
compaction: compaction,
wal: wal,
@ -144,7 +145,7 @@ impl Configuration {
cache_config: cache_config,
dirs: dirs,
file_path: self.args.arg_file.clone(),
format: None,
format: format,
pruning: pruning,
compaction: compaction,
wal: wal,
@ -228,6 +229,13 @@ impl Configuration {
to_address(self.args.flag_etherbase.clone().or(self.args.flag_author.clone()))
}
fn format(&self) -> Result<Option<DataFormat>, String> {
match self.args.flag_format {
Some(ref f) => Ok(Some(try!(f.parse()))),
None => Ok(None),
}
}
fn cache_config(&self) -> CacheConfig {
match self.args.flag_cache_size.or(self.args.flag_cache) {
Some(size) => CacheConfig::new_with_total_cache_size(size),
@ -548,7 +556,7 @@ mod tests {
use ethcore::client::{VMType, BlockID};
use helpers::{replace_home, default_network_config};
use run::RunCmd;
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain};
use blockchain::{BlockchainCmd, ImportBlockchain, ExportBlockchain, DataFormat};
use presale::ImportWallet;
use account::{AccountCmd, NewAccount, ImportAccounts};
use devtools::{RandomTempPath};
@ -623,7 +631,7 @@ mod tests {
cache_config: Default::default(),
dirs: Default::default(),
file_path: Some("blockchain.json".into()),
format: None,
format: Default::default(),
pruning: Default::default(),
compaction: Default::default(),
wal: true,
@ -654,6 +662,27 @@ mod tests {
})));
}
#[test]
fn test_command_blockchain_export_with_custom_format() {
let args = vec!["parity", "export", "--format", "hex", "blockchain.json"];
let conf = Configuration::parse(args).unwrap();
assert_eq!(conf.into_command().unwrap(), Cmd::Blockchain(BlockchainCmd::Export(ExportBlockchain {
spec: Default::default(),
logger_config: Default::default(),
cache_config: Default::default(),
dirs: Default::default(),
file_path: Some("blockchain.json".into()),
pruning: Default::default(),
format: Some(DataFormat::Hex),
compaction: Default::default(),
wal: true,
mode: Default::default(),
tracing: Default::default(),
from_block: BlockID::Number(1),
to_block: BlockID::Latest,
})));
}
#[test]
fn test_command_signer_new_token() {
let args = vec!["parity", "signer", "new-token"];