Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: incorporates ParitySharesNamespace and TailPaddingNamespace into IsReserved function (backport #2194) #2422

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/namespace/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
// primary reserved namespaces.
PrimaryReservedPaddingNamespace = primaryReservedNamespace(0xFF)

<<<<<<< HEAD

Check failure on line 53 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

syntax error: unexpected <<, expected name

Check failure on line 53 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

syntax error: unexpected <<, expected name

Check failure on line 53 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test

syntax error: unexpected <<, expected name

Check failure on line 53 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test-coverage

syntax error: unexpected <<, expected name

Check failure on line 53 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test-race

syntax error: unexpected <<, expected name
// MaxPrimaryReservedNamespace is the highest primary reserved namespace.
// Namespaces lower than this are reserved for protocol use.
MaxPrimaryReservedNamespace = primaryReservedNamespace(0xFF)
Expand All @@ -58,6 +59,12 @@
// reserved for protocol use. Namespaces higher than this are reserved for
// protocol use.
MinSecondaryReservedNamespace = secondaryReservedNamespace(0x00)
=======

Check failure on line 62 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

syntax error: unexpected ==, expected name

Check failure on line 62 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test

syntax error: unexpected ==, expected name

Check failure on line 62 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test-coverage

syntax error: unexpected ==, expected name

Check failure on line 62 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test-race

syntax error: unexpected ==, expected name
// 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})

Check failure on line 66 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

syntax error: unexpected ] in grouped declaration; possibly missing semicolon or newline or )

Check failure on line 66 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test

syntax error: unexpected ] in grouped declaration; possibly missing semicolon or newline or )

Check failure on line 66 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test-coverage

syntax error: unexpected ] in grouped declaration; possibly missing semicolon or newline or )

Check failure on line 66 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test-race

syntax error: unexpected ] in grouped declaration; possibly missing semicolon or newline or )
>>>>>>> b3b8611 (feat!: incorporates ParitySharesNamespace and TailPaddingNamespace into IsReserved function (#2194))

Check failure on line 67 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

invalid character U+0023 '#'

Check failure on line 67 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test

invalid character U+0023 '#'

Check failure on line 67 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test-coverage

invalid character U+0023 '#'

Check failure on line 67 in pkg/namespace/consts.go

View workflow job for this annotation

GitHub Actions / test / test-race

invalid character U+0023 '#'

// TailPaddingNamespace is the namespace reserved for tail padding. All data
// with this namespace will be ignored.
Expand Down
7 changes: 7 additions & 0 deletions pkg/namespace/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@

// IsReserved returns true if the namespace is reserved for protocol-use.
func (n Namespace) IsReserved() bool {
<<<<<<< HEAD

Check failure on line 109 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

syntax error: unexpected <<, expected }

Check failure on line 109 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test

syntax error: unexpected <<, expected }

Check failure on line 109 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test-coverage

syntax error: unexpected <<, expected }

Check failure on line 109 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test-race

syntax error: unexpected <<, expected }
return n.IsPrimaryReserved() || n.IsSecondaryReserved()
}

Expand All @@ -115,6 +116,12 @@

func (n Namespace) IsSecondaryReserved() bool {
return n.IsGreaterOrEqualThan(MinSecondaryReservedNamespace)
=======

Check failure on line 119 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

syntax error: unexpected ==, expected }

Check failure on line 119 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test

syntax error: unexpected ==, expected }

Check failure on line 119 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test-coverage

syntax error: unexpected ==, expected }

Check failure on line 119 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test-race

syntax error: unexpected ==, expected }
isLessThanOrEqualToMaxPrimaryReservedNamespace := bytes.Compare(n.Bytes(), MaxPrimaryReservedNamespace.Bytes()) < 1
isParityNamespace := n.IsParityShares()
isTailPadding := n.IsTailPadding()
return isLessThanOrEqualToMaxPrimaryReservedNamespace || isParityNamespace || isTailPadding
>>>>>>> b3b8611 (feat!: incorporates ParitySharesNamespace and TailPaddingNamespace into IsReserved function (#2194))

Check failure on line 124 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / lint / golangci-lint

invalid character U+0023 '#') (typecheck)

Check failure on line 124 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test

invalid character U+0023 '#'

Check failure on line 124 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test-coverage

invalid character U+0023 '#'

Check failure on line 124 in pkg/namespace/namespace.go

View workflow job for this annotation

GitHub Actions / test / test-race

invalid character U+0023 '#'
}

func (n Namespace) IsParityShares() bool {
Expand Down
26 changes: 26 additions & 0 deletions specs/src/specs/namespace.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ The namespace ID is a 28 byte identifier that uniquely identifies a namespace. T

## Reserved Namespaces

<<<<<<< HEAD
Celestia reserves some namespaces for protocol use.
These namespaces are called "reserved namespaces".
Reserved namespaces are used to arrange the contents of the [data square](./data_square_layout.md).
Expand All @@ -67,6 +68,31 @@ For additional information on the significance and application of the reserved n
| `MIN_SECONDARY_RESERVED_NAMESPACE` | `Namespace` | Secondary | `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00` | Namespace for the lowest secondary reserved namespace. |
| `TAIL_PADDING_NAMESPACE` | `Namespace` | Secondary | `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE` | Namespace for padding after all blobs to fill up the original data square. |
| `PARITY_SHARE_NAMESPACE` | `Namespace` | Secondary | `0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF` | Namespace for parity shares. |
=======
Celestia reserves certain namespaces with specific meanings.
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.

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 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.

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_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. |
>>>>>>> b3b8611 (feat!: incorporates ParitySharesNamespace and TailPaddingNamespace into IsReserved function (#2194))

## Assumptions and Considerations

Expand Down
Loading