From bdd04d10afa143a9736e2abb6f0218f2beee1f33 Mon Sep 17 00:00:00 2001 From: debris Date: Sun, 31 Jul 2016 12:51:55 +0200 Subject: [PATCH 1/4] fixed trace_transaction crash when block contained suicide --- ethcore/src/trace/db.rs | 33 +++++++++++++++++ ethcore/src/types/trace_types/flat.rs | 50 +++++++++++++++++++++----- ethcore/src/types/trace_types/trace.rs | 4 +-- util/src/rlp/rlpin.rs | 5 +-- 4 files changed, 79 insertions(+), 13 deletions(-) diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index f68cb6cf1..8100cf956 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -383,6 +383,7 @@ mod tests { } } + #[derive(Clone)] struct Extras { block_hashes: HashMap, transaction_hashes: HashMap>, @@ -598,4 +599,36 @@ mod tests { assert_eq!(tracedb.trace(0, 0, vec![]).unwrap(), create_simple_localized_trace(0, block_0.clone(), tx_0.clone())); assert_eq!(tracedb.trace(1, 0, vec![]).unwrap(), create_simple_localized_trace(1, block_1.clone(), tx_1.clone())); } + + #[test] + fn query_trace_after_reopen() { + let temp = RandomTempPath::new(); + let db = new_db(temp.as_str()); + let mut config = Config::default(); + let mut extras = Extras::default(); + let block_0 = H256::from(0xa1); + let tx_0 = H256::from(0xff); + + extras.block_hashes.insert(0, block_0.clone()); + extras.transaction_hashes.insert(0, vec![tx_0.clone()]); + + // set tracing on + config.enabled = Switch::On; + + { + let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone())).unwrap(); + + // import block 0 + let request = create_simple_import_request(0, block_0.clone()); + let batch = DBTransaction::new(&db); + tracedb.import(&batch, request); + db.write(batch).unwrap(); + } + + { + let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras)).unwrap(); + let traces = tracedb.transaction_traces(0, 0); + assert_eq!(traces.unwrap(), vec![create_simple_localized_trace(0, block_0, tx_0)]); + } + } } diff --git a/ethcore/src/types/trace_types/flat.rs b/ethcore/src/types/trace_types/flat.rs index 18c2b3b92..ee7cdc516 100644 --- a/ethcore/src/types/trace_types/flat.rs +++ b/ethcore/src/types/trace_types/flat.rs @@ -145,31 +145,63 @@ impl Into> for FlatBlockTraces { #[cfg(test)] mod tests { use super::{FlatBlockTraces, FlatTransactionTraces, FlatTrace}; - use trace::trace::{Action, Res, CallResult, Call}; + use trace::trace::{Action, Res, CallResult, Call, Suicide}; use types::executed::CallType; #[test] fn test_trace_serialization() { use util::rlp; + // block #51921 let flat_trace = FlatTrace { action: Action::Call(Call { - from: 1.into(), - to: 2.into(), - value: 3.into(), - gas: 4.into(), - input: vec![0x5], + from: "8dda5e016e674683241bf671cced51e7239ea2bc".parse().unwrap(), + to: "37a5e19cc2d49f244805d5c268c0e6f321965ab9".parse().unwrap(), + value: "3627e8f712373c0000".parse().unwrap(), + gas: 0x03e8.into(), + input: vec![], call_type: CallType::Call, }), result: Res::Call(CallResult { - gas_used: 10.into(), - output: vec![0x11, 0x12] + gas_used: 0.into(), + output: vec![], }), trace_address: Default::default(), subtraces: 0, }; - let block_traces = FlatBlockTraces(vec![FlatTransactionTraces(vec![flat_trace])]); + let flat_trace1 = FlatTrace { + action: Action::Call(Call { + from: "3d0768da09ce77d25e2d998e6a7b6ed4b9116c2d".parse().unwrap(), + to: "412fda7643b37d436cb40628f6dbbb80a07267ed".parse().unwrap(), + value: 0.into(), + gas: 0x010c78.into(), + input: vec![0x41, 0xc0, 0xe1, 0xb5], + call_type: CallType::Call, + }), + result: Res::Call(CallResult { + gas_used: 0x0127.into(), + output: vec![], + }), + trace_address: Default::default(), + subtraces: 1, + }; + + let flat_trace2 = FlatTrace { + action: Action::Suicide(Suicide { + address: "412fda7643b37d436cb40628f6dbbb80a07267ed".parse().unwrap(), + balance: 0.into(), + refund_address: "3d0768da09ce77d25e2d998e6a7b6ed4b9116c2d".parse().unwrap(), + }), + result: Res::None, + trace_address: vec![0].into_iter().collect(), + subtraces: 0, + }; + + let block_traces = FlatBlockTraces(vec![ + FlatTransactionTraces(vec![flat_trace]), + FlatTransactionTraces(vec![flat_trace1, flat_trace2]) + ]); let encoded = rlp::encode(&block_traces); let decoded = rlp::decode(&encoded); diff --git a/ethcore/src/types/trace_types/trace.rs b/ethcore/src/types/trace_types/trace.rs index ddd64af21..346b99c06 100644 --- a/ethcore/src/types/trace_types/trace.rs +++ b/ethcore/src/types/trace_types/trace.rs @@ -252,7 +252,7 @@ impl Decodable for Suicide { let res = Suicide { address: try!(d.val_at(0)), refund_address: try!(d.val_at(1)), - balance: try!(d.val_at(3)), + balance: try!(d.val_at(2)), }; Ok(res) @@ -298,7 +298,7 @@ impl Decodable for Action { match action_type { 0 => d.val_at(1).map(Action::Call), 1 => d.val_at(1).map(Action::Create), - 2 => d.val_at(2).map(Action::Suicide), + 2 => d.val_at(1).map(Action::Suicide), _ => Err(DecoderError::Custom("Invalid action type.")), } } diff --git a/util/src/rlp/rlpin.rs b/util/src/rlp/rlpin.rs index 945ae9b24..fb8395c0c 100644 --- a/util/src/rlp/rlpin.rs +++ b/util/src/rlp/rlpin.rs @@ -15,6 +15,7 @@ // along with Parity. If not, see . use std::fmt; +use rustc_serialize::hex::ToHex; use rlp::{View, DecoderError, UntrustedRlp, PayloadInfo, Prototype, RlpDecodable}; impl<'a> From> for Rlp<'a> { @@ -114,9 +115,9 @@ impl<'a, 'view> View<'a, 'view> for Rlp<'a> where 'a: 'view { } impl <'a, 'view> Rlp<'a> where 'a: 'view { - fn view_as_val(r: &R) -> T where R: View<'a, 'view>, T: RlpDecodable { + fn view_as_val(r: &'view R) -> T where R: View<'a, 'view>, T: RlpDecodable { let res: Result = r.as_val(); - res.unwrap_or_else(|e| panic!("DecodeError: {}", e)) + res.unwrap_or_else(|e| panic!("DecodeError: {}, {}", e, r.as_raw().to_hex())) } /// Decode into an object From 282e7d10d0fd378f79a2b985021a8fb3da9004ad Mon Sep 17 00:00:00 2001 From: arkpar Date: Sun, 31 Jul 2016 14:39:37 +0200 Subject: [PATCH 2/4] Version 1.2.3 --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- nsis/installer.nsi | 2 +- util/Cargo.toml | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 383dbdfa1..cfa0fbda0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "parity" -version = "1.2.2" +version = "1.2.3" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)", @@ -16,7 +16,7 @@ dependencies = [ "ethcore-ipc-nano 1.2.0", "ethcore-rpc 1.2.0", "ethcore-signer 1.2.0", - "ethcore-util 1.2.2", + "ethcore-util 1.2.3", "ethsync 1.2.0", "fdlimit 0.1.0", "hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -257,7 +257,7 @@ dependencies = [ "ethcore-devtools 1.2.0", "ethcore-ipc 1.2.0", "ethcore-ipc-codegen 1.2.0", - "ethcore-util 1.2.2", + "ethcore-util 1.2.3", "ethjson 0.1.0", "ethstore 0.1.0", "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -278,7 +278,7 @@ version = "1.2.0" dependencies = [ "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", - "ethcore-util 1.2.2", + "ethcore-util 1.2.3", "hyper 0.9.4 (git+https://github.com/ethcore/hyper)", "jsonrpc-core 2.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-http-server 5.1.0 (git+https://github.com/ethcore/jsonrpc-http-server.git)", @@ -308,7 +308,7 @@ name = "ethcore-ipc" version = "1.2.0" dependencies = [ "ethcore-devtools 1.2.0", - "ethcore-util 1.2.2", + "ethcore-util 1.2.3", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -342,7 +342,7 @@ dependencies = [ "ethash 1.2.0", "ethcore 1.2.0", "ethcore-devtools 1.2.0", - "ethcore-util 1.2.2", + "ethcore-util 1.2.3", "ethjson 0.1.0", "ethsync 1.2.0", "json-ipc-server 0.2.4 (git+https://github.com/ethcore/json-ipc-server.git)", @@ -364,7 +364,7 @@ dependencies = [ "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-rpc 1.2.0", - "ethcore-util 1.2.2", + "ethcore-util 1.2.3", "jsonrpc-core 2.0.7 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-signer 0.6.0 (git+https://github.com/ethcore/parity-ui.git)", @@ -375,7 +375,7 @@ dependencies = [ [[package]] name = "ethcore-util" -version = "1.2.2" +version = "1.2.3" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -414,7 +414,7 @@ dependencies = [ name = "ethjson" version = "0.1.0" dependencies = [ - "ethcore-util 1.2.2", + "ethcore-util 1.2.3", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.7.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -456,7 +456,7 @@ dependencies = [ "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore 1.2.0", - "ethcore-util 1.2.2", + "ethcore-util 1.2.3", "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 008d54b6c..c77393e08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Ethcore client." name = "parity" -version = "1.2.2" +version = "1.2.3" license = "GPL-3.0" authors = ["Ethcore "] build = "build.rs" diff --git a/nsis/installer.nsi b/nsis/installer.nsi index e4f423092..15a747169 100644 --- a/nsis/installer.nsi +++ b/nsis/installer.nsi @@ -4,7 +4,7 @@ !define DESCRIPTION "Fast, light, robust Ethereum implementation" !define VERSIONMAJOR 1 !define VERSIONMINOR 2 -!define VERSIONBUILD 2 +!define VERSIONBUILD 3 !addplugindir .\ diff --git a/util/Cargo.toml b/util/Cargo.toml index dfc0d0a2c..eb338aa42 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -3,7 +3,7 @@ description = "Ethcore utility library" homepage = "http://ethcore.io" license = "GPL-3.0" name = "ethcore-util" -version = "1.2.2" +version = "1.2.3" authors = ["Ethcore "] build = "build.rs" From e4f6871646173933f5b15d3318c5c34e1282c69b Mon Sep 17 00:00:00 2001 From: arkpar Date: Sun, 31 Jul 2016 14:40:12 +0200 Subject: [PATCH 3/4] Updated json-ipc-server --- Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index cfa0fbda0..af8a0171c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -597,7 +597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "json-ipc-server" version = "0.2.4" -source = "git+https://github.com/ethcore/json-ipc-server.git#93c2756f669c6a1872dec1ef755a0870f40c03c3" +source = "git+https://github.com/ethcore/json-ipc-server.git#7a02a0f8b249fda100b9bab5f90b2081d410d8cf" dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", From 73376f0c3ae7e18d756dd3964c2361be63b2c52c Mon Sep 17 00:00:00 2001 From: arkpar Date: Sun, 31 Jul 2016 14:49:23 +0200 Subject: [PATCH 4/4] Removed test --- ethcore/src/trace/db.rs | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/ethcore/src/trace/db.rs b/ethcore/src/trace/db.rs index 8100cf956..c43fe95a7 100644 --- a/ethcore/src/trace/db.rs +++ b/ethcore/src/trace/db.rs @@ -599,36 +599,4 @@ mod tests { assert_eq!(tracedb.trace(0, 0, vec![]).unwrap(), create_simple_localized_trace(0, block_0.clone(), tx_0.clone())); assert_eq!(tracedb.trace(1, 0, vec![]).unwrap(), create_simple_localized_trace(1, block_1.clone(), tx_1.clone())); } - - #[test] - fn query_trace_after_reopen() { - let temp = RandomTempPath::new(); - let db = new_db(temp.as_str()); - let mut config = Config::default(); - let mut extras = Extras::default(); - let block_0 = H256::from(0xa1); - let tx_0 = H256::from(0xff); - - extras.block_hashes.insert(0, block_0.clone()); - extras.transaction_hashes.insert(0, vec![tx_0.clone()]); - - // set tracing on - config.enabled = Switch::On; - - { - let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras.clone())).unwrap(); - - // import block 0 - let request = create_simple_import_request(0, block_0.clone()); - let batch = DBTransaction::new(&db); - tracedb.import(&batch, request); - db.write(batch).unwrap(); - } - - { - let tracedb = TraceDB::new(config.clone(), db.clone(), Arc::new(extras)).unwrap(); - let traces = tracedb.transaction_traces(0, 0); - assert_eq!(traces.unwrap(), vec![create_simple_localized_trace(0, block_0, tx_0)]); - } - } }