2024-01-08 14:24:20 +00:00
|
|
|
---
|
|
|
|
style: |
|
|
|
|
img[alt~="center"] {
|
|
|
|
display: block;
|
|
|
|
margin: 0 auto;
|
|
|
|
}
|
|
|
|
|
|
|
|
h3 {
|
|
|
|
font-size: 1.2em;
|
|
|
|
position: fixed;
|
|
|
|
top: 1em;
|
|
|
|
left: 50%;
|
|
|
|
transform: translateX(-50%);
|
|
|
|
}
|
|
|
|
|
|
|
|
h4 {
|
|
|
|
text-align: center;
|
|
|
|
font-size: 1.2em;
|
|
|
|
text-align: center;
|
|
|
|
}
|
|
|
|
|
|
|
|
img[alt~="top-m"] {
|
|
|
|
margin-top: 40px;
|
|
|
|
}
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2024-01-08 19:57:53 +00:00
|
|
|
# A Paxos Implementation
|
2024-01-08 14:24:20 +00:00
|
|
|
|
2024-01-09 10:32:13 +00:00
|
|
|
Andre Henriques, Seoeun Lee
|
2024-01-08 14:24:20 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
# Basis of the implentation
|
|
|
|
|
|
|
|
|
|
|
|
![Structure](./structure.png) ![Steps](./steps.png)
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
# Steps
|
|
|
|
|
|
|
|
```elixir
|
|
|
|
receive do
|
|
|
|
{:leader_elector, proc} -> ...
|
|
|
|
{:propose, inst, value, t, pid_to_inform} -> ...
|
|
|
|
{:prepare, proc, inst, ballot} -> ...
|
|
|
|
{:nack, inst, ballot} -> ...
|
|
|
|
{:prepared, inst, ballot, accepted_ballot, accepted_value} -> ...
|
|
|
|
{:accept, inst, ballot, value} -> ...
|
|
|
|
{:accepted, inst, ballot} -> ...
|
|
|
|
{:decide, inst, value} -> ...
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
### Step 1 - "Requirements"
|
|
|
|
|
|
|
|
![50% center](./first-step.png)
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2024-01-08 18:42:29 +00:00
|
|
|
### Step 1 - "Requirements" non-trivial aspects
|
|
|
|
|
|
|
|
```elixir
|
|
|
|
receive do
|
|
|
|
{:propose, inst, value, t, pid_to_inform} ->
|
|
|
|
...
|
|
|
|
broadcast({:other_propose, inst, value})
|
|
|
|
...
|
|
|
|
{:other_propose, inst, value} -> ...
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2024-01-08 19:09:23 +00:00
|
|
|
---
|
|
|
|
|
2024-01-08 14:24:20 +00:00
|
|
|
### Step 2 - "Prepare"
|
|
|
|
|
|
|
|
![w:600 center](./second-step.png)
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2024-01-08 18:42:29 +00:00
|
|
|
### Step 2 - "Prepare" non-trivial aspects
|
|
|
|
|
|
|
|
```elixir
|
|
|
|
receive do
|
|
|
|
{:nack, inst, ballot, new_ballot} ->
|
|
|
|
...
|
|
|
|
broadcast({:abort, inst, ballot})
|
|
|
|
...
|
|
|
|
{:abort, inst, ballot} -> ...
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2024-01-08 14:24:20 +00:00
|
|
|
### Step 3 - "Accept"
|
|
|
|
|
|
|
|
![w:600 center](./third-step.png)
|
|
|
|
|
2024-01-08 18:42:29 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
### Step 3 - "Accept" non-trivial aspects
|
|
|
|
|
|
|
|
```elixir
|
|
|
|
receive do
|
|
|
|
{:accepted, inst, ballot} ->
|
|
|
|
...
|
|
|
|
broadcast({:decide, inst, value})
|
|
|
|
...
|
|
|
|
{:decide, inst, value} -> ...
|
|
|
|
end
|
|
|
|
```
|
2024-01-08 14:24:20 +00:00
|
|
|
|
2024-01-08 19:42:07 +00:00
|
|
|
---
|
|
|
|
|
2024-01-08 14:24:20 +00:00
|
|
|
### Step 4 - "Leader Crash"
|
|
|
|
|
|
|
|
![w:600 center](./fourth-step.png)
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
# Application
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
### Atomas
|
|
|
|
|
|
|
|
![w:300 center top-m](./atomas.png)
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
## Safety
|
|
|
|
- If a game state exists, then it was created by a user
|
|
|
|
- The game state can not divert.
|
|
|
|
|
|
|
|
## Liveness
|
|
|
|
- Eventually all users will have the same game state
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2024-01-09 12:09:25 +00:00
|
|
|
## Interface
|
|
|
|
|
|
|
|
```elixir
|
|
|
|
receive do
|
|
|
|
{:start_game, paticipants} -> {:new_game, game, game_state}
|
|
|
|
{:make_move, game, participant, move} -> {:update_game, game, game_state} or {:game_finished, game}
|
|
|
|
{:get_game_state, game} -> {:game_state, game, game_state}
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
---
|
|
|
|
|
2024-01-08 14:24:20 +00:00
|
|
|
#### Questions?
|