From 07d1f80f2ea7fd0ee917d4b6cf760103436501ff Mon Sep 17 00:00:00 2001 From: isabellewei Date: Tue, 18 Jun 2024 12:26:44 -0400 Subject: [PATCH 01/25] Curie updates (#271) --- .../docs/en/technology/chain/rollup.mdx | 161 ++++++++++-------- .../technology/overview/scroll-upgrades.mdx | 69 +++++++- 2 files changed, 152 insertions(+), 78 deletions(-) diff --git a/src/content/docs/en/technology/chain/rollup.mdx b/src/content/docs/en/technology/chain/rollup.mdx index 1232dd60e..e74177540 100644 --- a/src/content/docs/en/technology/chain/rollup.mdx +++ b/src/content/docs/en/technology/chain/rollup.mdx @@ -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. @@ -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). + + +bernoulli +archimedes + + + + 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 + + + + + + #### `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 + + + diff --git a/src/content/docs/en/technology/overview/scroll-upgrades.mdx b/src/content/docs/en/technology/overview/scroll-upgrades.mdx index 87558da24..10d5f8ede 100644 --- a/src/content/docs/en/technology/overview/scroll-upgrades.mdx +++ b/src/content/docs/en/technology/overview/scroll-upgrades.mdx @@ -19,6 +19,71 @@ The following contracts are used to initiate upgrades and execute upgrades after You can join our [Telegram channel for technical updates](https://t.me/scroll_tech_updates), which includes future upgrade announcements and on-chain operation events. +## Curie Upgrade + +### Overview + +This significant upgrade will reduce gas fees on the Scroll chain by 1.5x. Highlights include: + +- Compresses the data stored in blobs using the [zstd](https://github.com/scroll-tech/da-codec/tree/main/libzstd) algorithm. This compression reduces the data size, allowing each blob to store more transactions, thereby reducing data availability cost per transaction. +- Adopts a modified version of the EIP-1559 pricing model which is compatible with the EIP-1559 transaction interface, bringing beneftis such as more accurate transaction pricing and a more predictable and stable fee structure. +- Support for new EVM opcodes `TLOAD`, `TSTORE`, and `MCOPY`. Users can safely use the latest Solidity compiler version `0.8.26` to build the contracts. +- Introduces a dynamic block time. During periods of traffic congestion, a block will be packed when the number of transactions reaches the circuit limit instead of waiting for the 3-second interval. + +### Timeline + +- **Scroll Sepolia** + - Network Upgrade: June 17th, 2024 +- **Scroll Mainnet** + - Upgrade Initiation: June 20th, 2024 + - Timelock Completion & Upgrade: June 27th, 2024 + +### Technical Details + +#### Contract Changes + +The code changes for this upgrade are documented in the following PRs: + +- [PR 1317](https://github.com/scroll-tech/scroll/pull/1317) +- [PR 1343](https://github.com/scroll-tech/scroll/pull/1343) +- [PR 1354](https://github.com/scroll-tech/scroll/pull/1354) +- [PR 1372](https://github.com/scroll-tech/scroll/pull/1372) + +The main changes are as follows: + +- The rollup contract (`ScrollChain`) will now accept batches with both versions 1 and 2. [Version 1](https://github.com/scroll-tech/da-codec/tree/main/encoding/codecv1) is used for uncompressed blobs (pre-Curie), while [version 2](https://github.com/scroll-tech/da-codec/tree/main/encoding/codecv2) is used for compressed blobs (post-Curie). +- The `L1GasPriceOracle` contract will be updated to change the data fee formula to account for blob DA, providing a more accurate estimation of DA costs: + - Original formula: `(l1GasUsed(txRlp) + overhead) * l1BaseFee * scalar` + - New formula: `l1BaseFee * commitScalar + len(txRlp) * l1BlobBaseFee * blobScalar` + +#### Node Changes + +The new node version is `v5.4.2`. See the [release notes](https://github.com/scroll-tech/go-ethereum/releases/tag/scroll-v5.4.2) for the list of changes. + +#### zkEVM circuit changes + +The new version of zkevm circuits is `v0.11.0`. See [here](https://github.com/scroll-tech/zkevm-circuits/releases/tag/v0.11.0) for the release log. + +#### Audits + +- TrailofBits: coming soon! +- Zellic: coming soon! + +### Compatibility + +#### Sequencer and Follower Nodes (l2geth) + +This upgrade is a hard fork, introducing the `TLOAD`, `TSTORE`, and `MCOPY` opcodes. Operators running an `l2geth` node are required to upgrade before the hard fork block. For more information, see the [node release note](https://github.com/scroll-tech/go-ethereum/releases/tag/scroll-v5.4.2). + +#### Dapps and Indexers + +For dApps, this upgrade is backward compatible. Developers should adjust the gas fee settings to incorporate the EIP-1559 pricing model. Note that dApps can no longer rely on the fixed 3-second block time in the application logic. + +For indexers, the [data format](https://docs.scroll.io/en/technology/chain/rollup/#codec) remains the same. The will be however changes to the data content: + +- The `version` field in `BatchHeader` will be changed to 2 since Curie block. +- The data stored in blob will be compressed and can be decompressed by [zstd v1.5.6](https://github.com/facebook/zstd/releases/tag/v1.5.6). + ## Bernoulli Upgrade ### Overview @@ -54,7 +119,7 @@ The new version of zkevm circuits is `v0.10.3`. See [here](https://github.com/sc #### Audits - [OpenZeppelin](https://blog.openzeppelin.com/scroll-eip-4844-support-audit) -- TrailofBits (will be posted soon) +- [TrailofBits](https://github.com/trailofbits/publications/blob/master/reviews/2024-04-scroll-4844-blob-securityreview.pdf) ### Compatibility @@ -87,14 +152,12 @@ To reduce bridging costs, we implemented several gas optimizations on our bridge ### Timeline - - **Scroll Sepolia:** - Network Upgrade: January 19, 2024 - **Scroll Mainnet:** - Upgrade Initiation: February 7, 2024 - Timelock Completion & Upgrade: February 21, 2024 - ### Technical Details #### Code Changes From 40c2df22f02085662007dd6f2eb8fdf452312dbc Mon Sep 17 00:00:00 2001 From: colinlyguo Date: Thu, 20 Jun 2024 19:49:32 +0800 Subject: [PATCH 02/25] curie-update-libzkp-version --- src/content/docs/en/technology/overview/scroll-upgrades.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/technology/overview/scroll-upgrades.mdx b/src/content/docs/en/technology/overview/scroll-upgrades.mdx index 10d5f8ede..50a288016 100644 --- a/src/content/docs/en/technology/overview/scroll-upgrades.mdx +++ b/src/content/docs/en/technology/overview/scroll-upgrades.mdx @@ -62,7 +62,7 @@ The new node version is `v5.4.2`. See the [release notes](https://github.com/scr #### zkEVM circuit changes -The new version of zkevm circuits is `v0.11.0`. See [here](https://github.com/scroll-tech/zkevm-circuits/releases/tag/v0.11.0) for the release log. +The new version of zkevm circuits is `v0.11.3`. See [here](https://github.com/scroll-tech/zkevm-circuits/releases/tag/v0.11.3) for the release log. #### Audits From eaa7858000d9a61fd52b001ad20d6047f0b32eaa Mon Sep 17 00:00:00 2001 From: isabelle Date: Thu, 20 Jun 2024 12:08:58 -0400 Subject: [PATCH 03/25] security nit --- .../en/technology/security/audits-and-bug-bounty.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx b/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx index 6f6d5d28b..00c1c8425 100644 --- a/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx +++ b/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx @@ -17,6 +17,12 @@ Aside from rigorous testing, an internal security team, and comprehensive code r exception. We encourage users to use the protocol with caution and at their own risk. +### Scope + +The scope of the bug bounty program covers the blockchain infrastructure and the smart contracts for bridging and rollup. For a detailed breakdown of bug categories, please refer to the bug bounty page. + +Besides the listed scopes in the bug bounty program, we also encourage reporting any vulnerabilities identified to Immunefi, which we will still consider for rewards. For any discoveries of critical vulnerabilities outside of the scope of the bug bounty program, please also send reports to security@scroll.io. + ## Independent Audits Scroll has worked with several industry-leading security audit firms to review our codebase, with critical code receiving reviews from multiple teams, including [Trail of Bits](https://www.trailofbits.com/), [OpenZeppelin](https://www.openzeppelin.com/), [Zellic](https://www.zellic.io/), and [KALOS](https://www.kalos.xyz/). @@ -73,9 +79,3 @@ Rewards depend on the severity of reported vulnerabilities: - **Critical**: up to \$1,000,000 - **High**: \$10,000 - \$50,000 - **Medium**: \$5,000 - -### Scope - -The scope of the bug bounty program covers the blockchain infrastructure and the smart contracts for bridging and rollup. For a detailed breakdown of bug categories, please refer to the bug bounty page. - -Besides the listed scopes in the bug bounty program, we also encourage reporting any vulnerabilities identified to Immunefi, which we will still consider for rewards. For any discoveries of critical vulnerabilities outside of the scope of the bug bounty program, please also send reports to security@scroll.io. From 403edeccb7fb670723ed3d6345f034fc5a1347c0 Mon Sep 17 00:00:00 2001 From: isabelle Date: Thu, 20 Jun 2024 15:43:13 -0400 Subject: [PATCH 04/25] move contact info into highlight --- .../security/audits-and-bug-bounty.mdx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx b/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx index 00c1c8425..6dcb3174c 100644 --- a/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx +++ b/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx @@ -8,6 +8,10 @@ permalink: "technology/security/audits-and-bug-bounty" import Aside from "../../../../../components/Aside.astro" + + Scroll treats security as a top priority. Aside from rigorous testing, an internal security team, and comprehensive code reviews, we have also engaged with multiple security audit firms to conduct audits on our codebase. We have also launched a bug bounty program to encourage the community to participate in the security of our protocol. @@ -17,12 +21,6 @@ Aside from rigorous testing, an internal security team, and comprehensive code r exception. We encourage users to use the protocol with caution and at their own risk. -### Scope - -The scope of the bug bounty program covers the blockchain infrastructure and the smart contracts for bridging and rollup. For a detailed breakdown of bug categories, please refer to the bug bounty page. - -Besides the listed scopes in the bug bounty program, we also encourage reporting any vulnerabilities identified to Immunefi, which we will still consider for rewards. For any discoveries of critical vulnerabilities outside of the scope of the bug bounty program, please also send reports to security@scroll.io. - ## Independent Audits Scroll has worked with several industry-leading security audit firms to review our codebase, with critical code receiving reviews from multiple teams, including [Trail of Bits](https://www.trailofbits.com/), [OpenZeppelin](https://www.openzeppelin.com/), [Zellic](https://www.zellic.io/), and [KALOS](https://www.kalos.xyz/). @@ -79,3 +77,9 @@ Rewards depend on the severity of reported vulnerabilities: - **Critical**: up to \$1,000,000 - **High**: \$10,000 - \$50,000 - **Medium**: \$5,000 + +### Scope + +The scope of the bug bounty program covers the blockchain infrastructure and the smart contracts for bridging and rollup. For a detailed breakdown of bug categories, please refer to the bug bounty page. + +Besides the listed scopes in the bug bounty program, we also encourage reporting any vulnerabilities identified to Immunefi, which we will still consider for rewards. From 2055873281cf291f9cb5495720ae24ce4f21dbed Mon Sep 17 00:00:00 2001 From: isabelle Date: Thu, 20 Jun 2024 15:45:42 -0400 Subject: [PATCH 05/25] change Aside type --- .../docs/en/technology/security/audits-and-bug-bounty.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx b/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx index 6dcb3174c..c6a5482dc 100644 --- a/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx +++ b/src/content/docs/en/technology/security/audits-and-bug-bounty.mdx @@ -8,7 +8,7 @@ permalink: "technology/security/audits-and-bug-bounty" import Aside from "../../../../../components/Aside.astro" -