Skip to content

feat(frontend): CRDT Merkle-DAG Cryptographic Signatures, Compaction & 3-Way Partition Reconciliation (#309) - #332

Closed
huangji6693-max wants to merge 1 commit into
LynxXProtocol:mainfrom
huangji6693-max:feat/crdt-merkle-dag-signatures-309
Closed

huangji6693-max wants to merge 1 commit into
LynxXProtocol:mainfrom
huangji6693-max:feat/crdt-merkle-dag-signatures-309

Conversation

@huangji6693-max

Copy link
Copy Markdown

Summary

Closes #309
/claim #309

Implements cryptographic node signing (Ed25519 via @stellar/stellar-sdk Keypair), Byzantine signature quarantine, Merkle-DAG compaction (>= 60% storage reduction on superseded intermediate milestone updates), and 3-way network partition reconciliation for the offline-first CRDT Merkle-DAG sync layer.

Key Changes

  1. Ed25519 Cryptographic Signatures for CRDT Nodes & Vector Clocks (merkleDAG.ts, secureVectorClock.ts):
    • Added signDAGNode, createSignedDAGNode, verifyNodeSignature, and addSignedNode on MerkleDAG using Stellar Ed25519 (Keypair.fromSecret / Keypair.fromPublicKey) over canonical node digests (hash|author|timestamp|parents|payload).
    • Added createEd25519VectorClock, verifyEd25519VectorClock, and pruneSaturatedVectorClock in secureVectorClock.ts to protect vector clock increments against Sybil clock-inflation and replay attacks.
  2. Byzantine Healer Signature Quarantine (byzantineHealer.ts):
    • Extended QuarantineReason with 'bad-signature' and integrated verifyNodeSignature into ByzantineHealer.heal() so nodes with forged or tampered Ed25519 signatures are immediately quarantined before causal ancestor closure.
  3. Merkle-DAG Compaction & 3-Way Partition Reconciliation (merkleDAG.ts):
    • Implemented encodeMilestonePayload, decodeMilestonePayload, and materializeMilestoneState with deterministic causal + LWW (timestamp, author, id) ordering.
    • Implemented compact() to prune superseded intermediate milestone operations into a signed checkpoint while preserving all terminal heads and final materialized milestone state, achieving >75% storage reduction (exceeding the >= 60% requirement).
    • Implemented reconcileThreeWay(replicaA, replicaB, replicaC) to heal 3-way network partitions and deterministically converge all replicas onto the same materialized state and unified multi-parent merge head.

Verification

  • Unit Tests (vitest):
    • npx vitest run src/lib/crdt/merkleDAG.test.ts src/lib/crdt/secureVectorClock.test.ts src/lib/crdt/byzantineHealer.test.ts → 43 / 43 passing
    • Covers Ed25519 signature verification & tampered payload rejection, Byzantine healer 'bad-signature' quarantine, >= 60% DAG compaction storage reduction (78.6% measured on 500 intermediate updates), and 3-way partition convergence.
  • Linter & Typecheck:
    • npm run lint (oxlint) → 0 errors
    • npx tsc -b --noEmit → 0 errors
    • node scripts/ci/check-numeric-ids.mjs → PASSED

@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a0f21636-dcdf-40cd-8936-e9fbb0d3bc50
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

design(frontend): Define signed CRDT sync guarantees

2 participants