mirror of
https://github.com/logos-messaging/OpChan.git
synced 2026-01-14 10:23:05 +00:00
2.9 KiB
2.9 KiB
Minimal SDS Integration Test Plan
Overview
This branch implements a minimal proof-of-concept for SDS (Scalable Data Sync) integration in OpChan, focusing exclusively on vote consistency.
What Changed
1. Core SDS Implementation
- New Package: Added
@waku/sdsdependency - MinimalSDSWrapper: Basic implementation at
src/lib/waku/sds/minimal-sds.ts- Manages Lamport timestamps for causal ordering
- Tracks causal history (last 3 message IDs)
- Provides
isCausallyNewer()comparison
2. Vote Message Enhancement
- Vote messages now include SDS metadata:
{ sds: { channelId: "opchan:votes:all", lamportTimestamp: number, causalHistory: string[] } }
3. Conflict Resolution
- When receiving votes, the system now:
- Checks if a vote already exists for the same target+author
- Uses Lamport timestamps to determine which is newer
- Only updates if the incoming vote is causally newer
- Logs all decisions for debugging
4. Visual Indicators
- Added SDS status badge in header showing "SDS: Active (Votes)"
- Debug console logs show SDS operations
Test Scenarios
Scenario 1: Basic Vote Ordering
- User A upvotes a post
- User A changes to downvote
- Verify the downvote is applied (newer Lamport timestamp)
Scenario 2: Concurrent Votes
- Open two browser tabs with same wallet
- Vote differently in each tab quickly
- Verify the last vote wins based on causal ordering
Scenario 3: Network Delays
- Vote on a post
- Disconnect network
- Change vote
- Reconnect
- Verify votes are ordered correctly when synced
Scenario 4: Vote History
- Vote multiple times on same content
- Check console logs for SDS debug messages
- Verify causal history is maintained
Debug Output
Enable browser console to see SDS operations:
[SDS HH:MM:SS] VOTE SENDING - postId:userAddress
[SDS HH:MM:SS] VOTE NEW - postId:userAddress
[SDS HH:MM:SS] VOTE UPDATED - postId:userAddress (old: 5, new: 7)
[SDS HH:MM:SS] VOTE IGNORED_OLDER - postId:userAddress
Verification
Console Commands
// Check current vote state
messageManager.messageCache.votes
// Check if message has SDS metadata
messageManager.messageCache.votes['postId:address'].sds
Expected Behavior
- Votes should never "flip back" to older states
- Lamport timestamps should increase monotonically
- Causal history should contain previous vote IDs
Limitations
This minimal implementation:
- Only applies to votes (not posts, comments, or moderation)
- Uses a single channel for all votes (not optimal for scale)
- Doesn't implement full SDS features (sync messages, bloom filters)
- No persistence of SDS state between sessions
Next Steps
If this test is successful:
- Extend to comments for thread ordering
- Add per-cell channels for better scalability
- Implement sync messages for reliability
- Add persistence of channel state
- Implement gap detection and recovery