@@ -15,17 +15,11 @@ use crate::{
15
15
block_header:: { BlockHeaderAPI , BlockHeaderDigest , BlockRef , VerifiedBlockHeader } ,
16
16
commit:: { Commit , CommitAPI , PendingSubDag , TrustedCommit , sort_sub_dag_blocks} ,
17
17
context:: Context ,
18
- dag_state:: { DagState , MAX_TRANSACTIONS_ACK_DEPTH } ,
18
+ dag_state:: DagState ,
19
19
leader_schedule:: LeaderSchedule ,
20
20
stake_aggregator:: { QuorumThreshold , StakeAggregator } ,
21
21
} ;
22
22
23
- /// The maximum depth of the linearizer, i.e. how many rounds back it will
24
- /// traverse the DAG from a committed leader block
25
- // TODO: https://github.com/iotaledger/iota/issues/8379
26
- // make it derivable from the protocol parameters
27
- pub ( crate ) const MAX_LINEARIZER_DEPTH : Round = 60 ;
28
-
29
23
/// The `StorageAPI` trait provides an interface for the block store and has
30
24
/// been mostly introduced for allowing to inject the test store in
31
25
/// `DagBuilder`.
@@ -92,6 +86,7 @@ impl Linearizer {
92
86
leader_block. clone ( ) ,
93
87
last_committed_rounds,
94
88
& dag_state_guard,
89
+ self . context . protocol_config . gc_depth ( ) ,
95
90
) ;
96
91
97
92
drop ( dag_state_guard) ;
@@ -152,6 +147,7 @@ impl Linearizer {
152
147
leader_block : VerifiedBlockHeader ,
153
148
last_committed_rounds : Vec < u32 > ,
154
149
dag_state : & impl BlockStoreAPI ,
150
+ max_linearizer_depth : u32 ,
155
151
) -> Vec < VerifiedBlockHeader > {
156
152
let leader_block_ref = leader_block. reference ( ) ;
157
153
let leader_round = leader_block. round ( ) ;
@@ -177,7 +173,7 @@ impl Linearizer {
177
173
!committed. contains ( ancestor)
178
174
&& last_committed_rounds[ ancestor. author ] < ancestor. round
179
175
&& ancestor. round
180
- >= leader_round. saturating_sub ( MAX_LINEARIZER_DEPTH )
176
+ >= leader_round. saturating_sub ( max_linearizer_depth )
181
177
} )
182
178
. collect :: < Vec < _ > > ( ) ,
183
179
)
@@ -260,8 +256,8 @@ impl Linearizer {
260
256
/// called for solid committed leader round since we rely on the ack
261
257
/// tracker in transaction synchronizer.
262
258
pub ( crate ) fn evict_old_acknowledgments ( & mut self , solid_commit_leader_round : Round ) {
263
- let lower_bound_round = solid_commit_leader_round
264
- . saturating_sub ( MAX_LINEARIZER_DEPTH + MAX_TRANSACTIONS_ACK_DEPTH ) ;
259
+ let lower_bound_round =
260
+ solid_commit_leader_round . saturating_sub ( self . context . protocol_config . gc_depth ( ) * 2 ) ;
265
261
let lower_bound = BlockRef :: new (
266
262
lower_bound_round + 1 ,
267
263
AuthorityIndex :: ZERO ,
@@ -281,7 +277,7 @@ impl Linearizer {
281
277
) -> Vec < BlockRef > {
282
278
let mut acknowledged_data = Vec :: new ( ) ;
283
279
for block_ref in acknowledgments {
284
- if block_ref. round < round. saturating_sub ( MAX_TRANSACTIONS_ACK_DEPTH ) {
280
+ if block_ref. round < round. saturating_sub ( self . context . protocol_config . gc_depth ( ) ) {
285
281
continue ; // Ignore acknowledgments for blocks that are too old
286
282
}
287
283
let votes_collector = self
@@ -735,10 +731,11 @@ mod tests {
735
731
) ) ;
736
732
let mut linearizer = Linearizer :: new ( context. clone ( ) , dag_state. clone ( ) , leader_schedule) ;
737
733
let num_rounds_to_evict = 20 ;
738
- // Populate fully connected test blocks for round 0 ~ MAX_LINEARIZER_DEPTH +
739
- // MAX_TRANSACTIONS_ACK_DEPTH + num_rounds_to_evict, authorities 0 ~ 3.
740
- let num_rounds: u32 =
741
- MAX_LINEARIZER_DEPTH + MAX_TRANSACTIONS_ACK_DEPTH + num_rounds_to_evict;
734
+ // Populate fully connected test blocks for round 0 ~ protocol_config.gc_depth()
735
+ // * 2
736
+ // + num_rounds_to_evict, authorities 0 ~
737
+ // 3.
738
+ let num_rounds: u32 = context. protocol_config . gc_depth ( ) * 2 + num_rounds_to_evict;
742
739
let mut dag_builder = DagBuilder :: new ( context. clone ( ) ) ;
743
740
dag_builder
744
741
. layers ( 1 ..=num_rounds)
0 commit comments