-
Notifications
You must be signed in to change notification settings - Fork 18
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
Da nomos core #390
Changes from all commits
ec98fa2
3d42ba9
9f9aa82
bb15638
2baa92b
6521278
e97ec14
20c9148
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub trait Certificate {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this supposed to validate a single attestation or the full proof? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe also a method to validate said certificate? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this have the blob in input?
EDIT: I think it's actually ok for now since we don't know much yet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not really sure, actually. Maybe we need to validate the certificate over the original data?
In this case certificate is the aggregation of attestations that proofs that data is distributed. Either we can check it stand alone or for all blobs (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess having something
Certificate::blob
is sufficient, you would then check that the certificate itself is valid on chain and you have the blob id to retrieve it if necessaryThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are calling blob different stuff here (it may be my fault in naming actually). A blob is what a node receives (and it may be just a chunk of the original data). Being the certificate an aggregation of attestations (refering to a blob) its difficult the certificate can return a single id of a single blob. In this case I see two things. I can rename it to
Blob
(the whole data) andBlobChunk
(a blob that a node receives). Or we consider the orinal data blob just data and pass away the hash of the whole thing (but I am not really sure we need this anyway, as it may be better to have validation methods where needed instead?).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I was confusing those terms. I think the fact that it might be sharded it's a protocol detail (e.g. we do that with rs encoding but not with full replication), while the concept of bl-blobs is independent of the way we do data availability, it's just a piece of data that is available somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But anyway, in the case of a full replication we would just create a
Blob
that contains the same data for each of them (encoding non-encoding 😂 ). I think for now we can assume that the certificate can be validated by itself, and we can change it later if we see fit?