@@ -38,7 +38,7 @@ pub enum HistoryType {
3838
3939/// Default number of blocks to retain for merkle changesets.
4040/// This is used by both the `MerkleChangeSets` stage and the pruner segment.
41- pub const MERKLE_CHANGESETS_RETENTION_BLOCKS : u64 = 64 ;
41+ pub const MERKLE_CHANGESETS_RETENTION_BLOCKS : u64 = 128 ;
4242
4343/// Default pruning mode for merkle changesets
4444const fn default_merkle_changesets_mode ( ) -> PruneMode {
@@ -95,13 +95,7 @@ pub struct PruneModes {
9595 pub bodies_history : Option < PruneMode > ,
9696 /// Merkle Changesets pruning configuration for `AccountsTrieChangeSets` and
9797 /// `StoragesTrieChangeSets`.
98- #[ cfg_attr(
99- any( test, feature = "serde" ) ,
100- serde(
101- default = "default_merkle_changesets_mode" ,
102- deserialize_with = "deserialize_prune_mode_with_min_blocks::<MERKLE_CHANGESETS_RETENTION_BLOCKS, _>"
103- )
104- ) ]
98+ #[ cfg_attr( any( test, feature = "serde" ) , serde( default = "default_merkle_changesets_mode" ) ) ]
10599 pub merkle_changesets : PruneMode ,
106100 /// Receipts pruning configuration by retaining only those receipts that contain logs emitted
107101 /// by the specified addresses, discarding others. This setting is overridden by `receipts`.
@@ -155,14 +149,15 @@ impl PruneModes {
155149 /// Returns `true` if any migration was performed.
156150 ///
157151 /// Currently migrates:
158- /// - `merkle_changesets`: `Distance(10064)` -> `Distance(64)`
159- pub fn migrate ( & mut self ) -> bool {
160- if self . merkle_changesets == PruneMode :: Distance ( MINIMUM_PRUNING_DISTANCE ) {
152+ /// - `merkle_changesets`: `Distance(n)` where `n < 128` or `n == 10064` -> `Distance(128)`
153+ pub const fn migrate ( & mut self ) -> bool {
154+ if let PruneMode :: Distance ( d) = self . merkle_changesets &&
155+ ( d < MERKLE_CHANGESETS_RETENTION_BLOCKS || d == MINIMUM_PRUNING_DISTANCE )
156+ {
161157 self . merkle_changesets = PruneMode :: Distance ( MERKLE_CHANGESETS_RETENTION_BLOCKS ) ;
162- true
163- } else {
164- false
158+ return true ;
165159 }
160+ false
166161 }
167162
168163 /// Returns an error if we can't unwind to the targeted block because the target block is
@@ -214,28 +209,6 @@ impl PruneModes {
214209 }
215210}
216211
217- /// Deserializes [`PruneMode`] and validates that the value is not less than the const
218- /// generic parameter `MIN_BLOCKS`. This parameter represents the number of blocks that needs to be
219- /// left in database after the pruning.
220- ///
221- /// 1. For [`PruneMode::Full`], it fails if `MIN_BLOCKS > 0`.
222- /// 2. For [`PruneMode::Distance`], it fails if `distance < MIN_BLOCKS + 1`. `+ 1` is needed because
223- /// `PruneMode::Distance(0)` means that we leave zero blocks from the latest, meaning we have one
224- /// block in the database.
225- #[ cfg( any( test, feature = "serde" ) ) ]
226- fn deserialize_prune_mode_with_min_blocks <
227- ' de ,
228- const MIN_BLOCKS : u64 ,
229- D : serde:: Deserializer < ' de > ,
230- > (
231- deserializer : D ,
232- ) -> Result < PruneMode , D :: Error > {
233- use serde:: Deserialize ;
234- let prune_mode = PruneMode :: deserialize ( deserializer) ?;
235- serde_deserialize_validate :: < MIN_BLOCKS , D > ( & prune_mode) ?;
236- Ok ( prune_mode)
237- }
238-
239212/// Deserializes [`Option<PruneMode>`] and validates that the value is not less than the const
240213/// generic parameter `MIN_BLOCKS`. This parameter represents the number of blocks that needs to be
241214/// left in database after the pruning.
0 commit comments