From 89b0b20990d3556cd1570355940ea9781a6d269d Mon Sep 17 00:00:00 2001 From: sanaz Date: Mon, 31 Jul 2023 15:02:51 +0300 Subject: [PATCH 01/10] includes parity namespace and tail padding namespace in the IsReserved --- pkg/namespace/namespace.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/namespace/namespace.go b/pkg/namespace/namespace.go index 42889dd8a1..f7c6ac49c8 100644 --- a/pkg/namespace/namespace.go +++ b/pkg/namespace/namespace.go @@ -104,8 +104,12 @@ func validateID(version uint8, id []byte) error { return nil } +// IsReserved returns true if the namespace is reserved according to the specs. func (n Namespace) IsReserved() bool { - return bytes.Compare(n.Bytes(), MaxReservedNamespace.Bytes()) < 1 + isLessThanMaxNamespace := bytes.Compare(n.Bytes(), MaxReservedNamespace.Bytes()) < 1 + isParityNamespace := n.IsParityShares() + isTailPadding := n.IsTailPadding() + return isLessThanMaxNamespace || isParityNamespace || isTailPadding } func (n Namespace) IsParityShares() bool { From 3ff02626707d59422c1fcc1f81b7e14ec7ef9bca Mon Sep 17 00:00:00 2001 From: sanaz Date: Mon, 31 Jul 2023 15:03:28 +0300 Subject: [PATCH 02/10] deletes unnecessary calls to IsParityShare and IsTailPadding --- pkg/namespace/random_blob.go | 8 -------- x/blob/types/payforblob.go | 10 +--------- x/blob/types/payforblob_test.go | 4 ++-- 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/pkg/namespace/random_blob.go b/pkg/namespace/random_blob.go index 1bc459ca29..156d8a574f 100644 --- a/pkg/namespace/random_blob.go +++ b/pkg/namespace/random_blob.go @@ -43,14 +43,6 @@ func isBlobNamespace(ns Namespace) bool { return false } - if ns.IsParityShares() { - return false - } - - if ns.IsTailPadding() { - return false - } - if !slices.Contains(SupportedBlobNamespaceVersions, ns.Version) { return false } diff --git a/x/blob/types/payforblob.go b/x/blob/types/payforblob.go index 7395b04f60..5fbb6ae9fe 100644 --- a/x/blob/types/payforblob.go +++ b/x/blob/types/payforblob.go @@ -186,15 +186,7 @@ func DefaultEstimateGas(blobSizes []uint32) uint64 { // tail padding). func ValidateBlobNamespace(ns appns.Namespace) error { if ns.IsReserved() { - return ErrReservedNamespace.Wrapf("got namespace: %x, want: > %x", ns, appns.MaxReservedNamespace) - } - - if ns.IsParityShares() { - return ErrParitySharesNamespace - } - - if ns.IsTailPadding() { - return ErrTailPaddingNamespace + return ErrReservedNamespace } if !slices.Contains(appns.SupportedBlobNamespaceVersions, ns.Version) { diff --git a/x/blob/types/payforblob_test.go b/x/blob/types/payforblob_test.go index cfdaa1d844..1cc8e5e652 100644 --- a/x/blob/types/payforblob_test.go +++ b/x/blob/types/payforblob_test.go @@ -176,12 +176,12 @@ func TestValidateBasic(t *testing.T) { { name: "parity shares namespace", msg: paritySharesMsg, - wantErr: ErrParitySharesNamespace, + wantErr: ErrReservedNamespace, }, { name: "tail padding namespace", msg: tailPaddingMsg, - wantErr: ErrTailPaddingNamespace, + wantErr: ErrReservedNamespace, }, { name: "tx namespace", From 6a3c1c23fe3eba76bd89aefc0fda4d2f7ea99fbe Mon Sep 17 00:00:00 2001 From: sanaz Date: Mon, 31 Jul 2023 16:40:14 +0300 Subject: [PATCH 03/10] changes a var name --- pkg/namespace/namespace.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/namespace/namespace.go b/pkg/namespace/namespace.go index f7c6ac49c8..c50a55bd26 100644 --- a/pkg/namespace/namespace.go +++ b/pkg/namespace/namespace.go @@ -106,10 +106,10 @@ func validateID(version uint8, id []byte) error { // IsReserved returns true if the namespace is reserved according to the specs. func (n Namespace) IsReserved() bool { - isLessThanMaxNamespace := bytes.Compare(n.Bytes(), MaxReservedNamespace.Bytes()) < 1 + isLessThanOrEqualToMaxNamespace := bytes.Compare(n.Bytes(), MaxReservedNamespace.Bytes()) < 1 isParityNamespace := n.IsParityShares() isTailPadding := n.IsTailPadding() - return isLessThanMaxNamespace || isParityNamespace || isTailPadding + return isLessThanOrEqualToMaxNamespace || isParityNamespace || isTailPadding } func (n Namespace) IsParityShares() bool { From 0da6cb38593ed844b0a67997bb370500613f596d Mon Sep 17 00:00:00 2001 From: sanaz Date: Tue, 1 Aug 2023 17:23:40 +0300 Subject: [PATCH 04/10] renames MaxReservedNamespace to MaxPrimaryReservedNamespace --- pkg/namespace/consts.go | 5 ++--- pkg/namespace/namespace.go | 2 +- x/blob/types/payforblob_test.go | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pkg/namespace/consts.go b/pkg/namespace/consts.go index 64b5f8db84..6ac2c77c95 100644 --- a/pkg/namespace/consts.go +++ b/pkg/namespace/consts.go @@ -51,9 +51,8 @@ var ( // (ordinary and PFBs) but before blobs. ReservedPaddingNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255}) - // MaxReservedNamespace is lexicographically the largest namespace that is - // reserved for protocol use. - MaxReservedNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255}) + // MaxPrimaryReservedNamespace is lexicographically the largest primary reserved namespaces which are reserved for protocol use. + MaxPrimaryReservedNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255}) // TailPaddingNamespace is the namespace reserved for tail padding. All data // with this namespace will be ignored. diff --git a/pkg/namespace/namespace.go b/pkg/namespace/namespace.go index c50a55bd26..cc457f67b9 100644 --- a/pkg/namespace/namespace.go +++ b/pkg/namespace/namespace.go @@ -106,7 +106,7 @@ func validateID(version uint8, id []byte) error { // IsReserved returns true if the namespace is reserved according to the specs. func (n Namespace) IsReserved() bool { - isLessThanOrEqualToMaxNamespace := bytes.Compare(n.Bytes(), MaxReservedNamespace.Bytes()) < 1 + isLessThanOrEqualToMaxNamespace := bytes.Compare(n.Bytes(), MaxPrimaryReservedNamespace.Bytes()) < 1 isParityNamespace := n.IsParityShares() isTailPadding := n.IsTailPadding() return isLessThanOrEqualToMaxNamespace || isParityNamespace || isTailPadding diff --git a/x/blob/types/payforblob_test.go b/x/blob/types/payforblob_test.go index 1cc8e5e652..e5f241faa7 100644 --- a/x/blob/types/payforblob_test.go +++ b/x/blob/types/payforblob_test.go @@ -141,7 +141,7 @@ func TestValidateBasic(t *testing.T) { // MsgPayForBlobs that uses the max reserved namespace maxReservedNamespaceMsg := validMsgPayForBlobs(t) - maxReservedNamespaceMsg.Namespaces[0] = appns.MaxReservedNamespace.Bytes() + maxReservedNamespaceMsg.Namespaces[0] = appns.MaxPrimaryReservedNamespace.Bytes() // MsgPayForBlobs that has an empty share commitment emptyShareCommitment := validMsgPayForBlobs(t) From ad875d71add38294934e98d674d237a11f9aa4ef Mon Sep 17 00:00:00 2001 From: sanaz Date: Tue, 1 Aug 2023 17:30:36 +0300 Subject: [PATCH 05/10] edits the const description --- pkg/namespace/consts.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/namespace/consts.go b/pkg/namespace/consts.go index 6ac2c77c95..df30ba4e21 100644 --- a/pkg/namespace/consts.go +++ b/pkg/namespace/consts.go @@ -51,7 +51,9 @@ var ( // (ordinary and PFBs) but before blobs. ReservedPaddingNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255}) - // MaxPrimaryReservedNamespace is lexicographically the largest primary reserved namespaces which are reserved for protocol use. + // MaxPrimaryReservedNamespace represents the largest primary reserved + // namespace reserved for protocol use. Note that there may be other + // non-primary reserved namespaces beyond this upper limit. MaxPrimaryReservedNamespace = MustNewV0([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 255}) // TailPaddingNamespace is the namespace reserved for tail padding. All data From 4e8d91147b5a81f8245d1f0f48bebdd0b57bf03d Mon Sep 17 00:00:00 2001 From: sanaz Date: Tue, 1 Aug 2023 17:32:22 +0300 Subject: [PATCH 06/10] renames a var --- pkg/namespace/namespace.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/namespace/namespace.go b/pkg/namespace/namespace.go index cc457f67b9..193919c91e 100644 --- a/pkg/namespace/namespace.go +++ b/pkg/namespace/namespace.go @@ -106,10 +106,10 @@ func validateID(version uint8, id []byte) error { // IsReserved returns true if the namespace is reserved according to the specs. func (n Namespace) IsReserved() bool { - isLessThanOrEqualToMaxNamespace := bytes.Compare(n.Bytes(), MaxPrimaryReservedNamespace.Bytes()) < 1 + isLessThanOrEqualToMaxPrimaryReservedNamespace := bytes.Compare(n.Bytes(), MaxPrimaryReservedNamespace.Bytes()) < 1 isParityNamespace := n.IsParityShares() isTailPadding := n.IsTailPadding() - return isLessThanOrEqualToMaxNamespace || isParityNamespace || isTailPadding + return isLessThanOrEqualToMaxPrimaryReservedNamespace || isParityNamespace || isTailPadding } func (n Namespace) IsParityShares() bool { From 1768e6248e6e74ac26b15ef44265d51059bc930f Mon Sep 17 00:00:00 2001 From: sanaz Date: Wed, 2 Aug 2023 10:52:50 +0300 Subject: [PATCH 07/10] addresses comments --- pkg/namespace/namespace.go | 2 +- x/blob/types/payforblob_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/namespace/namespace.go b/pkg/namespace/namespace.go index 193919c91e..682385721f 100644 --- a/pkg/namespace/namespace.go +++ b/pkg/namespace/namespace.go @@ -104,7 +104,7 @@ func validateID(version uint8, id []byte) error { return nil } -// IsReserved returns true if the namespace is reserved according to the specs. +// IsReserved returns true if the namespace is reserved for protocol-use. func (n Namespace) IsReserved() bool { isLessThanOrEqualToMaxPrimaryReservedNamespace := bytes.Compare(n.Bytes(), MaxPrimaryReservedNamespace.Bytes()) < 1 isParityNamespace := n.IsParityShares() diff --git a/x/blob/types/payforblob_test.go b/x/blob/types/payforblob_test.go index e5f241faa7..84c79f14da 100644 --- a/x/blob/types/payforblob_test.go +++ b/x/blob/types/payforblob_test.go @@ -139,7 +139,7 @@ func TestValidateBasic(t *testing.T) { intermediateStateRootsNamespaceMsg := validMsgPayForBlobs(t) intermediateStateRootsNamespaceMsg.Namespaces[0] = appns.IntermediateStateRootsNamespace.Bytes() - // MsgPayForBlobs that uses the max reserved namespace + // MsgPayForBlobs that uses the max primary reserved namespace maxReservedNamespaceMsg := validMsgPayForBlobs(t) maxReservedNamespaceMsg.Namespaces[0] = appns.MaxPrimaryReservedNamespace.Bytes() From bbffdf33b1e8c2765cbfbd686d4c1f2a5477cb14 Mon Sep 17 00:00:00 2001 From: sanaz Date: Wed, 2 Aug 2023 10:52:55 +0300 Subject: [PATCH 08/10] updates specs --- specs/src/specs/namespace.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/specs/src/specs/namespace.md b/specs/src/specs/namespace.md index d5fb595f3a..cbf0ab890d 100644 --- a/specs/src/specs/namespace.md +++ b/specs/src/specs/namespace.md @@ -58,14 +58,17 @@ The ID is encoded as a byte slice of length 28. ## Reserved Namespaces Celestia reserves certain namespaces with specific meanings. -Celestia makes use of the reserved namespaces to properly organize and order transactions and blobs inside the [data square](./data_square_layout.md). +Reserved namespaces are used to properly organize and order transactions and blobs inside the [data square](./data_square_layout.md). Applications MUST NOT use these reserved namespaces for their blob data. -Below is a list of reserved namespaces, along with a brief description of each. -In addition to the items listed in this table, it should be noted that namespaces with values less than `0x00000000000000000000000000000000000000000000000000000000FF` are exclusively reserved for use within the Celestia protocols. +Reserved namespaces fall into two categories, _Primary Reserved Namespaces_ and _Secondary Reserved Namespaces_. +- Primary Reserved Namespaces: Namespaces with values less than or equal to `0x00000000000000000000000000000000000000000000000000000000FF` are referred to as Primary Reserved Namespace and are exclusively reserved for use within the Celestia protocols. +- Secondary Reserved Namespaces: As of the time of writing, there are two secondary reserved namespaces, namely, `PARITY_SHARE_NAMESPACE` and `TAIL_PADDING_NAMESPACE` which fall out of the range of primary reserved namespaces. In the table, you will notice that the `PARITY_SHARE_NAMESPACE` and `TAIL_PADDING_NAMESPACE` utilize the namespace version `255`, which differs from the supported user-specified versions. The reason for employing version `255` for the `PARITY_SHARE_NAMESPACE` is to enable more efficient proof generation within the context of [nmt](https://github.com/celestiaorg/nmt), where it is used in conjunction with the `IgnoreMaxNamespace` feature. Similarly, the `TAIL_PADDING_NAMESPACE` utilizes the namespace version `255` to ensure that padding shares are always properly ordered and placed at the end of the Celestia data square even if a new namespace version is introduced. + +Below is a list of currently used reserved namespaces, along with a brief description of each. For additional information on the significance and application of the reserved namespaces, please refer to the [Data Square Layout](./data_square_layout.md) specifications. | name | type | value | description | From 7c76ff6e24b67c2d369fe9ba9c86917b9c92f23b Mon Sep 17 00:00:00 2001 From: sanaz Date: Wed, 2 Aug 2023 10:55:44 +0300 Subject: [PATCH 09/10] updates the table --- specs/src/specs/namespace.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/specs/src/specs/namespace.md b/specs/src/specs/namespace.md index cbf0ab890d..c37469bad3 100644 --- a/specs/src/specs/namespace.md +++ b/specs/src/specs/namespace.md @@ -63,23 +63,23 @@ Applications MUST NOT use these reserved namespaces for their blob data. Reserved namespaces fall into two categories, _Primary Reserved Namespaces_ and _Secondary Reserved Namespaces_. - Primary Reserved Namespaces: Namespaces with values less than or equal to `0x00000000000000000000000000000000000000000000000000000000FF` are referred to as Primary Reserved Namespace and are exclusively reserved for use within the Celestia protocols. -- Secondary Reserved Namespaces: As of the time of writing, there are two secondary reserved namespaces, namely, `PARITY_SHARE_NAMESPACE` and `TAIL_PADDING_NAMESPACE` which fall out of the range of primary reserved namespaces. +- Secondary Reserved Namespaces: Currently, there are two secondary reserved namespaces, namely, `PARITY_SHARE_NAMESPACE` and `TAIL_PADDING_NAMESPACE` which fall out of the range of primary reserved namespaces. In the table, you will notice that the `PARITY_SHARE_NAMESPACE` and `TAIL_PADDING_NAMESPACE` utilize the namespace version `255`, which differs from the supported user-specified versions. The reason for employing version `255` for the `PARITY_SHARE_NAMESPACE` is to enable more efficient proof generation within the context of [nmt](https://github.com/celestiaorg/nmt), where it is used in conjunction with the `IgnoreMaxNamespace` feature. Similarly, the `TAIL_PADDING_NAMESPACE` utilizes the namespace version `255` to ensure that padding shares are always properly ordered and placed at the end of the Celestia data square even if a new namespace version is introduced. -Below is a list of currently used reserved namespaces, along with a brief description of each. +Below is a list of currently used primary and secondary reserved namespaces, along with a brief description of each. For additional information on the significance and application of the reserved namespaces, please refer to the [Data Square Layout](./data_square_layout.md) specifications. -| name | type | value | description | -|-------------------------------------|-------------|----------------------------------------------------------------|------------------------------------------------------------------------------------------------------| -| `TRANSACTION_NAMESPACE` | `Namespace` | `0x0000000000000000000000000000000000000000000000000000000001` | Transactions: requests that modify the state. | -| `INTERMEDIATE_STATE_ROOT_NAMESPACE` | `Namespace` | `0x0000000000000000000000000000000000000000000000000000000002` | Intermediate state roots, committed after every transaction. | -| `PAY_FOR_BLOB_NAMESPACE` | `Namespace` | `0x0000000000000000000000000000000000000000000000000000000004` | Namespace reserved for transactions that contain a PayForBlob. | -| `RESERVED_PADDING_NAMESPACE` | `Namespace` | `0x00000000000000000000000000000000000000000000000000000000FF` | Padding after all reserved namespaces but before blobs. | -| `MAX_RESERVED_NAMESPACE` | `Namespace` | `0x00000000000000000000000000000000000000000000000000000000FF` | Max reserved namespace is lexicographically the largest namespace that is reserved for protocol use. | -| `TAIL_PADDING_NAMESPACE` | `Namespace` | `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE` | Tail padding for blobs: padding after all blobs to fill up the original data square. | -| `PARITY_SHARE_NAMESPACE` | `Namespace` | `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF` | Parity shares: extended shares in the available data matrix. | +| name | type | value | description | +|-------------------------------------|-------------|----------------------------------------------------------------|-------------------------------------------------------------------------------------------------------| +| `TRANSACTION_NAMESPACE` | `Namespace` | `0x0000000000000000000000000000000000000000000000000000000001` | Transactions: requests that modify the state. | +| `INTERMEDIATE_STATE_ROOT_NAMESPACE` | `Namespace` | `0x0000000000000000000000000000000000000000000000000000000002` | Intermediate state roots, committed after every transaction. | +| `PAY_FOR_BLOB_NAMESPACE` | `Namespace` | `0x0000000000000000000000000000000000000000000000000000000004` | Namespace reserved for transactions that contain a PayForBlob. | +| `RESERVED_PADDING_NAMESPACE` | `Namespace` | `0x00000000000000000000000000000000000000000000000000000000FF` | Padding after all reserved namespaces but before blobs. | +| `MAX_PRIMARY_RESERVED_NAMESPACE` | `Namespace` | `0x00000000000000000000000000000000000000000000000000000000FF` | Max primary reserved namespace is the largest primary reserved namespace designated for protocol use. | +| `TAIL_PADDING_NAMESPACE` | `Namespace` | `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE` | Tail padding for blobs: padding after all blobs to fill up the original data square. | +| `PARITY_SHARE_NAMESPACE` | `Namespace` | `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF` | Parity shares: extended shares in the available data matrix. | ## Assumptions and Considerations From 465813112213aa0e44f9c59bbc792a9a5bf2ce6d Mon Sep 17 00:00:00 2001 From: sanaz Date: Thu, 3 Aug 2023 11:15:51 +0300 Subject: [PATCH 10/10] addresses editorial comments --- specs/src/specs/namespace.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/specs/src/specs/namespace.md b/specs/src/specs/namespace.md index c37469bad3..1c6abd5257 100644 --- a/specs/src/specs/namespace.md +++ b/specs/src/specs/namespace.md @@ -62,8 +62,8 @@ Reserved namespaces are used to properly organize and order transactions and blo Applications MUST NOT use these reserved namespaces for their blob data. Reserved namespaces fall into two categories, _Primary Reserved Namespaces_ and _Secondary Reserved Namespaces_. -- Primary Reserved Namespaces: Namespaces with values less than or equal to `0x00000000000000000000000000000000000000000000000000000000FF` are referred to as Primary Reserved Namespace and are exclusively reserved for use within the Celestia protocols. -- Secondary Reserved Namespaces: Currently, there are two secondary reserved namespaces, namely, `PARITY_SHARE_NAMESPACE` and `TAIL_PADDING_NAMESPACE` which fall out of the range of primary reserved namespaces. +- Primary Reserved Namespaces: Namespaces with values less than or equal to `0x00000000000000000000000000000000000000000000000000000000FF` are referred to as Primary Reserved Namespaces and are exclusively reserved for use within the Celestia protocols. +- Secondary Reserved Namespaces: Currently, there are two secondary reserved namespaces, namely, `PARITY_SHARE_NAMESPACE` and `TAIL_PADDING_NAMESPACE` which fall out of the range of primary reserved namespaces. In the table, you will notice that the `PARITY_SHARE_NAMESPACE` and `TAIL_PADDING_NAMESPACE` utilize the namespace version `255`, which differs from the supported user-specified versions. The reason for employing version `255` for the `PARITY_SHARE_NAMESPACE` is to enable more efficient proof generation within the context of [nmt](https://github.com/celestiaorg/nmt), where it is used in conjunction with the `IgnoreMaxNamespace` feature. Similarly, the `TAIL_PADDING_NAMESPACE` utilizes the namespace version `255` to ensure that padding shares are always properly ordered and placed at the end of the Celestia data square even if a new namespace version is introduced.