Skip to content

Commit

Permalink
Remove retrys and add option to get inclusion data
Browse files Browse the repository at this point in the history
  • Loading branch information
gianbelinche committed Dec 4, 2024
1 parent 9511f4f commit 19504ae
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 381 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

4 changes: 0 additions & 4 deletions core/lib/config/src/configs/da_client/eigen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ pub struct EigenConfig {
pub eigenda_eth_rpc: String,
/// Address of the service manager contract
pub eigenda_svc_manager_address: String,
/// Maximun amount of time in milliseconds to wait for a status query response
pub status_query_timeout: u64,
/// Interval in milliseconds to query the status of a blob
pub status_query_interval: u64,
/// Wait for the blob to be finalized before returning the response
pub wait_for_finalization: bool,
/// Authenticated dispersal
Expand Down
6 changes: 0 additions & 6 deletions core/lib/env_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ impl FromEnv for DAClientConfig {
.parse()?,
eigenda_eth_rpc: env::var("DA_EIGENDA_ETH_RPC")?,
eigenda_svc_manager_address: env::var("DA_EIGENDA_SVC_MANAGER_ADDRESS")?,
status_query_timeout: env::var("DA_STATUS_QUERY_TIMEOUT")?.parse()?,
status_query_interval: env::var("DA_STATUS_QUERY_INTERVAL")?.parse()?,
wait_for_finalization: env::var("DA_WAIT_FOR_FINALIZATION")?.parse()?,
authenticated: env::var("DA_AUTHENTICATED")?.parse()?,
points_source: match env::var("DA_POINTS_SOURCE")?.as_str() {
Expand Down Expand Up @@ -280,8 +278,6 @@ mod tests {
DA_SETTLEMENT_LAYER_CONFIRMATION_DEPTH=0
DA_EIGENDA_ETH_RPC="http://localhost:8545"
DA_EIGENDA_SVC_MANAGER_ADDRESS="0x123"
DA_STATUS_QUERY_TIMEOUT=2
DA_STATUS_QUERY_INTERVAL=3
DA_WAIT_FOR_FINALIZATION=true
DA_AUTHENTICATED=false
DA_POINTS_SOURCE="Path"
Expand All @@ -298,8 +294,6 @@ mod tests {
settlement_layer_confirmation_depth: 0,
eigenda_eth_rpc: "http://localhost:8545".to_string(),
eigenda_svc_manager_address: "0x123".to_string(),
status_query_timeout: 2,
status_query_interval: 3,
wait_for_finalization: true,
authenticated: false,
points_source: PointsSource::Path("resources".to_string()),
Expand Down
6 changes: 0 additions & 6 deletions core/lib/protobuf_config/src/da_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ impl ProtoRepr for proto::DataAvailabilityClient {
eigenda_svc_manager_address: required(&conf.eigenda_svc_manager_address)
.context("eigenda_svc_manager_address")?
.clone(),
status_query_timeout: *required(&conf.status_query_timeout)
.context("status_query_timeout")?,
status_query_interval: *required(&conf.status_query_interval)
.context("status_query_interval")?,
wait_for_finalization: *required(&conf.wait_for_finalization)
.context("wait_for_finalization")?,
authenticated: *required(&conf.authenticated).context("authenticated")?,
Expand Down Expand Up @@ -132,8 +128,6 @@ impl ProtoRepr for proto::DataAvailabilityClient {
),
eigenda_eth_rpc: Some(config.eigenda_eth_rpc.clone()),
eigenda_svc_manager_address: Some(config.eigenda_svc_manager_address.clone()),
status_query_timeout: Some(config.status_query_timeout),
status_query_interval: Some(config.status_query_interval),
wait_for_finalization: Some(config.wait_for_finalization),
authenticated: Some(config.authenticated),
points_source: Some(match &config.points_source {
Expand Down
12 changes: 5 additions & 7 deletions core/lib/protobuf_config/src/proto/config/da_client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,13 @@ message EigenConfig {
optional int32 settlement_layer_confirmation_depth = 4;
optional string eigenda_eth_rpc = 5;
optional string eigenda_svc_manager_address = 6;
optional uint64 status_query_timeout = 7;
optional uint64 status_query_interval = 8;
optional bool wait_for_finalization = 9;
optional bool authenticated = 10;
optional bool wait_for_finalization = 8;
optional bool authenticated = 9;
oneof points_source {
Path path = 11;
Link link = 12;
Path path = 10;
Link link = 11;
}
optional uint64 chain_id = 13;
optional uint64 chain_id = 12;
reserved 1,2;
reserved "rpc_node_url","inclusion_polling_interval_ms";
}
Expand Down
1 change: 0 additions & 1 deletion core/node/da_clients/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ pbjson-types.workspace = true

# Eigen dependencies
tokio-stream.workspace = true
rlp.workspace = true
rand.workspace = true
sha3.workspace = true
tiny-keccak.workspace = true
Expand Down
238 changes: 0 additions & 238 deletions core/node/da_clients/src/eigen/blob_info.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use std::fmt;

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

use super::{
common::G1Commitment as DisperserG1Commitment,
disperser::{
Expand Down Expand Up @@ -43,23 +41,6 @@ impl G1Commitment {
}
}

impl Decodable for G1Commitment {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
let x: Vec<u8> = rlp.val_at(0)?; // Decode first element as Vec<u8>
let y: Vec<u8> = rlp.val_at(1)?; // Decode second element as Vec<u8>

Ok(G1Commitment { x, y })
}
}

impl Encodable for G1Commitment {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(2);
s.append(&self.x);
s.append(&self.y);
}
}

impl From<DisperserG1Commitment> for G1Commitment {
fn from(value: DisperserG1Commitment) -> Self {
Self {
Expand Down Expand Up @@ -89,27 +70,6 @@ impl BlobQuorumParam {
}
}

impl Decodable for BlobQuorumParam {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
Ok(BlobQuorumParam {
quorum_number: rlp.val_at(0)?,
adversary_threshold_percentage: rlp.val_at(1)?,
confirmation_threshold_percentage: rlp.val_at(2)?,
chunk_length: rlp.val_at(3)?,
})
}
}

impl Encodable for BlobQuorumParam {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(4);
s.append(&self.quorum_number);
s.append(&self.adversary_threshold_percentage);
s.append(&self.confirmation_threshold_percentage);
s.append(&self.chunk_length);
}
}

impl From<DisperserBlobQuorumParam> for BlobQuorumParam {
fn from(value: DisperserBlobQuorumParam) -> Self {
Self {
Expand Down Expand Up @@ -143,29 +103,6 @@ impl BlobHeader {
}
}

impl Decodable for BlobHeader {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
let commitment: G1Commitment = rlp.val_at(0)?;
let data_length: u32 = rlp.val_at(1)?;
let blob_quorum_params: Vec<BlobQuorumParam> = rlp.list_at(2)?;

Ok(BlobHeader {
commitment,
data_length,
blob_quorum_params,
})
}
}

impl Encodable for BlobHeader {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(3);
s.append(&self.commitment);
s.append(&self.data_length);
s.append_list(&self.blob_quorum_params);
}
}

impl TryFrom<DisperserBlobHeader> for BlobHeader {
type Error = ConversionError;
fn try_from(value: DisperserBlobHeader) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -208,27 +145,6 @@ impl BatchHeader {
}
}

impl Decodable for BatchHeader {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
Ok(BatchHeader {
batch_root: rlp.val_at(0)?,
quorum_numbers: rlp.val_at(1)?,
quorum_signed_percentages: rlp.val_at(2)?,
reference_block_number: rlp.val_at(3)?,
})
}
}

impl Encodable for BatchHeader {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(4);
s.append(&self.batch_root);
s.append(&self.quorum_numbers);
s.append(&self.quorum_signed_percentages);
s.append(&self.reference_block_number);
}
}

impl From<DisperserBatchHeader> for BatchHeader {
fn from(value: DisperserBatchHeader) -> Self {
Self {
Expand Down Expand Up @@ -260,31 +176,6 @@ impl BatchMetadata {
}
}

impl Decodable for BatchMetadata {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
let batch_header: BatchHeader = rlp.val_at(0)?;

Ok(BatchMetadata {
batch_header,
signatory_record_hash: rlp.val_at(1)?,
fee: rlp.val_at(2)?,
confirmation_block_number: rlp.val_at(3)?,
batch_header_hash: rlp.val_at(4)?,
})
}
}

impl Encodable for BatchMetadata {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(5);
s.append(&self.batch_header);
s.append(&self.signatory_record_hash);
s.append(&self.fee);
s.append(&self.confirmation_block_number);
s.append(&self.batch_header_hash);
}
}

impl TryFrom<DisperserBatchMetadata> for BatchMetadata {
type Error = ConversionError;
fn try_from(value: DisperserBatchMetadata) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -325,29 +216,6 @@ impl BlobVerificationProof {
}
}

impl Decodable for BlobVerificationProof {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
Ok(BlobVerificationProof {
batch_id: rlp.val_at(0)?,
blob_index: rlp.val_at(1)?,
batch_medatada: rlp.val_at(2)?,
inclusion_proof: rlp.val_at(3)?,
quorum_indexes: rlp.val_at(4)?,
})
}
}

impl Encodable for BlobVerificationProof {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(5);
s.append(&self.batch_id);
s.append(&self.blob_index);
s.append(&self.batch_medatada);
s.append(&self.inclusion_proof);
s.append(&self.quorum_indexes);
}
}

impl TryFrom<DisperserBlobVerificationProof> for BlobVerificationProof {
type Error = ConversionError;
fn try_from(value: DisperserBlobVerificationProof) -> Result<Self, Self::Error> {
Expand Down Expand Up @@ -382,26 +250,6 @@ impl BlobInfo {
}
}

impl Decodable for BlobInfo {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
let blob_header: BlobHeader = rlp.val_at(0)?;
let blob_verification_proof: BlobVerificationProof = rlp.val_at(1)?;

Ok(BlobInfo {
blob_header,
blob_verification_proof,
})
}
}

impl Encodable for BlobInfo {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(2);
s.append(&self.blob_header);
s.append(&self.blob_verification_proof);
}
}

impl TryFrom<DisperserBlobInfo> for BlobInfo {
type Error = ConversionError;
fn try_from(value: DisperserBlobInfo) -> Result<Self, Self::Error> {
Expand All @@ -416,89 +264,3 @@ impl TryFrom<DisperserBlobInfo> for BlobInfo {
})
}
}

#[cfg(test)]
mod test {
use super::*;

#[test]
fn test_blob_info_encoding_and_decoding() {
let blob_info = BlobInfo {
blob_header: BlobHeader {
commitment: G1Commitment {
x: vec![
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
],
y: vec![
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0,
],
},
data_length: 4,
blob_quorum_params: vec![
BlobQuorumParam {
quorum_number: 0,
adversary_threshold_percentage: 33,
confirmation_threshold_percentage: 55,
chunk_length: 1,
},
BlobQuorumParam {
quorum_number: 1,
adversary_threshold_percentage: 33,
confirmation_threshold_percentage: 55,
chunk_length: 1,
},
],
},
blob_verification_proof: BlobVerificationProof {
batch_id: 66507,
blob_index: 92,
batch_medatada: BatchMetadata {
batch_header: BatchHeader {
batch_root: vec![
179, 187, 53, 98, 192, 80, 151, 28, 125, 192, 115, 29, 129, 238, 216,
8, 213, 210, 203, 143, 181, 19, 146, 113, 98, 131, 39, 238, 149, 248,
211, 43,
],
quorum_numbers: vec![0, 1],
quorum_signed_percentages: vec![100, 100],
reference_block_number: 2624794,
},
signatory_record_hash: vec![
172, 32, 172, 142, 197, 52, 84, 143, 120, 26, 190, 9, 143, 217, 62, 19, 17,
107, 105, 67, 203, 5, 172, 249, 6, 60, 105, 240, 134, 34, 66, 133,
],
fee: vec![0],
confirmation_block_number: 2624876,
batch_header_hash: vec![
122, 115, 2, 85, 233, 75, 121, 85, 51, 81, 248, 170, 198, 252, 42, 16, 1,
146, 96, 218, 159, 44, 41, 40, 94, 247, 147, 11, 255, 68, 40, 177,
],
},
inclusion_proof: vec![
203, 160, 237, 48, 117, 255, 75, 254, 117, 144, 164, 77, 29, 146, 36, 48, 190,
140, 50, 100, 144, 237, 125, 125, 75, 54, 210, 247, 147, 23, 48, 189, 120, 4,
125, 123, 195, 244, 207, 239, 145, 109, 0, 21, 11, 162, 109, 79, 192, 100, 138,
157, 203, 22, 17, 114, 234, 72, 174, 231, 209, 133, 99, 118, 201, 160, 137,
128, 112, 84, 34, 136, 174, 139, 96, 26, 246, 148, 134, 52, 200, 229, 160, 145,
5, 120, 18, 187, 51, 11, 109, 91, 237, 171, 215, 207, 90, 95, 146, 54, 135,
166, 66, 157, 255, 237, 69, 183, 141, 45, 162, 145, 71, 16, 87, 184, 120, 84,
156, 220, 159, 4, 99, 48, 191, 203, 136, 112, 127, 226, 192, 184, 110, 6, 177,
182, 109, 207, 197, 239, 161, 132, 17, 89, 56, 137, 205, 202, 101, 97, 60, 162,
253, 23, 169, 75, 236, 211, 126, 121, 132, 191, 68, 167, 200, 16, 154, 149,
202, 197, 7, 191, 26, 8, 67, 3, 37, 137, 16, 153, 30, 209, 238, 53, 233, 148,
198, 253, 94, 216, 73, 25, 190, 205, 132, 208, 255, 219, 170, 98, 17, 160, 179,
183, 200, 17, 99, 36, 130, 216, 223, 72, 222, 250, 73, 78, 79, 72, 253, 105,
245, 84, 244, 196,
],
quorum_indexes: vec![0, 1],
},
};

let encoded_blob_info = rlp::encode(&blob_info);
let decoded_blob_info: BlobInfo = rlp::decode(&encoded_blob_info).unwrap();

assert_eq!(blob_info, decoded_blob_info);
}
}
Loading

0 comments on commit 19504ae

Please sign in to comment.