Skip to content

Commit 154f168

Browse files
committed
Fix docs/website/ code formatting
By running `make format`
1 parent faa4833 commit 154f168

File tree

75 files changed

+1887
-1694
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1887
-1694
lines changed

docs/website/adr/001-use-adr.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ slug: 1
33
title: |
44
1. Record Architecture Decisions
55
authors:
6-
- name: Mithril Team
6+
- name: Mithril Team
77
tags: [Accepted]
88
date: 2022-04-21
99
---
@@ -22,10 +22,10 @@ easily.
2222

2323
## Decision
2424

25-
* We will use _Architecture Decision Records_, as described by Michael Nygard in
25+
- We will use _Architecture Decision Records_, as described by Michael Nygard in
2626
this
2727
[article](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions).
28-
* We will follow the convention of storing those ADRs as Markdown formatted
28+
- We will follow the convention of storing those ADRs as Markdown formatted
2929
documents stored under `docs/adr` directory, as exemplified in Nat Pryce's
3030
[adr-tools](https://github.com/npryce/adr-tools). This does not imply we will
3131
be using `adr-tools` itself.

docs/website/adr/002-use-structured-logging.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ slug: 2
33
title: |
44
2. Use simple structured logging
55
authors:
6-
- name: Mithril Team
6+
- name: Mithril Team
77
tags: [Superseded]
88
date: 2022-04-24
99
---
@@ -14,18 +14,18 @@ Superseded by [ADR 7](/adr/7)
1414

1515
## Context
1616

17-
* Logs are a critical tool for operating any software system, enabling [observability](https://cloud.google.com/architecture/devops/devops-measurement-monitoring-and-observability) of the system.
18-
* Following [12 Factor Apps](https://12factor.net/logs) principles, providing the needed components and tools to be able to configure logging and monitoring should not be the responsibility of the software components
17+
- Logs are a critical tool for operating any software system, enabling [observability](https://cloud.google.com/architecture/devops/devops-measurement-monitoring-and-observability) of the system.
18+
- Following [12 Factor Apps](https://12factor.net/logs) principles, providing the needed components and tools to be able to configure logging and monitoring should not be the responsibility of the software components
1919

2020
## Decision
2121

2222
_Therefore_
2323

24-
* Each component of the system use [Structured logging](https://www.sumologic.com/glossary/structured-logging/) using documented and standardised JSON format for its logs
25-
* Logs are always emitted to `stdout` of the process the component is part of
24+
- Each component of the system use [Structured logging](https://www.sumologic.com/glossary/structured-logging/) using documented and standardised JSON format for its logs
25+
- Logs are always emitted to `stdout` of the process the component is part of
2626

2727
## Consequences
2828

29-
* The schema of the logged items should be properly documented in a JSON schema
30-
* It is the responsibility of the node operator to consume the logs and process them
31-
* We use existing libraries to provide needed log infrastructure, like [slog](https://zsiciarz.github.io/24daysofrust/book/vol2/day4.html) for Rust
29+
- The schema of the logged items should be properly documented in a JSON schema
30+
- It is the responsibility of the node operator to consume the logs and process them
31+
- We use existing libraries to provide needed log infrastructure, like [slog](https://zsiciarz.github.io/24daysofrust/book/vol2/day4.html) for Rust

docs/website/adr/003-release/index.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ slug: 3
33
title: |
44
3. Release process and versioning
55
authors:
6-
- name: Mithril Team
6+
- name: Mithril Team
77
tags: [Accepted]
88
date: 2022-10-21
99
---
@@ -14,32 +14,31 @@ Accepted
1414

1515
## Context
1616

17-
In order to deliver regularly the software to our users, we should implement a release process based on a predictable versioning scheme.
17+
In order to deliver regularly the software to our users, we should implement a release process based on a predictable versioning scheme.
1818

1919
### Versioning
2020

2121
A Release Version determines a distribution of determined node versions and underlying libraries.
2222

23-
* Our softwares must be able to interact seamlessly with other Mithril software.
24-
* Our softwares must be able to be hosted on crates.io.
25-
* Our softwares must clearly indicate compatibility with other Mithril components to end users.
26-
23+
- Our softwares must be able to interact seamlessly with other Mithril software.
24+
- Our softwares must be able to be hosted on crates.io.
25+
- Our softwares must clearly indicate compatibility with other Mithril components to end users.
2726

2827
### Release process
2928

3029
A Release is a software package that is built once and then promoted from the testing environment to the production environment. It can be signed.
3130

32-
* Keep it simple.
33-
* Automated as much as possible: all points not requiring human decision shall be automated.
34-
* Minimize the mean time to release.
31+
- Keep it simple.
32+
- Automated as much as possible: all points not requiring human decision shall be automated.
33+
- Minimize the mean time to release.
3534

3635
## Decision
3736

3837
There are 3 versioned layers in the Mithril stack:
3938

40-
* HTTP API protocol to ensure compatibility in the communication between nodes (use Semver).
41-
* Crate version: each node & library has its own version (use Semver). The commit digest is automatically added to the version by the CI pipeline.
42-
* Release Version: the distribution version (use version scheme **YYWW.patch** | **YYWW.patch-name**). The VERSION file is computed by the pipeline from the tag release.
39+
- HTTP API protocol to ensure compatibility in the communication between nodes (use Semver).
40+
- Crate version: each node & library has its own version (use Semver). The commit digest is automatically added to the version by the CI pipeline.
41+
- Release Version: the distribution version (use version scheme **YYWW.patch** | **YYWW.patch-name**). The VERSION file is computed by the pipeline from the tag release.
4342

4443
The documentation is tied to a Release Version.
4544

@@ -63,9 +62,11 @@ Starting just after a new release has been made:
6362
[![Release Process](./img/release_process.jpg)](./img/release_process.jpg)
6463

6564
### Hotfix Release
65+
6666
6767
In case of a blocking issue (following a distribution release) on the release environment that requires an immediate fix:
6868
69+
6970
1. Create a branch on the last release tag with the following scheme: `hotfix/{last_distribution-version}.{last_patch_number + 1}`.
7071
1. Development of the fix is done on this branch.
7172
1. After each commit on this branch, the CI creates an `unstable` tag & release which is not deployed on testing environment (testing must be done on an ad hoc environment manually created).
@@ -74,4 +75,3 @@ In case of a blocking issue (following a distribution release) on the release en
7475
1. In the release GitHub interface, edit the newly generated release, uncheck the `This is a pre-release` checkbox.
7576
1. The CI gets the built artifacts associated with this commit and generates a named release which is deployed on `release`.
7677
1. Merge the hotfix branch on main branch (and adapt the changes if they are not compatible with the current main branch).
77-

docs/website/adr/004-mithril-network-update-strategy.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ slug: 4
33
title: |
44
4. Mithril Network Upgrade Strategy
55
authors:
6-
- name: Mithril Team
6+
- name: Mithril Team
77
tags: [Accepted]
88
date: 2023-01-05
99
---
@@ -20,9 +20,9 @@ We need to be able to keep enough of signer nodes and the aggregator able to wor
2020

2121
Examples of such changes:
2222

23-
* change in the message structure
24-
* change in the cryptographic algorithm
25-
* change in communication channels
23+
- change in the message structure
24+
- change in the cryptographic algorithm
25+
- change in communication channels
2626

2727
## Decision
2828

@@ -43,8 +43,9 @@ This configuration works in the case where there is a centralized Aggregator Nod
4343
### Era Activation Marker
4444

4545
An Era Activation Marker is an information shared among all the nodes. For every upgrade, there are two phases:
46-
* a first marker is set on the blockchain that just indicates a new Era will start soon and softwares shall be updated.
47-
* a second marker is set that specifies the Epoch when they must switch from old to new behavior.
46+
47+
- a first marker is set on the blockchain that just indicates a new Era will start soon and softwares shall be updated.
48+
- a second marker is set that specifies the Epoch when they must switch from old to new behavior.
4849

4950
Every Era Activation Marker will be a transaction in the Cardano blockchain. This implies the nodes must be able to read transactions of the blockchain. Era Activation Markers can be of the same type, the first maker does not hold any Epoch information whereas the second does.
5051

docs/website/adr/005-use-rfc3339-for-dates.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
slug: 5
33
title: |
4-
5. Use rfc3339 for date formatting
4+
5. Use rfc3339 for date formatting
55
authors:
6-
- name: Mithril Team
6+
- name: Mithril Team
77
tags: [Accepted]
88
date: 2023-06-21
99
---
@@ -19,12 +19,14 @@ multiple formats being used.
1919

2020
For example when querying a certificate from an aggregator, the `initiated_at` field did not specify the timezone,
2121
timezone that could be found in the `sealed_at` field:
22+
2223
```json
2324
{
2425
"initiated_at": "2023-05-26T00:02:23",
2526
"sealed_at": "2023-05-26T00:03:23.998753492Z"
2627
}
2728
```
29+
2830
Same problem in our databases where a date could be stored without timezone and milliseconds (ie: `2023-06-13 16:35:28`)
2931
in one table column and with them in another (ie: `2023-06-13T16:35:28.143292875Z`).
3032

@@ -36,13 +38,13 @@ client can convert such date to their local time if needed.
3638

3739
_Therefore_
3840

39-
* We commit to use **RFC 3339** compatible date and time whenever we need to store or show a date and time.
41+
- We commit to use **RFC 3339** compatible date and time whenever we need to store or show a date and time.
4042

4143
## Consequences
4244

43-
* All dates and time must use a dedicated type in the application, ie: the `DateTime<Utc>` type from
44-
[chrono](https://crates.io/crates/chrono) crate.
45-
* This means that dates must **never** be stored in our types using Strings.
46-
* Internally, we will always use the **UTC timezone**, to avoid useless conversions between timezones.
47-
* Users or scripts querying dates from our applications or from our databases will be able to parse all of them using
48-
the same format.
45+
- All dates and time must use a dedicated type in the application, ie: the `DateTime<Utc>` type from
46+
[chrono](https://crates.io/crates/chrono) crate.
47+
- This means that dates must **never** be stored in our types using Strings.
48+
- Internally, we will always use the **UTC timezone**, to avoid useless conversions between timezones.
49+
- Users or scripts querying dates from our applications or from our databases will be able to parse all of them using
50+
the same format.

docs/website/adr/006-errors-implementation.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ slug: 6
33
title: |
44
6. Errors implementation Standard
55
authors:
6-
- name: Mithril Team
6+
- name: Mithril Team
77
tags: [Accepted]
88
date: 2023-09-27
99
---
@@ -15,22 +15,23 @@ Accepted
1515
## Context
1616

1717
Error handling is difficult with Rust:
18+
1819
- Many ways of implementing them with different crates ([`thiserror`](https://crates.io/crates/thiserror), [`anyhow`](https://crates.io/crates/anyhow), ...)
1920
- No exception like handling of errors
2021
- No stack trace or context available by default
2122
- Backtrace uniquely when a panic occurs and if `RUST_BACKTRACE` environment variable is set to `1` or `full`
2223

23-
We think the errors handling should be done in a consistent way in the project.
24+
We think the errors handling should be done in a consistent way in the project.
2425
Thus we have worked on a standardization of their implementation and tried to apply it to the whole repository.
2526
This has enabled us to have a clear vision of the do and don't that we intend to summarize in this ADR.
2627

2728
## Decision
2829

2930
_Therefore_
3031

31-
* We have decided to use `thiserror` and `anyhow` crates to implement the errors:
32-
* [`thiserror`](https://crates.io/crates/thiserror) is used to create module or domain errors that come from our developments and can be easily identified (as they are strongly typed).
33-
* [`anyhow`](https://crates.io/crates/anyhow) is used to add a context to an error triggered by a sub-system. The context is a convenient way to get 'stack trace' like debug information.
32+
- We have decided to use `thiserror` and `anyhow` crates to implement the errors:
33+
- [`thiserror`](https://crates.io/crates/thiserror) is used to create module or domain errors that come from our developments and can be easily identified (as they are strongly typed).
34+
- [`anyhow`](https://crates.io/crates/anyhow) is used to add a context to an error triggered by a sub-system. The context is a convenient way to get 'stack trace' like debug information.
3435

3536
Here is a [Rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=bf667c443696beb90106f6ae627a57b9) that summarizes the usage of `thiserror`:
3637

@@ -179,7 +180,7 @@ Caused by:
179180
Anyhow error: context
180181
```
181182

182-
Here is a [Rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=90f962ab001d2ea0321fc5da0d4ec0f1) that summarizes the usage of the `context` feature form `anyhow`:
183+
Here is a [Rust playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=90f962ab001d2ea0321fc5da0d4ec0f1) that summarizes the usage of the `context` feature form `anyhow`:
183184

184185
```rust
185186
#[allow(unused_imports)]
@@ -211,6 +212,7 @@ fn main() {
211212
```
212213

213214
Which will output errors this way:
215+
214216
```
215217
Error string:
216218
Service could not do the important work
@@ -242,9 +244,9 @@ Error pretty:
242244

243245
## Consequences
244246

245-
* We have defined the following aliases that should be used by default:
246-
* `StdResult`: the default result that should be returned by a function (unless a more specific type is required).
247-
* `StdError`: the default error that should be used (unless a more specific type is required).
247+
- We have defined the following aliases that should be used by default:
248+
- `StdResult`: the default result that should be returned by a function (unless a more specific type is required).
249+
- `StdError`: the default error that should be used (unless a more specific type is required).
248250

249251
```rust
250252
/* Code extracted from mithril-common::lib.rs */
@@ -255,14 +257,16 @@ pub type StdError = anyhow::Error;
255257
pub type StdResult<T> = anyhow::Result<T, StdError>;
256258
```
257259

258-
* The function that returns an error from a sub-system should systematically add a context to the error with the `with_context` method, in order to provide clear stack traces and ease debugging.
260+
- The function that returns an error from a sub-system should systematically add a context to the error with the `with_context` method, in order to provide clear stack traces and ease debugging.
261+
262+
- When printing an `StdError` we should use the debug format without the pretty modifier, ie:
259263

260-
* When printing an `StdError` we should use the debug format without the pretty modifier, ie:
261264
```rust
262265
println!("Error debug:\n {error:?}\n\n");
263266
```
264267

265-
* When wrapping an error in a `thiserror` enum variant we should use the `source` attribute that will provide a clearer stack trace:
268+
- When wrapping an error in a `thiserror` enum variant we should use the `source` attribute that will provide a clearer stack trace:
269+
266270
```rust
267271
/// Correct usage with `source` attribute
268272
#[derive(Error, Debug)]
@@ -281,8 +285,9 @@ pub enum DomainError {
281285
}
282286
```
283287

284-
* Here are some tips on how to discriminate between creating a new error using `thiserror` or using an `StdResult`:
285-
* If you raise an anyhow error which only contains a string this means that you are creating a new error that doesn't come from a sub-system. In that case you should create a type using `thiserror` intead, ie:
288+
- Here are some tips on how to discriminate between creating a new error using `thiserror` or using an `StdResult`:
289+
- If you raise an anyhow error which only contains a string this means that you are creating a new error that doesn't come from a sub-system. In that case you should create a type using `thiserror` intead, ie:
290+
286291
```rust
287292
// Avoid
288293
return Err(anyhow!("my new error"));
@@ -295,5 +300,5 @@ pub enum MyError {
295300
return Err(MyError::MyNewError);
296301
```
297302

298-
* (*Still undecided*) You should avoid wrapping a `StdError` in a `thiserror` type. This __breaks__ the stack trace and makes it really difficult to retrieve the innermost errors using `downcast_ref`. When the `thiserror` type is itself wrapped in a `StdError` afterward, you would have to `downcast_ref` twice: first to get the `thiserror` type and then to get the innermost error.
303+
- (_Still undecided_) You should avoid wrapping a `StdError` in a `thiserror` type. This **breaks** the stack trace and makes it really difficult to retrieve the innermost errors using `downcast_ref`. When the `thiserror` type is itself wrapped in a `StdError` afterward, you would have to `downcast_ref` twice: first to get the `thiserror` type and then to get the innermost error.
299304
This should be restricted to the topmost errors of our system (ie the state machine errors).

docs/website/adr/007-standardize-log-output.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ slug: 7
33
title: |
44
7. Standardize log output
55
authors:
6-
- name: Mithril Team
6+
- name: Mithril Team
77
tags: [Accepted]
88
date: 2024-04-07
99
---
@@ -14,16 +14,16 @@ Accepted
1414

1515
## Context
1616

17-
* [ADR 2](/adr/2) is not completely relevant now, we have migrated recently the logs in the client to `stderr`. Only the result of the command execution is in `stdout`. This makes it possible to exploit the result, see our [blog post](/dev-blog/2024/02/26/mithril-client-cli-output-breaking-change).
18-
* Mithril aggregator logs are always redirected to `stdout` but it mixes 2 types of CLI commands, some of which would benefit from the logs output to `stderr`.
19-
* Mithril aggregator and Mithril client CLI have not a consistent log strategy, that's why we need to standardize them.
17+
- [ADR 2](/adr/2) is not completely relevant now, we have migrated recently the logs in the client to `stderr`. Only the result of the command execution is in `stdout`. This makes it possible to exploit the result, see our [blog post](/dev-blog/2024/02/26/mithril-client-cli-output-breaking-change).
18+
- Mithril aggregator logs are always redirected to `stdout` but it mixes 2 types of CLI commands, some of which would benefit from the logs output to `stderr`.
19+
- Mithril aggregator and Mithril client CLI have not a consistent log strategy, that's why we need to standardize them.
2020

2121
## Decision
2222

23-
* For commands that provide a result or execute an action, logs are sent to `stderr`. Only the result of the command is sent to `stdout`.
24-
* For commands that launch a program without an expected result (server), logs are sent to `stdout`.
23+
- For commands that provide a result or execute an action, logs are sent to `stderr`. Only the result of the command is sent to `stdout`.
24+
- For commands that launch a program without an expected result (server), logs are sent to `stdout`.
2525

2626
## Consequences
2727

28-
* End users who use `stdout` logs would have a breaking change. They will have to retrieve the logs that come from `stderr` in addition.
29-
* Commands `genesis`, `era` and `tools` from Mithril aggregator now send their logs to `stderr`.
28+
- End users who use `stdout` logs would have a breaking change. They will have to retrieve the logs that come from `stderr` in addition.
29+
- Commands `genesis`, `era` and `tools` from Mithril aggregator now send their logs to `stderr`.

docs/website/babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module.exports = {
2-
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
2+
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
33
};

0 commit comments

Comments
 (0)