Skip to content

Commit 1ba709e

Browse files
committed
doc: update ARCHITECTURE.md to reflect recent commits
1 parent 0df0269 commit 1ba709e

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

ARCHITECTURE.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,18 @@ This repository contains a gRPC server which coordinates multi-party threshold p
3434
- `task` contains the logic for task computation
3535
- `protocol` contains the logic for protocol computation
3636
- `communicator` defines the communicator
37-
- `group` defines a created group
3837
- `error` contains definitions of error variants
3938
- `utils` contains a few helper functions
4039

41-
## Protobuf API
42-
TODO
43-
4440
## Persistence
4541
Most of the server state is persisted throughout server restarts, but some state is deliberately ephemeral and kept only in the RAM. The ephemeral state is mostly data which changes "rapidly", namely activity timestamps and messages exchanged during protocol computation.
4642

4743
Persistence is handled in the `state` module, with the exception of `task_store`, which is only used within `state`. This is to decouple the logic from bookkeeping.
4844

45+
The `persistence` module is supposed to be a "dumb" interface for communicating with the DB. In particular, it shouldn't validate data, perform complex logic, etc...
46+
4947
## State machines and state changes
50-
Much of the actual logic can be easily modelled using state machines. We use typestates to enforce valid state transitions. For example, a running task cannot change into a voting task.
48+
Much of the actual logic can be easily modeled using state machines. We use typestates to enforce valid state transitions. For example, a running task cannot change into a voting task.
5149

5250
Functions which update some state return a state change enum, which enforces handling of all possible situations and explicitly defines the logic. For example, saving a vote in a voting task can have three outcomes:
5351
- The task is accepted and transitions into a running task
@@ -77,12 +75,11 @@ Adding new protocols must be coordinated with the `meesign-crypto` repository.
7775

7876
Protocols are defined throughout several places in the codebase:
7977
1. The `proto/meesign.proto` files in this and `meesign-crypto` repositories define a `ProtocolType` enumeration. Both must be extended.
80-
2. A few trait implementations for `ProtocolType` must be extended in `main.rs`.
81-
3. Another `ProtocolType` enum must be extended in `persistence/enums.rs`.
82-
4. The `protocol_type` enum must be extended in the DB migrations.
83-
5. A module should be added into `protocols`, similar to other protocols defined there.
84-
6. The module needs to create a type implementing the `Protocol` trait for each of its variants, for example `<protocol>Group`, `<protocol>Sign`, ...
85-
7. The module should use constants from `meesign_crypto::protocols::<protocol>`.
78+
2. A few trait implementations for `ProtocolType` must be extended in `persistence/enums.rs`.
79+
3. The `protocol_type` enum must be extended in the DB migrations.
80+
4. A module should be added into `protocols`, similar to other protocols defined there.
81+
5. The module needs to create a type implementing the `Protocol` trait for each of its variants, for example `<protocol>Group`, `<protocol>Sign`, ...
82+
6. The module should use constants from `meesign_crypto::protocols::<protocol>`.
8683

8784
The overall structure should reflect the way other protocols are implemented. See the `protocols/frost.rs` module for example.
8885

@@ -91,13 +88,12 @@ Adding new task types must be coordinated with the `meesign-client` repository.
9188

9289
If the task follows the usual task phases (voting, declined, running, failed, finished), then it should follow the structure of other task types already established in this repo. Otherwise, it must be handled exceptionally.
9390

94-
Protocols are defined throughout several places in the codebase:
95-
1. The `proto/meesign.proto` files in this and `meesign-crypto` repositories define a `ProtocolType` enumeration. Both must be extended.
96-
2. A few trait implementations for `ProtocolType` must be extended in `main.rs`.
97-
3. Another `ProtocolType` enum must be extended in `persistence/enums.rs`.
98-
4. The `protocol_type` enum must be extended in the DB migrations.
99-
5. A module should be added into `protocols`, similar to other protocols defined there.
100-
6. The module needs to create a type implementing the `Protocol` trait for each of its variants, for example `<protocol>Group`, `<protocol>Sign`, ...
101-
7. The module should use constants from `meesign_crypto::protocols::<protocol>`.
91+
Here is a general process for when the new task type follows the usual task phases:
92+
1. The `proto/meesign.proto` file defines a `TaskType` enumeration. It must be extended.
93+
2. A few trait implementations for `TaskType` must be extended in `persistence/enums.rs`.
94+
3. The `task_type` enum must be extended in the DB migrations.
95+
4. The `RunningTaskContext` enum in `tasks/mod.rs` must be extended.
96+
5. A module should be added into `tasks`, similar to other tasks defined there.
97+
6. The module needs to create a type implementing the `RunningTask` trait.
10298

103-
The overall structure should reflect the way other protocols are implemented. See the `protocols/frost.rs` module for example.
99+
The overall structure should reflect the way other tasks are implemented. See the `tasks/sign.rs` module for example.

0 commit comments

Comments
 (0)