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

docs: Readd block header #13

Merged
merged 1 commit into from
Feb 27, 2022
Merged
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
49 changes: 49 additions & 0 deletions docs/Blocks/header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import APITable from '@site/src/components/APITable';

# Block structure

In StarkNet, the block is defined as a list of transactions and a block header.

## Block header

The following fields define the block header:

<APITable>

| Name | Type | Description | Implemented |
| ------------------------ | ------------------------ | ----------------------------------------------------------------------------------------- | :----------------: |
| `parent_block_hash` | `field element` | The hash of this block's parent | :heavy_check_mark: |
| `block_number` | `integer` \| `"pending"` | The number (height) of this block | :heavy_check_mark: |
| `global_state_root` | `field element` | The hash of this block's parent | :heavy_check_mark: |
| `sequencer_address` | `Ethereum address?` | The Ethereum address of the sequencer submitting the state update that creates this block | :heavy_check_mark: |
| `block_timestamp` | `timestamp` | The time the sequencer created this block before executing transactions | :heavy_check_mark: |
| `transaction_count` | `field element` | The number of transactions in a ablock | :heavy_check_mark: |
| `transaction_commitment` | `field element` | A commitment to the transactions included in the block | :heavy_check_mark: |
| `event_count` | `field element` | The number of events | :heavy_check_mark: |
| `event_commitment` | `field_element` | A commitment to the events produced in this block | :heavy_check_mark: |
| `protocol_version` | `integer` | The version of the StarkNet protocol used when creating this block | |
| `extra data` | `field element` | Extraneous data that might be useful for running transactions | |

</APITable>

:::info commitments
The commitment fields transaction_commitment, event_commitment are the roots of a hieght 64 binary Merkle Patricia tree. The leaf at index $i$ corresponds to the hash of the $i'th$ event/transaction.
:::

## Block hash

The block hash is defined as the Pedersen hash over the header's elements.

$$
\begin{aligned}
h(B)=h(&\text{block\_number}, \text{ global\_state\_root}, \text{ sequencer\_address}, \text{ block\_timestamp}, \\
&\text{transaction\_count}, \text{ transaction\_commitment}, \text{ event\_count},\\
& \text{event\_commitment}, 0, 0, \text{ parent\_block\_hash})
\end{aligned}
$$

Where $h$ is the [Pedersen](../Hashing/hash-functions#pedersen-hash) hash.

:::note placeholders
Zeroes inside the hash computation of an object are used as placeholders, to be replaced in the future by meaningful fields.
:::