ColumnIndex in DaBlob (#693)

* ColumnIndex in DaBlob

* Use u16 for column index
This commit is contained in:
gusto 2024-08-20 13:15:16 +03:00 committed by GitHub
parent 2922e9ce74
commit 2ca822e6ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 17 additions and 0 deletions

View File

@ -45,6 +45,9 @@ impl DaDispersal for MockExecutorDispersalAdapter {
for (i, column) in encoded_data.extended_data.columns().enumerate() { for (i, column) in encoded_data.extended_data.columns().enumerate() {
let blob = DaBlob { let blob = DaBlob {
column: column.clone(), column: column.clone(),
column_idx: i
.try_into()
.expect("Column index shouldn't overflow the target type"),
column_commitment: encoded_data.column_commitments[i], column_commitment: encoded_data.column_commitments[i],
aggregated_column_commitment: encoded_data.aggregated_column_commitment, aggregated_column_commitment: encoded_data.aggregated_column_commitment,
aggregated_column_proof: encoded_data.aggregated_column_proofs[i], aggregated_column_proof: encoded_data.aggregated_column_proofs[i],

View File

@ -6,6 +6,7 @@ use serde::{Deserialize, Serialize};
use sha3::{Digest, Sha3_256}; use sha3::{Digest, Sha3_256};
// internal // internal
use super::build_blob_id; use super::build_blob_id;
use super::ColumnIndex;
use crate::common::Column; use crate::common::Column;
use crate::common::Commitment; use crate::common::Commitment;
use crate::common::{ use crate::common::{
@ -15,6 +16,7 @@ use crate::common::{
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DaBlob { pub struct DaBlob {
pub column: Column, pub column: Column,
pub column_idx: ColumnIndex,
#[serde( #[serde(
serialize_with = "serialize_canonical", serialize_with = "serialize_canonical",
deserialize_with = "deserialize_canonical" deserialize_with = "deserialize_canonical"

View File

@ -19,6 +19,7 @@ pub struct Row(pub Vec<Chunk>);
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Column(pub Vec<Chunk>); pub struct Column(pub Vec<Chunk>);
pub struct ChunksMatrix(pub Vec<Row>); pub struct ChunksMatrix(pub Vec<Row>);
pub type ColumnIndex = u16;
pub const NOMOS_DA_DST: &[u8] = b"NOMOS_DA_AVAIL"; pub const NOMOS_DA_DST: &[u8] = b"NOMOS_DA_AVAIL";

View File

@ -105,6 +105,9 @@ mod tests {
let verifier = &verifiers[i]; let verifier = &verifiers[i];
let da_blob = DaBlob { let da_blob = DaBlob {
column, column,
column_idx: i
.try_into()
.expect("Column index shouldn't overflow the target type"),
column_commitment: encoded_data.column_commitments[i], column_commitment: encoded_data.column_commitments[i],
aggregated_column_commitment: encoded_data.aggregated_column_commitment, aggregated_column_commitment: encoded_data.aggregated_column_commitment,
aggregated_column_proof: encoded_data.aggregated_column_proofs[i], aggregated_column_proof: encoded_data.aggregated_column_proofs[i],

View File

@ -223,6 +223,9 @@ mod test {
let verifier = &verifiers[i]; let verifier = &verifiers[i];
let da_blob = DaBlob { let da_blob = DaBlob {
column, column,
column_idx: i
.try_into()
.expect("Column index shouldn't overflow the target type"),
column_commitment: encoded_data.column_commitments[i], column_commitment: encoded_data.column_commitments[i],
aggregated_column_commitment: encoded_data.aggregated_column_commitment, aggregated_column_commitment: encoded_data.aggregated_column_commitment,
aggregated_column_proof: encoded_data.aggregated_column_proofs[i], aggregated_column_proof: encoded_data.aggregated_column_proofs[i],

View File

@ -127,6 +127,7 @@ pub mod test {
.send(( .send((
0, 0,
DaBlob { DaBlob {
column_idx: 0,
column: Column(vec![]), column: Column(vec![]),
column_commitment: Default::default(), column_commitment: Default::default(),
aggregated_column_commitment: Default::default(), aggregated_column_commitment: Default::default(),

View File

@ -97,6 +97,7 @@ mod test {
Blob { Blob {
blob_id: vec![], blob_id: vec![],
data: bincode::serialize(&DaBlob { data: bincode::serialize(&DaBlob {
column_idx: 0,
column: Column(vec![]), column: Column(vec![]),
column_commitment: Default::default(), column_commitment: Default::default(),
aggregated_column_commitment: Default::default(), aggregated_column_commitment: Default::default(),

View File

@ -261,6 +261,9 @@ fn test_verifier() {
let da_blob = DaBlob { let da_blob = DaBlob {
column: column.clone(), column: column.clone(),
column_idx: i
.try_into()
.expect("Column index shouldn't overflow the target type"),
column_commitment: encoded_data.column_commitments[i], column_commitment: encoded_data.column_commitments[i],
aggregated_column_commitment: encoded_data.aggregated_column_commitment, aggregated_column_commitment: encoded_data.aggregated_column_commitment,
aggregated_column_proof: encoded_data.aggregated_column_proofs[i], aggregated_column_proof: encoded_data.aggregated_column_proofs[i],