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

feat: Eigenda disperser /get/ and /put/ endpoints #313

Closed
Show file tree
Hide file tree
Changes from 12 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
12 changes: 12 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions core/lib/config/src/configs/da_client/eigen_da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ pub struct MemStoreConfig {
#[derive(Clone, Debug, PartialEq, Deserialize, Default)]
pub struct DisperserConfig {
pub api_node_url: String, // todo: This should be removed once eigenda proxy is no longer used
pub custom_quorum_numbers: Option<Vec<u32>>, // todo: This should be removed once eigenda proxy is no longer used
pub account_id: Option<String>, // todo: This should be removed once eigenda proxy is no longer used
pub custom_quorum_numbers: Option<Vec<u32>>,
pub account_id: Option<String>,
pub disperser_rpc: String,
pub eth_confirmation_depth: i32,
pub eigenda_eth_rpc: String,
pub eigenda_svc_manager_addr: String,
pub blob_size_limit: u64,
pub status_query_timeout: u64,
pub status_query_interval: u64,
pub wait_for_finalization: bool,
}
16 changes: 16 additions & 0 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ impl ProtoRepr for proto::DataAvailabilityClient {
eigenda_svc_manager_addr: required(&conf.eigenda_svc_manager_addr)
.context("eigenda_svc_manager_addr")?
.clone(),
blob_size_limit: required(&conf.blob_size_limit)
.context("blob_size_limit")?
.clone(),
status_query_timeout: required(&conf.status_query_timeout)
.context("status_query_timeout")?
.clone(),
status_query_interval: required(&conf.status_query_interval)
.context("status_query_interval")?
.clone(),
wait_for_finalization: required(&conf.wait_for_finalization)
.context("wait_for_finalization")?
.clone(),
})
}
};
Expand Down Expand Up @@ -143,6 +155,10 @@ impl ProtoRepr for proto::DataAvailabilityClient {
eigenda_svc_manager_addr: Some(
config.eigenda_svc_manager_addr.clone(),
),
blob_size_limit: Some(config.blob_size_limit),
status_query_timeout: Some(config.status_query_timeout),
status_query_interval: Some(config.status_query_interval),
wait_for_finalization: Some(config.wait_for_finalization),
},
)),
},
Expand Down
8 changes: 6 additions & 2 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ message MemStoreConfig {

message DisperserConfig {
optional string api_node_url = 1; // TODO: This should be removed once eigenda proxy is no longer used
repeated uint32 custom_quorum_numbers = 2; // TODO: This should be removed once eigenda proxy is no longer used
optional string account_id = 3; // TODO: This should be removed once eigenda proxy is no longer used
repeated uint32 custom_quorum_numbers = 2;
optional string account_id = 3;
optional string disperser_rpc = 4;
optional int32 eth_confirmation_depth = 5;
optional string eigenda_eth_rpc = 6;
optional string eigenda_svc_manager_addr = 7;
optional uint64 blob_size_limit = 8;
optional uint64 status_query_timeout = 9;
optional uint64 status_query_interval = 10;
optional bool wait_for_finalization = 11;
}

message EigenDaConfig {
Expand Down
6 changes: 5 additions & 1 deletion core/node/eigenda_proxy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ tracing.workspace = true
rlp.workspace = true
rand.workspace = true
sha3.workspace = true
hex.workspace = true
zksync_config.workspace = true
# we can't use the workspace version of prost because
# the tonic dependency requires a hugher version.
prost = "0.13.1"
tonic = { version = "0.12.1", features = ["tls", "channel", "tls-roots"]}
tonic = { version = "0.12.1", features = ["tls", "channel", "tls-native-roots"]}
tonic-web = "0.12.1"
kzgpad-rs = { git = "https://github.com/Layr-Labs/kzgpad-rs.git", tag = "v0.1.0" }
rustls.workspace = true

[build-dependencies]
tonic-build = { version = "0.12.1", features = ["prost"] }
126 changes: 126 additions & 0 deletions core/node/eigenda_proxy/src/blob_info.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
use std::fmt;

use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};

use crate::{
common::G1Commitment as DisperserG1Commitment,
disperser::{
BatchHeader as DisperserBatchHeader, BatchMetadata as DisperserBatchMetadata,
BlobHeader as DisperserBlobHeader, BlobInfo as DisperserBlobInfo,
BlobQuorumParam as DisperserBlobQuorumParam,
BlobVerificationProof as DisperserBlobVerificationProof,
},
};

#[derive(Debug)]
pub enum ConversionError {
NotPresentError,
}

impl fmt::Display for ConversionError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ConversionError::NotPresentError => write!(f, "Failed to convert BlobInfo"),
}
}
}

#[derive(Debug)]
pub struct G1Commitment {
pub x: Vec<u8>,
Expand Down Expand Up @@ -35,6 +60,16 @@ impl Encodable for G1Commitment {
}
}

