Da nomos core (#390)
* Refactor da modules Include da core module in nomos-core * Include attestation trait * Added initial approach for Da protocol * Added empty certificate trait * Added certificate dispersal method * Rename validate method to validate attestation * Clippy happy * Add validate certificate method
This commit is contained in:
parent
efabf66994
commit
8da13f7012
|
@ -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",
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
pub trait Certificate {}
|
|
@ -0,0 +1,30 @@
|
|||
// std
|
||||
use std::error::Error;
|
||||
// crates
|
||||
use bytes::Bytes;
|
||||
use futures::Stream;
|
||||
// internal
|
||||
use crate::da::attestation::Attestation;
|
||||
use crate::da::blob::Blob;
|
||||
use crate::da::certificate::Certificate;
|
||||
|
||||
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>>;
|
||||
fn validate_attestation(&self, blob: &Self::Blob, attestation: &Self::Attestation) -> bool;
|
||||
|
||||
fn certificate_dispersal<S: Stream<Item = Self::Attestation>>(
|
||||
&self,
|
||||
attestations: S,
|
||||
) -> Self::Certificate;
|
||||
|
||||
fn validate_certificate(certificate: &Self::Certificate) -> bool;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod memory_cache;
|
||||
|
||||
use nomos_core::blob::Blob;
|
||||
use nomos_core::da::blob::Blob;
|
||||
use overwatch_rs::DynError;
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -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};
|
||||
|
|
Loading…
Reference in New Issue