Skip to content

Commit

Permalink
fix(rpc): less clones in logs filter (#7060)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
shekhirin and mattsse committed Mar 10, 2024
1 parent 84e9704 commit 4943619
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ reth-trie-parallel = { path = "crates/trie-parallel" }
# revm
revm = { version = "7.1.0", features = ["std", "secp256k1"], default-features = false }
revm-primitives = { version = "3.0.0", features = ["std"], default-features = false }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "846dec1" }
revm-inspectors = { git = "https://github.com/paradigmxyz/evm-inspectors", rev = "1f935e7" }

# eth
alloy-chains = { version = "0.1", feature = ["serde", "rlp", "arbitrary"] }
Expand All @@ -197,12 +197,12 @@ alloy-dyn-abi = "0.6"
alloy-sol-types = "0.6"
alloy-rlp = "0.3"
alloy-trie = "0.3"
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
alloy-rpc-trace-types = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }

# TODO: Remove
ethers-core = { version = "2.0.14", default-features = false }
Expand Down Expand Up @@ -287,4 +287,4 @@ proptest = "1.4"
proptest-derive = "0.4"
serial_test = "3"
similar-asserts = "1.5.0"
test-fuzz = "5"
test-fuzz = "5"
5 changes: 2 additions & 3 deletions crates/rpc/rpc/src/eth/logs_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use alloy_primitives::TxHash;
use reth_primitives::{BlockNumHash, ChainInfo, Receipt, U256};
use reth_provider::{BlockReader, ProviderError};
use reth_rpc_types::{FilteredParams, Log};
use reth_rpc_types_compat::log::from_primitive_log;

/// Returns all matching of a block's receipts when the transaction hashes are known.
pub(crate) fn matching_block_logs_with_tx_hashes<'a, I>(
Expand Down Expand Up @@ -119,8 +118,8 @@ pub(crate) fn log_matches_filter(
if params.filter.is_some() &&
(!params.filter_block_range(block.number) ||
!params.filter_block_hash(block.hash) ||
!params.filter_address(&from_primitive_log(log.clone())) ||
!params.filter_topics(&from_primitive_log(log.clone())))
!params.filter_address(&log.address) ||
!params.filter_topics(&log.topics))
{
return false
}
Expand Down
6 changes: 3 additions & 3 deletions examples/db-access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use reth_provider::{
StateProvider, TransactionsProvider,
};
use reth_rpc_types::{Filter, FilteredParams};
use reth_rpc_types_compat::log::from_primitive_log;
use std::path::Path;

// Providers are zero cost abstractions on top of an opened MDBX Transaction
Expand Down Expand Up @@ -201,8 +200,9 @@ fn receipts_provider_example<T: ReceiptProvider + TransactionsProvider + HeaderP
{
let receipts = provider.receipt(header_num)?.ok_or(eyre::eyre!("receipt not found"))?;
for log in &receipts.logs {
let log = from_primitive_log(log.clone());
if filter_params.filter_address(&log) && filter_params.filter_topics(&log) {
if filter_params.filter_address(&log.address) &&
filter_params.filter_topics(&log.topics)
{
// Do something with the log e.g. decode it.
println!("Matching log found! {log:?}")
}
Expand Down

0 comments on commit 4943619

Please sign in to comment.