Unit 6 of 15 · about 5 hours · derive, implement

State-based and operation-based CRDT requirements and one CRDT implementation

CRDTs give sufficient algebraic and delivery conditions for convergence without consensus. Derive the conditions for the particular type instead of treating one delivery contract as necessary for every design.

You'll be able to

  • State the state-based convergence conditions (a join-semilattice merge, inflationary updates and eventual dissemination) and a sufficient operation-based contract (reliable delivery, each operation applied once, concurrent operations commuting).
  • Prove the operation-based map CRDT converges and sketch its multi-value variant.
  • Optionally implement one CRDT (G-Counter or OR-Set) with merge-law and convergence tests.

Covers

State-based CRDT semilattice requirementsOperation-based CRDT delivery requirementsOne state-based or operation-based CRDT implementation
1

Read

In this order, only the parts listed

0 of 3 done

  1. Shapiro et al. 2011, Sections 1 to 3A Comprehensive Study of Convergent and Commutative Replicated Data Types (Shapiro et al., 2011)

    Sections 1 to 3: state-based and operation-based definitions, the join-semilattice merge laws and the delivery conditions, plus one example type for your implementation

    Read one example type only (G-Counter or OR-Set), not the whole catalog.

  2. Section 8.1: collaboration and conflict resolutionCambridge Concurrent and Distributed Systems Notes (Kleppmann) - CRDTs and Collaboration

    Section 8.1 (pp. 78-81): the operation-based map on Slides 144-145, Exercises 21 and 22 on p. 80, and the state-based map with its merge and the merge laws on Slides 146-147, p. 81

  3. HLD Handbook: CRDTs chapterHLD Handbook - CRDTs, Multi-Region and Architecture Trade-offs

    State-based (CvRDT) merge as least upper bound with the G-Counter elementwise-max code, op-based (CmRDT) over causal broadcast with the op-based OR-Set tag diagram, and the tombstone and metadata cost section

    Use the chapter for implementation texture (incremental-state CRDTs, reported Automerge figures). The requirements come from Shapiro and Kleppmann, not from here.

2

Focus on

  • G-Counter convergence uses a join-semilattice merge, inflationary increments to each replica's own component, stable replica identities and eventual dissemination of every update. Elementwise max is commutative, associative and idempotent, but the laws alone are not the whole argument.
  • A common sufficient operation-based contract is reliable causal delivery, each operation applied once, and concurrent operations commuting. Some types, including the notes' timestamped map, tolerate any order and repeats; derive the contract for your type.
  • Unique tags decide remove semantics. An OR-Set remove only removes observed tags, so a concurrent add with a fresh tag survives.
  • Tombstones and identifiers are the price. Removals keep metadata until late arrivals can no longer resurrect removed state; state the membership and causal-stability assumptions that allow collection, or budget for unbounded retention.
Common mistakes · 3
  • Calling a lossy state exchange op-based. State merge recovers from a lost message only because a later exchange carries the same state; operation delivery needs the broadcast guarantees the type requires.
  • Reading the HLD op-based section as two delivery modes. It states one requirement: causal order with duplicate suppression so each operation applies once. The transport alone does not give the second half.
  • Forgetting the tombstone set in a 2P-Set-style remove. A removed element re-added without fresh identity resurrects or vanishes depending on which replica you ask.
3

Try it yourself

Closed-book, before checking anything

Closed-book, merge {'A': 3} with {'B': 2, 'C': 5} by elementwise max to {'A': 3, 'B': 2, 'C': 5} with value , and state which merge law covers reorder, merge-of-merges and redelivery.
4

Quiz yourself

Answer first, then mark it. Missed ones go to Review.

0 got · 0 missed

  1. 1.State the three merge laws and the fault each one absorbs.Answer

    Commutative (reorder), associative (regrouping merges of merges), idempotent (duplication and redelivery). They make merge order and repetition irrelevant; convergence also needs every update to reach every replica eventually.

  2. 2.Why does the operation-based map need reliable broadcast while the state-based map works over best-effort broadcast?Answer

    Repeated state merges are harmless, and a lost message is repaired by a later exchange that carries the same state. The operation-based map needs every operation delivered eventually; its timestamped operations then tolerate reordering and repeats.

  3. 3.Two replicas hold {'A': 3} and {'B': 2, 'C': 5}. What is the merged state and its value?Answer

    {'A': 3, 'B': 2, 'C': 5} with value : elementwise max, then the sum.

  4. 4.A remove and a concurrent add of x race in an OR-Set. Does x survive?Answer

    Yes. The remove carries only observed tags; the concurrent add uses a fresh tag the remove never saw, so the merge keeps the new tagged entry.

  5. 5.What does Exercise 22 change relative to the last-writer-wins map?Answer

    Concurrent updates for a key keep all values (multi-value register semantics) instead of only the greatest timestamp; the reader returns the set.

