1
0
mirror of synced 2025-02-22 20:48:13 +00:00

Add first tx defition (#835)

* Add first tx defition

* address review comments

* review comments
This commit is contained in:
Giacomo Pasini 2024-10-22 15:51:54 +02:00 committed by GitHub
parent b0142d7173
commit ad88d2bc0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
89 changed files with 504 additions and 568 deletions

View File

@ -1,6 +1,7 @@
[workspace]
members = [
"nomos-core",
"nomos-core/chain-defs",
"nomos-core/cl",
"nomos-da/kzgrs",
"nomos-da/kzgrs-backend",
"nomos-da/storage",
@ -33,12 +34,12 @@ members = [
"nodes/nomos-executor",
"consensus/carnot-engine",
"consensus/cryptarchia-engine",
"ledger/cryptarchia-ledger",
"cl/cl",
"ledger/nomos-ledger",
"nomos-core/cl",
"proof_of_leadership/proof_statements",
"testnet/cfgsync",
"tests",
"clients/executor-http-client",
]
exclude = ["proof_of_leadership/risc0/risc0_proofs"]
exclude = ["proof_of_leadership/risc0/risc0_proofs", "nomos-core/risc0_proofs"]
resolver = "2"

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
nomos-executor = { path = "../../nodes/nomos-executor" }
reqwest = "0.12"
serde = "1.0"

View File

@ -1,5 +1,5 @@
[package]
name = "cryptarchia-ledger"
name = "nomos-ledger"
version = "0.1.0"
edition = "2021"
@ -12,8 +12,8 @@ thiserror = "1"
serde = { version = "1.0", features = ["derive"], optional = true }
# TODO: we only need types definition from this crate
cryptarchia-engine = { path = "../../consensus/cryptarchia-engine" }
cl = { path = "../../cl/cl" }
risc0-zkvm = { version = "1.0", optional = true }
cl = { path = "../../nomos-core/cl" }
risc0-zkvm = { version = "1.1", optional = true }
leader_proof_statements = { path = "../../proof_of_leadership/proof_statements" }
nomos_pol_risc0_proofs = { path = "../../proof_of_leadership/risc0/risc0_proofs", optional = true }
nomos_pol_prover = { path = "../../proof_of_leadership/risc0/prover", optional = true }

View File

@ -93,6 +93,10 @@ mod risc0 {
.decode()
.map_err(|e| D::Error::custom(format!("Invalid public inputs: {e}")))?;
risc0_receipt
.verify(nomos_pol_risc0_proofs::PROOF_OF_LEADERSHIP_ID)
.map_err(D::Error::custom)?;
Ok(Self {
public_inputs,
risc0_receipt,

View File

@ -11,7 +11,7 @@ color-eyre = "0.6.0"
hyper = { version = "0.14", features = ["full"] }
kzgrs-backend = { path = "../../nomos-da/kzgrs-backend" }
nomos-api = { path = "../../nomos-services/api" }
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
nomos-da-dispersal = { path = "../../nomos-services/data-availability/dispersal" }
nomos-da-network-core = { path = "../../nomos-da/network/core" }
nomos-da-network-service = { path = "../../nomos-services/data-availability/network" }

View File

@ -22,7 +22,7 @@ overwatch-rs = { git = "https://github.com/logos-co/Overwatch", rev = "2f70806"
overwatch-derive = { git = "https://github.com/logos-co/Overwatch", rev = "ac28d01" }
tracing = "0.1"
multiaddr = "0.18"
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs"}
nomos-da-sampling = { path = "../../nomos-services/data-availability/sampling", features = ["rocksdb-backend"] }
nomos-da-verifier = { path = "../../nomos-services/data-availability/verifier", features = ["rocksdb-backend", "libp2p"] }
nomos-da-indexer = { path = "../../nomos-services/data-availability/indexer", features = ["rocksdb-backend"] }
@ -42,9 +42,9 @@ nomos-libp2p = { path = "../../nomos-libp2p" }
nomos-system-sig = { path = "../../nomos-services/system-sig" }
tracing-subscriber = "0.3"
cryptarchia-engine = { path = "../../consensus/cryptarchia-engine" }
cryptarchia-ledger = { path = "../../ledger/cryptarchia-ledger" }
nomos-ledger = { path = "../../ledger/nomos-ledger" }
rand_chacha = "0.3"
cl = { path = "../../cl/cl" }
cl = { path = "../../nomos-core/cl" }
tokio = { version = "1.24", features = ["sync"] }
serde_json = "1.0"
serde_yaml = "0.9"

View File

@ -25,7 +25,7 @@ kzgrs-backend = { path = "../nomos-da/kzgrs-backend" }
nomos-log = { path = "../nomos-services/log" }
nomos-libp2p = { path = "../nomos-libp2p" }
libp2p = { version = "0.53", features = ["macros", "serde"] }
nomos-core = { path = "../nomos-core" }
nomos-core = { path = "../nomos-core/chain-defs" }
nomos-node = { path = "../nodes/nomos-node" }
nomos-da-network-core = { path = "../nomos-da/network/core" }
subnetworks-assignations = { path = "../nomos-da/network/subnetworks-assignations" }

View File

@ -12,10 +12,12 @@ authors = [
async-trait = { version = "0.1" }
blake2 = { version = "0.10" }
bytes = "1.3"
carnot-engine = { path = "../consensus/carnot-engine", features = ["serde"]}
cryptarchia-engine = { path = "../consensus/cryptarchia-engine", features = ["serde"]}
cryptarchia-ledger = { path = "../ledger/cryptarchia-ledger", features = ["serde", "risc0_proof"]}
cl = { path = "../cl/cl" }
carnot-engine = { path = "../../consensus/carnot-engine", features = ["serde"]}
cryptarchia-engine = { path = "../../consensus/cryptarchia-engine", features = ["serde"]}
nomos-ledger = { path = "../../ledger/nomos-ledger", features = ["serde", "risc0_proof"]}
nomos_cl_risc0_proofs = { path = "../risc0_proofs" }
nomos_proof_statements = { path = "../proof_statements" }
cl = { path = "../cl" }
futures = "0.3"
raptorq = { version = "1.7", optional = true }
serde = { version = "1.0", features = ["derive"] }
@ -24,10 +26,13 @@ bincode = "1.3"
once_cell = "1.0"
indexmap = { version = "1.9", features = ["serde"] }
const-hex = "1"
risc0-zkvm = "1.1"
tracing = "0.1"
anyhow = "1.0"
[dev-dependencies]
rand = "0.8"
risc0-zkvm = { version = "1.1", features = ["prove"] }
[features]
default = []

View File

@ -8,14 +8,10 @@ use serde::Serialize;
use crate::block::Block;
use crate::crypto::Blake2b;
use crate::da::blob::{info::DispersedBlobInfo, BlobSelect};
use crate::header::{
carnot::Builder as CarnotBuilder, cryptarchia::Builder as CryptarchiaBuilder, Header, HeaderId,
};
use crate::header::Builder;
use crate::tx::{Transaction, TxSelect};
use crate::wire;
use blake2::digest::Digest;
use carnot_engine::overlay::RandomBeaconState;
use carnot_engine::{LeaderProof, Qc, View};
/// Wrapper over a block building `new` method than holds intermediary state and can be
/// passed around. It also compounds the transaction selection and blob selection heuristics to be
/// used for transaction and blob selection.
@ -33,33 +29,11 @@ use carnot_engine::{LeaderProof, Qc, View};
pub struct BlockBuilder<Tx, Blob, TxSelector, BlobSelector> {
tx_selector: TxSelector,
blob_selector: BlobSelector,
carnot_header_builder: Option<CarnotBuilder>,
cryptarchia_header_builder: Option<CryptarchiaBuilder>,
header_builder: Builder,
txs: Option<Box<dyn Iterator<Item = Tx>>>,
blobs: Option<Box<dyn Iterator<Item = Blob>>>,
}
impl<Tx, C, TxSelector, BlobSelector> BlockBuilder<Tx, C, TxSelector, BlobSelector>
where
Tx: Clone + Eq + Hash,
C: Clone + Eq + Hash,
{
pub fn empty_carnot(
beacon: RandomBeaconState,
view: View,
parent_qc: Qc<HeaderId>,
leader_proof: LeaderProof,
) -> Block<Tx, C> {
Block {
header: Header::Carnot(
CarnotBuilder::new(beacon, view, parent_qc, leader_proof).build([0; 32].into(), 0),
),
cl_transactions: IndexSet::new(),
bl_blobs: IndexSet::new(),
}
}
}
impl<Tx, B, TxSelector, BlobSelector> BlockBuilder<Tx, B, TxSelector, BlobSelector>
where
Tx: Transaction + Clone + Eq + Hash + Serialize + DeserializeOwned,
@ -67,32 +41,20 @@ where
TxSelector: TxSelect<Tx = Tx>,
BlobSelector: BlobSelect<BlobId = B>,
{
pub fn new(tx_selector: TxSelector, blob_selector: BlobSelector) -> Self {
pub fn new(
tx_selector: TxSelector,
blob_selector: BlobSelector,
header_builder: Builder,
) -> Self {
Self {
tx_selector,
blob_selector,
carnot_header_builder: None,
cryptarchia_header_builder: None,
header_builder,
txs: None,
blobs: None,
}
}
#[must_use]
pub fn with_carnot_builder(mut self, carnot_header_builder: CarnotBuilder) -> Self {
self.carnot_header_builder = Some(carnot_header_builder);
self
}
#[must_use]
pub fn with_cryptarchia_builder(
mut self,
cryptarchia_header_builder: CryptarchiaBuilder,
) -> Self {
self.cryptarchia_header_builder = Some(cryptarchia_header_builder);
self
}
#[must_use]
pub fn with_transactions(mut self, txs: impl Iterator<Item = Tx> + 'static) -> Self {
self.txs = Some(Box::new(txs));
@ -113,8 +75,7 @@ where
if let Self {
tx_selector,
blob_selector,
carnot_header_builder: carnot_builder,
cryptarchia_header_builder: cryptarchia_builder,
header_builder,
txs: Some(txs),
blobs: Some(blobs),
} = self
@ -134,15 +95,7 @@ where
})?;
let content_id = <[u8; 32]>::from(Blake2b::digest(&serialized_content)).into();
let header = match (carnot_builder, cryptarchia_builder) {
(Some(carnot_builder), None) => {
Header::Carnot(carnot_builder.build(content_id, content_size))
}
(None, Some(cryptarchia_builder)) => {
Header::Cryptarchia(cryptarchia_builder.build(content_id, content_size))
}
_ => return Err("Exactly one header builder should be set".to_string()),
};
let header = header_builder.build(content_id, content_size);
Ok(Block {
header,

View File

@ -0,0 +1,2 @@
use blake2::digest::typenum::U32;
pub type Blake2b = blake2::Blake2b<U32>;

View File

@ -1,9 +1,18 @@
use super::{ContentId, HeaderId};
use crate::crypto::Blake2b;
// std
// crates
use blake2::Digest;
use cryptarchia_engine::Slot;
use cryptarchia_ledger::leader_proof::{LeaderProof, Risc0LeaderProof};
use serde::{Deserialize, Serialize};
// internal
use crate::crypto::Blake2b;
use crate::utils::{display_hex_bytes_newtype, serde_bytes_newtype};
use cryptarchia_engine::Slot;
use nomos_ledger::leader_proof::{LeaderProof, Risc0LeaderProof};
#[derive(Clone, Debug, Eq, PartialEq, Copy, Hash, PartialOrd, Ord)]
pub struct HeaderId([u8; 32]);
#[derive(Clone, Debug, Eq, PartialEq, Copy, Hash)]
pub struct ContentId([u8; 32]);
#[allow(dead_code)]
#[derive(Clone, Debug, Eq, PartialEq, Copy)]
@ -116,3 +125,42 @@ impl Builder {
}
}
}
impl From<[u8; 32]> for HeaderId {
fn from(id: [u8; 32]) -> Self {
Self(id)
}
}
impl From<HeaderId> for [u8; 32] {
fn from(id: HeaderId) -> Self {
id.0
}
}
impl From<[u8; 32]> for ContentId {
fn from(id: [u8; 32]) -> Self {
Self(id)
}
}
impl From<ContentId> for [u8; 32] {
fn from(id: ContentId) -> Self {
id.0
}
}
display_hex_bytes_newtype!(HeaderId);
display_hex_bytes_newtype!(ContentId);
serde_bytes_newtype!(HeaderId, 32);
serde_bytes_newtype!(ContentId, 32);
#[test]
fn test_serde() {
assert_eq!(
crate::wire::deserialize::<HeaderId>(&crate::wire::serialize(&HeaderId([0; 32])).unwrap())
.unwrap(),
HeaderId([0; 32])
);
}

View File

@ -1,4 +1,3 @@
pub mod account;
pub mod block;
pub mod crypto;
pub mod da;
@ -6,5 +5,4 @@ pub mod header;
pub mod staking;
pub mod tx;
pub mod utils;
pub mod vote;
pub mod wire;

View File

@ -0,0 +1,147 @@
// std
//crates
use bytes::{Bytes, BytesMut};
use risc0_zkvm::Prover;
use serde::{de::Error as _, Deserialize, Deserializer, Serialize, Serializer};
//internal
use super::Error;
use crate::wire;
use nomos_proof_statements::bundle::{BundlePrivate, BundlePublic};
#[derive(Debug, Clone)]
pub struct Bundle {
bundle: cl::Bundle,
//TODO: this can be pruned once validated
proof: risc0_zkvm::Receipt,
}
impl Bundle {
pub fn bundle(&self) -> &cl::Bundle {
&self.bundle
}
pub fn prove(bundle_witness: &cl::BundleWitness, prover: &dyn Prover) -> Result<Self, Error> {
// need to show that bundle is balanced.
// i.e. the sum of ptx balances is 0
let bundle_private = BundlePrivate {
balances: bundle_witness
.partial_witnesses()
.iter()
.map(|ptx| ptx.balance())
.collect(),
};
let env = risc0_zkvm::ExecutorEnv::builder()
.write(&bundle_private)?
.build()?;
let start_t = std::time::Instant::now();
let opts = risc0_zkvm::ProverOpts::groth16();
let prove_info = prover.prove_with_opts(env, nomos_cl_risc0_proofs::BUNDLE_ELF, &opts)?;
tracing::trace!(
"STARK 'bundle' prover time: {:.2?}, total_cycles: {}",
start_t.elapsed(),
prove_info.stats.total_cycles
);
let receipt = prove_info.receipt;
Ok(Self {
bundle: bundle_witness.commit(),
proof: receipt,
})
}
pub fn as_bytes(&self) -> Bytes {
let mut buff = BytesMut::new();
wire::serializer_into_buffer(&mut buff)
.serialize_into(&self)
.expect("MockTransaction serialization to buffer failed");
buff.freeze()
}
}
impl Serialize for Bundle {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
(&self.bundle, &self.proof).serialize(serializer)
}
}
impl<'de> Deserialize<'de> for Bundle {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
// TODO: limit number of bites serialized
let (bundle, proof) = <(cl::Bundle, risc0_zkvm::Receipt)>::deserialize(deserializer)?;
proof
.verify(nomos_cl_risc0_proofs::BUNDLE_ID)
.map_err(D::Error::custom)?;
let bundle_public: BundlePublic = proof.journal.decode().map_err(D::Error::custom)?;
if Vec::from_iter(bundle.partial_txs().iter().map(|ptx| ptx.balance))
!= bundle_public.balances
{
return Err(D::Error::custom("Bundle balance mismatch"));
}
Ok(Self { bundle, proof })
}
}
#[cfg(test)]
mod test {
use super::*;
use cl::{note::derive_unit, *};
fn receive_utxo(note: cl::NoteWitness, nf_pk: cl::NullifierCommitment) -> cl::OutputWitness {
cl::OutputWitness::new(note, nf_pk)
}
#[test]
fn test_bundle() {
let nmo = derive_unit("NMO");
let mut rng = rand::thread_rng();
let sender_nf_sk = cl::NullifierSecret::random(&mut rng);
let sender_nf_pk = sender_nf_sk.commit();
let recipient_nf_pk = cl::NullifierSecret::random(&mut rng).commit();
// Assume the sender has received an unspent output from somewhere
let utxo = receive_utxo(cl::NoteWitness::basic(10, nmo, &mut rng), sender_nf_pk);
// and wants to send 8 NMO to some recipient and return 2 NMO to itself.
let recipient_output =
cl::OutputWitness::new(cl::NoteWitness::basic(8, nmo, &mut rng), recipient_nf_pk);
let change_output =
cl::OutputWitness::new(cl::NoteWitness::basic(2, nmo, &mut rng), sender_nf_pk);
let ptx_witness = cl::PartialTxWitness {
inputs: vec![cl::InputWitness::from_output(utxo, sender_nf_sk)],
outputs: vec![recipient_output, change_output],
balance_blinding: BalanceWitness::random_blinding(&mut rng),
};
let bundle = cl::BundleWitness::new(vec![ptx_witness]);
// ATTENTION: building a valid proof requires a x86 machine with docker installed
// if you don't have one, you can run this test with RISC0_DEV_MODE=1 or skip the test
let prover = risc0_zkvm::default_prover();
let bundle = super::Bundle::prove(&bundle, prover.as_ref()).unwrap();
assert_eq!(
wire::serialize(&bundle).unwrap(),
wire::serialize(
&wire::deserialize::<super::Bundle>(&wire::serialize(&bundle).unwrap()).unwrap()
)
.unwrap()
);
}
}

View File

@ -1,10 +1,13 @@
use std::hash::Hash;
// std
use blake2::Digest;
use std::hash::Hash;
// crates
use crate::crypto::Blake2b;
use bytes::Bytes;
use thiserror::Error;
// internal
pub mod carnot;
pub mod bundle;
#[cfg(feature = "mock")]
pub mod mock;
pub mod select;
@ -30,3 +33,24 @@ pub trait TxSelect {
txs: I,
) -> impl Iterator<Item = Self::Tx> + 'i;
}
pub enum Tx {
Bundle(bundle::Bundle),
}
impl Transaction for Tx {
const HASHER: TransactionHasher<Self> = |tx| Blake2b::digest(tx.as_bytes()).into();
type Hash = [u8; 32];
fn as_bytes(&self) -> Bytes {
match self {
Tx::Bundle(bundle) => bundle.as_bytes(),
}
}
}
#[derive(Debug, Error)]
pub enum Error {
#[error("risc0 failed to prove execution of the zkvm")]
Risc0ProofFailed(#[from] anyhow::Error),
}

View File

@ -5,22 +5,39 @@ use crate::{partial_tx::PartialTx, BalanceWitness, PartialTxWitness};
/// The transaction bundle is a collection of partial transactions.
/// The goal in bundling transactions is to produce a set of partial transactions
/// that balance each other.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Bundle {
pub partials: Vec<PartialTx>,
partials: Vec<PartialTx>,
}
impl Bundle {
pub fn new(partials: Vec<PartialTx>) -> Self {
Self { partials }
}
pub fn partial_txs(&self) -> &[PartialTx] {
&self.partials
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct BundleWitness {
pub partials: Vec<PartialTxWitness>,
partials: Vec<PartialTxWitness>,
}
impl BundleWitness {
pub fn new(partials: Vec<PartialTxWitness>) -> Self {
Self { partials }
}
pub fn balance(&self) -> BalanceWitness {
BalanceWitness::combine(self.partials.iter().map(|ptx| ptx.balance()), [0u8; 16])
}
pub fn partial_witnesses(&self) -> &[PartialTxWitness] {
&self.partials
}
pub fn commit(&self) -> Bundle {
Bundle {
partials: Vec::from_iter(self.partials.iter().map(|ptx| ptx.commit())),

View File

@ -29,9 +29,7 @@ fn test_simple_transfer() {
balance_blinding: BalanceWitness::random_blinding(&mut rng),
};
let bundle = cl::BundleWitness {
partials: vec![ptx_witness],
};
let bundle = cl::BundleWitness::new(vec![ptx_witness]);
assert!(bundle.balance().is_zero())
}

View File

@ -0,0 +1,8 @@
[package]
name = "nomos_proof_statements"
version = "0.1.0"
edition = "2021"
[dependencies]
cl = { path = "../cl" }
serde = { version = "1.0", features = ["derive"] }

View File

@ -0,0 +1,12 @@
use cl::{Balance, BalanceWitness};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct BundlePublic {
pub balances: Vec<Balance>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct BundlePrivate {
pub balances: Vec<BalanceWitness>,
}

View File

@ -0,0 +1,8 @@
use cl::{Nullifier, PtxRoot};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub struct CovenantPublic {
pub nf: Nullifier,
pub ptx_root: PtxRoot,
}

View File

@ -0,0 +1,3 @@
pub mod bundle;
pub mod covenant;
pub mod ptx;

View File

@ -0,0 +1,15 @@
use cl::{PartialTx, PartialTxWitness};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PtxPublic {
pub ptx: PartialTx,
pub cm_root: [u8; 32],
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct PtxPrivate {
pub ptx: PartialTxWitness,
pub input_cm_paths: Vec<Vec<cl::merkle::PathNode>>,
pub cm_root: [u8; 32],
}

View File

@ -0,0 +1,11 @@
[package]
name = "nomos_cl_risc0_proofs"
version = "0.1.0"
edition = "2021"
[build-dependencies]
risc0-build = { version = "1.0" }
[package.metadata.risc0]
methods = ["bundle", "covenant_nop", "ptx"]

View File

@ -0,0 +1,3 @@
fn main() {
risc0_build::embed_methods();
}

View File

@ -0,0 +1,17 @@
[package]
name = "bundle"
version = "0.1.0"
edition = "2021"
[workspace]
[dependencies]
risc0-zkvm = { version = "1.0", default-features = false, features = ['std'] }
serde = { version = "1.0", features = ["derive"] }
cl = { path = "../../cl" }
nomos_proof_statements = { path = "../../proof_statements" }
[patch.crates-io]
# add RISC Zero accelerator support for all downstream usages of the following crates.
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" }

View File

@ -0,0 +1,17 @@
/// Bundle Proof
///
/// The bundle proof demonstrates that the set of partial transactions
/// balance to zero. i.e. \sum inputs = \sum outputs.
use risc0_zkvm::guest::env;
fn main() {
let bundle_private: nomos_proof_statements::bundle::BundlePrivate = env::read();
let bundle_public = nomos_proof_statements::bundle::BundlePublic {
balances: Vec::from_iter(bundle_private.balances.iter().map(|b| b.commit())),
};
assert!(cl::BalanceWitness::combine(bundle_private.balances, [0u8; 16]).is_zero());
env::commit(&bundle_public);
}

View File

@ -0,0 +1,12 @@
[package]
name = "covenant_nop"
version = "0.1.0"
edition = "2021"
[workspace]
[dependencies]
risc0-zkvm = { version = "1.0", default-features = false, features = ['std'] }
serde = { version = "1.0", features = ["derive"] }
cl = { path = "../../cl" }
nomos_proof_statements = { path = "../../proof_statements" }

View File

@ -0,0 +1,8 @@
/// Constraint No-op Proof
use nomos_proof_statements::covenant::CovenantPublic;
use risc0_zkvm::guest::env;
fn main() {
let public: CovenantPublic = env::read();
env::commit(&public);
}

View File

@ -0,0 +1,17 @@
[package]
name = "ptx"
version = "0.1.0"
edition = "2021"
[workspace]
[dependencies]
risc0-zkvm = { version = "1.0", default-features = false, features = ['std'] }
serde = { version = "1.0", features = ["derive"] }
cl = { path = "../../cl" }
nomos_proof_statements = { path = "../../proof_statements" }
[patch.crates-io]
# add RISC Zero accelerator support for all downstream usages of the following crates.
sha2 = { git = "https://github.com/risc0/RustCrypto-hashes", tag = "sha2-v0.10.8-risczero.0" }

View File

@ -0,0 +1,27 @@
use cl::merkle;
use nomos_proof_statements::ptx::{PtxPrivate, PtxPublic};
use risc0_zkvm::guest::env;
fn main() {
let PtxPrivate {
ptx,
input_cm_paths,
cm_root,
} = env::read();
assert_eq!(ptx.inputs.len(), input_cm_paths.len());
for (input, cm_path) in ptx.inputs.iter().zip(input_cm_paths) {
let note_cm = input.note_commitment();
let cm_leaf = merkle::leaf(note_cm.as_bytes());
assert_eq!(cm_root, merkle::path_root(cm_leaf, &cm_path));
}
for output in ptx.outputs.iter() {
assert!(output.note.value > 0);
}
env::commit(&PtxPublic {
ptx: ptx.commit(),
cm_root,
});
}

View File

@ -0,0 +1 @@
include!(concat!(env!("OUT_DIR"), "/methods.rs"));

View File

@ -1,4 +0,0 @@
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct AccountId;

View File

@ -1,7 +0,0 @@
use blake2::digest::typenum::U32;
pub type PublicKey = [u8; 32];
pub type PrivateKey = [u8; 32];
pub type Signature = [u8; 32];
pub type Blake2b = blake2::Blake2b<U32>;

View File

@ -1,116 +0,0 @@
use super::{ContentId, HeaderId};
use crate::crypto::Blake2b;
use crate::wire;
use blake2::Digest;
use serde::{Deserialize, Serialize};
use carnot_engine::overlay::RandomBeaconState;
use carnot_engine::{LeaderProof, Qc, View};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Header {
beacon: RandomBeaconState,
view: View,
parent_qc: Qc<HeaderId>,
leader_proof: LeaderProof,
content_id: ContentId,
content_size: u32,
}
impl Header {
pub fn new(
beacon: RandomBeaconState,
view: View,
parent_qc: Qc<HeaderId>,
leader_proof: LeaderProof,
content_id: ContentId,
content_size: u32,
) -> Self {
Self {
beacon,
view,
parent_qc,
leader_proof,
content_id,
content_size,
}
}
pub fn beacon(&self) -> &RandomBeaconState {
&self.beacon
}
pub fn id(&self) -> HeaderId {
let mut h = Blake2b::new();
let bytes = wire::serialize(&self).unwrap();
h.update(&bytes);
HeaderId(h.finalize().into())
}
pub fn parent_qc(&self) -> &Qc<HeaderId> {
&self.parent_qc
}
pub fn leader_proof(&self) -> &LeaderProof {
&self.leader_proof
}
pub fn content_id(&self) -> ContentId {
self.content_id
}
pub fn content_size(&self) -> u32 {
self.content_size
}
pub fn view(&self) -> View {
self.view
}
pub fn parent(&self) -> HeaderId {
self.parent_qc.block()
}
pub fn to_carnot_block(&self) -> carnot_engine::Block<HeaderId> {
carnot_engine::Block {
id: self.id(),
parent_qc: self.parent_qc.clone(),
view: self.view(),
leader_proof: self.leader_proof().clone(),
}
}
}
pub struct Builder {
beacon: RandomBeaconState,
view: View,
parent_qc: Qc<HeaderId>,
leader_proof: LeaderProof,
}
impl Builder {
pub fn new(
beacon: RandomBeaconState,
view: View,
parent_qc: Qc<HeaderId>,
leader_proof: LeaderProof,
) -> Self {
Self {
beacon,
view,
parent_qc,
leader_proof,
}
}
pub fn build(self, content_id: ContentId, content_size: u32) -> Header {
Header::new(
self.beacon,
self.view,
self.parent_qc,
self.leader_proof,
content_id,
content_size,
)
}
}

View File

@ -1,89 +0,0 @@
use serde::{Deserialize, Serialize};
use crate::utils::{display_hex_bytes_newtype, serde_bytes_newtype};
pub mod carnot;
pub mod cryptarchia;
#[derive(Clone, Debug, Eq, PartialEq, Copy, Hash, PartialOrd, Ord)]
pub struct HeaderId([u8; 32]);
#[derive(Clone, Debug, Eq, PartialEq, Copy, Hash)]
pub struct ContentId([u8; 32]);
// This lint is a false positive?
#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum Header {
Cryptarchia(cryptarchia::Header),
Carnot(carnot::Header),
}
impl Header {
pub fn cryptarchia(&self) -> &cryptarchia::Header {
match self {
Self::Cryptarchia(header) => header,
Self::Carnot(_) => panic!("Header is not a Cryptarchia header"),
}
}
pub fn carnot(&self) -> &carnot::Header {
match self {
Self::Carnot(header) => header,
Self::Cryptarchia(_) => panic!("Header is not a Carnot header"),
}
}
pub fn id(&self) -> HeaderId {
match self {
Self::Cryptarchia(header) => header.id(),
Self::Carnot(header) => header.id(),
}
}
pub fn parent(&self) -> HeaderId {
match self {
Self::Cryptarchia(header) => header.parent(),
Self::Carnot(header) => header.parent(),
}
}
}
impl From<[u8; 32]> for HeaderId {
fn from(id: [u8; 32]) -> Self {
Self(id)
}
}
impl From<HeaderId> for [u8; 32] {
fn from(id: HeaderId) -> Self {
id.0
}
}
impl From<[u8; 32]> for ContentId {
fn from(id: [u8; 32]) -> Self {
Self(id)
}
}
impl From<ContentId> for [u8; 32] {
fn from(id: ContentId) -> Self {
id.0
}
}
display_hex_bytes_newtype!(HeaderId);
display_hex_bytes_newtype!(ContentId);
serde_bytes_newtype!(HeaderId, 32);
serde_bytes_newtype!(ContentId, 32);
#[test]
fn test_serde() {
assert_eq!(
crate::wire::deserialize::<HeaderId>(&crate::wire::serialize(&HeaderId([0; 32])).unwrap())
.unwrap(),
HeaderId([0; 32])
);
}

View File

@ -1,35 +0,0 @@
// std
// crates
use bytes::Bytes;
use serde::{Deserialize, Serialize};
// internal
pub use crate::tx::carnot::transaction::TransferTransaction;
use crate::tx::{Transaction, TransactionHasher};
mod transaction;
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
pub enum Tx {
Transfer(TransferTransaction),
}
// TODO: We should probably abstract the de/serialization of the transaction as it s done in transaction.rs
fn hash_carnot_tx(tx: &Tx) -> [u8; 32] {
use blake2::{
digest::{consts::U32, Digest},
Blake2b,
};
let mut hasher = Blake2b::<U32>::new();
hasher.update(<Tx as Transaction>::as_bytes(tx));
let res = hasher.finalize();
res.into()
}
impl Transaction for Tx {
const HASHER: TransactionHasher<Self> = hash_carnot_tx;
type Hash = [u8; 32];
fn as_bytes(&self) -> Bytes {
[].to_vec().into()
}
}

View File

@ -1,71 +0,0 @@
use crate::account::AccountId;
use crate::crypto::Signature;
/// Verified transactions
///
/// Can only be constructed if the signature is valid,
/// but does not imply that it can be successfully applied
/// to the ledger.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct TransferTransaction {
pub from: AccountId,
pub to: AccountId,
pub value: u64,
// TODO: here for the moment because I still want to retain the ability
// to go from `Transaction` to wire format. We could otherwise
// save the id and rely on some storage
_signature: Signature,
}
mod serde {
use super::*;
use ::serde::{Deserialize, Deserializer, Serialize, Serializer};
// We have this additional definition so that we can automatically derive
// Serialize/Deserialize for the type while still being able to check
// the signature while deserializing.
// This would also allow to control ser/de independently from the Rust
// representation.
#[derive(Serialize, Deserialize)]
struct WireTransferTransaction {
from: AccountId,
to: AccountId,
value: u64,
signature: Signature,
}
impl<'de> Deserialize<'de> for TransferTransaction {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let WireTransferTransaction {
from,
to,
value,
signature,
} = WireTransferTransaction::deserialize(deserializer)?;
//TODO: check signature
Ok(TransferTransaction {
from,
to,
value,
_signature: signature,
})
}
}
impl Serialize for TransferTransaction {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
WireTransferTransaction {
from: self.from.clone(),
to: self.to.clone(),
value: self.value,
signature: self._signature,
}
.serialize(serializer)
}
}
}

View File

@ -1,81 +0,0 @@
// std
// crates
use crate::header::HeaderId;
use carnot_engine::{Block, View};
use futures::{Stream, StreamExt};
use serde::{Deserialize, Serialize};
// internal
use crate::vote::Tally;
#[derive(Serialize, Deserialize)]
pub struct MockVote {
view: View,
}
impl MockVote {
pub fn view(&self) -> View {
self.view
}
}
#[allow(dead_code)]
pub struct MockQc {
count_votes: usize,
}
#[derive(Debug, thiserror::Error)]
#[error("{0}")]
pub struct Error(String);
#[derive(Clone, Debug)]
pub struct MockTallySettings {
pub threshold: usize,
}
#[derive(Debug)]
pub struct MockTally {
threshold: usize,
}
impl MockQc {
pub fn new(count_votes: usize) -> Self {
Self { count_votes }
}
pub fn votes(&self) -> usize {
self.count_votes
}
}
#[async_trait::async_trait]
impl Tally for MockTally {
type Vote = MockVote;
type Qc = MockQc;
type Outcome = ();
type Subject = Block<HeaderId>;
type TallyError = Error;
type Settings = MockTallySettings;
fn new(settings: Self::Settings) -> Self {
let Self::Settings { threshold } = settings;
Self { threshold }
}
async fn tally<S: Stream<Item = Self::Vote> + Unpin + Send>(
&self,
block: Block<HeaderId>,
mut vote_stream: S,
) -> Result<(Self::Qc, Self::Outcome), Self::TallyError> {
let mut count_votes = 0;
while let Some(vote) = vote_stream.next().await {
if vote.view() != block.view {
return Err(Error("Invalid vote".into()));
}
count_votes += 1;
if count_votes > self.threshold {
return Ok((MockQc { count_votes }, ()));
}
}
Err(Error("Not enough votes".into()))
}
}

View File

@ -1,18 +0,0 @@
pub mod mock;
use futures::Stream;
#[async_trait::async_trait]
pub trait Tally {
type Vote;
type Qc;
type Outcome;
type Subject;
type TallyError;
type Settings: Clone;
fn new(settings: Self::Settings) -> Self;
async fn tally<S: Stream<Item = Self::Vote> + Unpin + Send>(
&self,
subject: Self::Subject,
vote_stream: S,
) -> Result<(Self::Qc, Self::Outcome), Self::TallyError>;
}

View File

@ -10,7 +10,7 @@ openapi = ["dep:utoipa", "serde_json"]
[dependencies]
blake2 = { version = "0.10" }
bytes = { version = "1.3", features = ["serde"] }
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
serde = { version = "1.0", features = ["derive"] }
utoipa = { version = "4.0", optional = true }

View File

@ -14,7 +14,7 @@ blake2 = "0.10"
blst = { version = "0.3.11", features = ["serde"] }
itertools = "0.12"
kzgrs = { path = "../kzgrs" }
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
num-bigint = "0.4.4"
rand = "0.8.5"
once_cell = "1.19"

View File

@ -12,7 +12,7 @@ tracing = "0.1"
indexmap = "2.2"
subnetworks-assignations = { path = "../subnetworks-assignations" }
nomos-da-messages = { path = "../messages" }
nomos-core = { path = "../../../nomos-core" }
nomos-core = { path = "../../../nomos-core/chain-defs" }
kzgrs-backend = { path = "../../kzgrs-backend" }
tracing-subscriber = "0.3.18"
void = "1.0.2"

View File

@ -13,7 +13,7 @@ bytes = "1.2"
overwatch-rs = { git = "https://github.com/logos-co/Overwatch", rev = "2f70806" }
overwatch-derive = { git = "https://github.com/logos-co/Overwatch", rev = "ac28d01" }
tracing = "0.1"
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
cryptarchia-consensus = { path = "../cryptarchia-consensus" }
nomos-network = { path = "../../nomos-services/network" }
nomos-mix-service = { path = "../../nomos-services/mix", features = ["libp2p"] }

View File

@ -10,15 +10,15 @@ async-trait = "0.1"
bytes = "1.3"
chrono = "0.4"
cryptarchia-engine = { path = "../../consensus/cryptarchia-engine", features = ["serde"] }
cryptarchia-ledger = { path = "../../ledger/cryptarchia-ledger", features = ["serde", "risc0_proof", "prove"] }
nomos-ledger = { path = "../../ledger/nomos-ledger", features = ["serde", "risc0_proof", "prove"] }
leader_proof_statements = { path = "../../proof_of_leadership/proof_statements" }
cl = { path = "../../cl/cl" }
cl = { path = "../../nomos-core/cl" }
futures = "0.3"
nomos-da-sampling = { path = "../data-availability/sampling" }
nomos-network = { path = "../network" }
nomos-mix-service = { path = "../mix" }
nomos-mempool = { path = "../mempool" }
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
overwatch-rs = { git = "https://github.com/logos-co/Overwatch", rev = "2f70806" }
nomos-storage = { path = "../storage" }
rand_chacha = "0.3"

View File

@ -1,14 +1,14 @@
use cl::{input::InputWitness, note::NoteWitness, nullifier::Nullifier};
use cryptarchia_engine::Slot;
use cryptarchia_ledger::{leader_proof::Risc0LeaderProof, Config, EpochState, NoteTree};
use leader_proof_statements::{LeaderPrivate, LeaderPublic};
use nomos_core::header::HeaderId;
use nomos_ledger::{leader_proof::Risc0LeaderProof, Config, EpochState, NoteTree};
use std::collections::HashMap;
pub struct Leader {
// for each block, the indexes in the note tree of the notes we control
notes: HashMap<HeaderId, Vec<InputWitness>>,
config: cryptarchia_ledger::Config,
config: nomos_ledger::Config,
}
impl Leader {

View File

@ -7,23 +7,23 @@ mod time;
use cl::InputWitness;
use core::fmt::Debug;
use cryptarchia_engine::Slot;
use cryptarchia_ledger::{
leader_proof::{LeaderProof, Risc0LeaderProof},
LedgerState,
};
use futures::StreamExt;
use network::NetworkAdapter;
use nomos_core::da::blob::{
info::DispersedBlobInfo, metadata::Metadata as BlobMetadata, BlobSelect,
};
use nomos_core::header::{cryptarchia::Header, HeaderId};
use nomos_core::header::{Header, HeaderId};
use nomos_core::tx::{Transaction, TxSelect};
use nomos_core::{
block::{builder::BlockBuilder, Block},
header::cryptarchia::Builder,
header::Builder,
};
use nomos_da_sampling::backend::DaSamplingServiceBackend;
use nomos_da_sampling::{DaSamplingService, DaSamplingServiceMsg};
use nomos_ledger::{
leader_proof::{LeaderProof, Risc0LeaderProof},
LedgerState,
};
use nomos_mempool::{
backend::MemPool, network::NetworkAdapter as MempoolAdapter, DaMempoolService, MempoolMsg,
TxMempoolService,
@ -61,13 +61,13 @@ const CRYPTARCHIA_ID: ServiceId = "Cryptarchia";
#[derive(Debug, Clone, Error)]
pub enum Error {
#[error("Ledger error: {0}")]
Ledger(#[from] cryptarchia_ledger::LedgerError<HeaderId>),
Ledger(#[from] nomos_ledger::LedgerError<HeaderId>),
#[error("Consensus error: {0}")]
Consensus(#[from] cryptarchia_engine::Error<HeaderId>),
}
struct Cryptarchia {
ledger: cryptarchia_ledger::Ledger<HeaderId>,
ledger: nomos_ledger::Ledger<HeaderId>,
consensus: cryptarchia_engine::Cryptarchia<HeaderId>,
}
@ -107,7 +107,7 @@ impl Cryptarchia {
Ok(Self { ledger, consensus })
}
fn epoch_state_for_slot(&self, slot: Slot) -> Option<&cryptarchia_ledger::EpochState> {
fn epoch_state_for_slot(&self, slot: Slot) -> Option<&nomos_ledger::EpochState> {
let tip = self.tip();
let state = self.ledger.state(&tip).expect("no state for tip");
let requested_epoch = self.ledger.config().epoch(slot);
@ -127,7 +127,7 @@ pub struct CryptarchiaSettings<Ts, Bs, NetworkAdapterSettings, MixAdapterSetting
pub transaction_selector_settings: Ts,
#[serde(default)]
pub blob_selector_settings: Bs,
pub config: cryptarchia_ledger::Config,
pub config: nomos_ledger::Config,
pub genesis_state: LedgerState,
pub time: TimeConfig,
pub notes: Vec<InputWitness>,
@ -420,7 +420,7 @@ where
genesis_id,
config.consensus_config.clone(),
),
ledger: <cryptarchia_ledger::Ledger<_>>::from_genesis(
ledger: <nomos_ledger::Ledger<_>>::from_genesis(
genesis_id,
genesis_state,
config.clone(),
@ -680,7 +680,7 @@ where
// TODO: filter on time?
let header = block.header().cryptarchia();
let header = block.header();
let id = header.id();
let sampled_blobs = match get_sampled_blobs(sampling_relay.clone()).await {
Ok(sampled_blobs) => sampled_blobs,
@ -731,7 +731,7 @@ where
cryptarchia = new_state;
}
Err(Error::Ledger(cryptarchia_ledger::LedgerError::ParentNotFound(parent)))
Err(Error::Ledger(nomos_ledger::LedgerError::ParentNotFound(parent)))
| Err(Error::Consensus(cryptarchia_engine::Error::ParentMissing(parent))) => {
tracing::debug!("missing parent {:?}", parent);
// TODO: request parent block
@ -769,16 +769,17 @@ where
let blobs_ids = get_sampled_blobs(sampling_relay);
match futures::join!(cl_txs, da_certs, blobs_ids) {
(Ok(cl_txs), Ok(da_blobs_info), Ok(blobs_ids)) => {
let Ok(block) = BlockBuilder::new(tx_selector, blob_selector)
.with_cryptarchia_builder(Builder::new(parent, slot, proof))
.with_transactions(cl_txs)
.with_blobs_info(
da_blobs_info.filter(move |info| blobs_ids.contains(&info.blob_id())),
)
.build()
else {
panic!("Proposal block should always succeed to be built")
};
let block = BlockBuilder::new(
tx_selector,
blob_selector,
Builder::new(parent, slot, proof),
)
.with_transactions(cl_txs)
.with_blobs_info(
da_blobs_info.filter(move |info| blobs_ids.contains(&info.blob_id())),
)
.build()
.expect("Proposal block should always succeed to be built");
tracing::debug!("proposed block with id {:?}", block.header().id());
output = Some(block);
}

View File

@ -7,7 +7,7 @@ edition = "2021"
async-trait = "0.1"
futures = "0.3"
itertools = "0.13"
nomos-core = { path = "../../../nomos-core" }
nomos-core = { path = "../../../nomos-core/chain-defs" }
nomos-da-network-core = { path = "../../../nomos-da/network/core" }
nomos-da-network-service = { path = "../../../nomos-services/data-availability/network" }
nomos-da-sampling = { path = "../sampling" }

View File

@ -9,7 +9,7 @@ edition = "2021"
async-trait = "0.1"
bytes = "1.2"
futures = "0.3"
nomos-core = { path = "../../../nomos-core" }
nomos-core = { path = "../../../nomos-core/chain-defs" }
nomos-da-storage = { path = "../../../nomos-da/storage" }
nomos-da-sampling = { path = "../sampling" }
nomos-storage = { path = "../../../nomos-services/storage" }

View File

@ -8,7 +8,7 @@ async-trait = "0.1"
futures = "0.3"
kzgrs-backend = { path = "../../../nomos-da/kzgrs-backend" }
overwatch-rs = { git = "https://github.com/logos-co/Overwatch", rev = "2f70806" }
nomos-core = { path = "../../../nomos-core" }
nomos-core = { path = "../../../nomos-core/chain-defs" }
nomos-libp2p = { path = "../../../nomos-libp2p" }
nomos-da-network-core = { path = "../../../nomos-da/network/core" }
subnetworks-assignations = { path = "../../../nomos-da/network/subnetworks-assignations" }

View File

@ -10,7 +10,7 @@ futures = "0.3"
hex = "0.4.3"
kzgrs-backend = { path = "../../../nomos-da/kzgrs-backend" }
libp2p-identity = { version = "0.2" }
nomos-core = { path = "../../../nomos-core" }
nomos-core = { path = "../../../nomos-core/chain-defs" }
nomos-da-network-core = { path = "../../../nomos-da/network/core" }
nomos-da-network-service = { path = "../../../nomos-services/data-availability/network" }
nomos-da-storage = { path = "../../../nomos-da/storage" }

View File

@ -8,12 +8,12 @@ blst = "0.3.11"
bytes = "1.2"
cryptarchia-consensus = { path = "../../../nomos-services/cryptarchia-consensus" }
cryptarchia-engine = { path = "../../../consensus/cryptarchia-engine", features = ["serde"] }
cryptarchia-ledger = { path = "../../../ledger/cryptarchia-ledger", features = ["serde"] }
cl = { path = "../../../cl/cl" }
nomos-ledger = { path = "../../../ledger/nomos-ledger", features = ["serde"] }
cl = { path = "../../../nomos-core/cl" }
full-replication = { path = "../../../nomos-da/full-replication" }
hex = "0.4.3"
kzgrs-backend = { path = "../../../nomos-da/kzgrs-backend" }
nomos-core = { path = "../../../nomos-core" }
nomos-core = { path = "../../../nomos-core/chain-defs" }
nomos-da-indexer = { path = "../indexer", features = ["rocksdb-backend"] }
nomos-da-verifier = { path = "../verifier", features = ["rocksdb-backend", "libp2p"] }
nomos-da-sampling = { path = "../sampling" }

View File

@ -6,7 +6,6 @@ use std::time::Duration;
use bytes::Bytes;
use cl::InputWitness;
use cryptarchia_consensus::TimeConfig;
use cryptarchia_ledger::LedgerState;
use kzgrs_backend::common::blob::DaBlob;
use kzgrs_backend::dispersal::BlobInfo;
use kzgrs_backend::encoder::DaEncoder;
@ -43,6 +42,7 @@ use nomos_da_verifier::storage::adapters::rocksdb::RocksAdapter as VerifierStora
use nomos_da_verifier::storage::adapters::rocksdb::RocksAdapterSettings as VerifierStorageSettings;
use nomos_da_verifier::DaVerifierService;
use nomos_da_verifier::DaVerifierServiceSettings;
use nomos_ledger::LedgerState;
use nomos_libp2p::{Multiaddr, Swarm, SwarmConfig};
use nomos_mempool::da::service::DaMempoolService;
use nomos_mempool::network::adapters::libp2p::Libp2pAdapter as MempoolNetworkAdapter;
@ -185,7 +185,7 @@ pub struct TestDaNetworkSettings {
pub fn new_node(
note: &InputWitness,
ledger_config: &cryptarchia_ledger::Config,
ledger_config: &nomos_ledger::Config,
genesis_state: &LedgerState,
time_config: &TimeConfig,
swarm_config: &SwarmConfig,

View File

@ -11,7 +11,6 @@ use std::{
use bytes::Bytes;
use cl::{InputWitness, NoteWitness, NullifierSecret};
use cryptarchia_consensus::{ConsensusMsg, TimeConfig};
use cryptarchia_ledger::LedgerState;
use kzgrs_backend::{
common::blob::DaBlob,
dispersal::{BlobInfo, Metadata},
@ -22,6 +21,7 @@ use nomos_core::{da::blob::metadata::Metadata as _, staking::NMO_UNIT};
use nomos_da_storage::rocksdb::DA_VERIFIED_KEY_PREFIX;
use nomos_da_storage::{fs::write_blob, rocksdb::key_bytes};
use nomos_da_verifier::backend::kzgrs::KzgrsDaVerifierSettings;
use nomos_ledger::LedgerState;
use nomos_libp2p::{Multiaddr, SwarmConfig};
use nomos_node::Wire;
use nomos_storage::{
@ -68,7 +68,7 @@ fn test_indexer() {
notes.iter().map(|n| n.note_commitment()),
(ids.len() as u32).into(),
);
let ledger_config = cryptarchia_ledger::Config {
let ledger_config = nomos_ledger::Config {
epoch_stake_distribution_stabilization: 3,
epoch_period_nonce_buffer: 3,
epoch_period_nonce_stabilization: 4,

View File

@ -10,10 +10,10 @@ use std::{
// crates
use cl::{InputWitness, NoteWitness, NullifierSecret};
use cryptarchia_consensus::TimeConfig;
use cryptarchia_ledger::LedgerState;
use kzgrs_backend::common::blob::DaBlob;
use nomos_core::{da::DaEncoder as _, staking::NMO_UNIT};
use nomos_da_verifier::backend::kzgrs::KzgrsDaVerifierSettings;
use nomos_ledger::LedgerState;
use nomos_libp2p::Multiaddr;
use nomos_libp2p::SwarmConfig;
use rand::{thread_rng, Rng};
@ -49,7 +49,7 @@ fn test_verifier() {
notes.iter().map(|n| n.note_commitment()),
(ids.len() as u32).into(),
);
let ledger_config = cryptarchia_ledger::Config {
let ledger_config = nomos_ledger::Config {
epoch_stake_distribution_stabilization: 3,
epoch_period_nonce_buffer: 3,
epoch_period_nonce_stabilization: 4,

View File

@ -11,7 +11,7 @@ futures = "0.3"
hex = "0.4.3"
kzgrs-backend = { path = "../../../nomos-da/kzgrs-backend" }
libp2p = { version = "0.54", features = ["ed25519"] }
nomos-core = { path = "../../../nomos-core" }
nomos-core = { path = "../../../nomos-core/chain-defs" }
nomos-da-storage = { path = "../../../nomos-da/storage" }
nomos-da-network-core = { path = "../../../nomos-da/network/core" }
nomos-da-network-service = { path = "../../../nomos-services/data-availability/network" }

View File

@ -14,7 +14,7 @@ nomos-metrics = { path = "../../nomos-services/metrics" }
nomos-network = { path = "../network" }
nomos-da-network-core = { path = "../../nomos-da/network/core" }
nomos-da-sampling = { path = "../../nomos-services/data-availability/sampling/" }
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
full-replication = { path = "../../nomos-da/full-replication" }
kzgrs-backend = { path = "../../nomos-da/kzgrs-backend" }
overwatch-rs = { git = "https://github.com/logos-co/Overwatch", rev = "2f70806" }

View File

@ -8,7 +8,7 @@ async-trait = "0.1"
futures = "0.3"
libp2p = { version = "0.53", features = ["ed25519"] }
nomos-libp2p = { path = "../../nomos-libp2p", optional = true }
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
nomos-mix-network = { path = "../../nomos-mix/network" }
nomos-mix-message = { path = "../../nomos-mix/message" }
nomos-network = { path = "../network" }

View File

@ -20,7 +20,7 @@ tracing = "0.1"
rand = { version = "0.7.3", optional = true }
futures = "0.3"
parking_lot = "0.12"
nomos-core = { path = "../../nomos-core" }
nomos-core = { path = "../../nomos-core/chain-defs" }
nomos-libp2p = { path = "../../nomos-libp2p", optional = true }
utoipa = { version = "4.0", optional = true }

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
cl = { path = "../../cl/cl" }
cl = { path = "../../nomos-core/cl" }
serde = { version = "1.0", features = ["derive"] }
crypto-bigint = { version = "0.5.5", features = ["serde"] }
sha2 = "0.10"

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
cl = { path = "../../../cl/cl" }
cl = { path = "../../../nomos-core/cl" }
leader_proof_statements = { path = "../../proof_statements" }
nomos_pol_risc0_proofs = { path = "../risc0_proofs" }
risc0-zkvm = { version = "1.0", features = ["prove"] }

View File

@ -8,7 +8,7 @@ edition = "2021"
[dependencies]
risc0-zkvm = { version = "1.0", default-features = false, features = ['std'] }
serde = { version = "1.0", features = ["derive"] }
cl = { path = "../../../../cl/cl" }
cl = { path = "../../../../nomos-core/cl" }
leader_proof_statements = { path = "../../../proof_statements" }
sha2 = "0.10"
crypto-bigint = "0.5.5"

View File

@ -15,10 +15,10 @@ cryptarchia-consensus = { path = "../nomos-services/cryptarchia-consensus" }
nomos-log = { path = "../nomos-services/log" }
nomos-api = { path = "../nomos-services/api" }
overwatch-rs = { git = "https://github.com/logos-co/Overwatch", rev = "2f70806" }
nomos-core = { path = "../nomos-core" }
nomos-core = { path = "../nomos-core/chain-defs" }
cryptarchia-engine = { path = "../consensus/cryptarchia-engine", features = ["serde"] }
cryptarchia-ledger = { path = "../ledger/cryptarchia-ledger", features = ["serde"] }
cl = { path = "../cl/cl" }
nomos-ledger = { path = "../ledger/nomos-ledger", features = ["serde"] }
cl = { path = "../nomos-core/cl" }
nomos-mempool = { path = "../nomos-services/mempool", features = ["mock", "libp2p"] }
nomos-da-network-service = { path = "../nomos-services/data-availability/network" }
nomos-da-dispersal = { path = "../nomos-services/data-availability/dispersal" }

View File

@ -3,8 +3,8 @@ use std::time::Duration;
use cl::{InputWitness, NoteWitness, NullifierSecret};
use cryptarchia_consensus::TimeConfig;
use cryptarchia_ledger::LedgerState;
use nomos_core::staking::NMO_UNIT;
use nomos_ledger::LedgerState;
use rand::thread_rng;
use time::OffsetDateTime;
@ -37,7 +37,7 @@ impl ConsensusParams {
#[derive(Clone)]
pub struct GeneralConsensusConfig {
pub notes: Vec<InputWitness>,
pub ledger_config: cryptarchia_ledger::Config,
pub ledger_config: nomos_ledger::Config,
pub genesis_state: LedgerState,
pub time: TimeConfig,
}
@ -63,7 +63,7 @@ pub fn create_consensus_configs(
notes.iter().map(|n| n.note_commitment()),
(ids.len() as u32).into(),
);
let ledger_config = cryptarchia_ledger::Config {
let ledger_config = nomos_ledger::Config {
epoch_stake_distribution_stabilization: 3,
epoch_period_nonce_buffer: 3,
epoch_period_nonce_stabilization: 4,