aboutsummaryrefslogtreecommitdiffstats
path: root/docs/guides/federation/checkpoints.md
blob: 072fc801dd4feada1f44bc6e3435cb420a6c5c40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# Checkpoints

A checkpoint writes down what counts at some heads, so that nodes forget the rest and hold
what is relevant. The parties pass it as any version. The rules are the design's
([`federation.md`](../../federation.md), [Checkpoints](../../federation.md#checkpoints);
[`store.md`](../../store.md), [Checkpoints](../../store.md#checkpoints)).

## What one does

A version may name heads for a checkpoint (`checkpoint`). A node taking it **moves**:
it builds the checkpoint, the version current at those heads and the events that count
there, forgets everything else before them and every event not above them, and refuses
such events from then on. What it keeps is what judging needs: the version, every party's
keys and node list, the values that count, the proposals on the current version and
their votes.

What it loses: what counted no more before the heads, so a key added back or a place
given back brings back nothing signed before them; votes on versions behind it, so a
party that voted twice there shows only in the votes the parties' clients kept; and what
isn't above the heads, which its party signs again ([After a move](#after-a-move), below).

## Proposing one

A version that only moves the store on is the current one with the next `number`, the
current version's hash as `changes`, and the heads as `checkpoint`: `propose checkpoint`
writes and proposes it, at the heads the node shows then, as late as you can, so that
what was written before is in their history:

```sh
continuum-party --node http://tv:secret@localhost:3000 --key tv.key --record tv.record \
  propose checkpoint --yes
```

The heads are events after the current checkpoint, at which the current version is
current too, none in another's history, their IDs ascending; by hand, `heads` in `GET
/events` ([`proposing-and-voting.md`](proposing-and-voting.md),
[Writing a version](proposing-and-voting.md#writing-a-version)). The client signs the
proposal on the heads its node shows then, above the ones it names, as it must be.

Like any version, it lapses the proposals on the version before: propose one where
nothing that can still pass is proposed on the current version.

A node voting for its party by itself proposes checkpoints by its operator's rules: once
it holds so many events beyond its checkpoint (`--store-propose-events`), so many
versions changing more than moving to a checkpoint were written since it
(`--store-propose-versions`, 1 unless set), or so long after its store moved there
(`--store-propose-every`), at the heads it holds,
no more than an event may name (64, which it merges first under a revision with merge
events), where no proposal holds it back ([`voting-by-itself.md`](voting-by-itself.md),
[Its rules](voting-by-itself.md#its-rules)); and it backs what it proposes.

## Backing one

Back a checkpoint only where everything you held for a while before it was proposed is
among its heads, in their history, or above them, proposals and votes aside, which lapse
with the move: heads a proposer made up, built on little, would take back what was
written since, a key set dropping a stolen key among it. A node voting by itself backs one
only so, and so does a vote by hand through it (`continuum-party vote … --through`). A
party's client voting on its own (`continuum-party vote`) checks no heads: check them
yourself, or vote through such a node. A node shows what its parties signed that moving
there refuses, writes, key sets and node lists neither among the heads, in their history,
nor above them (`beside` of the proposal in `GET /events/counts`): those its parties sign
again.

* `--store-follow PARTY,…` has a node voting by itself follow those parties' `true`,
  by default on versions that only move to a checkpoint, and still by that rule, but not
  where a proposal changing more holds it back, as a node proposing one keeps to
  ([`voting-by-itself.md`](voting-by-itself.md),
  [Its rules](voting-by-itself.md#its-rules)).
* `--store-back-after` (ten minutes unless set) has it back none before its store held its
  checkpoint, or ran, that long.

## Two proposed at once

Nodes voting by themselves each propose a random wait after a checkpoint is due, so that
the first proposal reaches the others before they make one of their own. Two can still
come at once: in a cut, or where a party proposes one beside another on purpose. Each
party's one `true` is then on the one its node proposed, or follows.

Where two thirds back one of them, it passes, every node moves there, and the other
lapses with the move: nothing to do. Where neither gets two thirds, both stay proposed
and their backers stay bound, as a `true` holds its party until its proposal is dead, and
no node votes `false` by a rule: a `false` cast so is one a party it follows could count
on, to pass two checkpoints voting twice. Then the parties end one by hand:

1. See both, and who backs which: `continuum-party proposals`, or `status`.
2. Agree which one to end. Either moves the store to heads its backers held; `beside` of
   each in `GET /events/counts` says what moving there refuses.
3. More than a third of the parties vote `false` on it, none of them a party that backs it,
   as none votes `true` and `false` on one proposal:

   ```sh
   continuum-party vote 8d02… no              # by its client
   continuum-party vote 8d02… no --through    # a party whose node votes for it
   ```

4. It is dead. Its backers are free: their nodes back the other by themselves where they
   follow one of its backers, and a party votes `true` on it by hand otherwise.

A party that backed one may vote `false` on the other, so the backers of one, where they
are more than a third of the parties, end the other by themselves.

## After a move

A write signed on heads from before the move, still on its way, is refused (`it isn't
above the checkpoint's heads`). The client signs it again, on the heads its node shows:

```sh
continuum-party --node http://tv:secret@localhost:3000 --key tv.key --record tv.record \
  again
```

Votes and proposals aren't signed again: their version is behind.

## Nodes that weren't there

A node reads its store at every start from its document's checkpoint, or from the one
its operator pins (`--store-checkpoint`), which it finds in its document. Until a remake
leaves out what a checkpoint forgot, the document holds what came before, and a node
that was away builds the checkpoint from it as any. After such a remake, a node away
across it, or joining, takes the checkpoint only where its operator pins it: ask a node
you trust for it (`checkpoint` in `GET /events`)
([`running-a-node.md`](running-a-node.md), [Joining](running-a-node.md#joining)).