Paxos acceptors preserve promises and accepted proposals across protocol messages. A proposer can move forward only when enough acceptors promise not to accept older proposals.
Design a PaxosAcceptor class:
PaxosAcceptor() creates an acceptor with no promise and no accepted proposal.int[] prepare(int proposalNumber) processes a Phase 1 prepare request.boolean accept(int proposalNumber, int value) processes a Phase 2 accept request.int[] accepted() returns the currently accepted [proposalNumber, value], or [-1, -1] when none exists.The acceptor stores promised, acceptedProposal, and acceptedValue, all initially -1.
For prepare(n):
n > promised, set promised = n and return [1, acceptedProposal, acceptedValue].[0, acceptedProposal, acceptedValue].For accept(n, value):
n >= promised, store promised = n, acceptedProposal = n, and acceptedValue = value, then return true.false without changing any state.Proposal numbers are globally unique, so one proposal number is never used with two different values.
Input:
Output:
Explanation: Prepare 10 establishes the promise. The matching accept request is allowed and records value 42.
Input:
Output:
Explanation: The higher prepare reports the accepted proposal and value. It does not erase them. Once proposal 8 is promised, prepare 6 is rejected.
0 <= proposalNumber <= 10^9-10^9 <= value <= 10^910^5 method calls are made per object.| Call | Returns |
|---|---|
| new PaxosAcceptor() | null |
| prepare(10) | [1,-1,-1] |
| accept(10, 42) | true |
| accepted() | [10,42] |
Proposal 10 obtains the promise. Its accept request meets that promise, so value 42 becomes the accepted value.
Run checks these cases. Submit also runs a larger hidden set.

