From e44fff7052a75b6b67646881282ca693a9bf7c53 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 28 Nov 2024 18:21:57 +0530 Subject: [PATCH 1/6] refactor: update filtering of logs --- scripts/tests/api_compare/filter-list | 2 -- scripts/tests/api_compare/filter-list-offline | 2 -- src/rpc/methods/eth.rs | 11 +++++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/tests/api_compare/filter-list b/scripts/tests/api_compare/filter-list index 301ad29e8c4..2207a79c755 100644 --- a/scripts/tests/api_compare/filter-list +++ b/scripts/tests/api_compare/filter-list @@ -14,5 +14,3 @@ # TODO: https://github.com/ChainSafe/forest/issues/4701 !Filecoin.EthGetTransactionByBlockHashAndIndex !Filecoin.EthGetTransactionByBlockNumberAndIndex -# TODO: https://github.com/ChainSafe/forest/issues/5006 -!Filecoin.EthGetBlockReceipts diff --git a/scripts/tests/api_compare/filter-list-offline b/scripts/tests/api_compare/filter-list-offline index 75aa20c4123..0c79cfe162c 100644 --- a/scripts/tests/api_compare/filter-list-offline +++ b/scripts/tests/api_compare/filter-list-offline @@ -44,5 +44,3 @@ # TODO: https://github.com/ChainSafe/forest/issues/4701 !Filecoin.EthGetTransactionByBlockHashAndIndex !Filecoin.EthGetTransactionByBlockNumberAndIndex -# TODO: https://github.com/ChainSafe/forest/issues/5006 -!Filecoin.EthGetBlockReceipts diff --git a/src/rpc/methods/eth.rs b/src/rpc/methods/eth.rs index 26ac7cc6be2..976764075b3 100644 --- a/src/rpc/methods/eth.rs +++ b/src/rpc/methods/eth.rs @@ -1154,6 +1154,17 @@ async fn new_eth_tx_receipt( let mut events = vec![]; EthEventHandler::collect_events(ctx, &parent_ts, None, &mut events).await?; + + let current_block_hash = receipt.block_hash.clone(); + events.retain(|event| { + if let Ok(block_hash) = event.tipset_key.cid() { + let event_block_hash: EthHash = block_hash.into(); + event_block_hash == current_block_hash + } else { + false + } + }); + receipt.logs = eth_filter_logs_from_events(ctx, &events)?; Ok(receipt) From 2243af509c57daa47a77d07ac414f6ae0f3d8453 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 28 Nov 2024 18:28:01 +0530 Subject: [PATCH 2/6] chore: update CHANGELOG to include log filtering fix for block queries (#5006) --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd4d0775815..b3403e790d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,8 @@ ### Fixed +- [#5006](https://github.com/ChainSafe/forest/pull/5006) Filter logs for only the block being queried + - [#4959](https://github.com/ChainSafe/forest/pull/4959) Re-enable garbage collection after implementing a "persistent" storage for manifests. From 81dc82e86e4e5fb99af6787ed6199a00d61368be Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 28 Nov 2024 18:37:45 +0530 Subject: [PATCH 3/6] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3403e790d6..860bba238d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,8 @@ ### Fixed -- [#5006](https://github.com/ChainSafe/forest/pull/5006) Filter logs for only the block being queried +- [#5016](https://github.com/ChainSafe/forest/pull/5016) Filter logs for only the + block being queried. - [#4959](https://github.com/ChainSafe/forest/pull/4959) Re-enable garbage collection after implementing a "persistent" storage for manifests. From 3eb82daccfca5275844fee977ec952e0dbd5cd90 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 28 Nov 2024 18:40:26 +0530 Subject: [PATCH 4/6] chore: update CHANGELOG to correct formatting for log filtering entry (#5016) --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 860bba238d2..12725c34561 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,8 +44,8 @@ ### Fixed -- [#5016](https://github.com/ChainSafe/forest/pull/5016) Filter logs for only the - block being queried. +- [#5016](https://github.com/ChainSafe/forest/pull/5016) Filter logs for only + the block being queried. - [#4959](https://github.com/ChainSafe/forest/pull/4959) Re-enable garbage collection after implementing a "persistent" storage for manifests. From 2b25529e11d0c7dc7039928d3b8cc4e8f7e7f666 Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 28 Nov 2024 19:01:47 +0530 Subject: [PATCH 5/6] refactor: optimize event filtering by using a reference for current block hash in eth.rs --- src/rpc/methods/eth.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/methods/eth.rs b/src/rpc/methods/eth.rs index bd10e89d2fb..01314bf43a8 100644 --- a/src/rpc/methods/eth.rs +++ b/src/rpc/methods/eth.rs @@ -1155,11 +1155,11 @@ async fn new_eth_tx_receipt( let mut events = vec![]; EthEventHandler::collect_events(ctx, &parent_ts, None, &mut events).await?; - let current_block_hash = receipt.block_hash.clone(); + let current_block_hash = &receipt.block_hash; events.retain(|event| { if let Ok(block_hash) = event.tipset_key.cid() { let event_block_hash: EthHash = block_hash.into(); - event_block_hash == current_block_hash + event_block_hash == *current_block_hash } else { false } From 3dcec2289ef9722596fe7196e2bf46902628764c Mon Sep 17 00:00:00 2001 From: Viraj Bhartiya Date: Thu, 28 Nov 2024 19:28:43 +0530 Subject: [PATCH 6/6] refactor: improve event filtering by using a reference for current block hash in eth.rs --- src/rpc/methods/eth.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/methods/eth.rs b/src/rpc/methods/eth.rs index 01314bf43a8..2aa28804123 100644 --- a/src/rpc/methods/eth.rs +++ b/src/rpc/methods/eth.rs @@ -1159,7 +1159,7 @@ async fn new_eth_tx_receipt( events.retain(|event| { if let Ok(block_hash) = event.tipset_key.cid() { let event_block_hash: EthHash = block_hash.into(); - event_block_hash == *current_block_hash + &event_block_hash == current_block_hash } else { false }