feat: multi-chain Soroban state synchronizer using CRDTs (#49)#92
Merged
elizabetheonoja-art merged 1 commit intoJun 26, 2026
Merged
Conversation
…tocol#49) Merges concurrent updates from multiple Soroban chains (testnet/futurenet/ mainnet) deterministically so the local store always converges without manual reconciliation. - types/crdt.ts: LamportTimestamp, LWWRegister, ORSet, VectorClock, the CrdtEvent discriminated union, resource diffs, and bounds (chain priority mainnet > testnet > futurenet, 12-ledger/~60s reconcile timeout) - utils/lamportClock.ts: LamportClock (tick/observe/tickAfter) + compareTimestamp total order with chain-priority tie-breaking - utils/crdtMerge.ts: pure engine — LWW register merge, tag-based OR-set with tombstones (remove carries observed tags so merges are order-independent), orSetValues, and a batched mergeEvents producing per-resource diffs + vector clocks + chain-seen counters - workers/crdtMerge.worker.ts: accumulates merged state off-thread and posts diffs - store/slices/crdtSlice.ts: applies diffs immutably, tracks per-resource vector clocks + per-chain lastSeen, and a staleness watcher flagging chains for a full snapshot re-fetch past the reconcile timeout - hooks/useContractState.ts: stamps each ingested event with the originating chain's Lamport clock, batches to the worker (inline-merge fallback), runs the staleness watch, auto-cleans on unmount - tests for the clock ordering, CRDT convergence under arbitrary interleavings (LWW tie-breaks, OR-set add-wins, commutativity), and the store/staleness
elizabetheonoja-art
approved these changes
Jun 26, 2026
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.
Multi-Chain Soroban Contract State Synchronizer Using CRDTs (#49)
Closes #49
What's included
src/types/crdt.tsLamportTimestamp,LWWRegister,ORSet,VectorClock, theCrdtEventdiscriminated union, resource diffs, and bounds (chain prioritymainnet > testnet > futurenet, 12-ledger / ~60 s reconcile timeout).src/utils/lamportClock.tsLamportClock(tick/observe/tickAfter) andcompareTimestamp— a total order by counter with chain-priority tie-breaking.src/utils/crdtMerge.tsorSetValues, and a batchedmergeEventsproducing per-resource diffs + vector clocks + chain-seen counters.src/workers/crdtMerge.worker.tssrc/store/slices/crdtSlice.tslastSeen, and a staleness watcher that flags a chain for a full snapshot re-fetch past the reconcile timeout.src/hooks/useContractState.tstests/unit/*