From 6a6e3f5886cc0fc7b738358a1d4f16c34e0f6018 Mon Sep 17 00:00:00 2001 From: tgmichel Date: Fri, 29 Jan 2021 11:35:34 +0100 Subject: [PATCH] Fix topic wildcards bug (#277) --- client/rpc-core/src/types/filter.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/rpc-core/src/types/filter.rs b/client/rpc-core/src/types/filter.rs index 3d8728e6b..acc0ea416 100644 --- a/client/rpc-core/src/types/filter.rs +++ b/client/rpc-core/src/types/filter.rs @@ -272,8 +272,18 @@ impl FilteredParams { } } }, - VariadicValue::Multiple(_) => { - let replaced: Option> = self.replace(log, topic); + VariadicValue::Multiple(multi) => { + // Shrink the topics until the last item is Some. + let mut new_multi = multi; + while new_multi.iter().last().unwrap_or(&Some(H256::default())).is_none() { + new_multi.pop(); + } + // We can discard right away any logs with lesser topics than the filter. + if new_multi.len() > log.topics.len() { + out = false; + break; + } + let replaced: Option> = self.replace(log, VariadicValue::Multiple(new_multi)); if let Some(replaced) = replaced { out = false; if log.topics.starts_with(