Skip to content

Commit 6f04667

Browse files
committed
proper grace period
1 parent 7cc7fa2 commit 6f04667

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

consensus/src/processes/pruning.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<
8787

8888
let prev_finality_depth = self.finality_depth.before();
8989
//
90-
let grace_period = ((self.pruning_depth.before() as f64 / prev_finality_depth as f64).ceil() as u64) * prev_finality_depth;
90+
let grace_period = ((self.pruning_depth.after() as f64 / prev_finality_depth as f64) as u64) * prev_finality_depth;
9191
if selected_parent_daa_score <= self.finality_depth.activation().daa_score() + grace_period {
9292
finality_depth = prev_finality_depth;
9393
}
@@ -220,13 +220,13 @@ impl<
220220
// TODO: remove. Some range I want to look at
221221
let should_log = ghostdag_data.blue_score >= 900 - 50 && ghostdag_data.blue_score <= 1000 + 50;
222222

223+
// What are the pruning points pointed to by the chain blocks?
224+
let mut bhs = BlockHashSet::default();
225+
223226
// ATTEMPT TO FIND Q: Find the would be pruning points that may never be pointed at and therefore their ancestry gets skipped
224227
if selected_parent_daa_score > self.finality_depth.activation().daa_score()
225228
&& selected_parent_daa_score <= self.finality_depth.activation().daa_score() + 10
226229
{
227-
// What are the pruning points pointed to by the chain blocks?
228-
let mut bhs = BlockHashSet::default();
229-
230230
// Gist: https://gist.github.com/coderofstuff/2f1eda63f6a7e395c5b423464d57a3f5
231231
// Find out what Q(1) and Q(2) are. They would be the first chain blocks that are of different finality score from P(A)
232232
// whose pruning points are P(-2) and P(1)
@@ -275,10 +275,15 @@ impl<
275275
// Q8.pp == ~P5
276276
//
277277
// case 2:
278-
// |--------------- F1 --------------|--------------- F1 --------------|--------------- F1 --------------|--------------- F1 --------------|--------------- F1 --------------|
279-
// |------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|
280-
// P0 --------------P1 --------------P2 --------------P3 --------------P4 --------------P5 -------- A ---Q6 --------------Q7 --------------Q8 --------------Q9
278+
// |--------------- F1 --------------|--------------- F1 --------------|--------------- F1 --------------|--------------- F1 --------------|--------------- F1 --------------|--------------- F1 --------------|
279+
// |------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|
280+
// P0 --------------P1 --------------P2 --------------P3 --------------P4 --------------P5 -------- A ---Q6 --------------Q7 --------------Q8 --------------Q9 --------------Q10 -------------Q11
281281
// | -------------- prev_pruning_depth -------------|
282+
// | -------------- prev_pruning_depth -------------|
283+
// | -------------- prev_pruning_depth -------------|
284+
// | ---------------------------------- new_pruning_depth ------------------------------|
285+
// | ---------------------------------- new_pruning_depth ------------------------------|
286+
// | ---------------------------------- new_pruning_depth ------------------------------|
282287
// P4.pp == ~P1
283288
// P5.pp == ~P2
284289
// Q6.pp == ~P3
@@ -289,7 +294,7 @@ impl<
289294
// env: TN10 (incomplete)
290295
// |---------------------------------------- F1 ----------------------------------------|---------------------------------------- F1 ----------------------------------------|
291296
// |------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|------ F0 ------|
292-
// P1 --------------P2 --------------P3 --------------P4 --------------P5 -------- A ---Q6 --------------Q7 --------------Q8 --------------Q9
297+
// P1 --------------P2 --------------P3 --------------P4 --------------P5 -------- A ---Q6 --------------Q7 --------------Q8 --------------Q9 --------------Q10 -------------Q11
293298
// | -------------- prev_pruning_depth -------------|
294299
// P4.pp == ~P1
295300
// P5.pp == ~P2
@@ -299,7 +304,7 @@ impl<
299304

300305
let prev_finality_depth = self.finality_depth.before();
301306
//
302-
let grace_period = ((self.pruning_depth.before() as f64 / prev_finality_depth as f64).ceil() as u64) * prev_finality_depth;
307+
let grace_period = ((self.pruning_depth.after() as f64 / prev_finality_depth as f64) as u64) * prev_finality_depth;
303308
if selected_parent_daa_score <= self.finality_depth.activation().daa_score() + grace_period {
304309
finality_depth = prev_finality_depth;
305310
}

0 commit comments

Comments
 (0)