Skip to content

Commit

Permalink
chore(types)!: Rename rsmt2d module to eds (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
oblique authored Oct 22, 2024
1 parent 4551dbc commit f431b35
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions types/src/byzantine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use serde::{Deserialize, Serialize};

use crate::bail_validation;
use crate::consts::appconsts;
use crate::eds::AxisType;
use crate::fraud_proof::FraudProof;
use crate::nmt::{Namespace, NamespaceProof, Nmt, NmtExt, NS_SIZE};
use crate::rsmt2d::AxisType;
use crate::{Error, ExtendedHeader, Result};

/// A proof that the block producer incorrectly encoded [`ExtendedDataSquare`].
Expand Down Expand Up @@ -304,7 +304,7 @@ pub(crate) mod test_utils {
use rand::Rng;

use crate::consts::appconsts::{FIRST_SPARSE_SHARE_CONTENT_SIZE, SHARE_SIZE};
use crate::rsmt2d::is_ods_square;
use crate::eds::is_ods_square;
use crate::test_utils::{random_bytes, ExtendedHeaderGenerator};
use crate::{DataAvailabilityHeader, ExtendedDataSquare};

Expand Down
4 changes: 2 additions & 2 deletions types/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ pub mod appconsts {
pub mod data_availability_header {
/// A maximum width of the [`ExtendedDataSquare`].
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub const MAX_EXTENDED_SQUARE_WIDTH: usize = super::appconsts::SQUARE_SIZE_UPPER_BOUND * 2;
/// A minimum width of the [`ExtendedDataSquare`].
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub const MIN_EXTENDED_SQUARE_WIDTH: usize = super::appconsts::MIN_SQUARE_SIZE * 2;
}

Expand Down
10 changes: 5 additions & 5 deletions types/src/data_availability_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use sha2::Sha256;
use crate::consts::data_availability_header::{
MAX_EXTENDED_SQUARE_WIDTH, MIN_EXTENDED_SQUARE_WIDTH,
};
use crate::eds::AxisType;
use crate::hash::Hash;
use crate::nmt::{NamespacedHash, NamespacedHashExt};
use crate::rsmt2d::AxisType;
use crate::{
bail_validation, bail_verification, validation_error, Error, ExtendedDataSquare, MerkleProof,
Result, ValidateBasic, ValidationError,
Expand Down Expand Up @@ -51,7 +51,7 @@ use crate::{
/// assert!(proof.verify_complete_namespace(&root, &shares, *namespace).is_ok());
/// ```
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(
try_from = "RawDataAvailabilityHeader",
Expand Down Expand Up @@ -121,14 +121,14 @@ impl DataAvailabilityHeader {

/// Merkle roots of the [`ExtendedDataSquare`] rows.
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn row_roots(&self) -> &[NamespacedHash] {
&self.row_roots
}

/// Merkle roots of the [`ExtendedDataSquare`] columns.
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn column_roots(&self) -> &[NamespacedHash] {
&self.column_roots
}
Expand Down Expand Up @@ -175,7 +175,7 @@ impl DataAvailabilityHeader {

/// Get the size of the [`ExtendedDataSquare`] for which this header was built.
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn square_width(&self) -> u16 {
// `validate_basic` checks that rows num = cols num
self.row_roots
Expand Down
2 changes: 1 addition & 1 deletion types/src/rsmt2d.rs → types/src/eds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{bail_validation, DataAvailabilityHeader, Error, InfoByte, Result, Sh

/// Represents either column or row of the [`ExtendedDataSquare`].
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[repr(u8)]
pub enum AxisType {
Expand Down
2 changes: 1 addition & 1 deletion types/src/fraud_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub struct RawFraudProof {
pub enum Proof {
/// A proof that a block producer incorrectly encoded [`ExtendedDataSquare`].
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
BadEncoding(BadEncodingFraudProof),
}

Expand Down
4 changes: 2 additions & 2 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ mod block;
mod byzantine;
pub mod consts;
mod data_availability_header;
mod eds;
mod error;
mod extended_header;
pub mod fraud_proof;
Expand All @@ -17,7 +18,6 @@ pub mod nmt;
pub mod p2p;
pub mod row;
pub mod row_namespace_data;
mod rsmt2d;
pub mod sample;
mod share;
pub mod state;
Expand All @@ -33,11 +33,11 @@ mod validator_set;
pub use crate::blob::{Blob, Commitment};
pub use crate::block::*;
pub use crate::data_availability_header::*;
pub use crate::eds::{AxisType, ExtendedDataSquare};
pub use crate::error::*;
pub use crate::extended_header::*;
pub use crate::fraud_proof::FraudProof;
pub use crate::merkle_proof::MerkleProof;
pub use crate::rsmt2d::{AxisType, ExtendedDataSquare};
pub use crate::share::*;
pub use crate::sync::*;
pub use crate::tx_config::TxConfig;
Expand Down
6 changes: 3 additions & 3 deletions types/src/nmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Namespace {
/// so that user-defined namespaces are correctly aligned in [`ExtendedDataSquare`]
///
/// [`Share`]: crate::share::Share
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub const PRIMARY_RESERVED_PADDING: Namespace = Namespace::MAX_PRIMARY_RESERVED;

/// Maximal primary reserved [`Namespace`].
Expand All @@ -133,7 +133,7 @@ impl Namespace {
/// It is used to fill up the `original data square` after all user-submitted
/// blobs before the parity data is generated for the [`ExtendedDataSquare`].
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub const TAIL_PADDING: Namespace = Namespace::const_v255(0xfe);

/// The [`Namespace`] for `parity shares`.
Expand All @@ -142,7 +142,7 @@ impl Namespace {
/// [`ExtendedDataSquare`] are inserted to the [`Nmt`] when computing
/// merkle roots.
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub const PARITY_SHARE: Namespace = Namespace::const_v255(0xff);

/// Create a new [`Namespace`] from the raw bytes.
Expand Down
6 changes: 3 additions & 3 deletions types/src/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! row of the [`ExtendedDataSquare`].
//!
//! [`Share`]: crate::Share
//! [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
//! [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
use std::iter;

Expand All @@ -18,8 +18,8 @@ use prost::Message;
use serde::{Deserialize, Serialize};

use crate::consts::appconsts::SHARE_SIZE;
use crate::eds::ExtendedDataSquare;
use crate::nmt::{NamespacedSha2Hasher, Nmt};
use crate::rsmt2d::ExtendedDataSquare;
use crate::{DataAvailabilityHeader, Error, Result, Share};

/// Number of bytes needed to represent [`EdsId`] in `multihash`.
Expand Down Expand Up @@ -192,7 +192,7 @@ impl RowId {

/// An index of the row in the [`ExtendedDataSquare`].
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn index(&self) -> u16 {
self.index
}
Expand Down
6 changes: 3 additions & 3 deletions types/src/row_namespace_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! the same [`Namespace`] in a single row of the [`ExtendedDataSquare`].
//!
//! [`Share`]: crate::Share
//! [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
//! [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
use blockstore::block::CidError;
use bytes::{BufMut, BytesMut};
Expand All @@ -29,7 +29,7 @@ pub const ROW_NAMESPACE_DATA_CODEC: u64 = 0x7820;
/// block's [`ExtendedDataSquare`].
///
/// [`Share`]: crate::Share
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
#[derive(Debug, PartialEq, Clone, Copy)]
pub struct RowNamespaceDataId {
row_id: RowId,
Expand Down Expand Up @@ -195,7 +195,7 @@ impl RowNamespaceDataId {

/// Row index of the [`ExtendedDataSquare`] that shares are located on.
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn row_index(&self) -> u16 {
self.row_id.index()
}
Expand Down
14 changes: 7 additions & 7 deletions types/src/sample.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//!
//! [`row`]: crate::row
//! [`Share`]: crate::Share
//! [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
//! [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
use blockstore::block::CidError;
use bytes::{Buf, BufMut, BytesMut};
Expand All @@ -16,9 +16,9 @@ use nmt_rs::nmt_proof::NamespaceProof as NmtNamespaceProof;
use prost::Message;
use serde::{Deserialize, Serialize};

use crate::eds::{AxisType, ExtendedDataSquare};
use crate::nmt::NamespaceProof;
use crate::row::{RowId, ROW_ID_SIZE};
use crate::rsmt2d::{AxisType, ExtendedDataSquare};
use crate::{bail_validation, DataAvailabilityHeader, Error, Result, Share};

/// Number of bytes needed to represent [`SampleId`] in `multihash`.
Expand All @@ -31,7 +31,7 @@ pub const SAMPLE_ID_CODEC: u64 = 0x7810;
/// Identifies a particular [`Share`] located in the [`ExtendedDataSquare`].
///
/// [`Share`]: crate::Share
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
#[derive(Debug, PartialEq, Clone, Copy)]
pub struct SampleId {
row_id: RowId,
Expand Down Expand Up @@ -92,7 +92,7 @@ impl Sample {
/// ```
///
/// [`Share`]: crate::Share
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn new(
row_index: u16,
column_index: u16,
Expand Down Expand Up @@ -229,7 +229,7 @@ impl SampleId {
/// ```
///
/// [`Share`]: crate::Share
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn new(row_index: u16, column_index: u16, block_height: u64) -> Result<Self> {
if block_height == 0 {
return Err(Error::ZeroBlockHeight);
Expand All @@ -248,14 +248,14 @@ impl SampleId {

/// Row index of the [`ExtendedDataSquare`] that sample is located on.
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn row_index(&self) -> u16 {
self.row_id.index()
}

/// Column index of the [`ExtendedDataSquare`] that sample is located on.
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
pub fn column_index(&self) -> u16 {
self.column_index
}
Expand Down
2 changes: 1 addition & 1 deletion types/src/share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const SHARE_SEQUENCE_LENGTH_OFFSET: usize = NS_SIZE + appconsts::SHARE_INFO_BYTE
///
/// `sequence length` is the length of the original data in bytes and is present only in the first of the shares the data was split into.
///
/// [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare
/// [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare
/// [`Blob::to_shares`]: crate::Blob::to_shares
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(try_from = "RawShare", into = "RawShare")]
Expand Down

0 comments on commit f431b35

Please sign in to comment.