$ show dusk-network/rusk
This repository implements the Dusk Network blockchain node (Rusk), a full Proof-of-Stake node with privacy-preserving transactions (Phoenix) and public transactions (Moonlight). The system is a Rust workspace containing a consensus engine (succinct attestation consensus with proposal/validation/ratification steps), a WebAssembly-based smart contract VM (Piecrust), a RocksDB/SQLite ledger, a mempool, an HTTP/GraphQL API server (Axum), and a CLI/TUI wallet. It also includes a JavaScript SDK (w3sper.js) for browser/Deno wallet interaction and a wallet-core library compilable to WASM. The architecture is modular: the node binary (rusk/src/bin/main.rs) composes services via a builder pattern (RuskNodeBuilder), supporting both full-chain and HTTP-only modes. Key data flows include transaction submission via RUES (Rusk Event System) or GraphQL, consensus message propagation over Kadcast P2P, block execution through the VM with hard-fork feature gating, and state persistence via RocksDB column families. External dependencies include dusk-plonk, dusk-poseidon, jubjub-schnorr, wasmtime, rkyv, and sqlx. The codebase demonstrates high craftsmanship in areas like deterministic committee sortition, zero-knowledge proof verification caching, and a reusable data-driver pattern for contract encoding/decoding.
The LLM identified 7 files worth highlighting for reuse:
Defines the `ConvertibleContract` trait for encoding/decoding smart contract calls and events between JSON and RKYV binary format. Includes a `generate_wasm_entrypoint!` macro that produces WASM-compatible FFI entry points. This pattern is self-contained and can be reused for any smart contract driver, demonstrating non-obvious skill in bridging Rust types with WASM memory management.
Implements a Bloom filter with IUF (Insert/Union/Find) API for event filtering. The implementation is standalone, uses a bit vector and multiple hash functions, and is optimized for blockchain event queries. It can be extracted and reused in any project requiring probabilistic membership testing.
Implements deterministic committee selection using SHA3-256 and modular score computation. The `CommitteeSet` struct caches extracted committees and supports exclusion lists. This algorithm is reusable for any proof-of-stake or weighted random selection system, demonstrating careful cryptographic design.
Defines a `PricedHostQuery` struct that combines deserialization and pricing with execution for VM host queries. The pricing model uses flat costs plus per-byte/scalar costs, activated at a hard fork. This pattern is reusable for any VM or execution environment requiring deterministic gas metering.
Provides a `define_cache!` macro that creates typed LRU caches with optional environment-variable size override. The cache keys include revision information derived from PLONK version and hardfork. This macro is generic and can be reused in any Rust project needing a configurable, thread-safe LRU cache.
Implements `HttpRequestPolicy` with an ACL engine (wildcard-to-regex matching) and a rate/concurrency limiter using `RateLimit` and `Semaphore`. This component is self-contained and can be extracted as a generic HTTP middleware for any Axum-based service.
Contains the `Acceptor` struct that manages block acceptance, consensus integration, and rolling finality. The `rolling_finality` function computes block labels (Accepted, Attested, Confirmed, Final) based on attestation bitsets and stable counts. This algorithm is reusable for any blockchain needing gradual confirmation and finalization logic.