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(eigen-client-extra-features): Add soft confirmations #322

Merged
merged 25 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
226834f
initial commit
juan518munoz Oct 31, 2024
27413ac
Merge branch 'eigen-client-extra-features' into eigen-client-non-auth…
gianbelinche Nov 1, 2024
0dd2289
Merge branch 'eigen-client-extra-features' into eigen-client-non-auth…
gianbelinche Nov 1, 2024
7f5d01e
Add tests
gianbelinche Nov 1, 2024
ab03654
Add memstore
gianbelinche Nov 1, 2024
c565e84
Add assert to tests
gianbelinche Nov 1, 2024
f15932c
Merge branch 'eigen-client-non-auth-dispersal' into eigen-client-mems…
gianbelinche Nov 1, 2024
dc5b721
Add rest of memstore
gianbelinche Nov 1, 2024
1bac89a
Add soft confirmations
gianbelinche Nov 1, 2024
70b10a9
Remove print
gianbelinche Nov 1, 2024
46838fc
Address pr comments
gianbelinche Nov 1, 2024
d450f8a
Merge branch 'eigen-client-extra-features' into eigen-client-memstore
gianbelinche Nov 1, 2024
ec1a65a
Remove to retriable error
gianbelinche Nov 1, 2024
7864534
Merge branch 'eigen-client-extra-features' into eigen-client-memstore
gianbelinche Nov 4, 2024
edafcff
Fix conflicts
gianbelinche Nov 4, 2024
645f15e
Merge branch 'eigen-client-memstore' into eigen-client-soft-conf
gianbelinche Nov 4, 2024
3bd5812
Add inclusion data
gianbelinche Nov 4, 2024
860bc28
Change status query timeout to millis
gianbelinche Nov 4, 2024
f892e99
Merge branch 'eigen-client-extra-features' into eigen-client-memstore
gianbelinche Nov 4, 2024
22fd8a2
Document memstore
gianbelinche Nov 4, 2024
84cbecd
Fix typo
gianbelinche Nov 4, 2024
07f4a22
Merge branch 'eigen-client-memstore' into eigen-client-soft-conf
gianbelinche Nov 4, 2024
1476acf
Fix typo
gianbelinche Nov 4, 2024
04a144f
Merge branch 'eigen-client-extra-features' into eigen-client-soft-conf
gianbelinche Nov 5, 2024
0b64699
Format
gianbelinche Nov 5, 2024
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
45 changes: 41 additions & 4 deletions core/node/da_clients/src/eigen/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ mod tests {
eigenda_eth_rpc: String::default(),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
blob_size_limit: 2 * 1024 * 1024, // 2MB
status_query_timeout: 1800, // 30 minutes
status_query_interval: 5, // 5 seconds
status_query_timeout: 1800000, // 30 minutes
status_query_interval: 5, // 5 ms
wait_for_finalization: false,
authenticated: false,
});
Expand Down Expand Up @@ -157,8 +157,8 @@ mod tests {
eigenda_eth_rpc: String::default(),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
blob_size_limit: 2 * 1024 * 1024, // 2MB
status_query_timeout: 1800, // 30 minutes
status_query_interval: 5, // 5 seconds
status_query_timeout: 1800000, // 30 minutes
status_query_interval: 5, // 5 ms
wait_for_finalization: false,
authenticated: true,
});
Expand Down Expand Up @@ -218,6 +218,43 @@ mod tests {
assert_eq!(retrieved_data.unwrap(), data);
}

#[tokio::test]
async fn test_wait_for_finalization() {
let config = EigenConfig::Disperser(DisperserConfig {
custom_quorum_numbers: None,
disperser_rpc: "https://disperser-holesky.eigenda.xyz:443".to_string(),
eth_confirmation_depth: -1,
eigenda_eth_rpc: String::default(),
eigenda_svc_manager_address: "0xD4A7E1Bd8015057293f0D0A557088c286942e84b".to_string(),
blob_size_limit: 2 * 1024 * 1024, // 2MB
status_query_timeout: 1800000, // 30 minutes
status_query_interval: 5000, // 5000 ms
wait_for_finalization: true,
authenticated: true,
});
let secrets = EigenSecrets {
private_key: PrivateKey::from_str(
"d08aa7ae1bb5ddd46c3c2d8cdb5894ab9f54dec467233686ca42629e826ac4c6",
)
.unwrap(),
};
let client = EigenClient::new(config, secrets).await.unwrap();
let data = vec![1; 20];
let result = client.dispatch_blob(0, data.clone()).await.unwrap();
let blob_info: BlobInfo =
rlp::decode(&hex::decode(result.blob_id.clone()).unwrap()).unwrap();
let expected_inclusion_data = blob_info.blob_verification_proof.inclusion_proof;
let actual_inclusion_data = client
.get_inclusion_data(&result.blob_id)
.await
.unwrap()
.unwrap()
.data;
assert_eq!(expected_inclusion_data, actual_inclusion_data);
let retrieved_data = client.get_blob_data(&result.blob_id).await.unwrap();
assert_eq!(retrieved_data.unwrap(), data);
}

#[tokio::test]
async fn test_eigenda_dispatch_blob_too_large() {
let config = EigenConfig::MemStore(MemStoreConfig {
Expand Down
18 changes: 15 additions & 3 deletions core/node/da_clients/src/eigen/sdk.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{str::FromStr, time::Duration};

use secp256k1::{ecdsa::RecoverableSignature, SecretKey};
use tokio::sync::mpsc;
use tokio::{sync::mpsc, time::Instant};
use tokio_stream::{wrappers::ReceiverStream, StreamExt};
use tonic::{
transport::{Channel, ClientTlsConfig, Endpoint},
Expand Down Expand Up @@ -221,7 +221,9 @@ impl RawEigenClient {
request_id: disperse_blob_reply.request_id,
};

loop {
let start_time = Instant::now();
while Instant::now() - start_time < Duration::from_millis(self.config.status_query_timeout)
{
tokio::time::sleep(Duration::from_millis(self.config.status_query_interval)).await;
let resp = client
.get_blob_status(polling_request.clone())
Expand All @@ -236,7 +238,15 @@ impl RawEigenClient {
disperser::BlobStatus::InsufficientSignatures => {
return Err(anyhow::anyhow!("Insufficient signatures"))
}
disperser::BlobStatus::Confirmed | disperser::BlobStatus::Finalized => {
disperser::BlobStatus::Confirmed => {
if !self.config.wait_for_finalization {
let blob_info = resp
.info
.ok_or_else(|| anyhow::anyhow!("No blob header in response"))?;
return Ok(blob_info);
}
}
disperser::BlobStatus::Finalized => {
let blob_info = resp
.info
.ok_or_else(|| anyhow::anyhow!("No blob header in response"))?;
Expand All @@ -246,6 +256,8 @@ impl RawEigenClient {
_ => return Err(anyhow::anyhow!("Received unknown blob status")),
}
}

Err(anyhow::anyhow!("Failed to disperse blob (timeout)"))
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions eigenda-integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ da_client:
eigenda_eth_rpc: <your_desired_rpc>
eigenda_svc_manager_address: '0xD4A7E1Bd8015057293f0D0A557088c286942e84b'
blob_size_limit: 2097152
status_query_timeout: 1800
status_query_interval: 5
status_query_timeout: 1800000 # ms
status_query_interval: 5 # ms
wait_for_finalization: false
authenticated: false
```
Expand Down
Loading