From f431b35cb0b35a24a96fb0cbad8f1bec088f2a09 Mon Sep 17 00:00:00 2001 From: Yiannis Marangos Date: Tue, 22 Oct 2024 17:34:27 +0300 Subject: [PATCH] chore(types)!: Rename `rsmt2d` module to `eds` (#449) --- types/src/byzantine.rs | 4 ++-- types/src/consts.rs | 4 ++-- types/src/data_availability_header.rs | 10 +++++----- types/src/{rsmt2d.rs => eds.rs} | 2 +- types/src/fraud_proof.rs | 2 +- types/src/lib.rs | 4 ++-- types/src/nmt.rs | 6 +++--- types/src/row.rs | 6 +++--- types/src/row_namespace_data.rs | 6 +++--- types/src/sample.rs | 14 +++++++------- types/src/share.rs | 2 +- 11 files changed, 30 insertions(+), 30 deletions(-) rename types/src/{rsmt2d.rs => eds.rs} (99%) diff --git a/types/src/byzantine.rs b/types/src/byzantine.rs index 5b529451..8724b480 100644 --- a/types/src/byzantine.rs +++ b/types/src/byzantine.rs @@ -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`]. @@ -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}; diff --git a/types/src/consts.rs b/types/src/consts.rs index a93a4316..fb02c167 100644 --- a/types/src/consts.rs +++ b/types/src/consts.rs @@ -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; } diff --git a/types/src/data_availability_header.rs b/types/src/data_availability_header.rs index bf09508e..53373a59 100644 --- a/types/src/data_availability_header.rs +++ b/types/src/data_availability_header.rs @@ -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, @@ -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", @@ -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 } @@ -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 diff --git a/types/src/rsmt2d.rs b/types/src/eds.rs similarity index 99% rename from types/src/rsmt2d.rs rename to types/src/eds.rs index f9561c13..b5f5e966 100644 --- a/types/src/rsmt2d.rs +++ b/types/src/eds.rs @@ -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 { diff --git a/types/src/fraud_proof.rs b/types/src/fraud_proof.rs index 83d59d91..6faf93ef 100644 --- a/types/src/fraud_proof.rs +++ b/types/src/fraud_proof.rs @@ -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), } diff --git a/types/src/lib.rs b/types/src/lib.rs index cf76ca77..25676617 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -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; @@ -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; @@ -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; diff --git a/types/src/nmt.rs b/types/src/nmt.rs index 0a1b1e58..eb68985f 100644 --- a/types/src/nmt.rs +++ b/types/src/nmt.rs @@ -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`]. @@ -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`. @@ -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. diff --git a/types/src/row.rs b/types/src/row.rs index d22543e0..8c133012 100644 --- a/types/src/row.rs +++ b/types/src/row.rs @@ -4,7 +4,7 @@ //! row of the [`ExtendedDataSquare`]. //! //! [`Share`]: crate::Share -//! [`ExtendedDataSquare`]: crate::rsmt2d::ExtendedDataSquare +//! [`ExtendedDataSquare`]: crate::eds::ExtendedDataSquare use std::iter; @@ -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`. @@ -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 } diff --git a/types/src/row_namespace_data.rs b/types/src/row_namespace_data.rs index 16bf3cf0..0624c4e0 100644 --- a/types/src/row_namespace_data.rs +++ b/types/src/row_namespace_data.rs @@ -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}; @@ -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, @@ -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() } diff --git a/types/src/sample.rs b/types/src/sample.rs index c10a1e1b..04d2a9ba 100644 --- a/types/src/sample.rs +++ b/types/src/sample.rs @@ -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}; @@ -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`. @@ -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, @@ -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, @@ -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 { if block_height == 0 { return Err(Error::ZeroBlockHeight); @@ -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 } diff --git a/types/src/share.rs b/types/src/share.rs index 99b195e0..ed282c65 100644 --- a/types/src/share.rs +++ b/types/src/share.rs @@ -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")]