From e08b6d369061a88c8e85424ba5d1873a0340c884 Mon Sep 17 00:00:00 2001 From: incrypto32 Date: Wed, 24 Apr 2024 16:35:07 +0400 Subject: [PATCH] chain/ethereum: fix incorrect comparison of transaction hash --- chain/ethereum/src/data_source.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/chain/ethereum/src/data_source.rs b/chain/ethereum/src/data_source.rs index d9360dce4e8..d5453bee92f 100644 --- a/chain/ethereum/src/data_source.rs +++ b/chain/ethereum/src/data_source.rs @@ -770,14 +770,9 @@ impl DataSource { // See also ca0edc58-0ec5-4c89-a7dd-2241797f5e50. // There is another special case in zkSync-era, where the transaction hash in this case would be zero // See https://docs.zksync.io/zk-stack/concepts/blocks.html#fictive-l2-block-finalizing-the-batch - let transaction = if log.transaction_hash != block.hash + let transaction = if log.transaction_hash == block.hash || log.transaction_hash == Some(H256::zero()) { - block - .transaction_for_log(&log) - .context("Found no transaction for event")? - } else { - // Infer some fields from the log and fill the rest with zeros. Transaction { hash: log.transaction_hash.unwrap(), block_hash: block.hash, @@ -786,6 +781,12 @@ impl DataSource { from: Some(H160::zero()), ..Transaction::default() } + } else { + // This is the general case where the log's transaction hash does not match the block's hash + // and is not a special zero hash, implying a real transaction associated with this log. + block + .transaction_for_log(&log) + .context("Found no transaction for event")? }; let logging_extras = Arc::new(o! {