diff --git a/lib/ain-evm/src/log.rs b/lib/ain-evm/src/log.rs index 2db8484bfa..305329d2af 100644 --- a/lib/ain-evm/src/log.rs +++ b/lib/ain-evm/src/log.rs @@ -5,7 +5,7 @@ use ethereum::ReceiptV3; use log::debug; use primitive_types::{H160, H256, U256}; use serde::{Deserialize, Serialize}; -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::sync::Arc; #[derive(Serialize, Deserialize, Clone, Debug)] @@ -66,7 +66,7 @@ impl LogHandler { pub fn get_logs( &self, address: Option>, - topics: Option>, + topics: Option>>, block_number: U256, ) -> Vec { debug!("Getting logs for block {:#x?}", block_number); @@ -89,8 +89,13 @@ impl LogHandler { Some(topics) => logs .into_iter() .filter(|log| { - let set: HashSet<_> = log.topics.iter().copied().collect(); - topics.iter().any(|item| set.contains(item)) + topics + .iter() // for all topic filters + .zip(&log.topics) // construct tuple with corresponding log topics + .all(|(filter_item, log_item)| { + // check if topic filter at index matches log topic + filter_item.as_ref().map_or(true, |item| item == log_item) + }) }) .collect(), } diff --git a/lib/ain-grpc/src/transaction_log.rs b/lib/ain-grpc/src/transaction_log.rs index d8113ce6a5..dfee21e245 100644 --- a/lib/ain-grpc/src/transaction_log.rs +++ b/lib/ain-grpc/src/transaction_log.rs @@ -40,5 +40,5 @@ pub struct GetLogsRequest { pub block_hash: Option, pub from_block: Option, pub to_block: Option, - pub topics: Option>, + pub topics: Option>>, }