ARCHIVED from builddistributedsystem.com on 2026-04-28 — URL: https://builddistributedsystem.com/tracks/advanced/tasks/task-10-5-crdt
TASK

Implementation

Build CRDTs for conflict-free replication: G-Counter (grow-only counter), G-Set, OR-Set.

Sample Test Cases

G-Counter increment and mergeTimeout: 5000ms
Input
{"src":"c0","dest":"n1","body":{"type":"init","msg_id":1,"node_id":"n1","node_ids":["n1","n2"]}}
{"src":"c1","dest":"n1","body":{"type":"gcounter_increment","msg_id":2}}
{"src":"c2","dest":"n2","body":{"type":"gcounter_increment","msg_id":3}}
{"src":"c3","dest":"n1","body":{"type":"gcounter_value","msg_id":4}}
Expected Output
(no output)

Hints

Hint 1
Merge must be commutative, associative, idempotent
Hint 2
G-Counter: only increment
Hint 3
OR-Set: add wins over remove
OVERVIEW

Theoretical Hub

CRDTs

Conflict-free Replicated Data Types allow concurrent updates that merge without conflicts. Merge is associative, commutative, idempotent.

Key Concepts

CRDTeventual consistencyconflict-free
main.py
python
Implement CRDTs - Advanced | Build Distributed Systems