Skip to content

refactor(dpp): split document serialization formats into per-generation files - #4484

Merged
QuantumExplorer merged 2 commits into
v4.2-devfrom
claude/split-document-serialize-formats
Aug 26, 2026
Merged

refactor(dpp): split document serialization formats into per-generation files#4484
QuantumExplorer merged 2 commits into
v4.2-devfrom
claude/split-document-serialize-formats

Conversation

@QuantumExplorer

Copy link
Copy Markdown
Member

Issue being fixed or feature implemented

Follow-up to #4400, deferred there deliberately so that PR's inline diffs of the legacy serialization formats stayed reviewable. packages/rs-dpp/src/document/v0/serialize.rs had grown to 3,815 lines holding four frozen wire-format generations plus ~1,700 lines of tests.

What was done?

Pure relocation — no semantic change anywhere:

  • Each serialization format generation moves to its own file: document/v0/serialize/{v0,v1,v2,v3}.rs. Method bodies are byte-for-byte identical, relocated into inherent impl DocumentV0 blocks (signatures gain only pub(super)).
  • mod.rs keeps the three trait impls: the serialization/deserialization ones become one-line dispatch shims into the per-format inherent methods (inherent methods take precedence, so the same-name delegation is unambiguous via DocumentV0::method(...) UFCS); the conversion impl (prefix-driven dispatchers) is unchanged.
  • Tests move verbatim (one indentation level) into serialize/tests.rs, with the four imports they previously inherited from the file header made explicit.
  • Import blocks were copied to each file and pruned to what each format uses; feature-gate attributes were kept correct (verified by building --no-default-features --features state-transitions in addition to --all-features).

Why: consensus hygiene. A shipped format's file must never change, so after this split a diff touching serialize/v1.rs is immediately suspect in review — the same physical isolation the version tables give generation modules.

How Has This Been Tested?

  • git diff --color-moved=zebra --color-moved-ws=allow-indentation-change classifies all but 85 of the ~4,000 added lines as moves; the 85 are module plumbing (per-file doc headers, impl wrappers, pub(super) markers, the 8 shims, 4 test imports).
  • Full dpp suite passes (3,942 tests), including the entire serialization matrix — any delegation mistake would recurse or misdispatch instantly there.
  • cargo clippy --all-targets --all-features -- -D warnings clean; cargo check --no-default-features --features state-transitions clean; cargo fmt applied.

Breaking Changes

None — pure file reorganization; public API and wire behavior untouched.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

…on files

serialize.rs had grown to 3,815 lines holding four frozen wire-format
generations plus their tests. Each format now lives in its own file —
document/v0/serialize/{v0,v1,v2,v3}.rs — as inherent methods with bodies
moved verbatim; the trait impls in mod.rs are one-line dispatch shims, and
the tests move unchanged (one dedent) into tests.rs. Pure relocation: git
diff --color-moved-ws=allow-indentation-change classifies all but 85 of the
~4,000 added lines as moves, the 85 being module plumbing (headers, impl
wrappers, pub(super) markers, shims, test imports).

The point is consensus hygiene: a shipped format's file must never change,
so a future diff touching serialize/v1.rs is immediately suspect in review
— the same physical isolation the version tables give generation modules.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added this to the v4.2.0 milestone Aug 26, 2026
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 18 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d87360cc-3d82-4a40-b52b-826bc3b9d365

📥 Commits

Reviewing files that changed from the base of the PR and between a98c6d7 and 68f8716.

📒 Files selected for processing (7)
  • packages/rs-dpp/src/document/v0/serialize.rs
  • packages/rs-dpp/src/document/v0/serialize/mod.rs
  • packages/rs-dpp/src/document/v0/serialize/tests.rs
  • packages/rs-dpp/src/document/v0/serialize/v0.rs
  • packages/rs-dpp/src/document/v0/serialize/v1.rs
  • packages/rs-dpp/src/document/v0/serialize/v2.rs
  • packages/rs-dpp/src/document/v0/serialize/v3.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

🕓 Ready for review — 4 ahead in queue (commit 68f8716)
Queue position: 5/5
ETA: start ~10:45 UTC · complete ~11:07 UTC (median 22m across 30 recent reviews; 2 slots)
Queued 2m ago · Last checked: 2026-08-26 10:00 UTC

@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 61.11463% with 614 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.70%. Comparing base (bea4122) to head (68f8716).
⚠️ Report is 7 commits behind head on v4.2-dev.

Files with missing lines Patch % Lines
packages/rs-dpp/src/document/v0/serialize/v1.rs 56.57% 142 Missing ⚠️
packages/rs-dpp/src/document/v0/serialize/v2.rs 61.18% 137 Missing ⚠️
packages/rs-dpp/src/document/v0/serialize/v3.rs 64.36% 134 Missing ⚠️
packages/rs-dpp/src/document/v0/serialize/v0.rs 67.16% 110 Missing ⚠️
packages/rs-dpp/src/document/v0/serialize/mod.rs 51.59% 91 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           v4.2-dev    #4484      +/-   ##
============================================
- Coverage     87.39%   81.70%   -5.70%     
============================================
  Files          2735     2748      +13     
  Lines        347804   369740   +21936     
============================================
- Hits         303979   302090    -1889     
- Misses        43825    67650   +23825     
Components Coverage Δ
dpp 79.61% <70.52%> (-9.36%) ⬇️
drive 81.08% <74.14%> (-5.25%) ⬇️
drive-abci 86.25% <79.65%> (-3.48%) ⬇️
sdk ∅ <ø> (∅)
dapi-client ∅ <ø> (∅)
platform-version ∅ <ø> (∅)
platform-value 92.92% <ø> (ø)
platform-wallet ∅ <ø> (∅)
drive-proof-verifier 47.03% <ø> (-0.38%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Each per-format file header now states the protocol version the format
became the default at and why it exists (v0: original all-i64 encoding,
protocols 1-8, with the 0-prefix read fallback; v1: protocol 9's
schema-typed native-size integers; v2: protocol 10's $creatorId for
transferable/tradable types; v3: protocol 14's contract-version stamp for
requiredSince). The write-path dispatcher gets matching comments on the
arms that lacked them (0 and 2).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@QuantumExplorer QuantumExplorer left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Nice refactor

@QuantumExplorer
QuantumExplorer merged commit 507192c into v4.2-dev Aug 26, 2026
4 checks passed
@QuantumExplorer
QuantumExplorer deleted the claude/split-document-serialize-formats branch August 26, 2026 10:00
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