From f0c775b11f3292b9f8118c82ceea8019da6bc527 Mon Sep 17 00:00:00 2001 From: nanocryk <6422796+nanocryk@users.noreply.github.com> Date: Thu, 2 Sep 2021 13:13:44 +0000 Subject: [PATCH] Filters out invalid transaction trace entries (#771) * ignore consecutive call list new events * Remove empty entries in `proxy::v1` * Remove empty entries in `proxy::formats` Co-authored-by: tgmichel --- primitives/rpc/debug/src/proxy/formats/trace_filter.rs | 5 ++++- primitives/rpc/debug/src/proxy/v1/mod.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/primitives/rpc/debug/src/proxy/formats/trace_filter.rs b/primitives/rpc/debug/src/proxy/formats/trace_filter.rs index 81e3f4db6f..ec2ad09b08 100644 --- a/primitives/rpc/debug/src/proxy/formats/trace_filter.rs +++ b/primitives/rpc/debug/src/proxy/formats/trace_filter.rs @@ -29,7 +29,10 @@ impl super::TraceResponseBuilder for Response { type Listener = Listener; type Response = Vec; - fn build(listener: Listener) -> Option> { + fn build(mut listener: Listener) -> Option> { + // Remove empty BTreeMaps pushed to `entries`. + // I.e. InvalidNonce or other pallet_evm::runner exits + listener.entries.retain(|x| !x.is_empty()); let mut traces = Vec::new(); for (eth_tx_index, entry) in listener.entries.iter().enumerate() { let mut tx_traces: Vec<_> = entry diff --git a/primitives/rpc/debug/src/proxy/v1/mod.rs b/primitives/rpc/debug/src/proxy/v1/mod.rs index 92efdcdda0..42d0a80b9d 100644 --- a/primitives/rpc/debug/src/proxy/v1/mod.rs +++ b/primitives/rpc/debug/src/proxy/v1/mod.rs @@ -167,7 +167,10 @@ impl CallListProxy { /// Format the RPC output for multiple transactions. Each call-stack represents a single /// transaction/EVM execution. - pub fn into_tx_traces(self) -> Vec { + pub fn into_tx_traces(&mut self) -> Vec { + // Remove empty BTreeMaps pushed to `entries`. + // I.e. InvalidNonce or other pallet_evm::runner exits + self.entries.retain(|x| !x.is_empty()); let mut traces = Vec::new(); for (eth_tx_index, entry) in self.entries.iter().enumerate() { let mut tx_traces: Vec<_> = entry