Skip to content

Commit

Permalink
rework a bit after review
Browse files Browse the repository at this point in the history
  • Loading branch information
fl0rek committed Jan 8, 2024
1 parent bf21388 commit f66ab21
Show file tree
Hide file tree
Showing 9 changed files with 221 additions and 204 deletions.
10 changes: 5 additions & 5 deletions rpc/tests/share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use celestia_types::consts::appconsts::{
SHARE_INFO_BYTES,
};
use celestia_types::nmt::{Namespace, NamespacedSha2Hasher, Nmt};
use celestia_types::{Blob, Share};
use celestia_types::Blob;
use nmt_rs::NamespaceMerkleHasher;

pub mod utils;
Expand Down Expand Up @@ -158,12 +158,12 @@ async fn get_eds() {
for (x, leaf) in chunk.iter().enumerate() {
if x < width / 2 && y < width / 2 {
// the `OriginalDataSquare` part of the `EDS`
let share = Share::from_raw(leaf).unwrap();
let ns = share.namespace();
nmt.push_leaf(share.as_ref(), *ns).unwrap();
let ns = leaf.namespace();
nmt.push_leaf(leaf.as_ref(), *ns).unwrap();
} else {
// the parity data computed using `eds.codec`
nmt.push_leaf(leaf, *Namespace::PARITY_SHARE).unwrap();
nmt.push_leaf(leaf.as_ref(), *Namespace::PARITY_SHARE)
.unwrap();
}
}

Expand Down
2 changes: 1 addition & 1 deletion types/src/byzantine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use tendermint_proto::Protobuf;

use crate::bail_validation;
use crate::consts::appconsts;
use crate::extended_data_square::AxisType;
use crate::fraud_proof::FraudProof;
use crate::nmt::{
Namespace, NamespaceProof, NamespacedHash, NamespacedHashExt, NMT_CODEC, NMT_ID_SIZE,
NMT_MULTIHASH_CODE, NS_SIZE,
};
use crate::rsmt2d::AxisType;
use crate::{Error, ExtendedHeader, Result, Share};

type Cid = CidGeneric<NMT_ID_SIZE>;
Expand Down
2 changes: 1 addition & 1 deletion types/src/data_availability_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use tendermint_proto::Protobuf;
use crate::consts::data_availability_header::{
MAX_EXTENDED_SQUARE_WIDTH, MIN_EXTENDED_SQUARE_WIDTH,
};
use crate::extended_data_square::AxisType;
use crate::hash::Hash;
use crate::nmt::{NamespacedHash, NamespacedHashExt};
use crate::rsmt2d::AxisType;
use crate::{bail_validation, Error, Result, ValidateBasic, ValidationError};

#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
Expand Down
150 changes: 0 additions & 150 deletions types/src/extended_data_square.rs

This file was deleted.

1 change: 0 additions & 1 deletion types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ mod byzantine;
pub mod consts;
mod data_availability_header;
mod error;
mod extended_data_square;
mod extended_header;
pub mod fraud_proof;
pub mod hash;
Expand Down
6 changes: 5 additions & 1 deletion types/src/namespaced_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use tendermint_proto::Protobuf;

use crate::extended_data_square::AxisType;
use crate::nmt::{Namespace, NamespaceProof, NamespacedHashExt, HASH_SIZE, NS_SIZE};
use crate::rsmt2d::AxisType;
use crate::{DataAvailabilityHeader, Error, Result, Share};

const NAMESPACED_DATA_ID_SIZE: usize = NamespacedDataId::size();
Expand All @@ -26,6 +26,10 @@ pub struct NamespacedDataId {
pub block_height: u64,
}

/// `NamespacedData` is constructed out of the ExtendedDataSquare, containing up to a row of
/// shares belonging to a particular namespace and a proof of their inclusion. If, for
/// particular EDS, shares from the namespace span multiple rows, one needs multiple
/// NamespacedData instances to cover the whole range.
#[derive(Serialize, Deserialize, Clone)]
#[serde(try_from = "RawNamespacedData", into = "RawNamespacedData")]
pub struct NamespacedData {
Expand Down
Loading

0 comments on commit f66ab21

Please sign in to comment.