Merge pull request #1782 from ethcore/beta-staging

BETA: fixed trace_transaction crash when block contained suicide
This commit is contained in:
Marek Kotewicz 2016-07-31 17:26:15 +02:00 committed by GitHub
commit a9a41a03c5
8 changed files with 61 additions and 27 deletions

22
Cargo.lock generated
View File

@ -1,6 +1,6 @@
[root] [root]
name = "parity" name = "parity"
version = "1.2.2" version = "1.2.3"
dependencies = [ dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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-ipc-nano 1.2.0",
"ethcore-rpc 1.2.0", "ethcore-rpc 1.2.0",
"ethcore-signer 1.2.0", "ethcore-signer 1.2.0",
"ethcore-util 1.2.2", "ethcore-util 1.2.3",
"ethsync 1.2.0", "ethsync 1.2.0",
"fdlimit 0.1.0", "fdlimit 0.1.0",
"hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
@ -257,7 +257,7 @@ dependencies = [
"ethcore-devtools 1.2.0", "ethcore-devtools 1.2.0",
"ethcore-ipc 1.2.0", "ethcore-ipc 1.2.0",
"ethcore-ipc-codegen 1.2.0", "ethcore-ipc-codegen 1.2.0",
"ethcore-util 1.2.2", "ethcore-util 1.2.3",
"ethjson 0.1.0", "ethjson 0.1.0",
"ethstore 0.1.0", "ethstore 0.1.0",
"heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "heapsize 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -278,7 +278,7 @@ version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-rpc 1.2.0", "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)", "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-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)", "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" version = "1.2.0"
dependencies = [ dependencies = [
"ethcore-devtools 1.2.0", "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)", "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)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
@ -342,7 +342,7 @@ dependencies = [
"ethash 1.2.0", "ethash 1.2.0",
"ethcore 1.2.0", "ethcore 1.2.0",
"ethcore-devtools 1.2.0", "ethcore-devtools 1.2.0",
"ethcore-util 1.2.2", "ethcore-util 1.2.3",
"ethjson 0.1.0", "ethjson 0.1.0",
"ethsync 1.2.0", "ethsync 1.2.0",
"json-ipc-server 0.2.4 (git+https://github.com/ethcore/json-ipc-server.git)", "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)", "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)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-rpc 1.2.0", "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)", "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)", "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)", "parity-dapps-signer 0.6.0 (git+https://github.com/ethcore/parity-ui.git)",
@ -375,7 +375,7 @@ dependencies = [
[[package]] [[package]]
name = "ethcore-util" name = "ethcore-util"
version = "1.2.2" version = "1.2.3"
dependencies = [ dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
@ -414,7 +414,7 @@ dependencies = [
name = "ethjson" name = "ethjson"
version = "0.1.0" version = "0.1.0"
dependencies = [ 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)", "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 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)", "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)", "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)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.2.0", "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)", "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)", "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)", "rand 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)",
@ -597,7 +597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "json-ipc-server" name = "json-ipc-server"
version = "0.2.4" 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 = [ dependencies = [
"bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,7 +1,7 @@
[package] [package]
description = "Ethcore client." description = "Ethcore client."
name = "parity" name = "parity"
version = "1.2.2" version = "1.2.3"
license = "GPL-3.0" license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs" build = "build.rs"

View File

@ -383,6 +383,7 @@ mod tests {
} }
} }
#[derive(Clone)]
struct Extras { struct Extras {
block_hashes: HashMap<BlockNumber, H256>, block_hashes: HashMap<BlockNumber, H256>,
transaction_hashes: HashMap<BlockNumber, Vec<H256>>, transaction_hashes: HashMap<BlockNumber, Vec<H256>>,

View File

@ -145,31 +145,63 @@ impl Into<Vec<FlatTransactionTraces>> for FlatBlockTraces {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::{FlatBlockTraces, FlatTransactionTraces, FlatTrace}; use super::{FlatBlockTraces, FlatTransactionTraces, FlatTrace};
use trace::trace::{Action, Res, CallResult, Call}; use trace::trace::{Action, Res, CallResult, Call, Suicide};
use types::executed::CallType; use types::executed::CallType;
#[test] #[test]
fn test_trace_serialization() { fn test_trace_serialization() {
use util::rlp; use util::rlp;
// block #51921
let flat_trace = FlatTrace { let flat_trace = FlatTrace {
action: Action::Call(Call { action: Action::Call(Call {
from: 1.into(), from: "8dda5e016e674683241bf671cced51e7239ea2bc".parse().unwrap(),
to: 2.into(), to: "37a5e19cc2d49f244805d5c268c0e6f321965ab9".parse().unwrap(),
value: 3.into(), value: "3627e8f712373c0000".parse().unwrap(),
gas: 4.into(), gas: 0x03e8.into(),
input: vec![0x5], input: vec![],
call_type: CallType::Call, call_type: CallType::Call,
}), }),
result: Res::Call(CallResult { result: Res::Call(CallResult {
gas_used: 10.into(), gas_used: 0.into(),
output: vec![0x11, 0x12] output: vec![],
}), }),
trace_address: Default::default(), trace_address: Default::default(),
subtraces: 0, 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 encoded = rlp::encode(&block_traces);
let decoded = rlp::decode(&encoded); let decoded = rlp::decode(&encoded);

View File

@ -252,7 +252,7 @@ impl Decodable for Suicide {
let res = Suicide { let res = Suicide {
address: try!(d.val_at(0)), address: try!(d.val_at(0)),
refund_address: try!(d.val_at(1)), refund_address: try!(d.val_at(1)),
balance: try!(d.val_at(3)), balance: try!(d.val_at(2)),
}; };
Ok(res) Ok(res)
@ -298,7 +298,7 @@ impl Decodable for Action {
match action_type { match action_type {
0 => d.val_at(1).map(Action::Call), 0 => d.val_at(1).map(Action::Call),
1 => d.val_at(1).map(Action::Create), 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.")), _ => Err(DecoderError::Custom("Invalid action type.")),
} }
} }

View File

@ -4,7 +4,7 @@
!define DESCRIPTION "Fast, light, robust Ethereum implementation" !define DESCRIPTION "Fast, light, robust Ethereum implementation"
!define VERSIONMAJOR 1 !define VERSIONMAJOR 1
!define VERSIONMINOR 2 !define VERSIONMINOR 2
!define VERSIONBUILD 2 !define VERSIONBUILD 3
!addplugindir .\ !addplugindir .\

View File

@ -3,7 +3,7 @@ description = "Ethcore utility library"
homepage = "http://ethcore.io" homepage = "http://ethcore.io"
license = "GPL-3.0" license = "GPL-3.0"
name = "ethcore-util" name = "ethcore-util"
version = "1.2.2" version = "1.2.3"
authors = ["Ethcore <admin@ethcore.io>"] authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs" build = "build.rs"

View File

@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
use std::fmt; use std::fmt;
use rustc_serialize::hex::ToHex;
use rlp::{View, DecoderError, UntrustedRlp, PayloadInfo, Prototype, RlpDecodable}; use rlp::{View, DecoderError, UntrustedRlp, PayloadInfo, Prototype, RlpDecodable};
impl<'a> From<UntrustedRlp<'a>> for Rlp<'a> { impl<'a> From<UntrustedRlp<'a>> 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 { impl <'a, 'view> Rlp<'a> where 'a: 'view {
fn view_as_val<T, R>(r: &R) -> T where R: View<'a, 'view>, T: RlpDecodable { fn view_as_val<T, R>(r: &'view R) -> T where R: View<'a, 'view>, T: RlpDecodable {
let res: Result<T, DecoderError> = r.as_val(); let res: Result<T, DecoderError> = 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 /// Decode into an object