From 1ac1224cd3f983d66d650e78428d274350c84a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Fri, 11 Jan 2019 18:08:58 +0100 Subject: [PATCH] Fix #9822: trace_filter does not return failed contract creation (#10140) currently trace_filter can't return failed contract creation transaction but trace_block can query the failed contract creation transaction.it because the logic of parity-ethereum/ethcore/src/trace/types/filter.rs Line 109 in 9982eba ``` _ => false ``` this patch correct the logic: ``` _ => self.to_address.matches_all() ``` Signed-off-by: Deshi Xiao --- ethcore/src/trace/types/filter.rs | 42 ++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/ethcore/src/trace/types/filter.rs b/ethcore/src/trace/types/filter.rs index 00fe38e48..d7b8fcc18 100644 --- a/ethcore/src/trace/types/filter.rs +++ b/ethcore/src/trace/types/filter.rs @@ -106,7 +106,7 @@ impl Filter { let to_matches = match trace.result { Res::Create(ref create_result) => self.to_address.matches(&create_result.address), - _ => false + _ => self.to_address.matches_all(), }; from_matches && to_matches @@ -385,4 +385,44 @@ mod tests { assert!(f1.matches(&trace)); assert!(f2.matches(&trace)); } + + #[test] + fn filter_match_failed_contract_creation_fix_9822() { + + let f0 = Filter { + range: (0..0), + from_address: vec![1.into()].into(), + to_address: vec![].into(), + }; + + let f1 = Filter { + range: (0..0), + from_address: vec![].into(), + to_address: vec![].into(), + }; + + let f2 = Filter { + range: (0..0), + from_address: vec![].into(), + to_address: vec![2.into()].into(), + }; + + let trace = FlatTrace { + action: Action::Create(Create { + from: 1.into(), + gas: 4.into(), + init: vec![0x5], + value: 3.into(), + }), + result: Res::FailedCall(TraceError::BadInstruction), + trace_address: vec![].into_iter().collect(), + subtraces: 0 + }; + + assert!(f0.matches(&trace)); + assert!(f1.matches(&trace)); + assert!(!f2.matches(&trace)); + } + } +