Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions crates/node/core/src/args/pruning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,11 @@ impl PruningArgs {
receipts: Some(PruneMode::Distance(MINIMUM_PRUNING_DISTANCE)),
account_history: Some(PruneMode::Distance(MINIMUM_PRUNING_DISTANCE)),
storage_history: Some(PruneMode::Distance(MINIMUM_PRUNING_DISTANCE)),
// TODO: set default to pre-merge block if available
bodies_history: None,
// Set default to pre-merge block if available
bodies_history: chain_spec
.ethereum_fork_activation(EthereumHardfork::Paris)
.block_number()
.map(PruneMode::Before),
receipts_log_filter: Default::default(),
},
}
Expand Down Expand Up @@ -296,6 +299,8 @@ mod tests {
use super::*;
use alloy_primitives::address;
use clap::Parser;
use reth_chainspec::ChainSpec;
use reth_ethereum_forks::ForkCondition;

/// A helper type to parse Args more easily
#[derive(Parser)]
Expand Down Expand Up @@ -384,4 +389,37 @@ mod tests {
);
assert!(matches!(result, Err(ReceiptsLogError::InvalidBlockNumber(_))));
}

#[test]
fn test_full_node_bodies_history_pre_merge() {
// Mainnet Paris block activated at block 15537394
let mut chain_spec = ChainSpec::default();
chain_spec.hardforks.insert(EthereumHardfork::Paris, ForkCondition::Block(15537394));

let args = CommandParser::<PruningArgs>::parse_from(["reth", "--full"]).args;
let config = args.prune_config(&chain_spec).expect("should create config");

assert!(config.segments.bodies_history.is_some());
if let Some(PruneMode::Before(block_number)) = config.segments.bodies_history {
assert_eq!(block_number, 15537394);
} else {
panic!("bodies_history should be PruneMode::Before with Paris block number");
}

// Without --full flag should not set bodies_history by default
let args = CommandParser::<PruningArgs>::parse_from(["reth"]).args;
let config = args.prune_config(&chain_spec).expect("should create config");
assert!(config.segments.bodies_history.is_none());
}

#[test]
fn test_full_node_bodies_history_no_pre_merge() {
// Default without Paris fork activated
let chain_spec = ChainSpec::default();

let args = CommandParser::<PruningArgs>::parse_from(["reth", "--full"]).args;
let config = args.prune_config(&chain_spec).expect("should create config");

assert!(config.segments.bodies_history.is_none());
}
}