-
Notifications
You must be signed in to change notification settings - Fork 10
feat(db): add versioned db types for backward compatibility #118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Original prompt from karii@cartridge.gg: |
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Binary size report 📊
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #118 +/- ##
==========================================
- Coverage 73.73% 73.47% -0.26%
==========================================
Files 205 209 +4
Lines 22689 22944 +255
==========================================
+ Hits 16730 16859 +129
- Misses 5959 6085 +126 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
c15773f to
73a39a2
Compare
|
@claude let's cherry-pick commit |
afa4f68 to
afd80f5
Compare
There has been a mistake on the progression of the database version. For the latest stable release of Katana (v1.5.3), the database version is [6](https://github.com/dojoengine/katana/blob/8cca707d20a52b3d8d559193c77dc720ca3a4fbd/crates/storage/db/src/version.rs#L8) which hadn't changed since Katana [v1.0.10](https://github.com/dojoengine/dojo/blob/v1.0.10/crates/katana/storage/db/src/version.rs). If the rule for bumping the database version is followed correctly - bump the version if there are changes in the serialization for the database [types](https://github.com/dojoengine/katana/blob/8cca707d20a52b3d8d559193c77dc720ca3a4fbd/crates/storage/db/src/tables.rs#L191-L266) - the fact that the version remain unchanged since v1.0.10 would supposedly imply the database format remains compatible from v1.0.10 all the way to v1.5.3. Unfortunately, it is not the case for this (6) database version. The correct version for Katana v1.5.* should've been 7 following a change made to the `Header` struct - addition of the `l2_gas_prices` - by this [PR](#19). But I've made a mistake of forgetting to perform a version bump following the change. So, this commit doubles as a patch (for v1.5.*) to maintain backward compatibility across all versions of Katana with database version 6, and as the first part of implementing an actual database migration tool.
- Add versioned Header and Tx storage types supporting versions 5-7 - Implement version-aware codecs with fallback deserialization - Update database initialization to allow older versions for block data - Maintain strict versioning for non-block tables - Update storage provider to handle versioned type conversions - Fix all test cases to use versioned types properly This enables backward compatibility for block data across different database versions while allowing state reconstruction through re-execution. Co-Authored-By: karii@cartridge.gg <evergreenkary@gmail.com>
- Break long versioned header calls into multiple lines - Fix formatting issues identified by CI fmt check Co-Authored-By: karii@cartridge.gg <evergreenkary@gmail.com>
- Add ResourceBoundsMappingV6 with only l1_gas and l2_gas fields - Create V6-specific transaction types for InvokeTxV3, DeclareTxV3, DeployAccountTxV3 - Implement conversion logic from V6 to V7 with default l1_data_gas - Update TxV6 enum to use proper V6-specific types - Fix ChainId import to use katana_primitives::chain::ChainId Co-Authored-By: karii@cartridge.gg <evergreenkary@gmail.com>
- Fix From<Tx> for VersionedTx to use V7 format for new transactions - Update fallback deserialization to handle V5, V6, and V7 properly - Remove useless as_ref() call to fix clippy warning - Resolve compilation errors in CI Co-Authored-By: karii@cartridge.gg <evergreenkary@gmail.com>
afd80f5 to
8f29fd8
Compare
|
Claude finished @devin-ai-integration[bot]'s task —— View job Code Review CompleteI've conducted a comprehensive review of the versioned database types implementation for backward compatibility. Here's my detailed feedback: Critical Issues
|
|
Claude finished @devin-ai-integration[bot]'s task —— View job Comprehensive Code Review CompleteI've conducted a thorough review of the versioned database types implementation for backward compatibility. Here's my detailed analysis: Critical Issues
|
|
Claude finished @devin-ai-integration[bot]'s task —— View job Comprehensive Code Review for Versioned Database Types
|

Add Versioned Storage Types for Database Backward Compatibility
This PR implements versioned storage types for Katana's database to enable backward compatibility for block data across different database versions. The implementation allows newer versions of Katana to read/deserialize databases created with older versions by creating separate versioned storage types in the database layer.
This is the first half of implementing a full database migration from previous database versions. The objective is to make sure future changes that affect the database format will not introduce compatibility issue with current/older format.
Changes Made
Core Implementation
crates/storage/db/src/versioned/)VersionedHeaderenum supporting Header (v6), and current Header (v7)VersionedTxenum supporting Tx (v6), and current Tx (v7)Compress/Decompressimplementations for the versioned types with fallback deserialization.