@@ -65,8 +65,6 @@ pub struct BlockchainTree<DB, E> {
65
65
externals : TreeExternals < DB , E > ,
66
66
/// Tree configuration
67
67
config : BlockchainTreeConfig ,
68
- /// Prune modes.
69
- prune_modes : Option < PruneModes > ,
70
68
/// Broadcast channel for canon state changes notifications.
71
69
canon_state_notification_sender : CanonStateNotificationSender ,
72
70
/// Metrics for sync stages.
@@ -115,16 +113,19 @@ where
115
113
/// storage space efficiently. It's important to validate this configuration to ensure it does
116
114
/// not lead to unintended data loss.
117
115
pub fn new (
118
- externals : TreeExternals < DB , E > ,
116
+ mut externals : TreeExternals < DB , E > ,
119
117
config : BlockchainTreeConfig ,
120
- prune_modes : Option < PruneModes > ,
118
+ prune_modes : PruneModes ,
121
119
) -> ProviderResult < Self > {
122
120
let max_reorg_depth = config. max_reorg_depth ( ) as usize ;
123
121
// The size of the broadcast is twice the maximum reorg depth, because at maximum reorg
124
122
// depth at least N blocks must be sent at once.
125
123
let ( canon_state_notification_sender, _receiver) =
126
124
tokio:: sync:: broadcast:: channel ( max_reorg_depth * 2 ) ;
127
125
126
+ // Set the prune modes argument, on the provider
127
+ externals. provider_factory = externals. provider_factory . with_prune_modes ( prune_modes) ;
128
+
128
129
let last_canonical_hashes =
129
130
externals. fetch_latest_canonical_hashes ( config. num_of_canonical_hashes ( ) as usize ) ?;
130
131
@@ -138,7 +139,6 @@ where
138
139
config. max_unconnected_blocks ( ) ,
139
140
) ,
140
141
config,
141
- prune_modes,
142
142
canon_state_notification_sender,
143
143
sync_metrics_tx : None ,
144
144
metrics : Default :: default ( ) ,
@@ -1258,7 +1258,6 @@ where
1258
1258
state,
1259
1259
hashed_state,
1260
1260
trie_updates,
1261
- self . prune_modes . as_ref ( ) ,
1262
1261
)
1263
1262
. map_err ( |e| CanonicalError :: CanonicalCommit ( e. to_string ( ) ) ) ?;
1264
1263
@@ -1424,7 +1423,6 @@ mod tests {
1424
1423
provider
1425
1424
. insert_historical_block (
1426
1425
genesis. try_seal_with_senders ( ) . expect ( "invalid tx signature in genesis" ) ,
1427
- None ,
1428
1426
)
1429
1427
. unwrap ( ) ;
1430
1428
@@ -1545,7 +1543,6 @@ mod tests {
1545
1543
SealedBlock :: new ( chain_spec. sealed_genesis_header ( ) , Default :: default ( ) )
1546
1544
. try_seal_with_senders ( )
1547
1545
. unwrap ( ) ,
1548
- None ,
1549
1546
)
1550
1547
. unwrap ( ) ;
1551
1548
let account = Account { balance : initial_signer_balance, ..Default :: default ( ) } ;
@@ -1647,7 +1644,7 @@ mod tests {
1647
1644
let mut tree = BlockchainTree :: new (
1648
1645
TreeExternals :: new ( provider_factory, consensus, executor_provider) ,
1649
1646
BlockchainTreeConfig :: default ( ) ,
1650
- None ,
1647
+ PruneModes :: default ( ) ,
1651
1648
)
1652
1649
. expect ( "failed to create tree" ) ;
1653
1650
@@ -1727,7 +1724,8 @@ mod tests {
1727
1724
1728
1725
// make tree
1729
1726
let config = BlockchainTreeConfig :: new ( 1 , 2 , 3 , 2 ) ;
1730
- let mut tree = BlockchainTree :: new ( externals, config, None ) . expect ( "failed to create tree" ) ;
1727
+ let mut tree = BlockchainTree :: new ( externals, config, PruneModes :: default ( ) )
1728
+ . expect ( "failed to create tree" ) ;
1731
1729
// genesis block 10 is already canonical
1732
1730
tree. make_canonical ( B256 :: ZERO ) . unwrap ( ) ;
1733
1731
@@ -1803,7 +1801,8 @@ mod tests {
1803
1801
1804
1802
// make tree
1805
1803
let config = BlockchainTreeConfig :: new ( 1 , 2 , 3 , 2 ) ;
1806
- let mut tree = BlockchainTree :: new ( externals, config, None ) . expect ( "failed to create tree" ) ;
1804
+ let mut tree = BlockchainTree :: new ( externals, config, PruneModes :: default ( ) )
1805
+ . expect ( "failed to create tree" ) ;
1807
1806
// genesis block 10 is already canonical
1808
1807
tree. make_canonical ( B256 :: ZERO ) . unwrap ( ) ;
1809
1808
@@ -1888,7 +1887,8 @@ mod tests {
1888
1887
1889
1888
// make tree
1890
1889
let config = BlockchainTreeConfig :: new ( 1 , 2 , 3 , 2 ) ;
1891
- let mut tree = BlockchainTree :: new ( externals, config, None ) . expect ( "failed to create tree" ) ;
1890
+ let mut tree = BlockchainTree :: new ( externals, config, PruneModes :: default ( ) )
1891
+ . expect ( "failed to create tree" ) ;
1892
1892
// genesis block 10 is already canonical
1893
1893
tree. make_canonical ( B256 :: ZERO ) . unwrap ( ) ;
1894
1894
@@ -1986,7 +1986,8 @@ mod tests {
1986
1986
1987
1987
// make tree
1988
1988
let config = BlockchainTreeConfig :: new ( 1 , 2 , 3 , 2 ) ;
1989
- let mut tree = BlockchainTree :: new ( externals, config, None ) . expect ( "failed to create tree" ) ;
1989
+ let mut tree = BlockchainTree :: new ( externals, config, PruneModes :: default ( ) )
1990
+ . expect ( "failed to create tree" ) ;
1990
1991
1991
1992
let mut canon_notif = tree. subscribe_canon_state ( ) ;
1992
1993
// genesis block 10 is already canonical
@@ -2379,7 +2380,8 @@ mod tests {
2379
2380
2380
2381
// make tree
2381
2382
let config = BlockchainTreeConfig :: new ( 1 , 2 , 3 , 2 ) ;
2382
- let mut tree = BlockchainTree :: new ( externals, config, None ) . expect ( "failed to create tree" ) ;
2383
+ let mut tree = BlockchainTree :: new ( externals, config, PruneModes :: default ( ) )
2384
+ . expect ( "failed to create tree" ) ;
2383
2385
2384
2386
assert_eq ! (
2385
2387
tree. insert_block( block1. clone( ) , BlockValidationKind :: Exhaustive ) . unwrap( ) ,
@@ -2399,8 +2401,8 @@ mod tests {
2399
2401
tree. make_canonical ( block2. hash ( ) ) . unwrap ( ) ;
2400
2402
2401
2403
// restart
2402
- let mut tree =
2403
- BlockchainTree :: new ( cloned_externals_1 , config , None ) . expect ( "failed to create tree" ) ;
2404
+ let mut tree = BlockchainTree :: new ( cloned_externals_1 , config , PruneModes :: default ( ) )
2405
+ . expect ( "failed to create tree" ) ;
2404
2406
assert_eq ! ( tree. block_indices( ) . last_finalized_block( ) , 0 ) ;
2405
2407
2406
2408
let mut block1a = block1;
@@ -2416,8 +2418,8 @@ mod tests {
2416
2418
tree. finalize_block ( block1a. number ) . unwrap ( ) ;
2417
2419
2418
2420
// restart
2419
- let tree =
2420
- BlockchainTree :: new ( cloned_externals_2 , config , None ) . expect ( "failed to create tree" ) ;
2421
+ let tree = BlockchainTree :: new ( cloned_externals_2 , config , PruneModes :: default ( ) )
2422
+ . expect ( "failed to create tree" ) ;
2421
2423
2422
2424
assert_eq ! ( tree. block_indices( ) . last_finalized_block( ) , block1a. number) ;
2423
2425
}
0 commit comments