chore(sdk): make BlockBatchRecord generic over receipt (#12449)

This commit is contained in:
Emilia Hane
2024-11-14 17:10:46 +01:00
committed by GitHub
parent 217d9f7c12
commit b1635fcba2
3 changed files with 156 additions and 105 deletions

217
Cargo.lock generated
View File

@ -146,14 +146,14 @@ dependencies = [
"alloy-transport",
"futures",
"futures-util",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
name = "alloy-dyn-abi"
version = "0.8.11"
version = "0.8.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85132f2698b520fab3f54beed55a44389f7006a7b557a0261e1e69439dcc1572"
checksum = "ef2364c782a245cf8725ea6dbfca5f530162702b5d685992ea03ce64529136cc"
dependencies = [
"alloy-json-abi",
"alloy-primitives",
@ -250,7 +250,7 @@ dependencies = [
"alloy-sol-types",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tracing",
]
@ -274,7 +274,7 @@ dependencies = [
"futures-utils-wasm",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -302,7 +302,7 @@ dependencies = [
"rand 0.8.5",
"serde_json",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tracing",
"url",
]
@ -373,7 +373,7 @@ dependencies = [
"schnellru",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
"url",
@ -494,7 +494,7 @@ dependencies = [
"alloy-rpc-types-engine",
"serde",
"serde_with",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -573,7 +573,7 @@ dependencies = [
"alloy-serde",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -611,7 +611,7 @@ dependencies = [
"auto_impl",
"elliptic-curve",
"k256",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -629,7 +629,7 @@ dependencies = [
"coins-bip39",
"k256",
"rand 0.8.5",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -714,7 +714,7 @@ dependencies = [
"futures-utils-wasm",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tower 0.5.1",
"tracing",
@ -1400,7 +1400,7 @@ dependencies = [
"static_assertions",
"tap",
"thin-vec",
"thiserror",
"thiserror 1.0.69",
"time",
]
@ -1625,7 +1625,7 @@ dependencies = [
"semver 1.0.23",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -1803,7 +1803,7 @@ dependencies = [
"k256",
"serde",
"sha2 0.10.8",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -1819,7 +1819,7 @@ dependencies = [
"pbkdf2",
"rand 0.8.5",
"sha2 0.10.8",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -1838,7 +1838,7 @@ dependencies = [
"serde",
"sha2 0.10.8",
"sha3",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -2627,7 +2627,7 @@ dependencies = [
"revm",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"walkdir",
]
@ -2782,7 +2782,7 @@ dependencies = [
"reth-node-ethereum",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -2871,7 +2871,7 @@ dependencies = [
"reth-tracing",
"reth-trie-db",
"serde",
"thiserror",
"thiserror 1.0.69",
"tokio",
]
@ -3142,7 +3142,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e182f7dbc2ef73d9ef67351c5fbbea084729c48362d3ce9dd44c28e32e277fe5"
dependencies = [
"libc",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -3455,7 +3455,7 @@ dependencies = [
"pin-project",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@ -4300,7 +4300,7 @@ dependencies = [
"combine",
"jni-sys",
"log",
"thiserror",
"thiserror 1.0.69",
"walkdir",
]
@ -4363,7 +4363,7 @@ dependencies = [
"rustls-pki-types",
"rustls-platform-verifier",
"soketto",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-rustls",
"tokio-util",
@ -4391,7 +4391,7 @@ dependencies = [
"rustc-hash 2.0.0",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -4416,7 +4416,7 @@ dependencies = [
"rustls-platform-verifier",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tower 0.4.13",
"tracing",
@ -4455,7 +4455,7 @@ dependencies = [
"serde",
"serde_json",
"soketto",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tokio-util",
@ -4472,7 +4472,7 @@ dependencies = [
"http",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -4627,7 +4627,7 @@ dependencies = [
"multihash",
"quick-protobuf",
"sha2 0.10.8",
"thiserror",
"thiserror 1.0.69",
"tracing",
"zeroize",
]
@ -4865,7 +4865,7 @@ dependencies = [
"metrics",
"metrics-util",
"quanta",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -4915,7 +4915,7 @@ dependencies = [
"reqwest",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -5573,7 +5573,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "879952a81a83930934cbf1786752d6dedc3b1f29e8f8fb2ad1d0a36f377cf442"
dependencies = [
"memchr",
"thiserror",
"thiserror 1.0.69",
"ucd-trie",
]
@ -5763,7 +5763,7 @@ dependencies = [
"smallvec",
"symbolic-demangle",
"tempfile",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -6011,9 +6011,9 @@ dependencies = [
[[package]]
name = "quinn"
version = "0.11.5"
version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684"
checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef"
dependencies = [
"bytes",
"pin-project-lite",
@ -6022,26 +6022,29 @@ dependencies = [
"rustc-hash 2.0.0",
"rustls",
"socket2",
"thiserror",
"thiserror 2.0.3",
"tokio",
"tracing",
]
[[package]]
name = "quinn-proto"
version = "0.11.8"
version = "0.11.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6"
checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d"
dependencies = [
"bytes",
"getrandom 0.2.15",
"rand 0.8.5",
"ring",
"rustc-hash 2.0.0",
"rustls",
"rustls-pki-types",
"slab",
"thiserror",
"thiserror 2.0.3",
"tinyvec",
"tracing",
"web-time",
]
[[package]]
@ -6227,7 +6230,7 @@ checksum = "ba009ff324d1fc1b900bd1fdb31564febe58a8ccc8a6fdbb93b543d33b13ca43"
dependencies = [
"getrandom 0.2.15",
"libredox",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -6491,7 +6494,7 @@ dependencies = [
"reth-tokio-util",
"reth-tracing",
"schnellru",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -6526,7 +6529,7 @@ dependencies = [
"reth-rpc-types-compat",
"reth-tracing",
"serde",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tower 0.4.13",
"tracing",
@ -6580,7 +6583,7 @@ dependencies = [
"reth-execution-errors",
"reth-primitives",
"reth-storage-errors",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -6735,7 +6738,7 @@ dependencies = [
"reth-fs-util",
"secp256k1",
"serde",
"thiserror",
"thiserror 1.0.69",
"tikv-jemallocator",
"tracy-client",
]
@ -6878,7 +6881,7 @@ dependencies = [
"sysinfo",
"tempfile",
"test-fuzz",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -6934,7 +6937,7 @@ dependencies = [
"reth-trie-db",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tracing",
]
@ -6976,7 +6979,7 @@ dependencies = [
"schnellru",
"secp256k1",
"serde",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -7001,7 +7004,7 @@ dependencies = [
"reth-network-peers",
"reth-tracing",
"secp256k1",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -7027,7 +7030,7 @@ dependencies = [
"secp256k1",
"serde",
"serde_with",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -7066,7 +7069,7 @@ dependencies = [
"reth-testing-utils",
"reth-tracing",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tokio-util",
@ -7132,7 +7135,7 @@ dependencies = [
"secp256k1",
"sha2 0.10.8",
"sha3",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tokio-util",
@ -7205,7 +7208,7 @@ dependencies = [
"reth-prune",
"reth-stages-api",
"reth-tasks",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
]
@ -7254,7 +7257,7 @@ dependencies = [
"reth-trie",
"reth-trie-parallel",
"revm-primitives",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -7301,7 +7304,7 @@ dependencies = [
"reth-execution-errors",
"reth-fs-util",
"reth-storage-errors",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -7332,7 +7335,7 @@ dependencies = [
"serde",
"snap",
"test-fuzz",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tokio-util",
@ -7360,7 +7363,7 @@ dependencies = [
"reth-primitives",
"reth-primitives-traits",
"serde",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -7619,7 +7622,7 @@ dependencies = [
"reth-transaction-pool",
"reth-trie-db",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
]
@ -7645,7 +7648,7 @@ version = "1.1.1"
dependencies = [
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -7687,7 +7690,7 @@ dependencies = [
"rand 0.8.5",
"reth-tracing",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tokio-util",
@ -7712,7 +7715,7 @@ dependencies = [
"reth-mdbx-sys",
"smallvec",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tracing",
]
@ -7751,7 +7754,7 @@ dependencies = [
"reqwest",
"reth-tracing",
"serde_with",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -7809,7 +7812,7 @@ dependencies = [
"serial_test",
"smallvec",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tokio-util",
@ -7834,7 +7837,7 @@ dependencies = [
"reth-network-types",
"reth-tokio-util",
"serde",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
]
@ -7872,7 +7875,7 @@ dependencies = [
"secp256k1",
"serde_json",
"serde_with",
"thiserror",
"thiserror 1.0.69",
"tokio",
"url",
]
@ -7903,7 +7906,7 @@ dependencies = [
"reth-fs-util",
"serde",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tracing",
"zstd",
]
@ -8036,7 +8039,7 @@ dependencies = [
"serde",
"shellexpand",
"strum",
"thiserror",
"thiserror 1.0.69",
"tokio",
"toml",
"tracing",
@ -8350,7 +8353,7 @@ dependencies = [
"reth-trie",
"revm",
"sha2 0.10.8",
"thiserror",
"thiserror 1.0.69",
"tracing",
]
@ -8401,7 +8404,7 @@ dependencies = [
"reth-transaction-pool",
"revm",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -8454,7 +8457,7 @@ dependencies = [
"reth-primitives",
"reth-transaction-pool",
"serde",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -8618,7 +8621,7 @@ dependencies = [
"reth-tokio-util",
"reth-tracing",
"rustc-hash 2.0.0",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -8639,7 +8642,7 @@ dependencies = [
"serde",
"serde_json",
"test-fuzz",
"thiserror",
"thiserror 1.0.69",
"toml",
]
@ -8653,6 +8656,7 @@ dependencies = [
"reth-ethereum-forks",
"reth-execution-errors",
"reth-primitives",
"reth-primitives-traits",
"reth-prune-types",
"reth-storage-api",
"reth-storage-errors",
@ -8724,7 +8728,7 @@ dependencies = [
"revm-primitives",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tower 0.4.13",
@ -8818,7 +8822,7 @@ dependencies = [
"reth-transaction-pool",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-util",
"tower 0.4.13",
@ -8858,7 +8862,7 @@ dependencies = [
"reth-tokio-util",
"reth-transaction-pool",
"serde",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -8941,7 +8945,7 @@ dependencies = [
"schnellru",
"serde",
"serde_json",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -9042,7 +9046,7 @@ dependencies = [
"reth-trie",
"reth-trie-db",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -9069,7 +9073,7 @@ dependencies = [
"reth-static-file-types",
"reth-testing-utils",
"reth-tokio-util",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -9169,7 +9173,7 @@ dependencies = [
"pin-project",
"rayon",
"reth-metrics",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
"tracing-futures",
@ -9251,7 +9255,7 @@ dependencies = [
"serde_json",
"smallvec",
"tempfile",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tokio-stream",
"tracing",
@ -9362,7 +9366,7 @@ dependencies = [
"reth-trie",
"reth-trie-common",
"reth-trie-db",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
]
@ -9384,7 +9388,7 @@ dependencies = [
"reth-trie",
"reth-trie-common",
"smallvec",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -9418,7 +9422,7 @@ dependencies = [
"colorchoice",
"revm",
"serde_json",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -9760,6 +9764,9 @@ name = "rustls-pki-types"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b"
dependencies = [
"web-time",
]
[[package]]
name = "rustls-platform-verifier"
@ -10023,7 +10030,7 @@ checksum = "c7715380eec75f029a4ef7de39a9200e0a63823176b759d055b613f5a87df6a6"
dependencies = [
"percent-encoding",
"serde",
"thiserror",
"thiserror 1.0.69",
]
[[package]]
@ -10259,7 +10266,7 @@ checksum = "adc4e5204eb1910f40f9cfa375f6f05b68c3abac4b6fd879c8ff5e7ae8a0a085"
dependencies = [
"num-bigint",
"num-traits",
"thiserror",
"thiserror 1.0.69",
"time",
]
@ -10601,7 +10608,16 @@ version = "1.0.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
dependencies = [
"thiserror-impl",
"thiserror-impl 1.0.69",
]
[[package]]
name = "thiserror"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa"
dependencies = [
"thiserror-impl 2.0.3",
]
[[package]]
@ -10615,6 +10631,17 @@ dependencies = [
"syn 2.0.87",
]
[[package]]
name = "thiserror-impl"
version = "2.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.87",
]
[[package]]
name = "thiserror-impl-no-std"
version = "2.0.2"
@ -10977,7 +11004,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf"
dependencies = [
"crossbeam-channel",
"thiserror",
"thiserror 1.0.69",
"time",
"tracing-subscriber",
]
@ -11128,7 +11155,7 @@ dependencies = [
"once_cell",
"rand 0.8.5",
"smallvec",
"thiserror",
"thiserror 1.0.69",
"tinyvec",
"tokio",
"tracing",
@ -11151,7 +11178,7 @@ dependencies = [
"resolv-conf",
"serde",
"smallvec",
"thiserror",
"thiserror 1.0.69",
"tokio",
"tracing",
"trust-dns-proto",
@ -11179,7 +11206,7 @@ dependencies = [
"rustls",
"rustls-pki-types",
"sha1",
"thiserror",
"thiserror 1.0.69",
"utf-8",
]
@ -11535,6 +11562,16 @@ dependencies = [
"wasm-bindgen",
]
[[package]]
name = "web-time"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[package]]
name = "webpki-roots"
version = "0.26.6"
@ -11910,7 +11947,7 @@ dependencies = [
"pharos",
"rustc_version 0.4.1",
"send_wrapper 0.6.0",
"thiserror",
"thiserror 1.0.69",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",

View File

@ -19,6 +19,7 @@ reth-execution-errors.workspace = true
reth-prune-types.workspace = true
reth-storage-api.workspace = true
reth-trie = { workspace = true, optional = true }
reth-primitives-traits.workspace = true
# alloy
alloy-eips.workspace = true
@ -41,13 +42,15 @@ std = [
"revm/std",
"alloy-eips/std",
"alloy-consensus/std",
"reth-primitives-traits/std",
]
test-utils = [
"dep:reth-trie",
"reth-primitives/test-utils",
"reth-trie?/test-utils",
"revm/test-utils",
"reth-prune-types/test-utils"
"reth-prune-types/test-utils",
"reth-primitives-traits/test-utils",
]
serde = [
"revm/serde",

View File

@ -1,10 +1,12 @@
//! Helper for handling execution of multiple blocks.
use alloc::vec::Vec;
use alloy_eips::eip7685::Requests;
use alloy_primitives::{map::HashSet, Address, BlockNumber};
use reth_execution_errors::{BlockExecutionError, InternalBlockExecutionError};
use reth_primitives::{Receipt, Receipts};
use reth_primitives::Receipts;
use reth_primitives_traits::Receipt;
use reth_prune_types::{PruneMode, PruneModes, PruneSegmentError, MINIMUM_PRUNING_DISTANCE};
use revm::db::states::bundle_state::BundleRetention;
@ -13,7 +15,7 @@ use revm::db::states::bundle_state::BundleRetention;
/// - pruning receipts according to the pruning configuration.
/// - batch range if known
#[derive(Debug, Default)]
pub struct BlockBatchRecord {
pub struct BlockBatchRecord<T = reth_primitives::Receipt> {
/// Pruning configuration.
prune_modes: PruneModes,
/// The collection of receipts.
@ -21,7 +23,7 @@ pub struct BlockBatchRecord {
/// The inner vector stores receipts ordered by transaction number.
///
/// If receipt is None it means it is pruned.
receipts: Receipts,
receipts: Receipts<T>,
/// The collection of EIP-7685 requests.
/// Outer vector stores requests for each block sequentially.
/// The inner vector stores requests ordered by transaction number.
@ -41,9 +43,12 @@ pub struct BlockBatchRecord {
tip: Option<BlockNumber>,
}
impl BlockBatchRecord {
impl<T> BlockBatchRecord<T> {
/// Create a new receipts recorder with the given pruning configuration.
pub fn new(prune_modes: PruneModes) -> Self {
pub fn new(prune_modes: PruneModes) -> Self
where
T: Default,
{
Self { prune_modes, ..Default::default() }
}
@ -73,12 +78,15 @@ impl BlockBatchRecord {
}
/// Returns the recorded receipts.
pub const fn receipts(&self) -> &Receipts {
pub const fn receipts(&self) -> &Receipts<T> {
&self.receipts
}
/// Returns all recorded receipts.
pub fn take_receipts(&mut self) -> Receipts {
pub fn take_receipts(&mut self) -> Receipts<T>
where
T: Default,
{
core::mem::take(&mut self.receipts)
}
@ -111,7 +119,10 @@ impl BlockBatchRecord {
}
/// Save receipts to the executor.
pub fn save_receipts(&mut self, receipts: Vec<Receipt>) -> Result<(), BlockExecutionError> {
pub fn save_receipts(&mut self, receipts: Vec<T>) -> Result<(), BlockExecutionError>
where
T: Receipt,
{
let mut receipts = receipts.into_iter().map(Some).collect();
// Prune receipts if necessary.
self.prune_receipts(&mut receipts).map_err(InternalBlockExecutionError::from)?;
@ -121,10 +132,10 @@ impl BlockBatchRecord {
}
/// Prune receipts according to the pruning configuration.
fn prune_receipts(
&mut self,
receipts: &mut Vec<Option<Receipt>>,
) -> Result<(), PruneSegmentError> {
fn prune_receipts(&mut self, receipts: &mut Vec<Option<T>>) -> Result<(), PruneSegmentError>
where
T: Receipt,
{
let (Some(first_block), Some(tip)) = (self.first_block, self.tip) else { return Ok(()) };
let block_number = first_block + self.receipts.len() as u64;
@ -161,7 +172,7 @@ impl BlockBatchRecord {
// If there is an address_filter, it does not contain any of the
// contract addresses, then remove this receipt.
let inner_receipt = receipt.as_ref().expect("receipts have not been pruned");
if !inner_receipt.logs.iter().any(|log| filter.contains(&log.address)) {
if !inner_receipt.logs().iter().any(|log| filter.contains(&log.address)) {
receipt.take();
}
}
@ -186,7 +197,7 @@ mod tests {
#[test]
fn test_save_receipts_empty() {
let mut recorder = BlockBatchRecord::default();
let mut recorder: BlockBatchRecord = BlockBatchRecord::default();
// Create an empty vector of receipts
let receipts = vec![];