impl TryFrom<DisperserG1Commitment> for G1Commitment {
type Error = ConversionError;
fn try_from(value: DisperserG1Commitment) -> Result<Self, Self::Error> {
Ok(Self {
x: value.x,
y: value.y,
})
}
}

#[derive(Debug)]
pub struct BlobQuorumParam {
pub quorum_number: u32,
Expand Down Expand Up @@ -76,6 +111,18 @@ impl Encodable for BlobQuorumParam {
}
}

impl TryFrom<DisperserBlobQuorumParam> for BlobQuorumParam {
type Error = ConversionError;
fn try_from(value: DisperserBlobQuorumParam) -> Result<Self, Self::Error> {
Ok(Self {
quorum_number: value.quorum_number,
adversary_threshold_percentage: value.adversary_threshold_percentage,
confirmation_threshold_percentage: value.confirmation_threshold_percentage,
chunk_length: value.chunk_length,
})
}
}

#[derive(Debug)]
pub struct BlobHeader {
pub commitment: G1Commitment,
Expand Down Expand Up @@ -121,6 +168,26 @@ impl Encodable for BlobHeader {
}
}

impl TryFrom<DisperserBlobHeader> for BlobHeader {
type Error = ConversionError;
fn try_from(value: DisperserBlobHeader) -> Result<Self, Self::Error> {
if value.commitment.is_none() {
return Err(ConversionError::NotPresentError);
}
let blob_quorum_params: Result<Vec<BlobQuorumParam>, Self::Error> = value
.blob_quorum_params
.iter()
.map(|param| BlobQuorumParam::try_from(param.clone()))
.collect();
let blob_quorum_params = blob_quorum_params?;
Ok(Self {
commitment: G1Commitment::try_from(value.commitment.unwrap())?,
data_length: value.data_length,
blob_quorum_params,
})
}
}

#[derive(Debug)]
pub struct BatchHeader {
pub batch_root: Vec<u8>,
Expand Down Expand Up @@ -165,6 +232,18 @@ impl Encodable for BatchHeader {
}
}

impl TryFrom<DisperserBatchHeader> for BatchHeader {
type Error = ConversionError;
fn try_from(value: DisperserBatchHeader) -> Result<Self, Self::Error> {
Ok(Self {
batch_root: value.batch_root,
quorum_numbers: value.quorum_numbers,
quorum_signed_percentages: value.quorum_signed_percentages,
reference_block_number: value.reference_block_number,
})
}
}

#[derive(Debug)]
pub struct BatchMetadata {
pub batch_header: BatchHeader,
Expand Down Expand Up @@ -210,6 +289,22 @@ impl Encodable for BatchMetadata {
}
}

impl TryFrom<DisperserBatchMetadata> for BatchMetadata {
type Error = ConversionError;
fn try_from(value: DisperserBatchMetadata) -> Result<Self, Self::Error> {
if value.batch_header.is_none() {
return Err(ConversionError::NotPresentError);
}
Ok(Self {
batch_header: BatchHeader::try_from(value.batch_header.unwrap())?,
signatory_record_hash: value.signatory_record_hash,
fee: value.fee,
confirmation_block_number: value.confirmation_block_number,
batch_header_hash: value.batch_header_hash,
})
}
}

#[derive(Debug)]
pub struct BlobVerificationProof {
pub batch_id: u32,
Expand Down Expand Up @@ -257,6 +352,22 @@ impl Encodable for BlobVerificationProof {
}
}

impl TryFrom<DisperserBlobVerificationProof> for BlobVerificationProof {
type Error = ConversionError;
fn try_from(value: DisperserBlobVerificationProof) -> Result<Self, Self::Error> {
if value.batch_metadata.is_none() {
return Err(ConversionError::NotPresentError);
}
Ok(Self {
batch_id: value.batch_id,
blob_index: value.blob_index,
batch_medatada: BatchMetadata::try_from(value.batch_metadata.unwrap())?,
inclusion_proof: value.inclusion_proof,
quorum_indexes: value.quorum_indexes,
})
}
}

#[derive(Debug)]
pub struct BlobInfo {
pub blob_header: BlobHeader,
Expand Down Expand Up @@ -294,3 +405,18 @@ impl Encodable for BlobInfo {
s.append(&self.blob_verification_proof);
}
}

impl TryFrom<DisperserBlobInfo> for BlobInfo {
type Error = ConversionError;
fn try_from(value: DisperserBlobInfo) -> Result<Self, Self::Error> {
if value.blob_header.is_none() || value.blob_verification_proof.is_none() {
return Err(ConversionError::NotPresentError);
}
Ok(Self {
blob_header: BlobHeader::try_from(value.blob_header.unwrap())?,
blob_verification_proof: BlobVerificationProof::try_from(
value.blob_verification_proof.unwrap(),
)?,
})
}
}
Loading
Loading