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 full_node add_block #18584

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Conversation

almogdepaz
Copy link
Contributor

Purpose:

full node add_block is only used to add blocks on top of the current Peak, it does not need ForkInfo besides from the usage in tests, this pr removes that field and updates all the tests, this allows us to remove cases from blockchain.py add_block that dont serve us in node operation

Current Behavior:

New Behavior:

Testing Notes:

@almogdepaz almogdepaz added Blockchain team Issues tagged for Blockchain team to work on full_node Fixed Required label for PR that categorizes merge commit message as "Fixed" for changelog Cleanup Code cleanup labels Sep 12, 2024
Copy link
Contributor

@arvidn arvidn left a comment

Choose a reason for hiding this comment

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

looks really good!

@@ -353,75 +352,19 @@ async def add_block(
# maybe fork_info should be mandatory to pass in, but we have a lot of
Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like fork_info is mandatory now, and this comment could be updated

if block_rec is not None:
self.add_block_record(block_rec)
# this means we have already seen and validated this block.
if fork_info is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think fork_info is allowed to be None now. mypy should complain

@@ -1856,12 +1857,13 @@ async def test_pre_validation(
end_pv = time.time()
times_pv.append(end_pv - start_pv)
assert res is not None
fork_info = ForkInfo(-1, -1, empty_blockchain.constants.GENESIS_CHALLENGE)
Copy link
Contributor

Choose a reason for hiding this comment

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

so, blocks_to_validate[0].prev_header_hash == GENESIS_CHALLENGE seems to be assumed here. Is that really right? I think you'd need to pick the fork point hash out of blocks_to_validate[0]

fork_height = block.height - len(fork_chain) - 1
fork_info = ForkInfo(fork_height, fork_height, fork_hash)

log.warning(f"slow path in block validation. Building coin set for fork ({fork_height}, {block.height})")
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably don't need this warning anymore now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blockchain team Issues tagged for Blockchain team to work on Cleanup Code cleanup Fixed Required label for PR that categorizes merge commit message as "Fixed" for changelog full_node
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants