mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
feat(primitives): increase minimum pruning distance (#4750)
This commit is contained in:
@@ -71,7 +71,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_prune_target_block() {
|
||||
let tip = 1000;
|
||||
let tip = 20000;
|
||||
let min_blocks = MINIMUM_PRUNING_DISTANCE;
|
||||
let prune_part = PrunePart::Receipts;
|
||||
|
||||
@@ -91,7 +91,6 @@ mod tests {
|
||||
PruneMode::Before(tip - MINIMUM_PRUNING_DISTANCE - 1),
|
||||
Ok(Some(tip - MINIMUM_PRUNING_DISTANCE - 2)),
|
||||
),
|
||||
// MINIMUM_PRUNING_DISTANCE is 128
|
||||
(PruneMode::Before(tip - 1), Err(PrunePartError::Configuration(prune_part))),
|
||||
];
|
||||
|
||||
@@ -113,7 +112,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_should_prune() {
|
||||
let tip = 1000;
|
||||
let tip = 20000;
|
||||
let should_prune = true;
|
||||
|
||||
let tests = vec![
|
||||
|
||||
@@ -5,8 +5,12 @@ use crate::{
|
||||
use paste::paste;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Minimum distance necessary from the tip so blockchain tree can work correctly.
|
||||
pub const MINIMUM_PRUNING_DISTANCE: u64 = 128;
|
||||
/// Minimum distance from the tip necessary for the node to work correctly:
|
||||
/// 1. Minimum 2 epochs (32 blocks per epoch) required to handle any reorg according to the
|
||||
/// consensus protocol.
|
||||
/// 2. Another 10k blocks to have a room for maneuver in case when things go wrong and a manual
|
||||
/// unwind is required.
|
||||
pub const MINIMUM_PRUNING_DISTANCE: u64 = 32 * 2 + 10_000;
|
||||
|
||||
/// Pruning configuration for every part of the data that can be pruned.
|
||||
#[derive(Debug, Clone, Default, Deserialize, Eq, PartialEq, Serialize)]
|
||||
@@ -22,19 +26,19 @@ pub struct PruneModes {
|
||||
/// and offers improved performance.
|
||||
#[serde(
|
||||
skip_serializing_if = "Option::is_none",
|
||||
deserialize_with = "deserialize_opt_prune_mode_with_min_blocks::<64, _>"
|
||||
deserialize_with = "deserialize_opt_prune_mode_with_min_blocks::<MINIMUM_PRUNING_DISTANCE, _>"
|
||||
)]
|
||||
pub receipts: Option<PruneMode>,
|
||||
/// Account History pruning configuration.
|
||||
#[serde(
|
||||
skip_serializing_if = "Option::is_none",
|
||||
deserialize_with = "deserialize_opt_prune_mode_with_min_blocks::<64, _>"
|
||||
deserialize_with = "deserialize_opt_prune_mode_with_min_blocks::<MINIMUM_PRUNING_DISTANCE, _>"
|
||||
)]
|
||||
pub account_history: Option<PruneMode>,
|
||||
/// Storage History pruning configuration.
|
||||
#[serde(
|
||||
skip_serializing_if = "Option::is_none",
|
||||
deserialize_with = "deserialize_opt_prune_mode_with_min_blocks::<64, _>"
|
||||
deserialize_with = "deserialize_opt_prune_mode_with_min_blocks::<MINIMUM_PRUNING_DISTANCE, _>"
|
||||
)]
|
||||
pub storage_history: Option<PruneMode>,
|
||||
/// Receipts pruning configuration by retaining only those receipts that contain logs emitted
|
||||
@@ -101,8 +105,8 @@ impl PruneModes {
|
||||
impl_prune_parts!(
|
||||
(sender_recovery, SenderRecovery, None),
|
||||
(transaction_lookup, TransactionLookup, None),
|
||||
(receipts, Receipts, Some(64)),
|
||||
(account_history, AccountHistory, Some(64)),
|
||||
(storage_history, StorageHistory, Some(64))
|
||||
(receipts, Receipts, Some(MINIMUM_PRUNING_DISTANCE)),
|
||||
(account_history, AccountHistory, Some(MINIMUM_PRUNING_DISTANCE)),
|
||||
(storage_history, StorageHistory, Some(MINIMUM_PRUNING_DISTANCE))
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user