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

Commit

Permalink
Merge pull request #1782 from ethcore/beta-staging
Browse files Browse the repository at this point in the history
BETA: fixed trace_transaction crash when block contained suicide
  • Loading branch information
debris authored Jul 31, 2016
2 parents 8b658b2 + 73376f0 commit a9a41a0
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 27 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
description = "Ethcore client."
name = "parity"
version = "1.2.2"
version = "1.2.3"
license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs"
Expand Down
1 change: 1 addition & 0 deletions ethcore/src/trace/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ mod tests {
}
}

#[derive(Clone)]
struct Extras {
block_hashes: HashMap<BlockNumber, H256>,
transaction_hashes: HashMap<BlockNumber, Vec<H256>>,
Expand Down
50 changes: 41 additions & 9 deletions ethcore/src/types/trace_types/flat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,31 +145,63 @@ impl Into<Vec<FlatTransactionTraces>> 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);
Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/types/trace_types/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.")),
}
}
Expand Down
2 changes: 1 addition & 1 deletion nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
!define DESCRIPTION "Fast, light, robust Ethereum implementation"
!define VERSIONMAJOR 1
!define VERSIONMINOR 2
!define VERSIONBUILD 2
!define VERSIONBUILD 3

!addplugindir .\

Expand Down
2 changes: 1 addition & 1 deletion util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <admin@ethcore.io>"]
build = "build.rs"

Expand Down
5 changes: 3 additions & 2 deletions util/src/rlp/rlpin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.

use std::fmt;
use rustc_serialize::hex::ToHex;
use rlp::{View, DecoderError, UntrustedRlp, PayloadInfo, Prototype, RlpDecodable};

impl<'a> From<UntrustedRlp<'a>> for Rlp<'a> {
Expand Down Expand Up @@ -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<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();
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
Expand Down

0 comments on commit a9a41a0

Please sign in to comment.