Skip to content

Commit 55acc93

Browse files
0xjungerRogerLamTdswarna1101
authored
feat(docs-site): add taiko-protocol section with economics and codebase analysis (#18542)
Co-authored-by: RogerLamTd <[email protected]> Co-authored-by: swarna1101 <[email protected]>
1 parent 7642961 commit 55acc93

19 files changed

+311
-27
lines changed

packages/docs-site/astro.config.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,34 +68,38 @@ export default defineConfig({
6868
label: "Core Concepts",
6969
items: [
7070
{ label: "What is Taiko?", link: "/core-concepts/what-is-taiko/" },
71-
{
72-
label: "Based sequencing",
73-
link: "/core-concepts/based-sequencing/",
74-
},
7571
{
7672
label: "Contestable rollups (BCR)",
77-
link: "/core-concepts/contestable-rollups/",
73+
link: "/core-concepts/contestable-rollup/",
7874
},
7975
{
8076
label: "Booster rollups (BBR)",
8177
link: "/core-concepts/booster-rollups/",
8278
},
8379
{ label: "Multi-proofs", link: "/core-concepts/multi-proofs/" },
84-
{ label: "Block states", link: "/core-concepts/block-states" },
85-
{
86-
label: "Taiko nodes",
87-
link: "/core-concepts/taiko-nodes/",
88-
},
89-
{
90-
label: "Bridging",
91-
link: "/core-concepts/bridging/",
92-
},
9380
{
9481
label: "Inception layers",
9582
link: "/core-concepts/inception-layers/",
9683
},
9784
],
9885
},
86+
{
87+
label: "Taiko Protocol",
88+
items: [
89+
{
90+
label: "Codebase Analysis",
91+
collapsed: true,
92+
items: [
93+
{label: "TaikoL1 Contract", link: "/taiko-protocol/codebase-analysis/taikol1-contract"},
94+
{label: "TaikoL2 Contract", link: "/taiko-protocol/codebase-analysis/taikol2-contract"},
95+
],
96+
},
97+
{ label: "Block states", link: "/taiko-protocol/block-states" },
98+
{ label: "Bridging", link: "/taiko-protocol/bridging" },
99+
{ label: "Economics", link: "/taiko-protocol/economics" },
100+
{ label: "Taiko nodes", link: "/taiko-protocol/taiko-nodes" },
101+
]
102+
},
99103
{
100104
label: "Guides",
101105
items: [
Loading
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
2-
title: Based sequencing
3-
description: Core concept page for "Based sequencing".
2+
title: Based rollup
3+
description: Core concept page for based rollups.
44
---
55

66
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.
77

8-
Check out plenty of great resources on based sequencing in our [Learning resources](/resources/learning-resources)!
8+
Check out plenty of great resources on **based sequencing** in our [Learning resources](/resources/learning-resources)!

packages/docs-site/src/content/docs/core-concepts/inception-layers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Further, Ethereum-equivalence across L2s, L3s, and beyond means inheriting some
1717

1818
![Inception layers diagram](~/assets/content/docs/core-concepts/inception-layers-diagram.png)
1919

20-
For more information on how Taiko's message passing works see the concept page on [Bridging](/core-concepts/bridging).
20+
For more information on how Taiko's message passing works see the concept page on [Bridging](/taiko-protocol/bridging).

packages/docs-site/src/content/docs/core-concepts/multi-proofs.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ For the visual learners here is a visualization of the three stages (proposed ->
2929

3030
**Proposed:**
3131

32-
![proposed](~/assets/content/docs/core-concepts/proposed.png)
32+
![proposed](~/assets/content/docs/taiko-protocol/proposed.png)
3333

3434
**Proved:**
3535

36-
![proved](~/assets/content/docs/core-concepts/proved.png)
36+
![proved](~/assets/content/docs/taiko-protocol/proved.png)
3737

3838
**Verified:**
3939

40-
![verified](~/assets/content/docs/core-concepts/verified.png)
40+
![verified](~/assets/content/docs/taiko-protocol/verified.png)
4141

4242
## Off chain prover market (PBS style)
4343

packages/docs-site/src/content/docs/core-concepts/what-is-taiko.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ description: Core concept page for "What is Taiko?".
55

66
Ethereum is too expensive. We believe in Ethereum's core properties (e.g., censorship-resistant, permissionless, secure). We also believe that rollups should **extend** (not augment) these properties.
77

8-
Taiko is a [based rollup](/core-concepts/based-sequencing) which makes Ethereum cheaper while maintaining its properties:
8+
Taiko is a [based rollup](/core-concepts/based-rollup) which makes Ethereum cheaper while maintaining its properties:
99

10-
- [Based contestable rollup](/core-concepts/contestable-rollups): A configurable rollup to reduce transaction fees on Ethereum.
10+
- [Based contestable rollup](/core-concepts/contestable-rollup): A configurable rollup to reduce transaction fees on Ethereum.
1111
- [Based booster rollup](/core-concepts/booster-rollups): An innovative approach to **native L1 scaling**.
1212

1313
Taiko is a **highly configurable, fully open source, permissionless (based), Ethereum-equivalent rollup**.
@@ -32,7 +32,7 @@ It can be easily configured as a fully ZK rollup, optimistic rollup, or anything
3232
### Non-critical infrastructure
3333

3434
:::note
35-
Anyone can run these components, not just Taiko Labs. Yes you can sequence blocks on Taiko, host your own bridge using our [signal service](/core-concepts/bridging#the-signal-service), etc.
35+
Anyone can run these components, not just Taiko Labs. Yes you can sequence blocks on Taiko, host your own bridge using our [signal service](/taiko-protocol/bridging#the-signal-service), etc.
3636
:::
3737

3838
#### Frontends

packages/docs-site/src/content/docs/core-concepts/bridging.md renamed to packages/docs-site/src/content/docs/taiko-protocol/bridging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ The bridge is a set of smart contracts and a frontend web app that allow you to
8080

8181
First, here is a flowchart of how our bridge dapp implementation works, which uses the signal service:
8282

83-
![bridging send message flowchart](~/assets/content/docs/core-concepts/bridging-source-chain.webp) \
84-
![bridging process message flowchart](~/assets/content/docs/core-concepts/bridging-dest-chain.webp)
83+
![bridging send message flowchart](~/assets/content/docs/taiko-protocol/bridging-source-chain.webp)
84+
![bridging process message flowchart](~/assets/content/docs/taiko-protocol/bridging-dest-chain.webp)
8585

8686
### How does Ether bridging work?
8787

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
title: TaikoL1
3+
description: Taiko protocol page for "TaikoL1.sol".
4+
---
5+
6+
[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.
7+
8+
---
9+
10+
## Core Purpose
11+
12+
1. **Block Lifecycle Management**
13+
Manages the proposal, proof, and verification of Taiko blocks, ensuring consistent state transitions.
14+
15+
2. **Cross-Layer Synchronization**
16+
Ensures the synchronization of states between Layer 1 (L1) and Layer 2 (L2).
17+
18+
3. **Bond Management**
19+
Handles the deposit and withdrawal of bonds to incentivize proposers and ensure accountability.
20+
21+
4. **Base Layer Scalability**
22+
Enables the deployment on L2 to create L3 rollups, expanding Taiko's scalability.
23+
24+
---
25+
26+
## Key Functions
27+
28+
### `proposeBlockV2`
29+
30+
- **Purpose:**
31+
Proposes a single block for inclusion in the rollup.
32+
33+
- **Parameters:**
34+
35+
- `_params`: Encoded block parameters.
36+
- `_txList`: Transactions to include in the block.
37+
38+
- **Returns:**
39+
`TaikoData.BlockMetadataV2` containing metadata of the proposed block.
40+
41+
---
42+
43+
### `proposeBlocksV2`
44+
45+
- **Purpose:**
46+
Proposes multiple blocks in batch.
47+
48+
- **Parameters:**
49+
50+
- `_paramsArr`: Array of encoded block parameters.
51+
- `_txListArr`: Arrays of transactions for each block.
52+
53+
- **Returns:**
54+
Array of `TaikoData.BlockMetadataV2` for all proposed blocks.
55+
56+
---
57+
58+
### `proveBlock`
59+
60+
- **Purpose:**
61+
Proves the validity of a single block.
62+
63+
- **Parameters:**
64+
- `_blockId`: ID of the block to be proven.
65+
- `_input`: Encoded proof data.
66+
67+
---
68+
69+
### `proveBlocks`
70+
71+
- **Purpose:**
72+
Proves multiple blocks in a single call.
73+
74+
- **Parameters:**
75+
- `_blockIds`: IDs of the blocks to be proven.
76+
- `_inputs`: Proofs for each block.
77+
- `_batchProof`: Batch proof covering all blocks.
78+
79+
---
80+
81+
### `verifyBlocks`
82+
83+
- **Purpose:**
84+
Verifies a batch of blocks after proofs are submitted.
85+
86+
- **Parameters:**
87+
- `_maxBlocksToVerify`: Maximum number of blocks to verify.
88+
89+
---
90+
91+
### `depositBond`
92+
93+
- **Purpose:**
94+
Deposits a bond required for proposing blocks.
95+
96+
- **Parameters:**
97+
- `_amount`: Amount of bond to deposit.
98+
99+
---
100+
101+
### `withdrawBond`
102+
103+
- **Purpose:**
104+
Withdraws bond deposits after successful proposals.
105+
106+
- **Parameters:**
107+
- `_amount`: Amount of bond to withdraw.
108+
109+
---
110+
111+
### `getLastVerifiedBlock`
112+
113+
- **Purpose:**
114+
Retrieves the details of the most recently verified block.
115+
116+
- **Returns:**
117+
- `blockId_`: ID of the last verified block.
118+
- `blockHash_`: Block hash of the verified block.
119+
- `stateRoot_`: State root of the verified block.
120+
- `verifiedAt_`: Timestamp when the block was verified.
121+
122+
---
123+
124+
## Key Events
125+
126+
1. **`DebugGasPerBlock`**
127+
Provides gas usage metrics for block proposals or proofs.
128+
129+
- `isProposeBlock`: Indicates whether the event is for proposals or proofs.
130+
- `gasUsed`: Gas consumed per block.
131+
- `batchSize`: Number of blocks in the batch.
132+
133+
2. **`StateVariablesUpdated`**
134+
Signals updates to the state variables.
135+
136+
---
137+
138+
## Important Data Structures
139+
140+
1. **`state`**:
141+
Tracks the rollup state, including blocks, bonds, and configurations.
142+
143+
2. **`__gap`**:
144+
Reserved storage for future upgrades.
145+
146+
---
147+
148+
## Design Highlights
149+
150+
---
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
---
2+
title: TaikoL2
3+
description: Taiko protocol page for "TaikoL2.sol".
4+
---
5+
6+
[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.
7+
8+
---
9+
10+
## Core Purpose
11+
12+
1. **Anchor:**
13+
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`.
14+
15+
2. **Gas Pricing:**
16+
The contract calculates **EIP-1559 base fee** and updates gas parameters dynamically for optimal gas pricing using key inputs such as `_parentGasUsed` and `_baseFeeConfig`.
17+
18+
3. **State Synchronization:**
19+
The contract ensures L2 remains in sync with L1 by storing verified block information and updating state data like block hashes and timestamps.
20+
21+
4. **Bridging Support:**
22+
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).
23+
24+
---
25+
26+
## Key Functions
27+
28+
### `anchorV2`
29+
30+
- **Purpose:**
31+
Anchors the latest L1 block details to L2, enabling **cross-layer message verification**.
32+
33+
- **Parameters:**
34+
35+
- `_anchorBlockId`: The L1 block ID to anchor.
36+
- `_anchorStateRoot`: State root of the specified L1 block.
37+
- `_parentGasUsed`: Gas usage in the parent block.
38+
- `_baseFeeConfig`: Configuration for base fee calculation.
39+
40+
- **Mechanism:**
41+
Verifies and updates the `publicInputHash`, calculates the base fee and gas excess using `getBasefeeV2`, and synchronizes chain data.
42+
43+
---
44+
45+
### `getBasefeeV2`
46+
47+
- **Purpose:**
48+
Computes the **EIP-1559 base fee** and updates gas parameters like **gas excess** and **gas target**.
49+
50+
- **Parameters:**
51+
52+
- `_parentGasUsed`: Gas used in the parent block.
53+
- `_baseFeeConfig`: Configuration for EIP-1559 calculations.
54+
55+
- **Returns:**
56+
57+
- `basefee_`: Calculated base fee per gas.
58+
- `newGasTarget_`: Updated gas target.
59+
- `newGasExcess_`: Updated gas excess.
60+
61+
- **Technical Details:**
62+
Uses `LibEIP1559.calc1559BaseFee` and `LibEIP1559.adjustExcess` for precise gas pricing dynamics.
63+
64+
---
65+
66+
### `getBlockHash`
67+
68+
- **Purpose:**
69+
Fetches the block hash for a specified block ID.
70+
71+
- **Technical Note:**
72+
If the block ID is too old (not in the last 256 blocks), it uses an internal mapping (`_blockhashes`) to retrieve stored hashes.
73+
74+
---
75+
76+
## Key Events
77+
78+
1. **`Anchored`**
79+
Emitted when L1 block details are successfully anchored to L2.
80+
81+
**Parameters:**
82+
83+
- `parentHash`: Hash of the parent block.
84+
- `parentGasExcess`: Gas excess for base fee calculation.
85+
86+
2. **`EIP1559Update`**
87+
Emitted when gas parameters (e.g., target, excess, base fee) are updated.
88+
89+
**Parameters:**
90+
91+
- `oldGasTarget`: Previous gas target.
92+
- `newGasTarget`: Updated gas target.
93+
- `oldGasExcess`: Previous gas excess.
94+
- `newGasExcess`: Updated gas excess.
95+
- `basefee`: Calculated base fee.
96+
97+
---
98+
99+
## Important Data Structures
100+
101+
### State Variables
102+
103+
1. **`publicInputHash`**:
104+
Validates the integrity of public inputs for block verification.
105+
106+
2. **`parentGasExcess`**:
107+
Tracks gas usage exceeding the target for dynamic base fee adjustment.
108+
109+
3. **`lastSyncedBlock`**:
110+
Stores the ID of the most recent L1 block synced with L2.
111+
112+
4. **`l1ChainId`**:
113+
Chain ID of the base layer (L1).
114+
115+
---

0 commit comments

Comments
 (0)