cleanup sub slot logic
This commit is contained in:
parent
e0114470b4
commit
270d015861
|
@ -774,8 +774,6 @@ class BlockTools:
|
|||
else:
|
||||
if guarantee_transaction_block:
|
||||
continue
|
||||
if pending_ses:
|
||||
pending_ses = False
|
||||
block_list.append(full_block)
|
||||
if full_block.transactions_generator is not None:
|
||||
compressor_arg = detect_potential_template_generator(
|
||||
|
@ -849,9 +847,10 @@ class BlockTools:
|
|||
sub_slot_iters,
|
||||
True,
|
||||
)
|
||||
if pending_ses:
|
||||
sub_epoch_summary: Optional[SubEpochSummary] = None
|
||||
else:
|
||||
# generate sub_epoch_summary, and if the last block was the last block of the sub-epoch
|
||||
# update the difficulty and sub_slot_iters, and include the hash in the next sub-slot
|
||||
sub_epoch_summary: Optional[SubEpochSummary] = None
|
||||
if not pending_ses: # if we just created a sub-epoch summary, we can at least skip another sub-slot
|
||||
sub_epoch_summary = next_sub_epoch_summary(
|
||||
constants,
|
||||
BlockCache(blocks, height_to_hash=height_to_hash),
|
||||
|
@ -859,19 +858,19 @@ class BlockTools:
|
|||
block_list[-1],
|
||||
False,
|
||||
)
|
||||
pending_ses = True
|
||||
|
||||
ses_hash: Optional[bytes32]
|
||||
if sub_epoch_summary is not None:
|
||||
ses_hash = sub_epoch_summary.get_hash()
|
||||
pending_ses = True
|
||||
ses_hash: Optional[bytes32] = sub_epoch_summary.get_hash()
|
||||
new_sub_slot_iters: Optional[uint64] = sub_epoch_summary.new_sub_slot_iters
|
||||
new_difficulty: Optional[uint64] = sub_epoch_summary.new_difficulty
|
||||
|
||||
self.log.info(f"Sub epoch summary: {sub_epoch_summary}")
|
||||
self.log.info(f"Sub epoch summary: {sub_epoch_summary} for block {latest_block.height+1}")
|
||||
else:
|
||||
pending_ses = False
|
||||
ses_hash = None
|
||||
new_sub_slot_iters = None
|
||||
new_difficulty = None
|
||||
self.log.debug(f"No sub epoch summary for block {latest_block.height+1}")
|
||||
|
||||
if icc_eos_vdf is not None:
|
||||
# Icc vdf (Deficit of latest block is <= 4)
|
||||
|
@ -944,11 +943,12 @@ class BlockTools:
|
|||
self.log.info(
|
||||
f"Sub slot finished. blocks included: {blocks_added_this_sub_slot} blocks_per_slot: "
|
||||
f"{(len(block_list) - initial_block_list_len)/sub_slots_finished}"
|
||||
f"Sub Epoch Summary Included: {sub_epoch_summary is not None} "
|
||||
)
|
||||
blocks_added_this_sub_slot = 0 # Sub slot ended, overflows are in next sub slot
|
||||
|
||||
# Handle overflows: No overflows on new epoch
|
||||
if new_sub_slot_iters is None and num_empty_slots_added >= skip_slots and new_difficulty is None:
|
||||
if new_sub_slot_iters is None and num_empty_slots_added >= skip_slots and not pending_ses:
|
||||
for signage_point_index in range(
|
||||
constants.NUM_SPS_SUB_SLOT - constants.NUM_SP_INTERVALS_EXTRA,
|
||||
constants.NUM_SPS_SUB_SLOT,
|
||||
|
@ -1056,8 +1056,6 @@ class BlockTools:
|
|||
last_timestamp = full_block.foliage_transaction_block.timestamp
|
||||
elif guarantee_transaction_block:
|
||||
continue
|
||||
if pending_ses:
|
||||
pending_ses = False
|
||||
|
||||
block_list.append(full_block)
|
||||
if full_block.transactions_generator is not None:
|
||||
|
@ -1089,7 +1087,8 @@ class BlockTools:
|
|||
if num_blocks < prev_num_of_blocks:
|
||||
num_empty_slots_added += 1
|
||||
|
||||
if new_sub_slot_iters is not None:
|
||||
if pending_ses:
|
||||
assert new_sub_slot_iters is not None
|
||||
assert new_difficulty is not None
|
||||
sub_slot_iters = new_sub_slot_iters
|
||||
difficulty = new_difficulty
|
||||
|
|
Loading…
Reference in New Issue