Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ducp-ledger = { path = "crates/ledger" }
ducp-consensus = { path = "crates/consensus" }
ducp-governance = { path = "crates/governance" }

# Canonical codec + hashing + identity (Profile 0 locked choices, spec/implementation/01).
# Canonical codec + hashing + identity (reference-node binding choices, spec/bindings/01).
borsh = { version = "1.7", features = ["derive"] }
blake3 = "1.8"
ed25519-dalek = "2"
Expand All @@ -46,7 +46,7 @@ clap = { version = "4", features = ["derive"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

# WebAssembly DVM (spec/implementation/02).
# WebAssembly DVM (spec/bindings/02).
wasmtime = "46"
wat = "1"

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

The reference implementation of the **Decentralized Universal Compute Protocol (DUCP)**, in Rust.

> **Status:** **Profile 0** (MVP / devnet) reference node for spec **v0.2.0** — functional end to end. A single-sequencer devnet accepts a task, executes it deterministically, verifies it by sampled re-execution / open challenge, and settles it with real 𝕌 and Standing accounting. Advanced tiers (TEE/ZK, BFT, trustless energy attestation, on-chain governance) sit behind traits as documented seams.
> **Status:** **Reference implementation** for DUCP-SPEC **v0.2.0** (reference-node binding, MVP / devnet) — functional end to end. A single-sequencer devnet accepts a task, executes it deterministically, verifies it by sampled re-execution / open challenge, and settles it with real 𝕌 and Standing accounting. Advanced tiers (TEE/ZK, BFT, trustless energy attestation, on-chain governance) sit behind traits as documented seams.

> **"node" means a network participant** — the software you run to take part in the DUCP network (as a Provider, Validator, etc.). It is **not** Node.js and contains no JavaScript.

## What this is

A node implementation of the DUCP protocol. The protocol itself — the white paper and the normative specification — lives in [`ducp-protocol/spec`](https://github.com/ducp-protocol/spec). This repository implements **spec v0.2.0**, **Profile 0** (the build-ready subset in `spec/implementation/`).
A node implementation of the DUCP protocol. The protocol itself — the white paper, normative specification, and reference-node binding — lives in [`ducp-protocol/spec`](https://github.com/ducp-protocol/spec). This repository is the **reference implementation** for **DUCP-SPEC v0.2.0**, conforming to the pinned choices in [`spec/bindings/`](https://github.com/ducp-protocol/spec/tree/main/spec/bindings).

Profile 0 locks the buildable choices — **WebAssembly** IR (wasmtime), **single-sequencer** devnet, **sampled re-execution** — while preserving every protocol invariant. The Quant (ℚ) efficiency observable is recorded as the reward-neutral **(𝕌, ℚ)** pair from genesis (ℚ null until energy attestation exists).
The reference-node binding pins the buildable choices — **WebAssembly** IR (wasmtime), **single-sequencer** devnet, **sampled re-execution** — while preserving every protocol invariant. The Quant (ℚ) efficiency observable is recorded as the reward-neutral **(𝕌, ℚ)** pair from genesis (ℚ null until energy attestation exists).

## Workspace layout

Expand Down Expand Up @@ -49,7 +49,7 @@ This starts a sequencer and runs the beachhead workload against it over JSON-RPC

## Architecture & milestones

The node was built along the Profile 0 roadmap (`spec/implementation/README.md`):
The node was built along the reference-node binding roadmap (`spec/bindings/README.md`):

| # | Milestone | What it delivers |
|---|---|---|
Expand All @@ -71,11 +71,11 @@ Published in [`test-vectors/`](test-vectors/) and checked by `ducp-conformance`.

| Family | Source | Milestone |
|---|---|---|
| `codec/` | spec/implementation/01 §7 | M0 |
| `metering/` | spec/implementation/02 §5 | M1 |
| `settlement/` | spec/implementation/04 §3 | M2/M3/M5 |
| `fraud/` | spec/implementation/03 §4, 04 §4 | M4/M5 |
| `replication/` | spec/implementation/04 §6 | M6 |
| `codec/` | spec/bindings/01 §7 | M0 |
| `metering/` | spec/bindings/02 §5 | M1 |
| `settlement/` | spec/bindings/04 §3 | M2/M3/M5 |
| `fraud/` | spec/bindings/03 §4, 04 §4 | M4/M5 |
| `replication/` | spec/bindings/04 §6 | M6 |
| `q-observable/` | spec/09 §10, DP-0001 §9 | ℚ |

Regenerate after an intentional change:
Expand All @@ -84,9 +84,9 @@ Regenerate after an intentional change:
cargo run -p ducp-conformance --bin gen-vectors
```

## Profile 0 scope & deferred seams
## Reference-node binding scope & deferred seams

Out of scope for Profile 0, each represented by a trait so it is additive later: TEE/ZK tiers (`Verifier`), BFT consensus (`ConsensusEngine`), trustless energy attestation and the efficiency bonus (`EnergyAttestor`), multiple IRs (`IrRegistry`), on-chain governance (`ParamSource`), and persistent/Merkle state (`Storage`). Provisional choices (borsh, BLAKE3, Ed25519, `UCU_DECIMALS = 9`, the fuel cost model) are tuned on devnet and frozen toward 1.0.
Out of scope for this binding, each represented by a trait so it is additive later: TEE/ZK tiers (`Verifier`), BFT consensus (`ConsensusEngine`), trustless energy attestation and the efficiency bonus (`EnergyAttestor`), multiple IRs (`IrRegistry`), on-chain governance (`ParamSource`), and persistent/Merkle state (`Storage`). Provisional choices (borsh, BLAKE3, Ed25519, `UCU_DECIMALS = 9`, the fuel cost model) are tuned on devnet and frozen toward 1.0.

## Specification <-> implementation

Expand Down
2 changes: 1 addition & 1 deletion crates/conformance/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ducp-conformance"
description = "DUCP Profile 0 conformance harness: loads the published test vectors and checks them against the reference crates"
description = "DUCP Reference-node binding conformance harness: loads the published test vectors and checks them against the reference crates"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
12 changes: 6 additions & 6 deletions crates/conformance/src/bin/gen-vectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::fs;
fn main() {
let dir = ducp_conformance::vectors_dir();

// --- codec / hash (M0, spec/implementation/01 §7) ---
// --- codec / hash (M0, spec/bindings/01 §7) ---
let codec_dir = dir.join("codec");
fs::create_dir_all(&codec_dir).expect("create codec dir");
let records = ducp_conformance::codec_records();
Expand All @@ -19,7 +19,7 @@ fn main() {
fs::write(&path, format!("{json}\n")).expect("write codec vectors");
println!("wrote {} ({} records)", path.display(), records.len());

// --- metering (M1, spec/implementation/02 §5) ---
// --- metering (M1, spec/bindings/02 §5) ---
let metering_dir = dir.join("metering");
fs::create_dir_all(&metering_dir).expect("create metering dir");
let metering = ducp_conformance::metering_records();
Expand All @@ -28,7 +28,7 @@ fn main() {
fs::write(&path, format!("{json}\n")).expect("write metering vectors");
println!("wrote {} ({} records)", path.display(), metering.len());

// --- settlement (M2/M3, spec/implementation/04 §3) ---
// --- settlement (M2/M3, spec/bindings/04 §3) ---
let settlement_dir = dir.join("settlement");
fs::create_dir_all(&settlement_dir).expect("create settlement dir");
let settlement = ducp_conformance::settlement_record();
Expand All @@ -37,14 +37,14 @@ fn main() {
fs::write(&path, format!("{json}\n")).expect("write settlement vector");
println!("wrote {}", path.display());

// --- finality / clawback window (M5, spec/implementation/04 §3) ---
// --- finality / clawback window (M5, spec/bindings/04 §3) ---
let finality = ducp_conformance::finality_record();
let json = serde_json::to_string_pretty(&finality).expect("serialize finality");
let path = settlement_dir.join("finality.json");
fs::write(&path, format!("{json}\n")).expect("write finality vector");
println!("wrote {}", path.display());

// --- fraud (M4/M5, spec/implementation/03 §4, 04 §4) ---
// --- fraud (M4/M5, spec/bindings/03 §4, 04 §4) ---
let fraud_dir = dir.join("fraud");
fs::create_dir_all(&fraud_dir).expect("create fraud dir");
let fraud = ducp_conformance::fraud_record();
Expand All @@ -53,7 +53,7 @@ fn main() {
fs::write(&path, format!("{json}\n")).expect("write fraud vector");
println!("wrote {}", path.display());

// --- replication (M6, spec/implementation/04 §6) ---
// --- replication (M6, spec/bindings/04 §6) ---
let replication_dir = dir.join("replication");
fs::create_dir_all(&replication_dir).expect("create replication dir");
let replication = ducp_conformance::replication_record();
Expand Down
18 changes: 9 additions & 9 deletions crates/conformance/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! # ducp-conformance
//!
//! Profile 0 conformance harness. Loads the published golden vectors from the
//! Reference-node binding conformance harness. Loads the published golden vectors from the
//! workspace-root `test-vectors/` directory and exposes helpers + canonical sample
//! values the per-milestone integration tests (under `tests/`) check the reference
//! crates against.
//!
//! The six vector families (spec/implementation/05 §5, spec/09 §10):
//! The six vector families (spec/bindings/05 §5, spec/09 §10):
//! `codec`, `metering`, `settlement`, `fraud`, `replication`, `q-observable`.
//!
//! Regenerate the committed vector files with the generator binary:
Expand Down Expand Up @@ -40,7 +40,7 @@ pub fn unhex(s: &str) -> Vec<u8> {
hex::decode(s).unwrap_or_else(|e| panic!("bad hex {s:?}: {e}"))
}

/// One codec/hash golden vector (spec/implementation/01 §7): a value, its canonical
/// One codec/hash golden vector (spec/bindings/01 §7): a value, its canonical
/// (borsh) bytes as hex, and the BLAKE3-256 of those bytes.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CodecRecord {
Expand Down Expand Up @@ -199,7 +199,7 @@ pub mod samples {
}
}

/// One metering golden vector (spec/implementation/02 §5): a canonical module +
/// One metering golden vector (spec/bindings/02 §5): a canonical module +
/// input and its deterministic `{total_fuel, ucu_count, result_hash}` under the
/// devnet benchmark. `total_fuel` is wasmtime-fuel-model-specific (provisional).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -248,7 +248,7 @@ pub fn metering_records() -> Vec<MeteringRecord> {
.collect()
}

/// The settlement golden vector (spec/implementation/04 §3): the post-state of a
/// The settlement golden vector (spec/bindings/04 §3): the post-state of a
/// `submit → claim → proof → settle` happy path. Pins the economic outcome, the
/// Receipt, the (𝕌, ℚ) entry (ℚ null in P0), and the `state_root`.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -333,7 +333,7 @@ pub fn settlement_record() -> SettlementRecord {
}
}

/// The replication golden vector (spec/implementation/04 §6): producing then
/// The replication golden vector (spec/bindings/04 §6): producing then
/// replaying a sequence of blocks reaches the identical `state_root` — state-machine
/// replication, so the devnet is verifiable even with one proposer.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -433,7 +433,7 @@ pub fn replication_record() -> ReplicationRecord {
}
}

/// The finality golden vector (spec/implementation/04 §3): a settled task whose
/// The finality golden vector (spec/bindings/04 §3): a settled task whose
/// clawback window closes, releasing the claim stake while the Receipt stays
/// immutable (`I-ECON-FINAL`).
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -519,7 +519,7 @@ pub fn finality_record() -> FinalityRecord {
}
}

/// The fraud golden vector (spec/implementation/03 §4, 04 §4): a forged proof, the
/// The fraud golden vector (spec/bindings/03 §4, 04 §4): a forged proof, the
/// re-execution verdict, and the post-resolution state (clawback, burn, fine,
/// Standing floor). Verifies `I-LEDGER-CONSERVE` across the fraud path.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down Expand Up @@ -778,7 +778,7 @@ mod tests {

#[test]
fn all_six_vector_families_present() {
// spec/implementation/05 §5 (five) + spec/09 §10 (ℚ).
// spec/bindings/05 §5 (five) + spec/09 §10 (ℚ).
let families = [
("codec", "types.json"),
("metering", "cases.json"),
Expand Down
2 changes: 1 addition & 1 deletion crates/conformance/tests/codec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! M0 conformance: codec / hash golden vectors (spec/implementation/01 §7).
//! M0 conformance: codec / hash golden vectors (spec/bindings/01 §7).
//!
//! Pins the canonical (borsh) bytes and BLAKE3-256 hashes of the core data model,
//! including the ℚ types. Regenerate with `cargo run -p ducp-conformance --bin
Expand Down
2 changes: 1 addition & 1 deletion crates/conformance/tests/finality.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! M5 conformance: clawback-window finality (spec/implementation/04 §3).
//! M5 conformance: clawback-window finality (spec/bindings/04 §3).
//!
//! After the clawback window closes with no successful challenge, the claim stake is
//! released while the settled Receipt stays immutable (`I-ECON-FINAL`).
Expand Down
2 changes: 1 addition & 1 deletion crates/conformance/tests/fraud.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! M4/M5 conformance: fraud golden vector (spec/implementation/03 §4, 04 §4).
//! M4/M5 conformance: fraud golden vector (spec/bindings/03 §4, 04 §4).
//!
//! A forged proof is settled optimistically, challenged, re-executed, and slashed.
//! Pins the post-state and verifies conservation across the fraud path.
Expand Down
2 changes: 1 addition & 1 deletion crates/conformance/tests/metering.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! M1 conformance: metering golden vectors (spec/implementation/02 §5).
//! M1 conformance: metering golden vectors (spec/bindings/02 §5).
//!
//! Verifies the deterministic 𝕌 derivation: the reference workload meters to
//! exactly one 𝕌, two independent runs agree, and the committed vectors match the
Expand Down
2 changes: 1 addition & 1 deletion crates/conformance/tests/replication.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! M6 conformance: state-machine replication (spec/implementation/04 §6).
//! M6 conformance: state-machine replication (spec/bindings/04 §6).
//!
//! Producing then replaying a block sequence reaches the identical `state_root`, so
//! every node converges on the same ledger state even with a single proposer.
Expand Down
4 changes: 2 additions & 2 deletions crates/conformance/tests/settlement.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! M2/M3 conformance: settlement golden vector (spec/implementation/04 §3).
//! M2/M3 conformance: settlement golden vector (spec/bindings/04 §3).
//!
//! Pins the post-state of a happy-path settlement and checks the cross-cutting
//! invariants on the published vector: conservation (`I-LEDGER-CONSERVE`) and the
//! reward-neutral (𝕌, ℚ) entry with ℚ null in Profile 0 (`I-Q-NULL`).
//! reward-neutral (𝕌, ℚ) entry with ℚ null in this binding (`I-Q-NULL`).

use ducp_conformance::{load_json, settlement_record, SettlementRecord};

Expand Down
2 changes: 1 addition & 1 deletion crates/consensus/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ducp-consensus"
description = "Transaction ordering and finality (Profile 0: single-sequencer devnet)"
description = "Transaction ordering and finality (binding: single-sequencer devnet)"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
Expand Down
10 changes: 5 additions & 5 deletions crates/consensus/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! # ducp-consensus
//!
//! Transaction ordering and finality. Profile 0 ships [`SingleSequencer`]: one
//! Transaction ordering and finality. The reference-node binding uses [`SingleSequencer`]: one
//! designated node orders admitted txs (FIFO by arrival, ties by `TxId`), applies
//! the ledger transition in order, and commits a `state_root`. Other nodes
//! **replay** [`SingleSequencer::commit`] and MUST reach the identical root — this
//! is state-machine replication, so the devnet is verifiable even with one proposer
//! (spec/implementation/04 §6). A BFT engine is a later `impl ConsensusEngine` with
//! (spec/bindings/04 §6). A BFT engine is a later `impl ConsensusEngine` with
//! no change to the ledger.
//!
//! Specification: <https://github.com/ducp-protocol/spec>
//! Status: Profile 0 implementation for spec v0.2.0.
//! Status: Reference implementation for DUCP-SPEC v0.2.0.

use ducp_governance::Params;
use ducp_ledger::{apply, State};
Expand Down Expand Up @@ -38,7 +38,7 @@ pub struct Proposal {
pub results: Vec<TxResult>,
}

/// The consensus interface (spec/implementation/04 §6). `produce` orders + applies
/// The consensus interface (spec/bindings/04 §6). `produce` orders + applies
/// admitted txs into a candidate block; `commit` deterministically replays a block,
/// which is how replicas reach the identical `state_root`.
pub trait ConsensusEngine {
Expand All @@ -57,7 +57,7 @@ pub trait ConsensusEngine {
) -> Result<State, Reject>;
}

/// The Profile 0 single-sequencer engine. Tracks the chain head (`height`,
/// The binding single-sequencer engine. Tracks the chain head (`height`,
/// `parent`) and the current `epoch`. `produce`/`commit` are pure with respect to
/// the head; the head advances only via [`SingleSequencer::adopt`].
#[derive(Debug, Clone)]
Expand Down
Loading
Loading