-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(docs-site): add taiko-protocol section with economics and codeba…
…se analysis (#18542) Co-authored-by: RogerLamTd <[email protected]> Co-authored-by: swarna1101 <[email protected]>
- Loading branch information
1 parent
7642961
commit 55acc93
Showing
19 changed files
with
311 additions
and
27 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
Binary file added
BIN
+210 KB
packages/docs-site/src/assets/content/docs/taiko-protocol/based-economics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
6 changes: 3 additions & 3 deletions
6
...nt/docs/core-concepts/based-sequencing.md → ...ontent/docs/core-concepts/based-rollup.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
--- | ||
title: Based sequencing | ||
description: Core concept page for "Based sequencing". | ||
title: Based rollup | ||
description: Core concept page for based rollups. | ||
--- | ||
|
||
One of Taiko's major differentiators from other rollups is that it is a **based rollup**. That is, it's sequencing is driven by the base L1. On Taiko, there is **no centralized sequencer**. The sequencer role instead falls on the shoulders of the Ethereum L1 validator. | ||
|
||
Check out plenty of great resources on based sequencing in our [Learning resources](/resources/learning-resources)! | ||
Check out plenty of great resources on **based sequencing** in our [Learning resources](/resources/learning-resources)! |
File renamed without changes.
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
File renamed without changes.
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
150 changes: 150 additions & 0 deletions
150
...docs-site/src/content/docs/taiko-protocol/codebase-analysis/taikol1-contract.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
--- | ||
title: TaikoL1 | ||
description: Taiko protocol page for "TaikoL1.sol". | ||
--- | ||
|
||
[TaikoL1](https://github.com/taikoxyz/taiko-mono/blob/main/packages/protocol/contracts/layer1/based/TaikoL1.sol) is a smart contract that serves as the **base layer** of the Taiko protocol. It provides functionalities for **proposing, proving, and verifying blocks**, enabling the rollup's consensus and state transitions. The contract also supports **bond deposits and withdrawals** and manages state synchronization between L1 and L2. | ||
|
||
--- | ||
|
||
## Core Purpose | ||
|
||
1. **Block Lifecycle Management** | ||
Manages the proposal, proof, and verification of Taiko blocks, ensuring consistent state transitions. | ||
|
||
2. **Cross-Layer Synchronization** | ||
Ensures the synchronization of states between Layer 1 (L1) and Layer 2 (L2). | ||
|
||
3. **Bond Management** | ||
Handles the deposit and withdrawal of bonds to incentivize proposers and ensure accountability. | ||
|
||
4. **Base Layer Scalability** | ||
Enables the deployment on L2 to create L3 rollups, expanding Taiko's scalability. | ||
|
||
--- | ||
|
||
## Key Functions | ||
|
||
### `proposeBlockV2` | ||
|
||
- **Purpose:** | ||
Proposes a single block for inclusion in the rollup. | ||
|
||
- **Parameters:** | ||
|
||
- `_params`: Encoded block parameters. | ||
- `_txList`: Transactions to include in the block. | ||
|
||
- **Returns:** | ||
`TaikoData.BlockMetadataV2` containing metadata of the proposed block. | ||
|
||
--- | ||
|
||
### `proposeBlocksV2` | ||
|
||
- **Purpose:** | ||
Proposes multiple blocks in batch. | ||
|
||
- **Parameters:** | ||
|
||
- `_paramsArr`: Array of encoded block parameters. | ||
- `_txListArr`: Arrays of transactions for each block. | ||
|
||
- **Returns:** | ||
Array of `TaikoData.BlockMetadataV2` for all proposed blocks. | ||
|
||
--- | ||
|
||
### `proveBlock` | ||
|
||
- **Purpose:** | ||
Proves the validity of a single block. | ||
|
||
- **Parameters:** | ||
- `_blockId`: ID of the block to be proven. | ||
- `_input`: Encoded proof data. | ||
|
||
--- | ||
|
||
### `proveBlocks` | ||
|
||
- **Purpose:** | ||
Proves multiple blocks in a single call. | ||
|
||
- **Parameters:** | ||
- `_blockIds`: IDs of the blocks to be proven. | ||
- `_inputs`: Proofs for each block. | ||
- `_batchProof`: Batch proof covering all blocks. | ||
|
||
--- | ||
|
||
### `verifyBlocks` | ||
|
||
- **Purpose:** | ||
Verifies a batch of blocks after proofs are submitted. | ||
|
||
- **Parameters:** | ||
- `_maxBlocksToVerify`: Maximum number of blocks to verify. | ||
|
||
--- | ||
|
||
### `depositBond` | ||
|
||
- **Purpose:** | ||
Deposits a bond required for proposing blocks. | ||
|
||
- **Parameters:** | ||
- `_amount`: Amount of bond to deposit. | ||
|
||
--- | ||
|
||
### `withdrawBond` | ||
|
||
- **Purpose:** | ||
Withdraws bond deposits after successful proposals. | ||
|
||
- **Parameters:** | ||
- `_amount`: Amount of bond to withdraw. | ||
|
||
--- | ||
|
||
### `getLastVerifiedBlock` | ||
|
||
- **Purpose:** | ||
Retrieves the details of the most recently verified block. | ||
|
||
- **Returns:** | ||
- `blockId_`: ID of the last verified block. | ||
- `blockHash_`: Block hash of the verified block. | ||
- `stateRoot_`: State root of the verified block. | ||
- `verifiedAt_`: Timestamp when the block was verified. | ||
|
||
--- | ||
|
||
## Key Events | ||
|
||
1. **`DebugGasPerBlock`** | ||
Provides gas usage metrics for block proposals or proofs. | ||
|
||
- `isProposeBlock`: Indicates whether the event is for proposals or proofs. | ||
- `gasUsed`: Gas consumed per block. | ||
- `batchSize`: Number of blocks in the batch. | ||
|
||
2. **`StateVariablesUpdated`** | ||
Signals updates to the state variables. | ||
|
||
--- | ||
|
||
## Important Data Structures | ||
|
||
1. **`state`**: | ||
Tracks the rollup state, including blocks, bonds, and configurations. | ||
|
||
2. **`__gap`**: | ||
Reserved storage for future upgrades. | ||
|
||
--- | ||
|
||
## Design Highlights | ||
|
||
--- |
115 changes: 115 additions & 0 deletions
115
...docs-site/src/content/docs/taiko-protocol/codebase-analysis/taikol2-contract.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
--- | ||
title: TaikoL2 | ||
description: Taiko protocol page for "TaikoL2.sol". | ||
--- | ||
|
||
[TaikoL2](https://github.com/taikoxyz/taiko-mono/blob/main/packages/protocol/contracts/layer2/based/TaikoL2.sol) is a smart contract that handles cross-layer message verification and manages EIP-1559 gas pricing for Taiko operations. It is used to anchor the latest L1 block details to L2 for cross-layer communication, manage EIP-1559 parameters for gas pricing, and store verified L1 block information. | ||
|
||
--- | ||
|
||
## Core Purpose | ||
|
||
1. **Anchor:** | ||
Due to Taiko's **based rollup** nature, each L2 block requires anchoring to the latest L1 block details. The first transaction of every block must perform this anchor, or all calls will revert with `L2_PUBLIC_INPUT_HASH_MISMATCH`. | ||
|
||
2. **Gas Pricing:** | ||
The contract calculates **EIP-1559 base fee** and updates gas parameters dynamically for optimal gas pricing using key inputs such as `_parentGasUsed` and `_baseFeeConfig`. | ||
|
||
3. **State Synchronization:** | ||
The contract ensures L2 remains in sync with L1 by storing verified block information and updating state data like block hashes and timestamps. | ||
|
||
4. **Bridging Support:** | ||
It plays a crucial role in **L1-L2 bridging**, anchoring state roots to enable secure and efficient communication between layers. For more, visit the [Bridging page](/taiko-protocol/bridging). | ||
|
||
--- | ||
|
||
## Key Functions | ||
|
||
### `anchorV2` | ||
|
||
- **Purpose:** | ||
Anchors the latest L1 block details to L2, enabling **cross-layer message verification**. | ||
|
||
- **Parameters:** | ||
|
||
- `_anchorBlockId`: The L1 block ID to anchor. | ||
- `_anchorStateRoot`: State root of the specified L1 block. | ||
- `_parentGasUsed`: Gas usage in the parent block. | ||
- `_baseFeeConfig`: Configuration for base fee calculation. | ||
|
||
- **Mechanism:** | ||
Verifies and updates the `publicInputHash`, calculates the base fee and gas excess using `getBasefeeV2`, and synchronizes chain data. | ||
|
||
--- | ||
|
||
### `getBasefeeV2` | ||
|
||
- **Purpose:** | ||
Computes the **EIP-1559 base fee** and updates gas parameters like **gas excess** and **gas target**. | ||
|
||
- **Parameters:** | ||
|
||
- `_parentGasUsed`: Gas used in the parent block. | ||
- `_baseFeeConfig`: Configuration for EIP-1559 calculations. | ||
|
||
- **Returns:** | ||
|
||
- `basefee_`: Calculated base fee per gas. | ||
- `newGasTarget_`: Updated gas target. | ||
- `newGasExcess_`: Updated gas excess. | ||
|
||
- **Technical Details:** | ||
Uses `LibEIP1559.calc1559BaseFee` and `LibEIP1559.adjustExcess` for precise gas pricing dynamics. | ||
|
||
--- | ||
|
||
### `getBlockHash` | ||
|
||
- **Purpose:** | ||
Fetches the block hash for a specified block ID. | ||
|
||
- **Technical Note:** | ||
If the block ID is too old (not in the last 256 blocks), it uses an internal mapping (`_blockhashes`) to retrieve stored hashes. | ||
|
||
--- | ||
|
||
## Key Events | ||
|
||
1. **`Anchored`** | ||
Emitted when L1 block details are successfully anchored to L2. | ||
|
||
**Parameters:** | ||
|
||
- `parentHash`: Hash of the parent block. | ||
- `parentGasExcess`: Gas excess for base fee calculation. | ||
|
||
2. **`EIP1559Update`** | ||
Emitted when gas parameters (e.g., target, excess, base fee) are updated. | ||
|
||
**Parameters:** | ||
|
||
- `oldGasTarget`: Previous gas target. | ||
- `newGasTarget`: Updated gas target. | ||
- `oldGasExcess`: Previous gas excess. | ||
- `newGasExcess`: Updated gas excess. | ||
- `basefee`: Calculated base fee. | ||
|
||
--- | ||
|
||
## Important Data Structures | ||
|
||
### State Variables | ||
|
||
1. **`publicInputHash`**: | ||
Validates the integrity of public inputs for block verification. | ||
|
||
2. **`parentGasExcess`**: | ||
Tracks gas usage exceeding the target for dynamic base fee adjustment. | ||
|
||
3. **`lastSyncedBlock`**: | ||
Stores the ID of the most recent L1 block synced with L2. | ||
|
||
4. **`l1ChainId`**: | ||
Chain ID of the base layer (L1). | ||
|
||
--- |
Oops, something went wrong.