|
1 | | -/* |
2 | | -
|
3 | | -Package dkg implements engines for the DKG protocol. |
4 | | -
|
5 | | -ReactorEngine |
6 | | -
|
7 | | -ReactorEngine implements triggers to control the lifecycle of DKG runs. A new |
8 | | -DKG protocol is started when an EpochSetup event is sealed and finalized. The |
9 | | -subsequent phase transitions are triggered when specified views are encountered |
10 | | -(specifically when the first block of a given view is finalized). In between |
11 | | -phase transitions the engine regularly queries the DKG smart-contract to read |
12 | | -broadcast messages. |
13 | | -
|
14 | | -MessagingEngine |
15 | | -
|
16 | | -MessagingEngine is a network engine that enables consensus nodes to securely |
17 | | -exchange private DKG messages. Note that broadcast messages are not exchanged |
18 | | -through this engine, but rather via the DKG smart-contract. |
19 | | -
|
20 | | -Architecture |
21 | | -
|
22 | | -For every new epoch, the ReactorEngine instantiates a new DKGController with a |
23 | | -new Broker using the provided ControllerFactory. The ControllerFactory ties new |
24 | | -DKGControllers to the MessagingEngine via a BrokerTunnel which exposes channels |
25 | | -to relay incoming and outgoing messages (cf. module/dkg). |
26 | | -
|
27 | | - EpochSetup/OnView |
28 | | - | |
29 | | - v |
30 | | - +---------------+ |
31 | | - | ReactorEngine | |
32 | | - +---------------+ |
33 | | - | |
34 | | - v |
35 | | -*~~~~~~~~~~~~~~~~~~~~~* (one/epoch) |
36 | | -| +---------------+ | |
37 | | -| | Controller | | |
38 | | -| +---------------+ | |
39 | | -| | | |
40 | | -| v | |
41 | | -| +---------------+ | |
42 | | -| | Broker | | |
43 | | -| +---------------+ | |
44 | | -*~~~~~~~~|~~~~~~~~~\~~* |
45 | | - tunnel smart-contract client |
46 | | - | \ |
47 | | - +--------------+ +------------------+ |
48 | | - | Messaging | | DKGSmartContract | |
49 | | - | Engine | | | |
50 | | - +--------------+ +------------------+ |
51 | | -
|
52 | | -*/ |
53 | | - |
| 1 | +// Package dkg implements engines for the DKG protocol. |
| 2 | +// |
| 3 | +// # Reactor Engine |
| 4 | +// |
| 5 | +// The [ReactorEngine] implements triggers to control the lifecycle of DKG instances. |
| 6 | +// A new DKG instance is started when an EpochSetup service event is sealed. |
| 7 | +// The subsequent phase transitions are triggered when specified views are encountered. |
| 8 | +// Specifically, phase transitions for a view V are triggered when the first block with view ≥V is finalized. |
| 9 | +// Between phase transitions, we periodically query the DKG smart-contract ("whiteboard") to read broadcast messages. |
| 10 | +// Before transitioning the state machine to the next phase, we query the whiteboard w.r.t. the final view |
| 11 | +// of the phase - this ensures all participants eventually observe the same set of messages for each phase. |
| 12 | +// |
| 13 | +// # Messaging Engine |
| 14 | +// |
| 15 | +// The [MessagingEngine] is a network engine that enables consensus nodes to securely exchange |
| 16 | +// private (not broadcast) DKG messages. Broadcast messages are sent via the DKG smart contract. |
| 17 | +// |
| 18 | +// # Architecture |
| 19 | +// |
| 20 | +// In the happy path, one DKG instance runs every epoch. For each DKG instance, the [ReactorEngine] |
| 21 | +// instantiates a new, epoch-scoped module.DKGController and module.DKGBroker using the provided dkg.ControllerFactory. |
| 22 | +// The dkg.ControllerFactory ties new module.DKGController's to the [MessagingEngine] via a dkg.BrokerTunnel, |
| 23 | +// which exposes channels to relay incoming and outgoing messages (see package module/dkg for details). |
| 24 | +// |
| 25 | +// EpochSetup/EpochCommit/OnView events |
| 26 | +// ↓ |
| 27 | +// ┏━━━━━━━━━━━━━━━━━┓ |
| 28 | +// ┃ ReactorEngine ┃ |
| 29 | +// ┗━━━━━━━━━━━━━━━━━┛ |
| 30 | +// ↓ |
| 31 | +// ┏━━━━━━━━━━━━━━━━━┓ ╮ |
| 32 | +// ┃ Controller ┃ │ |
| 33 | +// ┗━━━━━━━━━━━━━━━━━┛ │ |
| 34 | +// ↓ ┝ Epoch-scoped components |
| 35 | +// ┏━━━━━━━━━━━━━━━━━┓ │ |
| 36 | +// ┃ Broker ┃ │ |
| 37 | +// ┗━━━━━━━━━━━━━━━━━┛ ╯ |
| 38 | +// │ │ |
| 39 | +// BrokerTunnel DKGContractClient |
| 40 | +// ↓ ↓ |
| 41 | +// ┏━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━━━━┓ |
| 42 | +// ┃ Messaging ┃ ┃ FlowDKG smart ┃ |
| 43 | +// ┃ Engine ┃ ┃ contract ┃ |
| 44 | +// ┗━━━━━━━━━━━━━━┛ ┗━━━━━━━━━━━━━━━━━━┛ |
54 | 45 | package dkg |
0 commit comments