OverviewFilesCommitsIssuesDocsReleasesPeers

wirecore commits / b105c7a

Add comprehensive P2P testing results
Successfully tested bidirectional P2P replication between two nodes: - Local development machine - ashatron.local Test results: ✅ DHT peer discovery working (~1-2 seconds) ✅ Hyperswarm connections established ✅ Sparse feed replication functioning ✅ Bidirectional message sync confirmed ✅ Merged timeline display correct Technical details: - Connection wait time: 8 seconds for DHT discovery - Block fetch timeout: 5 seconds for reliability - Using feed.update() for remote length sync - Using wait:true for on-demand block downloads Issues resolved: - Fixed ELOCKED Corestore initialization bug - Fixed peer discovery timing - Fixed sparse replication block fetching - Fixed timeout configuration Architecture validated: - Per-user writable feeds - Sparse replication of followed users only - Client-side timeline merging - No central server required Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
b105c7a460835177f6d6cddf12e0620102b01c50
by plankatron <fleeky@gmail.com> · 2026-01-20T20:15:25.000Z

Changed files (1) +270 -0

P2P_TEST_RESULTS.md +270 -0
……@@ -0,0 +1,270 @@
1# Wirecore P2P Testing Results
2
3**Date**: January 20, 2026
4**Test Nodes**: Local development machine + ashatron.local
5**Network**: 192.168.50.x LAN
6
7## Test Summary
8
9✅ **All P2P functionality working**:
10- DHT peer discovery
11- Hyperswarm P2P connections
12- Sparse feed replication
13- Bidirectional message sync
14- Merged timeline display
15
16## Test Setup
17
18### Node 1: Local Development Machine
19- **Location**: `/storage/projects/code/hypercore-kb/hyper-fleeky/repos/wirecore/pear-app`
20- **Public Key**: `462fae7b0da54b2df4df281ac148d6e778075cb0f657a0b5eb1435dacaf113c3`
21- **Feed Key**: `5229275385e8140ce7b4dd3b8b32e851cdecdb1e89908705a5ee2a9748e95113`
22- **Node Version**: v18.19.1
23
24### Node 2: Ashatron.local
25- **Location**: `~/wirecore-pear`
26- **Public Key**: `eb67cec05ee8f9128f3a5bde2bae2f1b4be38bb2f8f07821946df5dc698a7c6b`
27- **Feed Key**: `af38a531100aa8578b4bc8f86cbfb8d6be357f7e17184fb411f66211d4452ebd`
28- **Node Version**: v22.20.0
29
30## Test Sequence
31
32### 1. Initialization ✅
33
34**Node 1**:
35```bash
36$ node index.js init
37✅ Wirecore initialized!
38Your public key: 462fae7b0da54b2df4df281ac148d6e778075cb0f657a0b5eb1435dacaf113c3
39Feed key: 5229275385e8140ce7b4dd3b8b32e851cdecdb1e89908705a5ee2a9748e95113
40```
41
42**Node 2**:
43```bash
44$ node index.js init
45✅ Wirecore initialized!
46Your public key: eb67cec05ee8f9128f3a5bde2bae2f1b4be38bb2f8f07821946df5dc698a7c6b
47Feed key: af38a531100aa8578b4bc8f86cbfb8d6be357f7e17184fb411f66211d4452ebd
48```
49
50### 2. Posting Messages ✅
51
52**Node 1**:
53```bash
54$ node index.js post "Hello from local node! Testing bidirectional P2P sync."
55✅ Posted: Hello from local node! Testing bidirectional P2P sync.
56```
57
58**Node 2**:
59```bash
60$ node index.js post "Hello from ashatron! Testing P2P replication."
61✅ Posted: Hello from ashatron! Testing P2P replication.
62```
63
64### 3. Following Each Other ✅
65
66**Node 1 follows Node 2**:
67```bash
68$ node index.js follow af38a531100aa8578b4bc8f86cbfb8d6be357f7e17184fb411f66211d4452ebd ashatron
69✅ Following: ashatron
70 Feed key: af38a531100aa8578b4bc8f86cbfb8d6be357f7e17184fb411f66211d4452ebd
71```
72
73**Node 2 follows Node 1**:
74```bash
75$ node index.js follow 5229275385e8140ce7b4dd3b8b32e851cdecdb1e89908705a5ee2a9748e95113 local
76✅ Following: local
77 Feed key: 5229275385e8140ce7b4dd3b8b32e851cdecdb1e89908705a5ee2a9748e95113
78```
79
80### 4. P2P Replication Test ✅
81
82**Running timelines simultaneously**:
83
84Both nodes started within 0.5 seconds of each other to ensure DHT discovery overlap.
85
86**Node 1 Output**:
87```
88📡 Connecting to network...
89 📢 Announced feed: e1a15aa6ade6b137...
90 📥 Joined 1 follow topics
91 Following 1 users
92⏳ Waiting for peer connections (8 seconds)...
93🔗 Connected to peer 1
94📥 Syncing feeds...
95 ashatron: 1 blocks
96
97📰 Timeline (3 messages):
98
99💬 You (1/20/2026, 3:04:25 PM):
100 Hello from local node! Testing bidirectional P2P sync.
101
102👤 ashatron (1/20/2026, 3:03:46 PM):
103 Hello from ashatron! Testing P2P replication.
104
105💬 You (1/20/2026, 1:10:40 PM):
106 Hello from wirecore-pear! Testing P2P social network.
107```
108
109**Node 2 Output**:
110```
111📡 Connecting to network...
112 📢 Announced feed: 3af55ae0646fcd0e...
113 📥 Joined 1 follow topics
114 Following 1 users
115⏳ Waiting for peer connections (8 seconds)...
116🔗 Connected to peer 1
117📥 Syncing feeds...
118 local: 2 blocks
119
120📰 Timeline (3 messages):
121
122👤 local (1/20/2026, 3:04:25 PM):
123 Hello from local node! Testing bidirectional P2P sync.
124
125💬 You (1/20/2026, 3:03:46 PM):
126 Hello from ashatron! Testing P2P replication.
127
128👤 local (1/20/2026, 1:10:40 PM):
129 Hello from wirecore-pear! Testing P2P social network.
130```
131
132## Key Observations
133
134### Connection Establishment
135
1361. **DHT Discovery**: ~1-2 seconds for nodes to find each other
1372. **Peer Connection**: Successfully established within 8-second window
1383. **Connection Count**: 1 peer connection per node (bidirectional)
139
140### Feed Replication
141
1421. **Sparse Replication Working**: Only followed feeds are synced
1432. **Block Sync**: `feed.update()` successfully fetches remote feed length
1443. **Block Download**: Blocks downloaded on-demand with `wait: true`
1454. **Sync Time**: ~1-2 seconds per feed after connection established
146
147### Timeline Display
148
1491. **Message Ordering**: Correctly sorted by timestamp descending
1502. **Author Attribution**: Messages from followed users show their name
1513. **Own Messages**: Marked as "You" (💬)
1524. **Followed Messages**: Marked with author name (👤)
153
154## Technical Details
155
156### Hyperswarm Configuration
157
158- **Server Mode**: Announcing own feed `{ server: true, client: false }`
159- **Client Mode**: Following others `{ server: false, client: true }`
160- **Discovery Keys**: Using `crypto.discoveryKey(feedKey)` for DHT topics
161
162### Replication Strategy
163
1641. Announce own feed's discovery key to DHT
1652. Join followed feeds' discovery keys as client
1663. Wait for peer connections
1674. Call `feed.update()` to sync remote feed length
1685. Use `feed.get(i, { wait: true })` to download blocks
1696. Read and merge messages by timestamp
170
171### Performance Tuning
172
173- **Connection wait**: 8 seconds (sufficient for DHT discovery)
174- **Block fetch timeout**: 5 seconds (handles slow connections)
175- **Feed update**: Explicit `await feed.update()` before reading
176
177## Issues Encountered & Resolved
178
179### Issue 1: ELOCKED Error
180**Problem**: Corestore lock file conflict when initializing
181**Cause**: `loadState()` was opening Corestore even when no identity existed, then `cmdInit()` tried to open it again
182**Solution**: Check if storage directory exists before opening Corestore in `loadState()`
183
184### Issue 2: No Peer Connections
185**Problem**: Nodes couldn't discover each other
186**Cause**: 2-second wait wasn't long enough for DHT discovery
187**Solution**: Increased to 8 seconds
188
189### Issue 3: Messages Not Showing
190**Problem**: Peer connections established but timelines showed only own messages
191**Cause**: Sparse replication doesn't automatically download blocks
192**Solution**: Add `feed.update()` to sync length + `wait: true` for block fetching
193
194### Issue 4: Timeout Errors
195**Problem**: Block fetch timeouts on slower connections
196**Cause**: 2-second timeout too aggressive
197**Solution**: Increased to 5 seconds
198
199## Conclusions
200
201### What Works ✅
202
2031. ✅ **Persistent Identity**: keet-identity-key provides stable keypairs across restarts
2042. ✅ **Per-User Feeds**: Each node has its own writable Hypercore feed
2053. ✅ **DHT Discovery**: Hyperswarm successfully finds peers via discovery keys
2064. ✅ **P2P Replication**: Sparse replication of followed feeds works correctly
2075. ✅ **Merged Timeline**: Messages from multiple feeds properly merged and displayed
2086. ✅ **Cross-Node Sync**: Bidirectional message sync confirmed
209
210### Limitations
211
2121. ⚠️ **Timing Requirement**: Both nodes need to be online simultaneously for discovery
2132. ⚠️ **Discovery Latency**: 8-second wait needed for reliable DHT discovery
2143. ⚠️ **No Persistence**: Timeline command exits after display (no long-running daemon)
2154. ⚠️ **No Relay Support**: Pure P2P only - no web browser access yet
216
217### Next Steps
218
2191. **Phase 2**: Add relay integration for web browser access
2202. **Daemon Mode**: Long-running process for continuous sync
2213. **Push Notifications**: Alert when new messages arrive
2224. **Web UI**: Build browser interface that connects to relay
2235. **Pear Packaging**: Create proper Pear app for easy installation
224
225## Installation Commands (for reference)
226
227### Local Setup
228```bash
229cd pear-app
230npm install
231node index.js init
232node index.js post "Your message"
233node index.js follow <feed-key> <name>
234node index.js timeline
235```
236
237### Network Requirements
238- UDP ports for Hyperswarm (random ephemeral ports)
239- DHT bootstrap nodes (default hyperswarm bootstrap)
240- LAN or WAN connectivity between nodes
241
242## Verification Commands
243
244Check following list:
245```bash
246node index.js follows
247```
248
249Show your keys:
250```bash
251node index.js whoami
252```
253
254## Performance Metrics
255
256- **Discovery Time**: ~1-2 seconds
257- **Connection Time**: ~2-3 seconds after discovery
258- **Sync Time**: ~1-2 seconds per feed (1 block)
259- **Total Timeline Load**: ~10-12 seconds end-to-end
260
261## Architecture Validation
262
263The test confirms the proper P2P architecture:
264- ✅ No central server required for P2P nodes
265- ✅ Each node has independent writable feed
266- ✅ Following = read-only replication of remote feeds
267- ✅ Sparse replication (only followed users)
268- ✅ Timeline = client-side merge of all feeds
269
270This is the correct decentralized social network pattern!