Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experiment with new simpler ar scaling method #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions sim/consensus.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

DIFF_DAMP_FACTOR = 3
AR_DAMP_FACTOR = 13
NEW_AR_DAMP = 0
CLAMP_FACTOR = 2
BLOCK_TIME_WINDOW = DIFFICULTY_ADJUST_WINDOW * 60

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down