-
Notifications
You must be signed in to change notification settings - Fork 66
docs: Add and improve module READMEs #4028
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,26 @@ | ||
| Implementation of Dusk [Succinct Attestation] consensus protocol | ||
| <div align="center"> | ||
|
|
||
| [Succinct Attestation]: (https://github.com/dusk-network/docs/blob/main/src/content/docs/learn/deep-dive/succinct-attestation.md) | ||
| # `🔗 Dusk Consensus` | ||
|
|
||
| > Implementation of Dusk's [Succinct Attestation](https://github.com/dusk-network/docs/blob/main/src/content/docs/learn/deep-dive/succinct-attestation.md) consensus protocol | ||
| </div> | ||
|
|
||
| ## Overview | ||
|
|
||
| Dusk Consensus implements the Succinct Attestation (SA) protocol, which drives block production and finality on the Dusk network. It coordinates a multi-phase process — proposal, validation, and ratification — where provisioners vote on candidate blocks and aggregate their votes into a compact attestation. | ||
|
|
||
| ## Key Components | ||
|
|
||
| | Component | Description | | ||
| |-----------|-------------| | ||
| | Consensus state machine | Drives the proposal / validation / ratification phases | | ||
| | Vote aggregation | Collects and verifies BLS-signed votes from provisioners | | ||
| | Quorum logic | Determines when sufficient stake weight has voted to finalize | | ||
| | Merkle aggregation | Batches proofs for efficient on-chain verification | | ||
|
|
||
| ## Related Crates | ||
|
|
||
| - [`node-data`](../node-data/) — defines consensus message types and ledger structures | ||
| - [`dusk-core`](../core/) — BLS signatures used for vote signing | ||
| - [`node`](../node/) — integrates the consensus engine into the full node runtime | ||
| - [`rusk`](../rusk/) — orchestrates consensus as part of the node entrypoint |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| <div align="center"> | ||
|
|
||
| # `📊 Node Data` | ||
|
|
||
| > Core datatypes for the Dusk blockchain node — ledger structures, network messages, and wire-format encoding | ||
| </div> | ||
|
|
||
| ## Overview | ||
|
|
||
| Node Data is the shared vocabulary between [`node`](../node/), [`consensus`](../consensus/), and [`rusk`](../rusk/). It defines all types that travel across the network or get persisted to the ledger, along with deterministic serialization logic for wire compatibility. | ||
|
|
||
| ## Modules | ||
|
|
||
| | Module | Description | | ||
| |--------|-------------| | ||
| | `bls` | BLS public key wrappers with base58 and hex encoding | | ||
| | `ledger` | `Header`, `Block`, `SpentTransaction`, `Fault`, `Slash`, `Attestation` | | ||
| | `message` | Consensus message types with versioning and status tracking | | ||
| | `encoding` | `Serializable` trait for deterministic wire-format encoding | | ||
| | `events` | Block, transaction, and contract event types | | ||
|
|
||
| ## Serialization | ||
|
|
||
| > **Warning**: Field ordering in serialized types is protocol-sensitive. Reordering fields or changing encoding can break network compatibility between nodes. | ||
|
|
||
| All wire-format types implement the `Serializable` trait, which provides `read` and `write` methods for deterministic binary encoding. | ||
|
|
||
| ## Features | ||
|
|
||
| | Feature | Description | | ||
| |---------|-------------| | ||
| | `faker` | Generates test data via the `fake` crate | | ||
|
|
||
| ## Related Crates | ||
|
|
||
| - [`dusk-core`](../core/) — foundation types (signatures, scalars) | ||
| - [`node`](../node/) — consumes ledger and message types for chain operations | ||
| - [`consensus`](../consensus/) — consumes message types for consensus protocol | ||
| - [`rusk`](../rusk/) — consumes event and ledger types for APIs | ||
| - [`rusk-wallet`](../rusk-wallet/) — consumes ledger types for transaction display |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <div align="center"> | ||
|
|
||
| # `🪪 Rusk Profile` | ||
|
|
||
| > Manages the local Rusk profile directory for circuit artifacts, proving keys, and genesis state | ||
| </div> | ||
| ## Overview | ||
|
|
||
| Rusk Profile manages the `~/.dusk/rusk/` directory tree that stores ZK circuit artifacts, proving/verifier keys, the Common Reference String (CRS), consensus keys, and genesis state. It provides integrity verification (blake3, SHA-256) for all trusted setup artifacts. | ||
|
|
||
| ## Directory Layout | ||
|
|
||
| ``` | ||
| ~/.dusk/rusk/ | ||
| ├── circuits/ # ZK circuit prover/verifier keys (blake3-verified) | ||
| ├── keys/ # Consensus keys | ||
| ├── state/ # Genesis and recovered chain state | ||
| └── drivers/ # Data-driver WASM storage | ||
| ``` | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| | Variable | Description | | ||
| |----------|-------------| | ||
| | `RUSK_PROFILE_PATH` | Override the default `~/.dusk/rusk` profile location | | ||
|
|
||
| ## Related Crates | ||
|
|
||
| - [`rusk-prover`](../rusk-prover/) — loads circuit prover keys from the profile | ||
| - [`rusk-recovery`](../rusk-recovery/) — writes state and keys into the profile | ||
| - [`rusk`](../rusk/) — reads genesis state from the profile at startup | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <div align="center"> | ||
|
|
||
| # `📨 Rusk Prover` | ||
|
|
||
| > Local PLONK zero-knowledge prover for Phoenix (shielded) transactions | ||
| </div> | ||
|
|
||
| ## Overview | ||
|
|
||
| Rusk Prover generates PLONK zero-knowledge proofs for Phoenix transactions locally. It implements the `dusk_core::transfer::phoenix::Prove` trait and supports transaction circuits with 1 to 4 input notes (each producing 2 output notes). Prover keys are loaded lazily from [`rusk-profile`](../rusk-profile/). | ||
|
|
||
| ## How It Works | ||
|
|
||
| 1. Receives a serialized `TxCircuitVec` containing the transaction circuit data | ||
| 2. Selects the matching circuit variant based on the number of input notes: | ||
| - `1-in / 2-out` | ||
| - `2-in / 2-out` | ||
| - `3-in / 2-out` | ||
| - `4-in / 2-out` | ||
| 3. Loads the corresponding prover key from the profile directory (cached after first load) | ||
| 4. Generates and returns the PLONK proof | ||
|
|
||
| ## Features | ||
|
|
||
| | Feature | Description | | ||
| |---------|-------------| | ||
| | `no_random` | Use a seeded RNG for deterministic proofs (for testing) | | ||
| | `debug` | Enable tracing and hex logging of proof data | | ||
|
|
||
| ## Related Crates | ||
|
|
||
| - [`dusk-core`](../core/) — defines the `Prove` trait and Phoenix circuit types | ||
| - [`rusk-profile`](../rusk-profile/) — stores and retrieves circuit prover keys | ||
| - [`rusk`](../rusk/) — uses the prover in prover node mode (`--features prover`) | ||
| - [`rusk-test`](../rusk-test/) — uses the prover with `no_random` + `debug` for deterministic test proofs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <div align="center"> | ||
|
|
||
| # `⬇️ Rusk Recovery` | ||
|
|
||
| > Bootstrap and recovery utilities for initializing a Dusk node | ||
| </div> | ||
|
|
||
| ## Overview | ||
|
|
||
| Rusk Recovery provides tools to bootstrap a new node or restore an existing one. It can deploy genesis state from snapshot configurations and download circuit proving keys, writing everything into the [`rusk-profile`](../rusk-profile/) directory. | ||
|
|
||
| ## Features | ||
|
|
||
| Both features are optional and gated behind Cargo feature flags: | ||
|
|
||
| | Feature | Description | | ||
| |---------|-------------| | ||
| | `state` | Deploy genesis state from snapshots (local TOML, HTTP, zip, or tar archives) | | ||
| | `keys` | Download and verify ZK circuit proving keys from the network | | ||
|
|
||
| ### State Recovery | ||
|
|
||
| The `state` feature provides: | ||
| - `Snapshot` — genesis configuration defining initial balances and stakes | ||
| - `PhoenixBalance` — shielded (Phoenix) balance entries | ||
| - `GenesisStake` — initial stake allocations | ||
| - `deploy()` — populates the transfer and stake contracts with genesis data | ||
|
|
||
| ### Key Recovery | ||
|
|
||
| The `keys` feature downloads circuit prover/verifier keys and verifies their integrity before storing them in the profile directory. | ||
|
|
||
| ## Usage | ||
|
|
||
| Recovery is typically invoked through Make targets rather than directly: | ||
|
|
||
| ```bash | ||
| make keys # Download circuit proving keys | ||
| make state # Generate genesis state | ||
| make prepare-dev # Keys + state + example consensus keys | ||
| ``` | ||
|
|
||
| ## Related Crates | ||
|
|
||
| - [`rusk-profile`](../rusk-profile/) — target directory for recovered state and keys | ||
| - [`dusk-vm`](../vm/) — used to deploy genesis state into the VM | ||
| - [`rusk`](../rusk/) — invokes recovery during first-run initialization | ||
| - [`rusk-test`](../rusk-test/) — uses state recovery to set up ephemeral test nodes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <div align="center"> | ||
|
|
||
| # `🧪 Rusk Test` | ||
|
|
||
| > Integration test harness and utilities for the Rusk workspace | ||
| </div> | ||
|
|
||
| ## Overview | ||
|
|
||
| Rusk Test provides a shared test harness for integration tests across the workspace. It can spin up an ephemeral Rusk node with genesis state, offers a deterministic test wallet, and includes async helpers for bridging async code into synchronous test contexts. | ||
|
|
||
| ## Key Utilities | ||
|
|
||
| | Utility | Description | | ||
| |---------|-------------| | ||
| | `new_state()` | Creates an ephemeral Rusk instance populated from a genesis snapshot | | ||
| | `new_state_with_chainid()` | Same as above, with a custom chain ID | | ||
| | `TestStateClient` | Wraps a Rusk instance with a mock Phoenix note cache | | ||
| | `TestStore` | Wallet store backed by a fixed seed (`[0u8; 64]`) for deterministic keys | | ||
| | `logger()` | Initializes `tracing` with a default filter (overridable via `RUST_LOG`) | | ||
| | `Block::wait()` | Async-to-sync bridge for blocking on futures in test contexts | | ||
|
|
||
| ## Features | ||
|
|
||
| | Feature | Description | | ||
| |---------|-------------| | ||
| | `archive` | Enables archive mode on the test node | | ||
|
|
||
| ## Related Crates | ||
|
|
||
| - [`dusk-rusk`](../rusk/) — the node instance spun up for tests | ||
| - [`rusk-recovery`](../rusk-recovery/) — provides genesis state deployment | ||
| - [`rusk-prover`](../rusk-prover/) — used with `no_random` + `debug` for deterministic proofs | ||
| - [`wallet-core`](../wallet-core/) — wallet primitives used by the test wallet | ||
| - [`dusk-core`](../core/) — transaction and key types |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.