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

Rust HeaderBlock #17694

Merged
merged 2 commits into from
Mar 19, 2024
Merged

Rust HeaderBlock #17694

merged 2 commits into from
Mar 19, 2024

Conversation

arvidn
Copy link
Contributor

@arvidn arvidn commented Mar 12, 2024

Purpose:

Transition HeaderBlock to use the rust implementation. The rationale is to speed up serialization and deserialization and preparing for validation logic to move to rust and threads (rather than processes).

The rust implementation and type definition can be found here:
https://github.com/Chia-Network/chia_rs/blob/main/crates/chia-protocol/src/header_block.rs

The batch_pre_validate_blocks() function is run in a ProcessPoolExecutor, i.e. in separate python processes. In order to support passing data across the process boundary, we need to serialize (and pickle) the arguments, and the return value.

We invoke the ProcessPoolExecutor job here: https://github.com/Chia-Network/chia-blockchain/blob/main/chia/consensus/multiprocess_validation.py#L347

We serialize the FullBlock objects a few lines up: https://github.com/Chia-Network/chia-blockchain/blob/main/chia/consensus/multiprocess_validation.py#L332

Since we already have valid FullBlock objects (i.e. the public keys and signatures are known to be on the curve, and the CLVM generator is know to have valid serialization), we don't need to validate that again in the worker process.

Current Behavior:

HeaderBlock is a python type.

New Behavior:

HeaderBlock is a rust type.

@arvidn arvidn added the Changed Required label for PR that categorizes merge commit message as "Changed" for changelog label Mar 12, 2024

This comment was marked as outdated.

@github-actions github-actions bot added the merge_conflict Branch has conflicts that prevent merge to main label Mar 14, 2024
@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Mar 15, 2024

This comment was marked as outdated.

@arvidn arvidn marked this pull request as ready for review March 16, 2024 09:56
@arvidn arvidn requested a review from a team as a code owner March 16, 2024 09:56
@arvidn arvidn changed the title Rust header block Rust HeaderBlock Mar 16, 2024
AmineKhaldi
AmineKhaldi previously approved these changes Mar 18, 2024
@github-actions github-actions bot added merge_conflict Branch has conflicts that prevent merge to main labels Mar 18, 2024

This comment was marked as outdated.

1 similar comment
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the merge_conflict Branch has conflicts that prevent merge to main label Mar 18, 2024

This comment was marked as outdated.

@arvidn arvidn requested a review from emlowe March 19, 2024 08:29
@arvidn arvidn added the ready_to_merge Submitter and reviewers think this is ready label Mar 19, 2024
@pmaslana pmaslana merged commit 1cee7f1 into main Mar 19, 2024
285 checks passed
@pmaslana pmaslana deleted the rust-header-block branch March 19, 2024 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog ready_to_merge Submitter and reviewers think this is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants