Skip to content

Commit

Permalink
docs: add share version 1 to specs (#3955)
Browse files Browse the repository at this point in the history
Closes #3867
  • Loading branch information
rootulp authored Oct 10, 2024
1 parent 206b96c commit 8c356c8
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
1 change: 1 addition & 0 deletions specs/src/consensus.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
| `SHARE_INFO_BYTES` | `uint64` | `1` | `byte` | The number of bytes used for [share](data_structures.md#share) information |
| `SHARE_RESERVED_BYTES` | `uint64` | `4` | `byte` | The number of bytes used to store the index of the first transaction in a transaction share. Must be able to represent any integer up to and including `SHARE_SIZE - 1`. |
| `SHARE_SIZE` | `uint64` | `512` | `byte` | Size of transaction and blob [shares](data_structures.md#share), in bytes. |
| `SignerSize` | `int` | `20` | `byte` | The number of bytes used to store the signer in a [share](data_structures.md#share). |
| `STATE_SUBTREE_RESERVED_BYTES` | `uint64` | `1` | `byte` | Number of bytes reserved to identify state subtrees. |
| `UNBONDING_DURATION` | `uint32` | | `block` | Duration, in blocks, for unbonding a validator or delegation. |
| `v1.Version` | `uint64` | `1` | | First version of the application. Breaking changes (hard forks) must update this parameter. |
Expand Down
25 changes: 25 additions & 0 deletions specs/src/figures/first_share_with_signer.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
digraph G {
node [shape = record, penwidth = 0];

share [label=<
<table border="0" cellborder="1" cellspacing="0">
<tr>
<td align="left" border="0" cellpadding="0">0</td>
<td align="left" border="0" cellpadding="0">1</td>
<td align="left" border="0" cellpadding="0">29</td>
<td align="left" border="0" cellpadding="0">30</td>
<td align="left" border="0" cellpadding="0">34</td>
<td align="left" border="0" cellpadding="0">54</td>
<td align="left" border="0" cellpadding="0">512</td>
</tr>
<tr>
<td width="8" cellpadding="4">namespace version</td>
<td width="8" cellpadding="4">namespace id</td>
<td width="1" cellpadding="4">info byte</td>
<td width="4" cellpadding="4">sequence length</td>
<td width="4" cellpadding="4">signer</td>
<td width="200" cellpadding="4">blob1</td>
</tr>
</table>
>];
}
31 changes: 31 additions & 0 deletions specs/src/figures/first_share_with_signer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 16 additions & 2 deletions specs/src/shares.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ User submitted transactions are split into shares (see [share splitting](#share-

## Share Format

### Share Version

The share version is a 7-bit big-endian unsigned integer that is used to indicate the version of the [share format](#share-format). A new share version MUST be introduced if the share format changes in a way that is not backwards compatible. There are two share versions [share version 0](#share-version-0) and [share version 1](#share-version-1).

### Share Version 0

Every share has a fixed size [`SHARE_SIZE`](./consensus.md#constants). The share format below is consistent for all shares:

- The first [`NAMESPACE_VERSION_SIZE`](./consensus.md#constants) bytes of a share's raw data is the namespace version of that share (denoted by "namespace version" in the figure below).
Expand All @@ -44,9 +50,17 @@ Continuation share in a sequence:

Since raw data that exceeds [`SHARE_SIZE`](./consensus.md#constants)`-`[`NAMESPACE_SIZE`](./consensus.md#constants)`-`[`SHARE_INFO_BYTES`](./consensus.md#constants) `-` [`SEQUENCE_BYTES`](./consensus.md#constants) bytes will span more than one share, developers MAY choose to encode additional metadata in their raw blob data prior to inclusion in a Celestia block. For example, Celestia transaction shares encode additional metadata in the form of "reserved bytes".

### Share Version
### Share Version 1

Share version 1 is similar to share version 0 with the addition of a `signer` field. The signer is located after the sequence length in the first share. The signer is [`SIGNER_SIZE`](./consensus.md#constants) bytes.

First share in a sequence with signer:

![figure 3: first share with signer](./figures/first_share_with_signer.svg)

Continuation share in a sequence:

The share version is a 7-bit big-endian unsigned integer that is used to indicate the version of the [share format](#share-format). The only supported share version is `0`. A new share version MUST be introduced if the share format changes in a way that is not backwards compatible.
![figure 4: share continuation](./figures/share_continuation.svg)

## Transaction Shares

Expand Down

0 comments on commit 8c356c8

Please sign in to comment.