Skip to content

Commit

Permalink
Curie updates (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
isabellewei committed Jun 18, 2024
1 parent 63bb328 commit 07d1f80
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 78 deletions.
161 changes: 86 additions & 75 deletions src/content/docs/en/technology/chain/rollup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ whatsnext: { "EVM Differences from Ethereum": "/en/technology/chain/differences/

import ClickToZoom from "../../../../../components/ClickToZoom.astro"
import RollupProcess from "../_images/rollup.png"
import NetworkTabs from "../../../../../components/Tabs/NetworkTabs.astro"
import { Tabs } from "../../../../../components/Tabs/Tabs.tsx"

This document describes the rollup process in Scroll.
Expand Down Expand Up @@ -121,77 +120,89 @@ At this stage, the state root of the latest finalized batch can be used trustles

This section describes the codec of three data structures in the Rollup contract: `BatchHeader`, `Chunk`, and `BlockContext`.

The latest update to the codec was introduced in the Bernoulli upgrade.

### Bernoulli

#### `BatchHeader` Codec

| Field | Bytes | Type | Offset | Description |
| ------------------------ | ------- | ----------- | ------ | --------------------------------------------------------------- |
| `version` | 1 | `uint8` | 0 | The batch header version |
| `batchIndex` | 8 | `uint64` | 1 | The index of the batch |
| `l1MessagePopped` | 8 | `uint64` | 9 | The number of L1 messages popped in the batch |
| `totalL1MessagePopped` | 8 | `uint64` | 17 | The number of total L1 messages popped after the batch |
| `dataHash` | 32 | `bytes32` | 25 | The data hash of the batch |
| `blobVersionedHash` | 32 | `bytes32` | 57 | The versioned hash of the blob with this batch’s data |
| `parentBatchHash` | 32 | `bytes32` | 89 | The parent batch hash |
| `skippedL1MessageBitmap` | dynamic | `uint256[]` | 121 | A bitmap to indicate which L1 messages are skipped in the batch |

#### `Chunk` Codec

| Field | Bytes | Type | Offset | Description |
| ---------------- | ------- | -------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `numBlocks` | 1 | `uint8` | 0 | The number of blocks in the chunk |
| `block[0]` | 60 | `BlockContext` | 1 | The block information of the 1st block |
| ... | ... | ... | ... | ... |
| `block[i]` | 60 | `BlockContext` | `60*i+1` | The block information of `i+1`-th block |
| ... | ... | ... | ... | ... |
| `block[n-1]` | 60 | `BlockContext` | `60*n-59` | The block information of the last block |

#### `BlockContext` Codec

| Field | Bytes | Type | Offset | Description |
| ----------------- | ----- | --------- | ------ | ----------------------------------------------------------------------------------- |
| `blockNumber` | 8 | `uint64` | 0 | The block number |
| `timestamp` | 8 | `uint64` | 8 | The block time |
| `baseFee` | 32 | `uint256` | 16 | The base fee of this block. Currently, it is always 0, because we disable EIP-1559. |
| `gasLimit` | 8 | `uint64` | 48 | The gas limit of this block |
| `numTransactions` | 2 | `uint16` | 56 | The number of transactions in this block, including both L1 & L2 txs |
| `numL1Messages` | 2 | `uint16` | 58 | The number of L1 messages in this block

### Archimedes
#### `BatchHeader` Codec

| Field | Bytes | Type | Offset | Description |
| ------------------------ | ------- | ----------- | ------ | --------------------------------------------------------------- |
| `version` | 1 | `uint8` | 0 | The batch header version |
| `batchIndex` | 8 | `uint64` | 1 | The index of the batch |
| `l1MessagePopped` | 8 | `uint64` | 9 | The number of L1 messages popped in the batch |
| `totalL1MessagePopped` | 8 | `uint64` | 17 | The number of total L1 messages popped after the batch |
| `dataHash` | 32 | `bytes32` | 25 | The data hash of the batch |
| `parentBatchHash` | 32 | `bytes32` | 57 | The parent batch hash |
| `skippedL1MessageBitmap` | dynamic | `uint256[]` | 89 | A bitmap to indicate which L1 messages are skipped in the batch |

#### `Chunk` Codec

| Field | Bytes | Type | Offset | Description |
| ---------------- | ------- | -------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `numBlocks` | 1 | `uint8` | 0 | The number of blocks in the chunk |
| `block[0]` | 60 | `BlockContext` | 1 | The block information of the 1st block |
| ... | ... | ... | ... | ... |
| `block[i]` | 60 | `BlockContext` | `60*i+1` | The block information of `i+1`-th block |
| ... | ... | ... | ... | ... |
| `block[n-1]` | 60 | `BlockContext` | `60*n-59` | The block information of the last block
| `l2Transactions` | dynamic | `bytes` | `60*n+1` | The concatenated RLP encoding of L2 transactions with signatures. The byte length (`uint32`) of RLP encoding is inserted before each transaction. | |

#### `BlockContext` Codec

| Field | Bytes | Type | Offset | Description |
| ----------------- | ----- | --------- | ------ | ----------------------------------------------------------------------------------- |
| `blockNumber` | 8 | `uint64` | 0 | The block number |
| `timestamp` | 8 | `uint64` | 8 | The block time |
| `baseFee` | 32 | `uint256` | 16 | The base fee of this block. Currently, it is always 0, because we disable EIP-1559. |
| `gasLimit` | 8 | `uint64` | 48 | The gas limit of this block |
| `numTransactions` | 2 | `uint16` | 56 | The number of transactions in this block, including both L1 & L2 txs |
| `numL1Messages` | 2 | `uint16` | 58 | The number of L1 messages in this block
The latest update to the codec was introduced in the [Bernoulli upgrade](/technology/overview/scroll-upgrades#bernoulli-upgrade).

<Tabs sharedStore="upgrades" client:visible>
<Fragment slot="tab.bernoulli">bernoulli</Fragment>
<Fragment slot="tab.archimedes">archimedes</Fragment>
<Fragment slot="panel.bernoulli">
<slot name="bernoulli" />

This data format is still applicable post-Curie upgrade, and has not been changed.

#### `BatchHeader` Codec

| Field | Bytes | Type | Offset | Description |
| ------------------------ | ------- | ----------- | ------ | --------------------------------------------------------------- |
| `version` | 1 | `uint8` | 0 | The batch header version |
| `batchIndex` | 8 | `uint64` | 1 | The index of the batch |
| `l1MessagePopped` | 8 | `uint64` | 9 | The number of L1 messages popped in the batch |
| `totalL1MessagePopped` | 8 | `uint64` | 17 | The number of total L1 messages popped after the batch |
| `dataHash` | 32 | `bytes32` | 25 | The data hash of the batch |
| `blobVersionedHash` | 32 | `bytes32` | 57 | The versioned hash of the blob with this batch’s data |
| `parentBatchHash` | 32 | `bytes32` | 89 | The parent batch hash |
| `skippedL1MessageBitmap` | dynamic | `uint256[]` | 121 | A bitmap to indicate which L1 messages are skipped in the batch |

#### `Chunk` Codec

| Field | Bytes | Type | Offset | Description |
| ---------------- | ------- | -------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `numBlocks` | 1 | `uint8` | 0 | The number of blocks in the chunk |
| `block[0]` | 60 | `BlockContext` | 1 | The block information of the 1st block |
| ... | ... | ... | ... | ... |
| `block[i]` | 60 | `BlockContext` | `60*i+1` | The block information of `i+1`-th block |
| ... | ... | ... | ... | ... |
| `block[n-1]` | 60 | `BlockContext` | `60*n-59` | The block information of the last block |

#### `BlockContext` Codec

| Field | Bytes | Type | Offset | Description |
| ----------------- | ----- | --------- | ------ | ----------------------------------------------------------------------------------- |
| `blockNumber` | 8 | `uint64` | 0 | The block number |
| `timestamp` | 8 | `uint64` | 8 | The block time |
| `baseFee` | 32 | `uint256` | 16 | The base fee of this block. Currently, it is always 0, because we disable EIP-1559. |
| `gasLimit` | 8 | `uint64` | 48 | The gas limit of this block |
| `numTransactions` | 2 | `uint16` | 56 | The number of transactions in this block, including both L1 & L2 txs |
| `numL1Messages` | 2 | `uint16` | 58 | The number of L1 messages in this block

</Fragment>

<Fragment slot="panel.archimedes">
<slot name="archimedes" />
#### `BatchHeader` Codec

| Field | Bytes | Type | Offset | Description |
| ------------------------ | ------- | ----------- | ------ | --------------------------------------------------------------- |
| `version` | 1 | `uint8` | 0 | The batch header version |
| `batchIndex` | 8 | `uint64` | 1 | The index of the batch |
| `l1MessagePopped` | 8 | `uint64` | 9 | The number of L1 messages popped in the batch |
| `totalL1MessagePopped` | 8 | `uint64` | 17 | The number of total L1 messages popped after the batch |
| `dataHash` | 32 | `bytes32` | 25 | The data hash of the batch |
| `parentBatchHash` | 32 | `bytes32` | 57 | The parent batch hash |
| `skippedL1MessageBitmap` | dynamic | `uint256[]` | 89 | A bitmap to indicate which L1 messages are skipped in the batch |

#### `Chunk` Codec

| Field | Bytes | Type | Offset | Description |
| ---------------- | ------- | -------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| `numBlocks` | 1 | `uint8` | 0 | The number of blocks in the chunk |
| `block[0]` | 60 | `BlockContext` | 1 | The block information of the 1st block |
| ... | ... | ... | ... | ... |
| `block[i]` | 60 | `BlockContext` | `60*i+1` | The block information of `i+1`-th block |
| ... | ... | ... | ... | ... |
| `block[n-1]` | 60 | `BlockContext` | `60*n-59` | The block information of the last block
| `l2Transactions` | dynamic | `bytes` | `60*n+1` | The concatenated RLP encoding of L2 transactions with signatures. The byte length (`uint32`) of RLP encoding is inserted before each transaction. | |

#### `BlockContext` Codec

| Field | Bytes | Type | Offset | Description |
| ----------------- | ----- | --------- | ------ | ----------------------------------------------------------------------------------- |
| `blockNumber` | 8 | `uint64` | 0 | The block number |
| `timestamp` | 8 | `uint64` | 8 | The block time |
| `baseFee` | 32 | `uint256` | 16 | The base fee of this block. Currently, it is always 0, because we disable EIP-1559. |
| `gasLimit` | 8 | `uint64` | 48 | The gas limit of this block |
| `numTransactions` | 2 | `uint16` | 56 | The number of transactions in this block, including both L1 & L2 txs |
| `numL1Messages` | 2 | `uint16` | 58 | The number of L1 messages in this block

</Fragment>
</Tabs>
Loading

0 comments on commit 07d1f80

Please sign in to comment.