Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: filter logs for only the block being queried #5016

Closed
wants to merge 7 commits into from
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@

### Fixed

- [#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.

Expand Down
2 changes: 0 additions & 2 deletions scripts/tests/api_compare/filter-list
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions scripts/tests/api_compare/filter-list-offline
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 11 additions & 0 deletions src/rpc/methods/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,17 @@ async fn new_eth_tx_receipt<DB: Blockstore + Send + Sync + 'static>(

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
}
});
virajbhartiya marked this conversation as resolved.
Show resolved Hide resolved

receipt.logs = eth_filter_logs_from_events(ctx, &events)?;

Ok(receipt)
Expand Down
Loading