fix(rpc): less clones in logs filter (#7060)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Alexey Shekhirin
2024-03-10 14:18:48 +00:00
committed by GitHub
parent 84e970414e
commit 494361992d
4 changed files with 21 additions and 21 deletions

15
Cargo.lock generated
View File

@ -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",

View File

@ -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"
test-fuzz = "5"

View File

@ -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
}

View File

@ -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<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:?}")
}