Skip to content
Closed
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
524 changes: 333 additions & 191 deletions Cargo.lock

Large diffs are not rendered by default.

33 changes: 19 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ license = "MIT OR Apache-2.0"
[workspace.dependencies]
alto-client = { version = "0.0.16", path = "client" }
alto-types = { version = "0.0.16", path = "types" }
commonware-broadcast ="0.0.63"
commonware-codec ="0.0.63"
commonware-consensus ="0.0.63"
commonware-cryptography ="0.0.63"
commonware-deployer = { version = "0.0.63", default-features = false }
commonware-macros ="0.0.63"
commonware-p2p ="0.0.63"
commonware-resolver ="0.0.63"
commonware-runtime ="0.0.63"
commonware-storage ="0.0.63"
commonware-stream ="0.0.63"
commonware-utils ="0.0.63"
commonware-broadcast = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-codec = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-consensus = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-cryptography = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-coding = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-deployer = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2", default-features = false }
commonware-macros = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-p2p = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-resolver = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-runtime = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-storage = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-stream = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
commonware-utils = { git = "https://github.com/commonwarexyz/monorepo.git", branch = "cl/consensus-coding-mk2" }
thiserror = "2.0.12"
bytes = "1.7.1"
rand = "0.8.5"
Expand All @@ -36,8 +37,8 @@ futures = "0.3.31"
futures-util = "0.3.31"
tracing = "0.1.41"
tracing-subscriber = "0.3.19"
governor = "0.6.3"
prometheus-client = "0.22.3"
governor = "0.10.2"
prometheus-client = "0.24.0"
clap = "4.5.18"

[profile.bench]
Expand All @@ -58,3 +59,7 @@ overflow-checks = true
# Although overflow checks are enabled by default in "test", we explicitly
# enable them here for clarity.
overflow-checks = true

[profile.profiling]
inherits = "release"
debug = true
1 change: 1 addition & 0 deletions chain/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ alto-types = { workspace = true }
alto-client = { workspace = true }
commonware-broadcast = { workspace = true }
commonware-codec = { workspace = true }
commonware-coding = { workspace = true }
commonware-consensus = { workspace = true }
commonware-cryptography = { workspace = true }
commonware-deployer = { workspace = true }
Expand Down
86 changes: 86 additions & 0 deletions chain/src/application.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
use alto_types::{Block, PublicKey, Scheme};
use commonware_consensus::{
marshal::{
ancestry::{AncestorStream, AncestryProvider},
coding::types::CodingCommitment,
Update,
},
simplex::types::Context,
Application, Block as _, Reporter,
};
use commonware_cryptography::{Digestible, Hasher, Sha256};
use commonware_runtime::{Clock, Metrics, Spawner};
use commonware_utils::{SystemTimeExt, Acknowledgement};
use futures::StreamExt;
use rand::Rng;
use tracing::info;

/// Genesis message to use during initialization.
const GENESIS: &[u8] = b"commonware is neat";

#[derive(Clone)]
pub struct AltoApp {
genesis: Block,
}

impl AltoApp {
pub fn new() -> Self {
let genesis = Block::new(Sha256::hash(GENESIS), 0, 0, Vec::new());
Self { genesis }
}
}

impl Default for AltoApp {
fn default() -> Self {
Self::new()
}
}

impl<E> Application<E> for AltoApp
where
E: Rng + Spawner + Metrics + Clock,
{
type SigningScheme = Scheme;
type Context = Context<CodingCommitment, PublicKey>;
type Block = Block;

async fn genesis(&mut self) -> Self::Block {
self.genesis.clone()
}

async fn propose<A: AncestryProvider<Block = Self::Block>>(
&mut self,
(mut runtime_context, _context): (E, Self::Context),
mut ancestry: AncestorStream<A, Self::Block>,
) -> Option<Self::Block> {
let parent = ancestry.next().await?;

// Create a new block
let mut current = runtime_context.current().epoch_millis();
if current <= parent.timestamp {
current = parent.timestamp + 1;
}

// Generate some random data.
let mut junk = vec![0u8; 4 * 1024 * 1024];
runtime_context.fill_bytes(&mut junk);

Some(Block::new(
parent.digest(),
parent.height + 1,
current,
junk,
))
}
}

impl Reporter for AltoApp {
type Activity = Update<Block>;

async fn report(&mut self, activity: Self::Activity) {
if let Update::Block(block, ack_rx) = activity {
info!(height = block.height(), "finalized block");
ack_rx.acknowledge();
}
}
}
209 changes: 0 additions & 209 deletions chain/src/application/actor.rs

This file was deleted.

Loading
Loading