5

Practice

You're done when

You prove the map's convergence from Exercise 21's premises without notes and explain both replication styles' assumptions. If you build the optional G-Counter, its merge-law and convergence tests pass and you state its dissemination contract.

Only when you can do this without notes.

Leads to

Notes

Resources · 3 for this unit, 12 more in the section

Also in this section

  • TLA+ Video CourseLeslie Lamport · primary

    Complete lectures 1 to 10 (lectures 8, 9 and 10 have two parts each) and check the corrections page, while specifying a reduced transaction, workflow or replicated-log model from the capstone. Run TLC after every extension, report the model bounds with every result, and retain the first meaningful counterexample rather than polishing only the final model.

  • TLA+ ExamplesTLA+ Foundation · support

    Check specifications/transaction_commit/ (TCommit.tla, TwoPhase.tla, PaxosCommit.tla with their .cfg files) with TLC alongside the lectures, and read the Paxos specifications for depth. specifications/TwoPhase/ is a hardware handshake, not transaction commit.

  • Learn TLA+Hillel Wayne · support

    Use the core lessons and the examples as a second explanation when a lecture stalls, and as the PlusCal reference if you write algorithms rather than raw actions.

  • Hypothesis - Stateful TestingHypothesis · required

    Use RuleBasedStateMachine against a reference model for property-based state-machine tests of your extension, keep the failing seeds and shrunk examples, and plant a bug to show the machine detects it.

  • MIT 6.5840 - Verification Lecture and Final ProjectMIT PDOS · required

    Study the Spring 2026 verification lecture and IronFleet reading, then use the final-project guidance to frame a bounded real-system extension, evaluation and report. Course grading and staff review are unavailable to self-study, so use the roadmap defense rubric.

  • Jepsen - Consistency Models and AnalysesJepsen · required

    Use the framework's generator, client, nemesis and checker roles to design the campaign, Knossos for single-register linearizability and Elle for transactional anomalies on recorded histories, and the public analyses for fault models. A simplified local checker must declare its object, model and completeness limits.

  • Elle: Inferring Isolation Anomalies from Experimental Observations (Kingsbury and Alvaro)arXiv · required

    Read how Elle infers version orders from list-append and register histories and detects cycles for G0 to G2. It needs complete histories, and a clean run is not a proof of serializability.

  • How Amazon Web Services Uses Formal Methods (Newcombe et al., 2015)Amazon Science · support

    Read it for why industrial teams specify designs in TLA+ and which bugs model checking found that testing missed. Its effort figures are anecdotes, not benchmarks.

  • FoundationDB: A Distributed Unbundled Transactional Key Value Store (Zhou et al., 2021)FoundationDB · support

    Read the simulation-testing section (deterministic single-threaded simulation, fault injection, seed replay) as the model for your own scheduler, and the architecture for unbundled transactions.

  • DDIA 2e - Chapters 9, 10 and 14 ReviewMartin Kleppmann and Chris Riccomini · required

    Revisit uncertainty, consistency, consensus and responsible system design while extracting the final contract. Use the book to challenge assumptions and alternatives, not to replace executable evidence.

  • CMU 15-721 - Selected Advanced Database Systems UnitsCarnegie Mellon Database Group · depth

    Select at most one lecture group that informs your extension: #02 and #03 (data formats and encoding), #08 (scheduling and coordination) or #17 to #22 (system analyses such as BigQuery, Databricks, Snowflake, DuckDB and Redshift), with their papers. The course project needs a group, cloud credits and staff sign-off, so there is no runnable self-study project.

  • Replicated Log and Stream Processor - Final CapstoneRoadmap-Final · support

    Finish the protocol and invariant specification, deterministic fault campaign, bounded real-code extension, fallback, ablations, workload regions, negative result, operations dossier and independent reproduction package.