From 494361992dcf0df3b92f9abaac13bec1c2e7b8d0 Mon Sep 17 00:00:00 2001 From: Alexey Shekhirin Date: Sun, 10 Mar 2024 14:18:48 +0000 Subject: [PATCH] fix(rpc): less clones in logs filter (#7060) Co-authored-by: Matthias Seitz --- Cargo.lock | 15 ++++++++------- Cargo.toml | 16 ++++++++-------- crates/rpc/rpc/src/eth/logs_utils.rs | 5 ++--- examples/db-access.rs | 6 +++--- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5eb34817b..c20503f43 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -164,7 +164,7 @@ dependencies = [ [[package]] name = "alloy-eips" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=64d0352#64d035273241e89a19a4fb724cf7fc88c0f36777" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -174,7 +174,7 @@ dependencies = [ [[package]] name = "alloy-genesis" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=64d0352#64d035273241e89a19a4fb724cf7fc88c0f36777" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -196,13 +196,14 @@ dependencies = [ [[package]] name = "alloy-node-bindings" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=64d0352#64d035273241e89a19a4fb724cf7fc88c0f36777" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-genesis", "alloy-primitives", "k256", "serde_json", "tempfile", + "thiserror", ] [[package]] @@ -257,7 +258,7 @@ dependencies = [ [[package]] name = "alloy-rpc-engine-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=64d0352#64d035273241e89a19a4fb724cf7fc88c0f36777" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -272,7 +273,7 @@ dependencies = [ [[package]] name = "alloy-rpc-trace-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=64d0352#64d035273241e89a19a4fb724cf7fc88c0f36777" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rpc-types", @@ -283,7 +284,7 @@ dependencies = [ [[package]] name = "alloy-rpc-types" version = "0.1.0" -source = "git+https://github.com/alloy-rs/alloy?rev=64d0352#64d035273241e89a19a4fb724cf7fc88c0f36777" +source = "git+https://github.com/alloy-rs/alloy?rev=9ac2c90#9ac2c90d58a9994d4b61c879e33c6af2739a2b4f" dependencies = [ "alloy-primitives", "alloy-rlp", @@ -6833,7 +6834,7 @@ dependencies = [ [[package]] name = "revm-inspectors" version = "0.1.0" -source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=846dec1#846dec1db14ac42067e7a4bb6a973091cd7eb808" +source = "git+https://github.com/paradigmxyz/evm-inspectors?rev=1f935e7#1f935e71849466c297a64df0b162e6ffd48da25b" dependencies = [ "alloy-primitives", "alloy-rpc-trace-types", diff --git a/Cargo.toml b/Cargo.toml index cb94a8dfc..25315d5b0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"] } @@ -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 } @@ -287,4 +287,4 @@ proptest = "1.4" proptest-derive = "0.4" serial_test = "3" similar-asserts = "1.5.0" -test-fuzz = "5" \ No newline at end of file +test-fuzz = "5" diff --git a/crates/rpc/rpc/src/eth/logs_utils.rs b/crates/rpc/rpc/src/eth/logs_utils.rs index f2632d0c9..c3f37202a 100644 --- a/crates/rpc/rpc/src/eth/logs_utils.rs +++ b/crates/rpc/rpc/src/eth/logs_utils.rs @@ -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>( @@ -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 } diff --git a/examples/db-access.rs b/examples/db-access.rs index b20f021ab..41d462204 100644 --- a/examples/db-access.rs +++ b/examples/db-access.rs @@ -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 @@ -201,8 +200,9 @@ fn receipts_provider_example