mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(book): [prune] config section (#4328)
This commit is contained in:
@ -81,7 +81,7 @@ pub use net::{
|
||||
};
|
||||
pub use peer::{PeerId, WithPeerId};
|
||||
pub use prune::{
|
||||
ContractLogsPruneConfig, PruneCheckpoint, PruneMode, PruneModes, PrunePart, PrunePartError,
|
||||
PruneCheckpoint, PruneMode, PruneModes, PrunePart, PrunePartError, ReceiptsLogPruneConfig,
|
||||
MINIMUM_PRUNING_DISTANCE,
|
||||
};
|
||||
pub use receipt::{Receipt, ReceiptWithBloom, ReceiptWithBloomRef};
|
||||
|
||||
@ -13,9 +13,9 @@ pub use target::{PruneModes, MINIMUM_PRUNING_DISTANCE};
|
||||
|
||||
/// Configuration for pruning receipts not associated with logs emitted by the specified contracts.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, Serialize, Deserialize)]
|
||||
pub struct ContractLogsPruneConfig(pub BTreeMap<Address, PruneMode>);
|
||||
pub struct ReceiptsLogPruneConfig(pub BTreeMap<Address, PruneMode>);
|
||||
|
||||
impl ContractLogsPruneConfig {
|
||||
impl ReceiptsLogPruneConfig {
|
||||
/// Checks if the configuration is empty
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.0.is_empty()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
prune::PrunePartError, serde_helper::deserialize_opt_prune_mode_with_min_blocks, BlockNumber,
|
||||
ContractLogsPruneConfig, PruneMode, PrunePart,
|
||||
PruneMode, PrunePart, ReceiptsLogPruneConfig,
|
||||
};
|
||||
use paste::paste;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@ -23,8 +23,8 @@ pub struct PruneModes {
|
||||
/// Transaction Lookup pruning configuration.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub transaction_lookup: Option<PruneMode>,
|
||||
/// Configuration for pruning of receipts. This setting overrides
|
||||
/// `PruneModes::contract_logs_filter` and offers improved performance.
|
||||
/// Receipts pruning configuration. This setting overrides `receipts_log_filter`
|
||||
/// and offers improved performance.
|
||||
#[serde(
|
||||
skip_serializing_if = "Option::is_none",
|
||||
deserialize_with = "deserialize_opt_prune_mode_with_min_blocks::<64, _>"
|
||||
@ -42,12 +42,12 @@ pub struct PruneModes {
|
||||
deserialize_with = "deserialize_opt_prune_mode_with_min_blocks::<64, _>"
|
||||
)]
|
||||
pub storage_history: Option<PruneMode>,
|
||||
/// Retains only those receipts that contain logs emitted by the specified addresses,
|
||||
/// discarding all others. Note that this setting is overridden by `PruneModes::receipts`.
|
||||
/// Receipts pruning configuration by retaining only those receipts that contain logs emitted
|
||||
/// by the specified addresses, discarding others. This setting is overridden by `receipts`.
|
||||
///
|
||||
/// The [`BlockNumber`] represents the starting block from which point onwards the receipts are
|
||||
/// preserved.
|
||||
pub contract_logs_filter: ContractLogsPruneConfig,
|
||||
pub receipts_log_filter: ReceiptsLogPruneConfig,
|
||||
}
|
||||
|
||||
macro_rules! impl_prune_parts {
|
||||
@ -90,7 +90,7 @@ macro_rules! impl_prune_parts {
|
||||
$(
|
||||
$part: Some(PruneMode::Full),
|
||||
)+
|
||||
contract_logs_filter: Default::default()
|
||||
receipts_log_filter: Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ impl<DB: Database> Pruner<DB> {
|
||||
.record(part_start.elapsed())
|
||||
}
|
||||
|
||||
if !self.modes.contract_logs_filter.is_empty() {
|
||||
if !self.modes.receipts_log_filter.is_empty() {
|
||||
let part_start = Instant::now();
|
||||
self.prune_receipts_by_logs(&provider, tip_block_number)?;
|
||||
self.metrics
|
||||
@ -305,7 +305,7 @@ impl<DB: Database> Pruner<DB> {
|
||||
.map(|checkpoint| checkpoint.block_number);
|
||||
|
||||
let address_filter =
|
||||
self.modes.contract_logs_filter.group_by_block(tip_block_number, pruned)?;
|
||||
self.modes.receipts_log_filter.group_by_block(tip_block_number, pruned)?;
|
||||
|
||||
// Splits all transactions in different block ranges. Each block range will have its own
|
||||
// filter address list and will check it while going through the table
|
||||
@ -411,7 +411,7 @@ impl<DB: Database> Pruner<DB> {
|
||||
// one using `get_next_tx_num_range_from_checkpoint`.
|
||||
let checkpoint_block = self
|
||||
.modes
|
||||
.contract_logs_filter
|
||||
.receipts_log_filter
|
||||
.lowest_block_with_distance(tip_block_number, pruned)?
|
||||
.unwrap_or(to_block);
|
||||
|
||||
|
||||
@ -661,7 +661,7 @@ impl PostState {
|
||||
|
||||
let contract_log_pruner = self
|
||||
.prune_modes
|
||||
.contract_logs_filter
|
||||
.receipts_log_filter
|
||||
.group_by_block(tip, None)
|
||||
.map_err(|e| Error::Custom(e.to_string()))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user