refactor(dpp): split document serialization formats into per-generation files - #4484
Conversation
…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>
|
Warning Review limit reachedNext included review available in 18 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
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. Comment |
|
🕓 Ready for review — 4 ahead in queue (commit 68f8716) |
Codecov Report❌ Patch coverage is 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
🚀 New features to boost your workflow:
|
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>
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.rshad 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:
document/v0/serialize/{v0,v1,v2,v3}.rs. Method bodies are byte-for-byte identical, relocated into inherentimpl DocumentV0blocks (signatures gain onlypub(super)).mod.rskeeps 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 viaDocumentV0::method(...)UFCS); the conversion impl (prefix-driven dispatchers) is unchanged.serialize/tests.rs, with the four imports they previously inherited from the file header made explicit.--no-default-features --features state-transitionsin addition to--all-features).Why: consensus hygiene. A shipped format's file must never change, so after this split a diff touching
serialize/v1.rsis 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-changeclassifies all but 85 of the ~4,000 added lines as moves; the 85 are module plumbing (per-file doc headers,implwrappers,pub(super)markers, the 8 shims, 4 test imports).dppsuite 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 warningsclean;cargo check --no-default-features --features state-transitionsclean;cargo fmtapplied.Breaking Changes
None — pure file reorganization; public API and wire behavior untouched.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code