forked from celestiaorg/celestia-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: update shares specs (celestiaorg#1880)
* docs: extract shares page * ignore generated .html files * rename figures * update diagrams * update reserved bytes * fix: broken links * link to reserved namespace and x/blob * extract common padding specs * update parity section * overview -> abstract * add link to NMT spec * link to block * add Glossary * clarify Celestia state * move blob data to glossary * nit: use may * remove data withholding attack * draft: overview * nit: may -> MAY * move terms up and fill out overview * adopt more of template * Improve share sequence term * fill out share splitting * fix links * add note to clarify blob * add references section * Update specs/src/specs/shares.md Co-authored-by: Sanaz Taheri <[email protected]> * Update specs/src/specs/shares.md Co-authored-by: Sanaz Taheri <[email protected]> * add figure numbers * clarify share sequence length * blob -> transaction * denote field in diagram * remove duplicate portion of transaction shares * clarify share size * fix: lint b/c non-interactive => blob share commitment --------- Co-authored-by: Sanaz Taheri <[email protected]>
- Loading branch information
Showing
16 changed files
with
165 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,4 @@ tmp/ | |
run.sh | ||
testing/e2e/networks/*/ | ||
square/testdata | ||
**/*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,3 @@ | ||
# Shares | ||
|
||
Package shares provides primitives for splitting block data into shares and | ||
parsing shares back into block data. | ||
|
||
## Compact vs. Sparse | ||
|
||
There are two types of shares: | ||
|
||
1. Compact | ||
2. Sparse | ||
|
||
Compact shares can contain data from one or more unit (transactions or | ||
intermediate state roots). Sparse shares can contain data from zero or one blob. | ||
Compact shares and sparse shares are encoded differently. The motivation behind | ||
the distinction is that transactions and intermediate state roots are expected | ||
to have small lengths so they are encoded in compact shares to minimize the | ||
number of shares needed to store them. On the other hand, blobs are expected to | ||
be larger and have the desideratum that clients should be able to create proofs | ||
of blob inclusion. This desiradum is infeasible if client A's blob is encoded | ||
into a share with another client B's blob that is unknown to A. It follows that | ||
client A's blob is encoded into a share such that the contents can be determined | ||
by client A without any additional information. See [non-interactive default | ||
rules](https://celestiaorg.github.io/celestia-app/rationale/data_square_layout.html#non-interactive-default-rules) | ||
or [ADR 006](../../docs/architecture/adr-006-non-interactive-defaults.md) for | ||
more details. | ||
|
||
## Universal Prefix | ||
|
||
Both types of shares have a universal prefix. The first 1 byte of a share | ||
contains the namespace version. The next 28 bytes contain the namespace ID. The | ||
next one byte is an [InfoByte] that contains the share version and a sequence | ||
start indicator. If the sequence start indicator is `1` (i.e. this is the first | ||
share of a sequence) then the next 4 bytes contain a big endian uint32 of the | ||
sequence length. If the sequence start indicator is `0` (i.e. this is the | ||
continuation share of a sequence) then the remaing bytes of the share contain | ||
the share data. | ||
|
||
For the first share of a sequence: | ||
|
||
```text | ||
| namespace_version | namespace_id | info_byte | sequence_length | sequence_data | | ||
| 1 byte | 28 bytes | 1 byte | 4 bytes | remaining bytes of share | | ||
``` | ||
|
||
For continuation share of a sequence: | ||
|
||
```text | ||
| namespace_version | namespace_id | info_byte | sequence_data | | ||
| 1 byte | 28 bytes | 1 byte | remaining bytes of share | | ||
``` | ||
|
||
The remaining bytes depend on the share type. | ||
|
||
## Compact Share Schema | ||
|
||
The four bytes after the universal prefix are reserved for | ||
the location in the share of the first unit of data that starts in this | ||
share. | ||
|
||
For the first compact share: | ||
|
||
```text | ||
| namespace_version | namespace_id | info_byte | sequence_length | location_of_first_unit | transactions or intermediate state roots | | ||
| 1 byte | 28 bytes | 1 byte | 4 bytes | 4 bytes | remaining bytes of share | | ||
``` | ||
|
||
For continuation compact share: | ||
|
||
```text | ||
| namespace_version | namespace_id | info_byte | location_of_first_unit | transactions or intermediate state roots | | ||
| 1 byte | 28 bytes | 1 byte | 4 bytes | remaining bytes of share | | ||
``` | ||
|
||
Notes | ||
|
||
- All shares in a reserved namespace belong to one sequence. | ||
- Each unit (transaction or intermediate state root) in data is prefixed with a varint of the length of the unit. | ||
|
||
## Sparse Share Schema | ||
|
||
The remaining bytes contain blob data. | ||
See the specs for [shares](../../specs/src/specs/shares.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.