support a new version of FullBlock serialization - #1456
Conversation
Coverage Report for CI Build 27024420785Coverage increased (+0.6%) to 81.583%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
c6892ae to
3932f65
Compare
|
@cursor review |
There was a problem hiding this comment.
✅ 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 3932f65. Configure here.
|
This seems reasonable. It's a bit sad that we have to write the code that was previously auto-generated. A way around it would be to extend the macros to allow enum variants with data; or generalize |
|
I experimented with extending the macros, and also implementing this at the python boundary, but this ended up being far simpler. It's unfortunate that we have to manually implement this trait, but at least it's easy to review and understand what it's doing (compared to the alternatives I tested with |
…rator is just a buffer
|
rebased over type-stub conflict. unchanged otherwise |
3932f65 to
d01897b
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d01897b. Configure here.
Add Option3<V1, V2> to chia-traits: a tri-state optional type with wire encoding 0x00/0x01/0x02. Use it for FullBlock.transactions_generator to cleanly express three states (no generator / v0 Program / v1 raw bytes) without hand-written serialization code. transactions_generator_ref_list changes from Vec<u32> to Option<Vec<u32>>: None signals v1 format (ref_list omitted), Some signals v0 format. This replaces the 145-line hand-written Streamable impl in PR #1456 with a #[streamable] derive and zero hand-written serialization code. The wire format differs by 1-2 bytes per block (negligible for a hard fork protocol change). Co-authored-by: Cursor <cursoragent@cursor.com>
Add Option3<V1, V2> to chia-traits: a tri-state optional type with wire encoding 0x00/0x01/0x02. Use it for FullBlock.transactions_generator to cleanly express three states (no generator / v0 Program / v1 raw bytes) without hand-written serialization code. transactions_generator_ref_list changes from Vec<u32> to Option<Vec<u32>>: None signals v1 format (ref_list omitted), Some signals v0 format. This replaces the 145-line hand-written Streamable impl in PR #1456 with a #[streamable] derive and zero hand-written serialization code. The wire format differs by 1-2 bytes per block (negligible for a hard fork protocol change). Co-authored-by: Cursor <cursoragent@cursor.com>
Add Option3<V1, V2> to chia-traits: a tri-state optional type with wire encoding 0x00/0x01/0x02. Use it for FullBlock.transactions_generator to cleanly express three states (no generator / v0 Program / v1 raw bytes) without hand-written serialization code. transactions_generator_ref_list changes from Vec<u32> to Option<Vec<u32>>: None signals v1 format (ref_list omitted), Some signals v0 format. This replaces the 145-line hand-written Streamable impl in PR #1456 with a #[streamable] derive and zero hand-written serialization code. The wire format differs by 1-2 bytes per block (negligible for a hard fork protocol change). Co-authored-by: Cursor <cursoragent@cursor.com>
Add Option3<V1, V2> to chia-traits: a tri-state optional type with wire encoding 0x00/0x01/0x02. Use it for FullBlock.transactions_generator to cleanly express three states (no generator / v0 Program / v1 raw bytes) without hand-written serialization code. transactions_generator_ref_list changes from Vec<u32> to Option<Vec<u32>>: None signals v1 format (ref_list omitted), Some signals v0 format. This replaces the 145-line hand-written Streamable impl in PR #1456 with a #[streamable] derive and zero hand-written serialization code. The wire format differs by 1-2 bytes per block (negligible for a hard fork protocol change). Co-authored-by: Cursor <cursoragent@cursor.com>
I was trying understand why this would be. Take a look at #1463 What am I missing? |
I don't think it's obvious that this is a simpler solution.
|

where the block generator is just a buffer.
This must be combined with a check in
chia-blockchainthatversion == 1iff the hard-fork has activated.Note
High Risk
Changes consensus-relevant block serialization and parsing; v1 must be gated by hard-fork checks in chia-blockchain (not in this PR) to avoid accepting invalid blocks on the network.
Overview
Adds a versioned
FullBlockwire format so post–hard-fork blocks can carry the transaction generator as raw length-prefixed bytes instead of a CLVMProgramplustransactions_generator_ref_list.FullBlockdrops the derived#[streamable]impl in favor of a manualStreamableimplementation. Version 0 keeps the legacy tail: optionalProgramgenerator andref_list. Version 1 encodes the format in the optional prefix byte (bit0b10, same pattern asProofOfSpace): no ref list on the wire; optional generator isBytes-style (4-byte length + payload) stored in newtransactions_generator_buffer, with in-memoryversiondriving encode/decode. Invalid versions returnError::InvalidFullBlock.The Python surface (
chia_rs.pyi) gainstransactions_generator_bufferandversion. Rust unit tests and a newtests/test_full_block.pycover round-trips, prefix-byte encoding, and v1 omitting the ref list.Reviewed by Cursor Bugbot for commit 8d4ac5d. Bugbot is set up for automated code reviews on this repo. Configure here.