Draft
Conversation
…tocol testing Replaces the flat `DigestCache` HashMap in `SimNode` with `SimStorage`, which uses the real `calimero-storage::Index<MainStorage>` implementation backed by `InMemoryDB`. This enables accurate simulation of sync protocols that depend on tree structure (e.g., HashComparison). Key changes: - Add `SimStorage` with in-memory Merkle tree using `Store + InMemoryDB` - Add `RuntimeEnv` bridge to connect storage Key operations - Update `SimNode` to use hybrid storage: real tree + metadata cache - Add `insert_entity_hierarchical()` for creating proper tree depth - Make `Index::get_index()` and `get_children_of()` public for traversal - Add tree structure verification tests for protocol selection - Fix: prevent self-referencing cycle in hierarchical insertion The entity counting now correctly excludes intermediate tree nodes, and `iter_entities()` returns only "real" entities (with metadata). Tree depth now affects protocol selection: - SubtreePrefetch scenarios have max_depth > 3 - LevelWise scenarios have max_depth <= 2 Spec reference: Simulation Framework Spec §5, §7, §11 Co-authored-by: cursor[bot] <cursor@calimero.network>
Remove duplicated dual-write logic in apply_storage_op by delegating to insert_entity_with_metadata for Insert/Update operations. This ensures the Merkle tree and entity_metadata cache stay in lockstep, preventing future bugs from divergent implementations.
Contributor
Author
|
Cursor Agent can help with this pull request. Just |
4 tasks
|
Your PR title does not adhere to the Conventional Commits convention: Common errors to avoid:
|
There was a problem hiding this comment.
🤖 AI Code Reviewer
Reviewed by 3 agents | Quality score: 95% | Review time: 117.9s
✅ No Issues Found
All agents reviewed the code and found no issues. LGTM! 🎉
🤖 Generated by AI Code Reviewer | Review ID: review-9e7eef31
|
This pull request has been automatically marked as stale. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
sync_sim: Refactorapply_storage_opto reuseinsert_entity_with_metadataDescription
Refactored
apply_storage_opto delegate toself.insert_entity_with_metadatafor Insert/Update operations. This fixes a bug (c8b01083-74ac-4bc1-b56f-4397d8eeff1d) where identical dual-write logic for the Merkle tree and metadata cache was duplicated across both methods. The change eliminates code duplication, reducing the risk of inconsistencies between the Merkle tree and theentity_metadatacache if the dual-write logic were to be modified in only one place.Test plan
The existing
sync_simtests were run usingcargo test. All 13 tests passed successfully after the change. This refactoring is within test utilities and does not affect the user interface or require new end-to-end tests.Documentation update
No public or internal documentation updates are required.