Skip to content

feat(db): add zstd compression to Transactions table#477

Merged
kariy merged 3 commits intomainfrom
feat/tx-compressed
Mar 12, 2026
Merged

feat(db): add zstd compression to Transactions table#477
kariy merged 3 commits intomainfrom
feat/tx-compressed

Conversation

@kariy
Copy link
Copy Markdown
Member

@kariy kariy commented Mar 11, 2026

Extracts the envelope logic introduced in #465 for ReceiptEnvelope into a generic Envelope<T> parameterized by an EnvelopePayload trait, then applies the same zstd compression to the Transactions table via a new TxEnvelope type alias.

Each payload type supplies a 4-byte magic (KRCP for receipts, KTXN for transactions), a human-readable name for error messages, and a from_legacy_bytes function for backward-compatible deserialization of pre-envelope rows. The shared Compress/Decompress impls handle the header, zstd encode/decode, version/encoding validation, and legacy fallback.

The Transactions table value type changes from VersionedTx to TxEnvelope. Existing uncompressed rows are transparently decoded via the legacy fallback in VersionedTx::from_legacy_bytes, so no migration is needed. However, any code that reads directly from the Transactions table outside of the provider (eg. custom tooling) will need to update to handle TxEnvelope instead of bare VersionedTx.

🤖 Generated with Claude Code

Extract the envelope logic from `ReceiptEnvelope` into a generic
`Envelope<T>` parameterized by an `EnvelopePayload` trait. Apply
the same zstd compression to the `Transactions` table via `TxEnvelope`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 11, 2026

Codecov Report

❌ Patch coverage is 92.02899% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.54%. Comparing base (9bde0ae) to head (b1b3499).
⚠️ Report is 306 commits behind head on main.

Files with missing lines Patch % Lines
crates/storage/db/src/models/envelope.rs 93.13% 7 Missing ⚠️
...storage/db/src/models/versioned/transaction/mod.rs 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #477      +/-   ##
==========================================
- Coverage   73.32%   68.54%   -4.78%     
==========================================
  Files         209      281      +72     
  Lines       23132    34394   +11262     
==========================================
+ Hits        16961    23577    +6616     
- Misses       6171    10817    +4646     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kariy kariy changed the title feat(db): generic compressed Envelope for Transactions table feat(db): add zstd compression to Transactions table Mar 11, 2026
kariy and others added 2 commits March 11, 2026 16:59
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace ad-hoc CodecError string formatting with a typed EnvelopeError
that covers each failure mode: incomplete header, unsupported version,
unsupported encoding, serialize/deserialize, zstd compress/decompress,
and legacy decode. EnvelopeError converts into CodecError at the
Compress/Decompress trait boundary.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kariy kariy merged commit 7be2974 into main Mar 12, 2026
10 of 11 checks passed
@kariy kariy deleted the feat/tx-compressed branch March 12, 2026 15:44
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