-
Notifications
You must be signed in to change notification settings - Fork 37
feat(storage): add CrdtType to entity metadata #1786
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
Closed
Closed
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
3f87ce3
feat(storage): add CrdtType to entity metadata
xilosada 68fef57
fix(storage): unify CrdtType definitions and fix backward compatibility
xilosada 7acdd9f
fix(storage): include crdt_type in hash_metadata_for_payload
xilosada 889600d
fix(storage): implement proper Borsh backward compatibility for Metad…
xilosada bff9846
feat(tests): add comprehensive CRDT test app and enhanced workflows w…
xilosada a00e06c
chore: format entities.rs
xilosada 1e5c36b
fix: crdt storage and events (#1804)
cursor[bot] e38ccfb
feat(storage): Add CrdtType to entity metadata for CRDT merge dispatch
xilosada 910fa41
feat(merodb): add CrdtType support for entity metadata deserialization
xilosada 150b57b
feat(storage): add field_name to metadata for schema inference
xilosada dc7a534
feat(kv-store,merodb): improve visualization with icons, colors, and …
xilosada 4c97f21
refactor(merodb): add field_name-based matching for tree building
xilosada b06584f
fix(merodb-gui): show field names instead of truncated IDs in tree view
xilosada 82d25dd
feat(storage): store correct CRDT type in collection metadata
xilosada 007eeaa
fix(merodb): treat Counter as Map type for proper tree building
xilosada 5fb27cb
fix(merodb-gui): show values for Vector and Set entries in tree labels
xilosada 1af25be
fix(merodb-gui): show Counter value instead of executor ID
xilosada 7cc9ecd
fix(merodb-gui): show correct children count in sidebar
xilosada 95b8c29
fix(merodb-gui): hide empty hash/timestamp sections in sidebar
xilosada f9839d3
fix(merodb-gui): show Vector/Set values in folder view
xilosada d427488
revert(kv-store): restore original kv-store app
xilosada 3d6732e
feat(apps): add state-visualization-test app for merodb testing
xilosada dbf792e
fix(merodb): remove debug eprintln from schema inference
xilosada 73cd91c
test(storage): add unit tests for field_name in Metadata and Element
xilosada 3f6735a
test(storage): add backward compatibility tests for Metadata deserial…
xilosada a540a8e
docs(storage): add schema inference documentation
xilosada ce967ad
fix(merodb): validate context_id slice length before conversion
xilosada 12f3b8b
fix(merodb): align CrdtType::Custom variant with canonical definition
xilosada c2adff5
fix(merodb): remove Copy trait from CrdtType enum
xilosada 01e3e1a
fix(sdk): simplify Default generation for LwwRegister fields
xilosada 392b728
fix(apps): add Default derive to Status and UserId32
xilosada e1f5984
fix(sdk): only generate Default impl when struct has collection fields
xilosada 4f6f5c1
fix(merodb,sdk): fix CrdtType::Custom pattern and quote! syntax
xilosada 5447d52
fix(storage): add missing crdt_type and field_name to test Metadata i…
xilosada 4bf97a3
fix(storage): add missing Metadata fields and fix UpdatedAt comparison
xilosada 7ec9721
fix(workflow): restore remote Docker image for CI
xilosada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| [package] | ||
| name = "comprehensive-crdt-test" | ||
| version.workspace = true | ||
| authors.workspace = true | ||
| edition.workspace = true | ||
| repository.workspace = true | ||
| license.workspace = true | ||
| publish = false | ||
|
|
||
| [lib] | ||
| crate-type = ["cdylib"] | ||
|
|
||
| [dependencies] | ||
| thiserror.workspace = true | ||
| calimero-sdk.workspace = true | ||
| calimero-storage.workspace = true | ||
| hex.workspace = true | ||
|
|
||
| [build-dependencies] | ||
| calimero-wasm-abi.workspace = true | ||
| serde_json.workspace = true | ||
|
|
||
| [package.metadata.workspaces] | ||
| independent = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| # Comprehensive CRDT Test Application | ||
|
|
||
| This application tests **ALL** CRDT types, UserStorage, FrozenStorage, and root-level concurrent modifications. | ||
|
|
||
| ## Features Tested | ||
|
|
||
| ### CRDT Types | ||
| - ✅ **Counter** - Grow-only counter with concurrent increments | ||
| - ✅ **UnorderedMap** - Field-level merge semantics | ||
| - ✅ **Vector** - Element-wise merge | ||
| - ✅ **UnorderedSet** - Union merge semantics | ||
| - ✅ **RGA (ReplicatedGrowableArray)** - Text CRDT for collaborative editing | ||
| - ✅ **LwwRegister** - Last-write-wins register | ||
|
|
||
| ### Storage Types | ||
| - ✅ **UserStorage (Simple)** - User-owned simple values | ||
| - ✅ **UserStorage (Nested)** - User-owned nested data structures | ||
| - ✅ **FrozenStorage** - Content-addressable immutable storage | ||
|
|
||
| ### Root-Level Merging | ||
| - ✅ **Concurrent Root Modifications** - Tests that root merge works when different nodes modify different root fields concurrently | ||
|
|
||
| ## Purpose | ||
|
|
||
| This app is designed to: | ||
| 1. Test all CRDT types in a single application | ||
| 2. Verify root-level concurrent modifications trigger proper merging | ||
| 3. Test UserStorage and FrozenStorage alongside CRDT types | ||
| 4. Serve as a comprehensive integration test for the sync protocol | ||
|
|
||
| ## Usage | ||
|
|
||
| Build the app: | ||
| ```bash | ||
| ./build.sh | ||
| ``` | ||
|
|
||
| Run the workflow: | ||
| ```bash | ||
| merobox bootstrap run workflows/comprehensive-crdt-test.yml | ||
| ``` | ||
|
|
||
| ## Workflow Tests | ||
|
|
||
| The `comprehensive-crdt-test.yml` workflow tests: | ||
| 1. Root Counter - concurrent increments merge correctly | ||
| 2. Root Map - field-level merge when different nodes modify different keys | ||
| 3. Root Vector - element-wise merge | ||
| 4. Root Set - union merge | ||
| 5. Root RGA - text CRDT merge | ||
| 6. Root Register - LWW semantics | ||
| 7. UserStorage Simple - user-owned data sync | ||
| 8. UserStorage Nested - nested user data with CRDTs | ||
| 9. FrozenStorage - content-addressable storage | ||
| 10. Root-Level Concurrent Modifications - different nodes modifying different root fields simultaneously | ||
|
|
||
| ## Architecture | ||
|
|
||
| The app state (`ComprehensiveCrdtApp`) contains all CRDT types and storage types as root-level fields. This design allows testing root-level concurrent modifications where: | ||
| - Node 1 modifies `root_counter` | ||
| - Node 2 modifies `root_map` | ||
| - Node 1 modifies `root_set` | ||
|
|
||
| All concurrently, triggering `merge_root_state` to merge all fields correctly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| use std::fs; | ||
| use std::path::Path; | ||
|
|
||
| use calimero_wasm_abi::emitter::emit_manifest; | ||
|
|
||
| fn main() { | ||
| println!("cargo:rerun-if-changed=src/lib.rs"); | ||
|
|
||
| // Parse the source code | ||
| let src_path = Path::new("src/lib.rs"); | ||
| let src_content = fs::read_to_string(src_path).expect("Failed to read src/lib.rs"); | ||
|
|
||
| // Generate ABI manifest using the emitter | ||
| let manifest = emit_manifest(&src_content).expect("Failed to emit ABI manifest"); | ||
|
|
||
| // Serialize the manifest to JSON | ||
| let json = serde_json::to_string_pretty(&manifest).expect("Failed to serialize manifest"); | ||
|
|
||
| // Write the ABI JSON to the res directory | ||
| let res_dir = Path::new("res"); | ||
| if !res_dir.exists() { | ||
| fs::create_dir_all(res_dir).expect("Failed to create res directory"); | ||
| } | ||
|
|
||
| let abi_path = res_dir.join("abi.json"); | ||
| fs::write(&abi_path, json).expect("Failed to write ABI JSON"); | ||
|
|
||
| // Extract and write the state schema | ||
| if let Ok(mut state_schema) = manifest.extract_state_schema() { | ||
| state_schema.schema_version = "wasm-abi/1".to_owned(); | ||
|
|
||
| let state_schema_json = | ||
| serde_json::to_string_pretty(&state_schema).expect("Failed to serialize state schema"); | ||
| let state_schema_path = res_dir.join("state-schema.json"); | ||
| fs::write(&state_schema_path, state_schema_json) | ||
| .expect("Failed to write state schema JSON"); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| # Add wasm32 target if not already present | ||
| rustup target add wasm32-unknown-unknown || true | ||
|
|
||
| # Build the app | ||
| cargo build -p comprehensive-crdt-test --target wasm32-unknown-unknown --release | ||
|
|
||
| # Copy WASM file to res directory | ||
| mkdir -p res | ||
| cp target/wasm32-unknown-unknown/release/comprehensive_crdt_test.wasm res/comprehensive_crdt_test.wasm | ||
|
|
||
| # Optimize WASM if wasm-opt is available | ||
| if command -v wasm-opt &> /dev/null; then | ||
| wasm-opt -O2 res/comprehensive_crdt_test.wasm -o res/comprehensive_crdt_test.wasm || true | ||
xilosada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| fi | ||
|
|
||
| echo "Build complete: res/comprehensive_crdt_test.wasm" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.