Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Da nomos core #390

Merged
merged 8 commits into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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 @@ -10,8 +10,8 @@ members = [
"nomos-services/mempool",
"nomos-services/http",
"nomos-services/data-availability",
"nomos-da-core/reed-solomon",
"nomos-da-core/kzg",
"nomos-da/reed-solomon",
"nomos-da/kzg",
"nodes/nomos-node",
"simulations",
"consensus-engine",
Expand Down
8 changes: 8 additions & 0 deletions nomos-core/src/da/attestation/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use crate::da::blob::Blob;
use bytes::Bytes;

pub trait Attestation {
type Blob: Blob;
fn blob(&self) -> <Self::Blob as Blob>::Hash;
fn as_bytes(&self) -> Bytes;
}
File renamed without changes.
1 change: 1 addition & 0 deletions nomos-core/src/da/certificate/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub trait Certificate {}
25 changes: 25 additions & 0 deletions nomos-core/src/da/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::da::attestation::Attestation;
use crate::da::blob::Blob;
use crate::da::certificate::Certificate;
use bytes::Bytes;
use futures::Stream;
use serde::de::Error;

pub mod attestation;
pub mod blob;
pub mod certificate;

pub trait DaProtocol {
type Blob: Blob;
type Attestation: Attestation;
type Certificate: Certificate;

fn encode<T: AsRef<[u8]>>(&self, data: T) -> Box<dyn Stream<Item = Self::Blob>>;
fn decode<S: Stream<Item = Self::Blob>>(&self, s: S) -> Result<Bytes, Box<dyn Error>>;

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Rust lints (libp2p)

the trait `account::_::_serde::de::Error` cannot be made into an object

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Check (libp2p)

the trait `account::_::_serde::de::Error` cannot be made into an object

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite (libp2p, ubuntu-latest)

the trait `account::_::_serde::de::Error` cannot be made into an object

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite (libp2p, macos-latest)

the trait `account::_::_serde::de::Error` cannot be made into an object

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite (waku, ubuntu-latest)

the trait `account::_::_serde::de::Error` cannot be made into an object

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite (libp2p, windows-latest)

the trait `account::_::_serde::de::Error` cannot be made into an object

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite (waku, macos-latest)

the trait `account::_::_serde::de::Error` cannot be made into an object

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Test

the trait `account::_::_serde::de::Error` cannot be made into an object

Check failure on line 18 in nomos-core/src/da/mod.rs

View workflow job for this annotation

GitHub Actions / Test Suite (waku, windows-latest)

the trait `account::_::_serde::de::Error` cannot be made into an object
fn validate_attestation(&self, blob: &Self::Blob, attestation: &Self::Attestation) -> bool;

fn certificate_dispersal<S: Stream<Item = Self::Attestation>>(
&self,
attestations: S,
) -> Self::Certificate;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to validate a single attestation or the full proof?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validate the attestation for an specific blob. We should probably add a trait method to create a certificate over the set of attestations. I'll add now as well

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe also a method to validate said certificate?

2 changes: 1 addition & 1 deletion nomos-core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub mod account;
pub mod blob;
pub mod block;
pub mod crypto;
pub mod da;
pub mod fountain;
pub mod staking;
pub mod tx;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::backend::{DaBackend, DaError};
use moka::future::{Cache, CacheBuilder};
use nomos_core::blob::Blob;
use nomos_core::da::blob::Blob;
use std::time::Duration;

#[derive(Clone, Copy)]
Expand Down
2 changes: 1 addition & 1 deletion nomos-services/data-availability/src/backend/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
mod memory_cache;

use nomos_core::blob::Blob;
use nomos_core::da::blob::Blob;
use overwatch_rs::DynError;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion nomos-services/data-availability/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use tokio::sync::oneshot::Sender;
// internal
use crate::backend::{DaBackend, DaError};
use crate::network::NetworkAdapter;
use nomos_core::blob::Blob;
use nomos_core::da::blob::Blob;
use nomos_network::NetworkService;
use overwatch_rs::services::handle::ServiceStateHandle;
use overwatch_rs::services::relay::{Relay, RelayMessage};
Expand Down
Loading