Skip to content

Commit

Permalink
SSI hard minimum preventing blockchain stalls when the timelord perfo…
Browse files Browse the repository at this point in the history
…rmance is too low
  • Loading branch information
bpx-chain committed Oct 31, 2024
1 parent 3c08bef commit df5f602
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions bpx/consensus/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class ConsensusConstants:
NUM_SPS_SUB_SLOT: uint32 # The number of signage points per sub-slot (including the 0th sp at the sub-slot start)

SUB_SLOT_ITERS_STARTING: uint64 # The sub_slot_iters for the first epoch
SUB_SLOT_ITERS_HARD_MIN: uint64 # Hard minimum for anti-stall protection
DIFFICULTY_CONSTANT_FACTOR: uint128 # Multiplied by the difficulty to get iterations
DIFFICULTY_STARTING: uint64 # The difficulty for the first epoch
# The maximum factor by which difficulty and sub_slot_iters can change per epoch
Expand Down
1 change: 1 addition & 0 deletions bpx/consensus/default_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"MAX_SUB_SLOT_BLOCKS": 128, # Must be less than half of SUB_EPOCH_BLOCKS
"NUM_SPS_SUB_SLOT": 64, # Must be a power of 2
"SUB_SLOT_ITERS_STARTING": 2**20,
"SUB_SLOT_ITERS_HARD_MIN": 2**19,
# DIFFICULTY_STARTING is the starting difficulty for the first epoch, which is then further
# multiplied by another factor of DIFFICULTY_CONSTANT_FACTOR, to be used in the VDF iter calculation formula.
"DIFFICULTY_CONSTANT_FACTOR": 2**51,
Expand Down
2 changes: 1 addition & 1 deletion bpx/consensus/difficulty_adjustment.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def _get_next_sub_slot_iters(
if new_ssi_precise >= last_block_curr.sub_slot_iters:
new_ssi_precise = uint64(min(new_ssi_precise, max_ssi))
else:
new_ssi_precise = uint64(max([constants.NUM_SPS_SUB_SLOT, new_ssi_precise, min_ssi]))
new_ssi_precise = uint64(max([constants.SUB_SLOT_ITERS_HARD_MIN, new_ssi_precise, min_ssi]))

new_ssi = truncate_to_significant_bits(new_ssi_precise, constants.SIGNIFICANT_BITS)
new_ssi = uint64(new_ssi - new_ssi % constants.NUM_SPS_SUB_SLOT) # Must divide the sub slot
Expand Down

0 comments on commit df5f602

Please sign in to comment.