Skip to content

Add full transaction CBOR reconstruction via raw segment splicing (returnFullTxCbor) [next] - #176

Merged
satran004 merged 1 commit into
nextfrom
feat/tx_full_cbor_next
Jul 12, 2026
Merged

Add full transaction CBOR reconstruction via raw segment splicing (returnFullTxCbor) [next]#176
satran004 merged 1 commit into
nextfrom
feat/tx_full_cbor_next

Conversation

@satran004

Copy link
Copy Markdown
Member

Summary

Cherry-pick of #169 (merged to main as 0b37894) onto next, bringing the returnFullTxCbor feature to the next branch.

  • Cherry-picked commit: f3182a5 — Add full transaction CBOR reconstruction via raw segment splicing (picked as 946d21b with -x annotation)
  • Skipped commit: 6e93408 (Replace Mockito stubs with Netty fakes in SessionTest) — it was an incidental CI test fix against the old, much simpler SessionTest on main. On next, SessionTest has since been rewritten and expanded (session retry / candidate work from feat(helper): app-chain sync (103) on the shared peer connection #175), so that commit no longer applies; the existing Mockito-based tests on next pass as-is.

Conflict resolution

One conflict in YaciConfig.java: both branches appended accessors at the same location (blockFetchCheckRangeExists on next vs. the new returnFullTxCbor accessors). Resolved by keeping both. WitnessUtil.java and BlockSerializer.java auto-merged.

Testing

  • Full :core:test (211 tests) and :helper:test (28 tests) suites pass with no failures, including the new AuxDataExtractorTest, BlockSerializerRawSegmentTest, TxCborUtilTest, and BlockFetchAgentListenerAdapterTest.

🤖 Generated with Claude Code

New YaciConfig.returnFullTxCbor flag. When enabled, the standalone
transaction CBOR ([body, witness_set, is_valid, auxiliary_data] per era
CDDL) is assembled by splicing the exact segment bytes sliced from the
original block, so no CBOR encoder touches the on-chain bytes:

- AuxDataExtractor slices raw auxiliary_data bytes per tx index
  (definite and indefinite maps)
- Witnesses.cbor and AuxData.cbor carry the raw segment bytes;
  TransactionBody.cbor is also populated when the new flag is set
- TxCborUtil assembles the envelope: 0x83 for Shelley/Allegra/Mary,
  0x84 with isValid for Alonzo and later; fails closed (null) for
  Byron/null era or missing segments
- Helper Transaction gains txCbor, populated in
  BlockFetchAgentListenerAdapter
- WitnessUtil.getWitnessRawData now handles indefinite-length
  witness-set arrays

Fail-closed invariants: segment count mismatches skip full tx cbor for
the whole block, and auxiliary data slices are verified against the
body's auxiliary_data_hash (blake2b-256) before use. A missing or
invalid segment yields txCbor=null, never wrong bytes, and sync
continues unaffected. Default behavior is unchanged when the flag is
off.

Verified with a real Babbage preprod block fixture: per-segment byte
equality, CCL Transaction.deserialize round-trip, invalid-tx flag, and
the aux-hash mismatch path.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
(cherry picked from commit f3182a5)
@sonarqubecloud

Copy link
Copy Markdown

@satran004
satran004 merged commit a2bfd9a into next Jul 12, 2026
3 checks passed
@satran004
satran004 deleted the feat/tx_full_cbor_next branch July 12, 2026 12:31
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.

1 participant