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

refactor get block generator #16335

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions chia/consensus/block_body_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def validate_block_body(
height: uint32,
npc_result: Optional[NPCResult],
fork_point_with_peak: int,
get_block_generator: Callable[[BlockInfo, uint32], Awaitable[Optional[BlockGenerator]]],
get_block_generator: Callable[[BlockInfo, int, Dict[uint32, FullBlock]], Awaitable[Optional[BlockGenerator]]],
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should bundle the fork_height and this height->block map into a class. We'll need to extend this with passing in the unspent coin set of the fork as well.

Also, I would worry about storing all the FullNode objects in memory. We're not likely to actually need all of that, and it can take up a lot of space

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean by "FullNode" objects?

*,
validate_signature: bool = True,
) -> Tuple[Optional[Err], Optional[NPCResult]]:
Expand Down Expand Up @@ -307,7 +307,7 @@ async def validate_block_body(
if curr.transactions_generator is not None:
# These blocks are in the past and therefore assumed to be valid, so get_block_generator won't raise
curr_block_generator: Optional[BlockGenerator] = await get_block_generator(
curr, uint32(0 if fork_point_with_peak is None else fork_point_with_peak)
curr, 0 if fork_point_with_peak is None else fork_point_with_peak, reorg_blocks
)
assert curr_block_generator is not None and curr.transactions_info is not None
curr_npc_result = get_name_puzzle_conditions(
Expand Down
Loading