From a5a9f5c2e700bf809f61472c27dab536ac7e1984 Mon Sep 17 00:00:00 2001 From: John Tromp Date: Sun, 13 Jan 2019 12:25:32 +0100 Subject: [PATCH 1/2] add new simpler ar scaling method --- sim/consensus.py | 12 +++++++++++- simulation.py | 6 +++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/sim/consensus.py b/sim/consensus.py index 83a0d7b..69d22b5 100644 --- a/sim/consensus.py +++ b/sim/consensus.py @@ -6,7 +6,8 @@ BASE_EDGE_BITS = 24 DIFF_DAMP_FACTOR = 3 -AR_DAMP_FACTOR = 13 +AR_DAMP_FACTOR = 3 +NEW_AR_DAMP = 0 CLAMP_FACTOR = 2 BLOCK_TIME_WINDOW = DIFFICULTY_ADJUST_WINDOW * 60 @@ -81,6 +82,15 @@ def clamp(actual: int, goal: int, clamp_factor: int) -> int: def secondary_pow_scaling(height: int, diff_data: List[HeaderInfo]) -> int: + if NEW_AR_DAMP > 0: + last = diff_data[-1] + scale = last.scaling + target_pct = secondary_pow_ratio(height) + if last.is_secondary: + scale -= (100 - target_pct) / NEW_AR_DAMP + else: + scale += target_pct / NEW_AR_DAMP + return max(AR_DAMP_FACTOR, scale) diff_iter = iter(diff_data) next(diff_iter) secondary_count = 0 diff --git a/simulation.py b/simulation.py index a96984c..1d5e039 100644 --- a/simulation.py +++ b/simulation.py @@ -10,14 +10,14 @@ def primary_graph_rate(edge_bits: int, height: int): if edge_bits == 30: - return 0 if height < 50000 else 0 + return 0 if height < 40000 else 0 if edge_bits == 31: - return 1 if height < 50000 else 2 + return 1 if height < 40000 else 2 return 0 def secondary_graph_rate(height: int): - return 36 if height < 50000 else 18 + return 36 if height < 40000 else 36 def test_difficulty_adjustment(): From 85f45a1864df8cb29b81695ad792a241a66d0571 Mon Sep 17 00:00:00 2001 From: John Tromp Date: Sun, 13 Jan 2019 12:28:35 +0100 Subject: [PATCH 2/2] undo unintentional change --- sim/consensus.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim/consensus.py b/sim/consensus.py index 69d22b5..1db29b9 100644 --- a/sim/consensus.py +++ b/sim/consensus.py @@ -6,7 +6,7 @@ BASE_EDGE_BITS = 24 DIFF_DAMP_FACTOR = 3 -AR_DAMP_FACTOR = 3 +AR_DAMP_FACTOR = 13 NEW_AR_DAMP = 0 CLAMP_FACTOR = 2 BLOCK_TIME_WINDOW = DIFFICULTY_ADJUST_WINDOW * 60