Skip to content

Commit

Permalink
Add new configs
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Oct 21, 2024
1 parent 1a9cf57 commit 017b544
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 8 deletions.
4 changes: 4 additions & 0 deletions core/lib/config/src/configs/da_client/eigen_da.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ pub struct DisperserConfig {
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
4 changes: 4 additions & 0 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ message DisperserConfig {
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
48 changes: 40 additions & 8 deletions core/node/eigenda_proxy/src/eigenda_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ pub struct EigenDAClient {
}

impl EigenDAClient {
pub const BLOB_SIZE_LIMIT_IN_BYTES: usize = 2 * 1024 * 1024; // 2MB todo: add to config
pub const STATUS_QUERY_TIMEOUT: u64 = 1800; // 30 minutes todo: add to config
pub const STATUS_QUERY_RETRY_INTERVAL: u64 = 5; // 5 seconds todo: add to config
pub const WAIT_FOR_FINALAZATION: bool = false; // todo: add to config
pub async fn new(config: DisperserConfig) -> Result<Self, EigenDAError> {
match rustls::crypto::ring::default_provider().install_default() {
Ok(_) => {}
Expand Down Expand Up @@ -63,6 +59,9 @@ impl EigenDAClient {

pub async fn put_blob(&self, blob_data: Vec<u8>) -> Result<Vec<u8>, EigenDAError> {
println!("Putting blob");
if blob_data.len() > self.config.blob_size_limit as usize {
return Err(EigenDAError::PutError);
}
let reply = self
.disperser
.lock()
Expand All @@ -87,9 +86,9 @@ impl EigenDAClient {
let request_id_str =
String::from_utf8(reply.request_id.clone()).map_err(|_| EigenDAError::PutError)?;

let mut interval = interval(Duration::from_secs(Self::STATUS_QUERY_RETRY_INTERVAL));
let mut interval = interval(Duration::from_secs(self.config.status_query_interval));
let start_time = Instant::now();
while Instant::now() - start_time < Duration::from_secs(Self::STATUS_QUERY_TIMEOUT) {
while Instant::now() - start_time < Duration::from_secs(self.config.status_query_timeout) {
let blob_status_reply = self
.disperser
.lock()
Expand All @@ -116,7 +115,7 @@ impl EigenDAClient {
interval.tick().await;
}
disperser::BlobStatus::Confirmed => {
if Self::WAIT_FOR_FINALAZATION {
if self.config.wait_for_finalization {
interval.tick().await;
} else {
match blob_status_reply.info {
Expand Down Expand Up @@ -190,7 +189,7 @@ mod test {
use super::*;

#[tokio::test]
async fn test_eigenda_proxy() {
async fn test_eigenda_client() {
let config = DisperserConfig {
api_node_url: "".to_string(),
custom_quorum_numbers: Some(vec![]),
Expand All @@ -199,6 +198,10 @@ mod test {
eth_confirmation_depth: -1,
eigenda_eth_rpc: "".to_string(),
eigenda_svc_manager_addr: "".to_string(),
blob_size_limit: 2 * 1024 * 1024, // 2MB
status_query_timeout: 1800, // 30 minutes
status_query_interval: 5, // 5 seconds
wait_for_finalization: false,
};
let store = match EigenDAClient::new(config).await {
Ok(store) => store,
Expand All @@ -221,6 +224,10 @@ mod test {
eth_confirmation_depth: -1,
eigenda_eth_rpc: "".to_string(),
eigenda_svc_manager_addr: "".to_string(),
blob_size_limit: 2 * 1024 * 1024, // 2MB
status_query_timeout: 1800, // 30 minutes
status_query_interval: 5, // 5 seconds
wait_for_finalization: false,
};
let store = match EigenDAClient::new(config).await {
Ok(store) => store,
Expand All @@ -237,4 +244,29 @@ mod test {
assert_eq!(blob, blob_result);
assert_eq!(blob2, blob_result2);
}

#[tokio::test]
async fn test_eigenda_blob_size_limit() {
let config = DisperserConfig {
api_node_url: "".to_string(),
custom_quorum_numbers: Some(vec![]),
account_id: Some("".to_string()),
disperser_rpc: "https://disperser-holesky.eigenda.xyz:443".to_string(),
eth_confirmation_depth: -1,
eigenda_eth_rpc: "".to_string(),
eigenda_svc_manager_addr: "".to_string(),
blob_size_limit: 2, // 2MB
status_query_timeout: 1800, // 30 minutes
status_query_interval: 5, // 5 seconds
wait_for_finalization: false,
};
let store = match EigenDAClient::new(config).await {
Ok(store) => store,
Err(e) => panic!("Failed to create EigenDAProxyClient {:?}", e),
};

let blob = vec![0u8; 3];
let cert = store.put_blob(blob.clone()).await;
assert!(cert.is_err());
}
}

0 comments on commit 017b544

Please sign in to comment.