Skip to content
Draft
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
3 changes: 3 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions coding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ mod no_coding;
pub use no_coding::{NoCoding, NoCodingError};

/// Configuration common to all encoding schemes.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Config {
/// The minimum number of shards needed to encode the data.
pub minimum_shards: u16,
Expand Down Expand Up @@ -116,13 +116,13 @@ pub trait Scheme: Debug + Clone + Send + Sync + 'static {
/// the data.
type ReShard: Clone + Eq + Codec + Send + Sync + 'static;
/// Data which can assist in checking shards.
type CheckingData: Clone + Send;
type CheckingData: Clone + Send + Sync;
/// A shard that has been checked for inclusion in the commitment.
///
/// This allows excluding [Scheme::ReShard]s which are invalid, and shouldn't
/// be considered as progress towards meeting the minimum number of shards.
type CheckedShard;
type Error: std::fmt::Debug;
type CheckedShard: Clone + Send;
type Error: std::fmt::Debug + Send;

/// Encode a piece of data, returning a commitment, along with shards, and proofs.
///
Expand Down
3 changes: 3 additions & 0 deletions consensus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ documentation = "https://docs.rs/commonware-consensus"

[dependencies]
commonware-codec = { workspace = true }
commonware-coding = { workspace = true }
commonware-broadcast = { workspace = true }
commonware-cryptography = { workspace = true }
commonware-resolver = { workspace = true }
Expand All @@ -20,6 +21,7 @@ bytes = { workspace = true }
cfg-if = { workspace = true }
thiserror = { workspace = true }
futures = { workspace = true }
rand_core = { workspace = true }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
commonware-macros = { workspace = true }
Expand All @@ -28,6 +30,7 @@ commonware-runtime = { workspace = true }
commonware-storage = { workspace = true, features = ["std"] }
prometheus-client = { workspace = true }
governor = { workspace = true }
rayon = { workspace = true }
rand = { workspace = true }
rand_distr = { workspace = true }
tracing = { workspace = true }
Expand Down
34 changes: 34 additions & 0 deletions consensus/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ cfg_if::cfg_if! {
use commonware_cryptography::{Digest, PublicKey};
use futures::channel::{oneshot, mpsc};
use std::future::Future;
use rand::Rng;
use commonware_runtime::{Clock, Metrics, Spawner};

pub mod marshal;
mod reporter;
Expand Down Expand Up @@ -102,6 +104,38 @@ cfg_if::cfg_if! {
) -> impl Future<Output = oneshot::Receiver<bool>> + Send;
}

/// Application is the interface responsible for building new blocks on top of consensus-provided parent
/// commitments as well as receiving finalized blocks from marshal.
pub trait Application<E>: Clone + Send + 'static
where
E: Rng + Spawner + Metrics + Clock
{
/// Context is metadata provided by the consensus engine associated with a given payload.
///
/// This often includes things like the proposer, view number, the height, or the epoch.
type Context: Epochable;

/// The block type produced by the application's builder.
type Block: Block;

/// Payload used to initialize the consensus engine.
fn genesis(
&mut self,
epoch: <Self::Context as Epochable>::Epoch
) -> impl Future<Output = Self::Block> + Send;

/// Build a new block on top of the provided parent commitment / block.
fn build(
&mut self,
context: E,
parent_commitment: <Self::Block as Committable>::Commitment,
parent_block: Self::Block,
) -> impl Future<Output = Self::Block> + Send;

/// Receive a finalized block from marshal.
fn finalize(&mut self, block: Self::Block) -> impl Future<Output = ()> + Send;
}

/// Relay is the interface responsible for broadcasting payloads to the network.
///
/// The consensus engine is only aware of a payload's digest, not its contents. It is up
Expand Down
Loading
Loading