Skip to content

Commit b985dac

Browse files
committed
create v0.9.6 and v0.10.0-rc2 versioned docs
1 parent 8493de8 commit b985dac

49 files changed

Lines changed: 5064 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
sidebar_position: 2
3+
---
4+
5+
# Commit Module
6+
7+
While a module can be written in any language, we currently provide some utilities for Rust, with the goal of supporting more generalized APIs and simplify development in languages other than Rust.
8+
9+
In Rust, we provide utilities to load and run modules. Simply add to your `Cargo.toml`:
10+
```toml
11+
commit-boost = { git = "https://github.com/Commit-Boost/commit-boost-client", version = "..." }
12+
```
13+
14+
You will now be able to import the utils with:
15+
```rust
16+
use commit_boost::prelude::*;
17+
```
18+
19+
20+
## Config
21+
Your module will likely need a configuration for the Node Operator to customize. This will have to be in the `cb-config.toml` file, in the correct `[[module]]` section. In the module, you can define and load your config as follows.
22+
23+
First, define all the parameters needed in a struct:
24+
```rust
25+
#[derive(Debug, Deserialize)]
26+
struct ExtraConfig {
27+
sleep_secs: u64,
28+
}
29+
```
30+
then pass that struct to the `load_commit_module_config` function, which will load and parse the config. Your custom config will be under the `extra` field.
31+
32+
```rust
33+
let config = load_commit_module_config::<ExtraConfig>().unwrap();
34+
let to_sleep = config.extra.sleep_secs;
35+
```
36+
37+
The loaded `config` also has a few other useful fields:
38+
- the unique `id` of the module
39+
- chain spec
40+
- a `SignerClient` to call the [SignerAPI](/api), already setup with the correct JWT
41+
42+
43+
## Requesting signatures
44+
At its core the Signer Module simply provides a signature on a 32-byte data digest. The signatures are currently provided with either the validator keys (BLS) or a proxy key (BLS or ECDSA) for a given validator key, both on the [builder domain](https://github.com/Commit-Boost/commit-boost-client/blob/main/crates/common/src/signature.rs#L88-L96).
45+
46+
In the example we use `TreeHash`, already used in the CL, to create the digest from a custom struct:
47+
```rust
48+
#[derive(TreeHash)]
49+
struct Datagram {
50+
data: u64,
51+
}
52+
```
53+
54+
Furthermore, in order to request a signature, we'd need a public key of the validator. You can get a list of available keys by calling:
55+
```rust
56+
let pubkeys = config.signer_client.get_pubkeys().await.unwrap();
57+
```
58+
59+
Which will call the `get_pubkeys` endpoint of the [SignerAPI](/api), returning all the consensus pubkeys and the corresponding proxy keys, of your module.
60+
61+
Note that the requests are authenticated using a JWT, that must be regularly refreshed as it expires after a certain time. To do so, you can call:
62+
```rust
63+
config.signer_client.refresh_token().await.unwrap();
64+
```
65+
You have the `SIGNER_JWT_EXPIRATION` constant available in the `commit-boost` crate, which is the time in seconds after which the JWT will expire.
66+
67+
Then, we can request a signature either with a consensus key or with a proxy key:
68+
69+
### With a consensus key
70+
Requesting a signature is as simple as:
71+
```rust
72+
let datagram = Datagram { data: 1 };
73+
let request = SignConsensusRequest::builder(pubkey).with_msg(&datagram);
74+
let signature = config.signer_client.request_consensus_signature(&request).await.unwrap();
75+
```
76+
77+
Where `pubkey` is the validator (consensus) public key for which the signature is requested.
78+
79+
### With a proxy key
80+
You'll have to first request a proxy key be generated for a given consensus key.
81+
We support two signature schemes for proxies: BLS or ECDSA.
82+
83+
To request a proxy:
84+
```rust
85+
// BLS proxy
86+
let proxy_delegation = self.config.signer_client.generate_proxy_key_bls(pubkey).await?;
87+
let proxy_pubkey = proxy_delegation.message.proxy;
88+
89+
// or ECDSA proxy
90+
let proxy_delegation = self.config.signer_client.generate_proxy_key_ecdsa(pubkey).await?;
91+
let proxy_address = proxy_delegation.message.proxy;
92+
```
93+
94+
Where `pubkey` is the validator (consensus) public key for which a proxy is to be generated.
95+
96+
Then you can use the generated proxy key to request a signature:
97+
```rust
98+
// if `proxy_pubkey` is a BLS proxy
99+
let datagram = Datagram { data: 1 };
100+
let request = SignProxyRequest::builder(proxy_pubkey).with_msg(&datagram);
101+
let signature = config.signer_client.request_proxy_signature_bls(&request).await.unwrap();
102+
103+
// or for ECDSA proxy
104+
let datagram = Datagram { data: 1 };
105+
let request = SignProxyRequest::builder(proxy_address).with_msg(&datagram);
106+
let signature = config.signer_client.request_proxy_signature_ecdsa(&request).await.unwrap();
107+
```
108+
109+
## Metrics
110+
We provide support for modules to record custom metrics which are automatically scraped by Prometheus. This involves three steps
111+
### Define metrics
112+
You can use the `prometheus` crate to create a custom registry and metrics, for example:
113+
114+
```rust
115+
static ref MY_CUSTOM_REGISTRY: Registry = Registry::new_custom(Some("da_commit".to_string()), None).unwrap();
116+
static ref SIG_RECEIVED_COUNTER: IntCounter = IntCounter::new("signature_received", "successful signature requests received").unwrap();
117+
```
118+
119+
### Start Metrics Provider
120+
When starting the module, you should register all metrics, and start the `MetricsProvider`:
121+
```rust
122+
MY_CUSTOM_REGISTRY.register(Box::new(SIG_RECEIVED_COUNTER.clone())).unwrap();
123+
MetricsProvider::load_and_run(MY_CUSTOM_REGISTRY.clone());
124+
```
125+
The `MetricsProvider` will load the configuration needed and start a server with a `/metrics` endpoint for Prometheus to scrape.
126+
127+
### Record metrics
128+
All that is left is to use the metrics throughout your code:
129+
```rust
130+
SIG_RECEIVED_COUNTER.inc();
131+
```
132+
These will be automatically scraped by the Prometheus service running, and exposed on port `9090`. We plan to allow developers to ship pre-made dashboards together with their modules, to allow Node Operators to have an improved oversight on the modules they are running.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Custom Modules
6+
7+
Commit-Boost aims to provide an open platform for developers to create and distribute commitment protocols sidecars.
8+
9+
There are two ways to leverage Commit-Boost modularity:
10+
11+
1. Commit Modules, which request signatures from the proposer, e.g. for preconfirmations ([example](https://github.com/Commit-Boost/commit-boost-client/tree/78bdc47bf89082f4d1ea302f9a3f86f609966b28/examples/da_commit)).
12+
2. PBS Modules, which tweak the default PBS Module with additional logic, e.g. verifying additional constraints in `get_header` ([example](https://github.com/Commit-Boost/commit-boost-client/tree/78bdc47bf89082f4d1ea302f9a3f86f609966b28/examples/status_api)).
243 KB
Loading
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
description: Overview of the architecture of Commit-Boost
3+
---
4+
5+
# Overview
6+
7+
Below is schematic overview of Commit-Boost.
8+
9+
Commit-Boost runs as a single sidecar composed of multiple modules:
10+
- Pbs Service with the [BuilderAPI](https://ethereum.github.io/builder-specs/) for [MEV Boost](https://docs.flashbots.net/flashbots-mev-boost/architecture-overview/specifications)
11+
- A Signer Service implementing the SignerAPI
12+
- Commit Modules that implement some custom commit protocol logic
13+
- Telemetry modules like Prometheus and Grafana
14+
15+
![architecture](./img/architecture.png)
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Commit Modules
6+
7+
Commit-Boost provides an open platform for developers to create and distribute commitment protocol sidecars. **Commit Modules** are the primary way to add custom logic — they run as sidecar processes alongside the PBS and Signer services, and can request signatures from the proposer.
8+
9+
> **For system context**, see the [Architecture Overview](../architecture/overview.md).
10+
11+
## Config entry
12+
13+
Each commit module is declared in the `cb-config.toml` file under a `[[modules]]` entry:
14+
15+
```toml
16+
[[modules]]
17+
id = "DA_COMMIT"
18+
type = "commit"
19+
docker_image = "my-module-image"
20+
signing_id = "0x6a33a23ef26a4836979edff86c493a69b26ccf0b4a16491a815a13787657431b"
21+
```
22+
23+
| Field | Description |
24+
|---|---|
25+
| `id` | A unique identifier for the module (used for JWT scoping and container naming). |
26+
| `type` | **Must be `"commit"`.** This is the only valid value. |
27+
| `docker_image` | The Docker image to run for this module. |
28+
| `signing_id` | A 32-byte identifier used to scope signatures to this module (see [Signing structure](#signing-structure)). |
29+
| (custom) | Additional fields are passed through as opaque config to the module's runtime. |
30+
31+
:::warning
32+
Setting `type = "pbs"` in a `[[modules]]` entry is **not** a supported path. The configuration parser will reject it at parse time. If you want to extend the PBS binary itself, see [Extending PBS](./extending-pbs.md).
33+
:::
34+
35+
36+
37+
## Rust SDK usage
38+
39+
While a module can be written in any language, we provide Rust utilities to simplify loading and running modules. Add to your `Cargo.toml`:
40+
41+
```toml
42+
commit-boost = { git = "https://github.com/Commit-Boost/commit-boost-client", version = "..." }
43+
```
44+
45+
Import the prelude:
46+
47+
```rust
48+
use commit_boost::prelude::*;
49+
```
50+
51+
### Loading module config
52+
53+
Your module will likely need a configuration section for the Node Operator to customize. Define it as a struct and pass it to `load_commit_module_config`:
54+
55+
```rust
56+
#[derive(Debug, Deserialize)]
57+
struct ExtraConfig {
58+
sleep_secs: u64,
59+
}
60+
61+
let config = load_commit_module_config::<ExtraConfig>().unwrap();
62+
let to_sleep = config.extra.sleep_secs;
63+
```
64+
65+
The returned `StartCommitModuleConfig` also provides:
66+
- `id` — unique module ID
67+
- `chain` — chain spec
68+
- `signer_client` — a pre-configured `SignerClient` to call the [SignerAPI](/api)
69+
70+
### Requesting signatures
71+
72+
At its core, the Signer Service provides a signature on a 32-byte data digest. Signatures are provided using either the validator keys (BLS) or a proxy key (BLS or ECDSA), both on the [Commit-Boost domain](#signing-structure).
73+
74+
Use `TreeHash` to create a digest from a custom struct:
75+
76+
```rust
77+
#[derive(TreeHash)]
78+
struct Datagram {
79+
data: u64,
80+
}
81+
```
82+
83+
To request a signature, you need a public key. Get available keys:
84+
85+
```rust
86+
let pubkeys = config.signer_client.get_pubkeys().await.unwrap();
87+
```
88+
89+
JWT tokens are created and refreshed internally by `SignerClient` — each method generates a fresh token with the correct `route`, `exp`, and `payload_hash` claims automatically. No manual token management is needed.
90+
91+
#### Consensus key signatures
92+
93+
```rust
94+
let datagram = Datagram { data: 1 };
95+
let request = SignConsensusRequest::builder(pubkey).with_msg(&datagram);
96+
let signature = config.signer_client.request_consensus_signature(&request).await.unwrap();
97+
```
98+
99+
Where `pubkey` is the validator (consensus) public key.
100+
101+
#### Proxy key signatures
102+
103+
First, generate a proxy key for a given consensus key. We support BLS and ECDSA:
104+
105+
```rust
106+
// BLS proxy
107+
let proxy_delegation = config.signer_client.generate_proxy_key_bls(pubkey).await?;
108+
let proxy_pubkey = proxy_delegation.message.proxy;
109+
110+
// ECDSA proxy
111+
let proxy_delegation = config.signer_client.generate_proxy_key_ecdsa(pubkey).await?;
112+
let proxy_address = proxy_delegation.message.proxy;
113+
```
114+
115+
Then request a signature using the proxy key:
116+
117+
```rust
118+
// BLS proxy
119+
let datagram = Datagram { data: 1 };
120+
let request = SignProxyRequest::builder(proxy_pubkey).with_msg(&datagram);
121+
let signature = config.signer_client.request_proxy_signature_bls(&request).await.unwrap();
122+
123+
// ECDSA proxy
124+
let datagram = Datagram { data: 1 };
125+
let request = SignProxyRequest::builder(proxy_address).with_msg(&datagram);
126+
let signature = config.signer_client.request_proxy_signature_ecdsa(&request).await.unwrap();
127+
```
128+
129+
### Signing structure
130+
131+
For details on the signing structure — including domain separation, nonces, SSZ Merkle tree construction, and the signing ID format — see [Requesting Proposer Commitment Signatures](./prop-commit-signing.md).
132+
133+
## Metrics
134+
135+
Modules can record custom metrics that are automatically scraped by Prometheus.
136+
137+
### Define metrics
138+
139+
Use the `prometheus` crate:
140+
141+
```rust
142+
static ref MY_CUSTOM_REGISTRY: Registry = Registry::new_custom(Some("da_commit".to_string()), None).unwrap();
143+
static ref SIG_RECEIVED_COUNTER: IntCounter = IntCounter::new("signature_received", "successful signature requests received").unwrap();
144+
```
145+
146+
### Start the metrics provider
147+
148+
```rust
149+
MY_CUSTOM_REGISTRY.register(Box::new(SIG_RECEIVED_COUNTER.clone())).unwrap();
150+
MetricsProvider::load_and_run(MY_CUSTOM_REGISTRY.clone());
151+
```
152+
153+
This starts a server with a `/metrics` endpoint on the configured port (default `9090`).
154+
155+
### Record metrics
156+
157+
```rust
158+
SIG_RECEIVED_COUNTER.inc();
159+
```
160+
161+
For a full reference of available metrics, see the [Metrics catalog](../get_started/running/metrics.md) (once created; the Prometheus scrape target is already configured by the docker-init setup).
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
sidebar_position: 3
3+
---
4+
# Environment setup
5+
6+
## Dirk signer
7+
8+
In order to test Commit-Boost with a Dirk signer, you need to have a running Dirk instance. You can find a complete step-by-step guide on how to setup one in the Dirk's docs [here](https://github.com/attestantio/dirk/blob/master/docs/distributed_key_generation.md).
9+
10+
If you are using a custom certificate authority, don't forget to add the CA certificate to the TOML config under `signer.dirk.ca_cert_path`.

0 commit comments

Comments
 (0)