Skip to content

introduce a new serialization for the generator in UnfinishedBlock - #1470

Merged
arvidn merged 1 commit into
mainfrom
unfinished-block-format
Jul 2, 2026
Merged

introduce a new serialization for the generator in UnfinishedBlock#1470
arvidn merged 1 commit into
mainfrom
unfinished-block-format

Conversation

@arvidn

@arvidn arvidn commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

just like FullBlock, where the generator is serialized as a byte blob. To parse an UnfinishedBlock, with the new format, we no longer need to deserialize CLVM.

This mirrors the changes in #1456 and #1345 .


Note

Medium Risk
Changes consensus-relevant block serialization and parsing for unfinished blocks on the network; backward compatibility for version 0 is preserved, but any mismatch with FullBlock or peers on v1 encoding would be high impact.

Overview
UnfinishedBlock now mirrors FullBlock’s dual generator wire format: version 0 keeps CLVM Program plus transactions_generator_ref_list; version 1 stores length-prefixed raw bytes in transactions_generator_buffer and omits the ref list, so peers can parse the block without deserializing CLVM. A custom Streamable implementation packs version and presence into the transactions_generator Option prefix byte (bit 0 = present, bit 1 = v1).

FullBlock parsing now derives version with prefix >> 1 instead of a single-bit check, and adds tests that prefix bytes with bits 2–7 set are rejected as InvalidFullBlock. UnfinishedBlock gets the same strict prefix rules via InvalidUnfinishedBlock (new error in chia-traits). Python stubs expose transactions_generator_buffer and version on UnfinishedBlock.

Comment-only renames from “Optional” to “Option” appear in a few protocol files.

Reviewed by Cursor Bugbot for commit 2798fa8. Bugbot is set up for automated code reviews on this repo. Configure here.

@coveralls-official

coveralls-official Bot commented Jun 26, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 28535161482

Coverage increased (+0.1%) to 81.664%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 27 uncovered changes across 1 file (253 of 280 lines covered, 90.36%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
crates/chia-protocol/src/unfinished_block.rs 258 231 89.53%
Total (2 files) 280 253 90.36%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 19192
Covered Lines: 15673
Line Coverage: 81.66%
Coverage Strength: 11771006.39 hits per line

💛 - Coveralls

@arvidn
arvidn force-pushed the unfinished-block-format branch 2 times, most recently from 391c428 to d07310a Compare June 30, 2026 09:22
@arvidn
arvidn marked this pull request as ready for review July 1, 2026 14:23
@arvidn

arvidn commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d07310a. Configure here.

…ust like FullBlock) where the generator is serialized as a byte blob. To parse an UnfinishedBlock, with the new format, we no longer need to deserialize CLVM
@arvidn
arvidn force-pushed the unfinished-block-format branch from d07310a to 2798fa8 Compare July 1, 2026 17:17
@arvidn
arvidn requested a review from AmineKhaldi July 1, 2026 17:18
@arvidn
arvidn merged commit 6eb209f into main Jul 2, 2026
122 of 123 checks passed
@arvidn
arvidn deleted the unfinished-block-format branch July 2, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants