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

Reduce log spam with will not infuse block. #19069

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 12 additions & 6 deletions chia/timelord/timelord.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ def get_height(self) -> uint32:
else:
return uint32(self.last_state.get_height() + 1)

def _get_rc_cache_index(self, block: timelord_protocol.NewUnfinishedBlockTimelord) -> Optional[int]:
for index, (rc, _) in enumerate(self.last_state.reward_challenge_cache):
if rc == block.rc_prev:
return index

return None

def _can_infuse_unfinished_block(self, block: timelord_protocol.NewUnfinishedBlockTimelord) -> Optional[uint64]:
assert self.last_state is not None
sub_slot_iters = self.last_state.get_sub_slot_iters()
Expand All @@ -260,12 +267,9 @@ def _can_infuse_unfinished_block(self, block: timelord_protocol.NewUnfinishedBlo
block_sp_total_iters = self.last_state.total_iters - ip_iters + block_sp_iters
if is_overflow_block(self.constants, block.reward_chain_block.signage_point_index):
block_sp_total_iters -= self.last_state.get_sub_slot_iters()
found_index = -1
for index, (rc, total_iters) in enumerate(self.last_state.reward_challenge_cache):
if rc == block.rc_prev:
found_index = index
break
if found_index == -1:

found_index = self._get_rc_cache_index(block)
if found_index is None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if found_index is None:
if self._get_rc_cache_index(block) is None:

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing line 271

log.warning(f"Will not infuse {block.rc_prev} because its reward chain challenge is not in the chain")
return None
if ip_iters > block_ip_iters:
Expand Down Expand Up @@ -337,6 +341,8 @@ async def _reset_chains(self, *, first_run: bool = False, only_eos: bool = False
self.iteration_to_proof_type[new_block_iters] = IterationType.INFUSION_POINT
# Remove all unfinished blocks that have already passed.
self.unfinished_blocks = new_unfinished_blocks
# Remove old overflow blocks that we didn't infuse.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we clean all the blocks we cant infuse in the loop above but we dont clean the blocks that we moved from self.overflow_blocks to the new_unfinished

i think just adding
if block in self.overflow_blocks:
self.overflow_blocks.remove(block)

to line 337 would be a better solution, also it looks like we currently duplicate blocks in both self.unfinished and self.overflow_blocks in the loop above

self.overflow_blocks = [block for block in self.overflow_blocks if self._get_rc_cache_index(block) is not None]
# Signage points.
if not only_eos and len(self.signage_point_iters) > 0:
count_signage = 0
Expand Down
Loading