mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(rpc): less clones in logs filter (#7060)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
15
Cargo.lock
generated
15
Cargo.lock
generated
@ -164,7 +164,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "alloy-eips"
|
name = "alloy-eips"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rlp",
|
"alloy-rlp",
|
||||||
@ -174,7 +174,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "alloy-genesis"
|
name = "alloy-genesis"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rpc-types",
|
"alloy-rpc-types",
|
||||||
@ -196,13 +196,14 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "alloy-node-bindings"
|
name = "alloy-node-bindings"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"alloy-genesis",
|
"alloy-genesis",
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"k256",
|
"k256",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -257,7 +258,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "alloy-rpc-engine-types"
|
name = "alloy-rpc-engine-types"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rlp",
|
"alloy-rlp",
|
||||||
@ -272,7 +273,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "alloy-rpc-trace-types"
|
name = "alloy-rpc-trace-types"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rpc-types",
|
"alloy-rpc-types",
|
||||||
@ -283,7 +284,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "alloy-rpc-types"
|
name = "alloy-rpc-types"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rlp",
|
"alloy-rlp",
|
||||||
@ -6833,7 +6834,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "revm-inspectors"
|
name = "revm-inspectors"
|
||||||
version = "0.1.0"
|
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 = [
|
dependencies = [
|
||||||
"alloy-primitives",
|
"alloy-primitives",
|
||||||
"alloy-rpc-trace-types",
|
"alloy-rpc-trace-types",
|
||||||
|
|||||||
16
Cargo.toml
16
Cargo.toml
@ -188,7 +188,7 @@ reth-trie-parallel = { path = "crates/trie-parallel" }
|
|||||||
# revm
|
# revm
|
||||||
revm = { version = "7.1.0", features = ["std", "secp256k1"], default-features = false }
|
revm = { version = "7.1.0", features = ["std", "secp256k1"], default-features = false }
|
||||||
revm-primitives = { version = "3.0.0", features = ["std"], 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
|
# eth
|
||||||
alloy-chains = { version = "0.1", feature = ["serde", "rlp", "arbitrary"] }
|
alloy-chains = { version = "0.1", feature = ["serde", "rlp", "arbitrary"] }
|
||||||
@ -197,12 +197,12 @@ alloy-dyn-abi = "0.6"
|
|||||||
alloy-sol-types = "0.6"
|
alloy-sol-types = "0.6"
|
||||||
alloy-rlp = "0.3"
|
alloy-rlp = "0.3"
|
||||||
alloy-trie = "0.3"
|
alloy-trie = "0.3"
|
||||||
alloy-rpc-types = { 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 = "64d0352" }
|
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 = "64d0352" }
|
alloy-rpc-engine-types = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
|
||||||
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
|
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
|
||||||
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
|
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
|
||||||
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "64d0352" }
|
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "9ac2c90" }
|
||||||
|
|
||||||
# TODO: Remove
|
# TODO: Remove
|
||||||
ethers-core = { version = "2.0.14", default-features = false }
|
ethers-core = { version = "2.0.14", default-features = false }
|
||||||
@ -287,4 +287,4 @@ proptest = "1.4"
|
|||||||
proptest-derive = "0.4"
|
proptest-derive = "0.4"
|
||||||
serial_test = "3"
|
serial_test = "3"
|
||||||
similar-asserts = "1.5.0"
|
similar-asserts = "1.5.0"
|
||||||
test-fuzz = "5"
|
test-fuzz = "5"
|
||||||
|
|||||||
@ -3,7 +3,6 @@ use alloy_primitives::TxHash;
|
|||||||
use reth_primitives::{BlockNumHash, ChainInfo, Receipt, U256};
|
use reth_primitives::{BlockNumHash, ChainInfo, Receipt, U256};
|
||||||
use reth_provider::{BlockReader, ProviderError};
|
use reth_provider::{BlockReader, ProviderError};
|
||||||
use reth_rpc_types::{FilteredParams, Log};
|
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.
|
/// 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>(
|
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() &&
|
if params.filter.is_some() &&
|
||||||
(!params.filter_block_range(block.number) ||
|
(!params.filter_block_range(block.number) ||
|
||||||
!params.filter_block_hash(block.hash) ||
|
!params.filter_block_hash(block.hash) ||
|
||||||
!params.filter_address(&from_primitive_log(log.clone())) ||
|
!params.filter_address(&log.address) ||
|
||||||
!params.filter_topics(&from_primitive_log(log.clone())))
|
!params.filter_topics(&log.topics))
|
||||||
{
|
{
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ use reth_provider::{
|
|||||||
StateProvider, TransactionsProvider,
|
StateProvider, TransactionsProvider,
|
||||||
};
|
};
|
||||||
use reth_rpc_types::{Filter, FilteredParams};
|
use reth_rpc_types::{Filter, FilteredParams};
|
||||||
use reth_rpc_types_compat::log::from_primitive_log;
|
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
// Providers are zero cost abstractions on top of an opened MDBX Transaction
|
// 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"))?;
|
let receipts = provider.receipt(header_num)?.ok_or(eyre::eyre!("receipt not found"))?;
|
||||||
for log in &receipts.logs {
|
for log in &receipts.logs {
|
||||||
let log = from_primitive_log(log.clone());
|
if filter_params.filter_address(&log.address) &&
|
||||||
if filter_params.filter_address(&log) && filter_params.filter_topics(&log) {
|
filter_params.filter_topics(&log.topics)
|
||||||
|
{
|
||||||
// Do something with the log e.g. decode it.
|
// Do something with the log e.g. decode it.
|
||||||
println!("Matching log found! {log:?}")
|
println!("Matching log found! {log:?}")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user