These problems practise running the algorithms of Module 2 by hand and adapting their proofs.
Problem 1
Problem 2.1 (Counting messages).A group has
nodes and uses eager reliable broadcast (Theorem 2.2) over reliable links.
- How many point-to-point messages does one broadcast cause when no node crashes?
- The sender crashes after sending its copy to exactly one other node, which is correct. How many messages are sent in total, at most and at least?
- With push gossip of fanout
, use Proposition 2.5 to give a number of rounds after the half-informed point such that the probability that some node is still uninformed is at most . Roughly how many messages does this phase send?
Solution
1. Every node handles the message once and sends
copies: messages. 2. The sender sent 1 copy. The recipient
is correct, so it relays to all 99 others, and every correct node that receives it for the first time relays to its 99 others. The 98 nodes other than the sender and are all correct (only the sender crashed), so all of them relay: messages. Copies addressed to the crashed sender count as sent even if they are never received. This is both the minimum and the maximum, because in eager reliable broadcast each correct node relays exactly once no matter in which order copies arrive. 3. We need
, that is , so rounds. In each round at most informed nodes send messages: at most messages, far fewer than the of eager broadcast. For the saving is modest; it grows with , since gossip sends messages in total and eager broadcast .
Problem 2
Problem 2.2 (Tracing the FIFO algorithm).Three nodes A, B, C run the FIFO algorithm of Module 2 over reliable broadcast. A broadcasts
(sequence numbers 0, 1, 2) and B broadcasts . Node C receives the tuples from reliable broadcast in the order
- Give, after each arrival, the messages C delivers, its buffer, and its
deliveredvector (order A, B, C).- Suppose A crashes and
never reaches any correct node. Which messages does C deliver? Is this allowed by FIFO broadcast?
Solution
1.
Arrival Delivered Buffer afterwards deliverednothing nothing , , 2. C delivers
, and stays in the buffer forever. This is allowed: A is faulty, so validity says nothing about its messages, and agreement only requires that correct nodes deliver the same messages. Since reaches no correct node, no correct node delivers or (both are stuck everywhere alike, as the intuition box after Theorem 2.7 explains). Delivering would violate FIFO order.
Problem 3
Problem 2.3 (Dependency vectors by hand).Three nodes A, B, C (in this order) run the causal algorithm of Module 2. The following happens.
A broadcasts
. C broadcasts
, before receiving anything. B delivers
and then , and broadcasts . A delivers
and broadcasts ; at that time A has not delivered .
- Give
of . - Node C has delivered only its own
. In which order may the messages arrive at C so that C delivers everything at the moment arrives? Give C’s final deliveredvector.- Which pairs among
are concurrent? Compare their vectors. Can a receiver tell from the vectors alone whether two messages are concurrent?
Solution
1. Each node delivers its own message when it broadcasts it (its own tuple comes back through reliable broadcast at once, and is ready). So:
: A has delivered nothing, : . : . : B delivered and , : . : A delivered (its own) and , : . 2. C has
. Both and need , which only provides. So C delivers everything when arrives exactly if arrives last: or . Then is delivered ( ), after which both and are ready and are delivered in some order. Final vector . 3.
: A broadcast before delivering , C broadcast before receiving anything. : neither node delivered the other’s message before broadcasting. All other pairs are ordered: , , , . For
: . For : . The vectors of each concurrent pair are equal, not incomparable, so (unlike vector clocks) dependency vectors alone do not reveal concurrency: equal vectors say nothing about whether the messages are related. The algorithm never needs to decide concurrency. It only needs Lemma 2.12, which compares the predecessor’s own number with the successor’s vector, for example .
Problem 4
Problem 2.4 (A tempting simplification breaks FIFO).A student simplifies the causal algorithm: when node
broadcasts, it sets (a copy) and does not overwrite entry with . Every node still delivers its own messages through reliable broadcast.
- Give an execution with two nodes in which some node delivers two messages of the same sender in the wrong order.
- Which step of the proof of Lemma 2.11 fails?
Solution
1. Nodes A and B. A broadcasts
and, before its own copy of has come back through reliable broadcast, broadcasts . (Asynchrony allows this: the reliable-broadcast delivery of A’s own message is a separate event.) Then at both broadcasts, so . At B, arrives first; its vector makes it ready, and B delivers before . That violates FIFO order, hence causal order. 2. The program-order case. It used
. With the student’s change, , which may still equal when has not yet delivered . The strict inequality that makes the successor wait for is lost. (If every node delivered its own message in the same step as the broadcast, entry of would equal and the change would be harmless; Kleppmann’s version does not rely on that.)
Problem 5
Problem 2.5 (Lamport total order is causal).Prove that the Lamport timestamp algorithm of Module 2 satisfies causal order: if
and node delivers , then delivered before . Conclude that, in executions without crashes, it implements causal-total order broadcast.
Solution
By the main claim in the proof of Theorem 2.16, a node delivers a message only after every message with a smaller key. So it suffices to show
, and for that it suffices to show it for one step of a causal chain, since on keys is transitive. Program order. The same node
broadcast , then . It increments before each send and never decreases, so the timestamp of is larger: . Delivery then broadcast. Node
delivered , with key , and later broadcast . Before delivering , node received it, and the receive handler set . The clock never decreases, and the broadcast of increments it first, so the timestamp of is at least . Hence . By induction on the length of the chain,
implies . If delivers , it has delivered every smaller key before, in particular . Together with total order, integrity, and liveness without crashes (Theorem 2.16), the algorithm implements causal-total order broadcast when no node crashes. The sequencer of Theorem 2.15 is causal for the same reason. A program-order step is FIFO order. For a delivery-then-broadcast step, node
delivered , so had already FIFO-broadcast ; only afterwards does send , so broadcasts later, and every node’s prefix of ‘s sequence contains before .