Support serde_2026 generators in trusted RPC helpers - #1500
Draft
richardkiss wants to merge 1 commit into
Draft
Conversation
Post-HF2 blocks (INTERNED_GENERATOR) encode their transactions generator with serde_2026, but several trusted (non-consensus) helpers the full node uses to respond to RPCs still parsed generators with node_from_bytes_backrefs() only, and would fail on such blocks: - additions_and_removals() - get_puzzle_and_solution_for_coin() / ..._for_coin2() (python bindings) - generator_interned_vbytes() (python binding) These helpers run on already-validated blocks, so unlike the consensus path (which stays strict about the one legal encoding per era) they now detect the encoding by sniffing the serde_2026 magic prefix, via the existing node_from_bytes_auto() from chia_consensus::serde_2026. The sniffing is unambiguous: the magic prefix starts with 0xfd, which cannot begin a valid classic CLVM serialization. Each changed helper gets a test exercising it with both a classic and a serde_2026 encoding of the same spends, asserting identical results. Co-authored-by: Cursor <cursoragent@cursor.com>
Coverage Report for CI Build 30841843169Coverage increased (+0.1%) to 82.041%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
#1438 made the
INTERNED_GENERATORconsensus path emit and require serde_2026-encoded generators. Bugbot flagged on that PR (r3662079661) that trusted helper functions still parse generators withnode_from_bytes_backrefs()only, and arvidn confirmed as a non-blocking follow-up: the helper functions the full node uses to respond to RPCs (likeget_puzzle_and_solution_for_coinandadditions_and_removals) need to support the new generator format as well.Layering: consensus stays strict, trusted read helpers sniff
run_block_generator2) is unchanged: withINTERNED_GENERATORactive, serde_2026 is the only legal encoding, and pre-HF2 the classic/backrefs encodings are the only legal ones. No sniffing there.chia_consensus::serde_2026::node_from_bytes_auto()(introduced for exactly this purpose). Detection is unambiguous: the 6-byte magic starts with0xfd, which cannot begin a valid classic CLVM serialization (0xfddeclares an atom length >= 2^40, above the 2^34 cap).Audited surface
Changed (parsed generator blobs with
node_from_bytes_backrefs()only):additions_and_removals()(chia-consensus) — also fixes the python binding, which wraps itget_puzzle_and_solution_for_coin()andget_puzzle_and_solution_for_coin2()(python bindings; the generator-bytes parsing for these lives in the wheel)generator_interned_vbytes()(python binding)Audited and deliberately unchanged:
run_block_generator()/run_block_generator2()— consensus path, stays strictget_coinspends_for_trusted_block()/get_coinspends_with_conditions_for_trusted_block()— already handle serde_2026 (viaINTERNED_GENERATORflag dispatch, from [CHIA-3823] Add INTERNED_GENERATOR consensus path + serde_2026 prefix guard #1438)solution_generator*(),InternedBlockBuilder,run_spendbundle(), fast-forward — parse puzzle/solution blobs from spend bundles, not block generatorsrun_chia_program()— general-purpose CLVM runner, not a generator-specific helpervisit_spends::run_generator,test-block-generators --test-serializer) — offline analysis tools; can be updated when post-HF2 blocks exist on chainNotes
Program(Streamable) cannot hold a serde_2026 blob yet (serialized_length_from_bytes*rejects0xfd), soget_puzzle_and_solution_for_coin2()and theget_coinspends_*wrappers — which take the generator asProgram— can't receive serde_2026 blobs from python until that lands. The buffer-taking helpers are covered end-to-end from python now.Tests
Each changed helper has a test exercising it with both a classic and a serde_2026 encoding of the same spends (built with
solution_generator()/solution_generator_2026(), the latter producing the same wire format asInternedBlockBuilder::finalize()), asserting identical results:test_serde_2026_generator_equivalenceinadditions_and_removals.rs(with pre- and post-HF2 flag sets)test_additions_and_removals_serde_2026,test_get_puzzle_and_solution_for_coin_serde_2026,test_generator_interned_vbytes_serde_2026Made with Cursor