Skip to content

Commit 72eaf9d

Browse files
committed
Move to separate Fjord directory
1 parent 059f74d commit 72eaf9d

10 files changed

+484
-399
lines changed

specs/fjord/deposits.md

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Deposits
2+
3+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
4+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
5+
**Table of Contents**
6+
7+
- [L1 Attributes Deposited Transaction](#l1-attributes-deposited-transaction)
8+
- [L1 Attributes Deposited Transaction Calldata](#l1-attributes-deposited-transaction-calldata)
9+
- [L1 Attributes - Fjord](#l1-attributes---fjord)
10+
- [Special Accounts on L2](#special-accounts-on-l2)
11+
- [L1 Attributes Predeployed Contract](#l1-attributes-predeployed-contract)
12+
- [Fjord L1Block upgrade](#fjord-l1block-upgrade)
13+
14+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
15+
16+
## L1 Attributes Deposited Transaction
17+
18+
### L1 Attributes Deposited Transaction Calldata
19+
20+
#### L1 Attributes - Fjord
21+
22+
On the Fjord activation block, and if Fjord is not activated at Genesis,
23+
the L1 Attributes Transaction includes a call to `setL1BlockValuesEcotone()`
24+
because the L1 Attributes transaction precedes the [Fjord Upgrade Transactions][fjord-upgrade-txs],
25+
meaning that `setL1BlockValuesFjord` is not guaranteed to exist yet.
26+
27+
Every subsequent L1 Attributes transaction should include a call to the `setL1BlockValuesFjord()` function.
28+
The input args are no longer ABI encoded function parameters,
29+
but are instead packed into 5 32-byte aligned segments and one 12-byte segment (starting after the function selector).
30+
Each signed and unsigned integer argument is encoded as big-endian using a number of bytes corresponding to the
31+
underlying type. The overall calldata layout is as follows:
32+
33+
[fjord-upgrade-txs]: derivation.md#fjord
34+
35+
| Input arg | Type | Calldata bytes | Segment |
36+
|-------------------|---------|----------------|---------|
37+
| {0x850c16d8} | | 0-3 | n/a |
38+
| baseFeeScalar | uint32 | 4-7 | 1 |
39+
| blobBaseFeeScalar | uint32 | 8-11 | |
40+
| sequenceNumber | uint64 | 12-19 | |
41+
| l1BlockTimestamp | uint64 | 20-27 | |
42+
| l1BlockNumber | uint64 | 28-35 | |
43+
| basefee | uint256 | 36-67 | 2 |
44+
| blobBaseFee | uint256 | 68-99 | 3 |
45+
| l1BlockHash | bytes32 | 100-131 | 4 |
46+
| batcherHash | bytes32 | 132-163 | 5 |
47+
| l1CostIntercept | int32 | 164-167 | 6 |
48+
| l1CostFastlzCoef | int32 | 168-171 | |
49+
| l1CostTxSizeCoef | int32 | 172-175 | |
50+
51+
Total calldata length MUST be exactly 176 bytes.
52+
53+
In the first L2 block after the Fjord activation block, the Fjord L1 attributes are first used.
54+
55+
The pre-Fjord values are migrated over 1:1.
56+
Blocks after the Fjord activation block contain all pre-Fjord values 1:1,
57+
and also set the following new attributes:
58+
59+
- The `l1CostIntercept` is set to `0`.
60+
- The `l1CostFastlzCoef` is set to `0`.
61+
- The `l1CostTxSizeCoef` is set to `1e6`.
62+
63+
## Special Accounts on L2
64+
65+
### L1 Attributes Predeployed Contract
66+
67+
- With the Fjord upgrade, the predeploy additionally stores:
68+
- `l1CostIntercept` (`int32`): system configurable to set the L1 cost formula intercept
69+
- `l1CostFastlzCoef` (`int32`): system configurable to set the L1 cost formula FastLZ coefficient
70+
- `l1CostTxSizeCoef` (`int32`): system configurable to set the L1 cost formula transaction size coefficient
71+
72+
#### Fjord L1Block upgrade
73+
74+
The L1 Attributes Predeployed contract, `L1Block.sol`, is upgraded as part of the Fjord upgrade.
75+
The version is incremented to `1.3.0`, and one existing slot begins to store additional data:
76+
77+
- `l1CostIntercept` (`int32`): system configurable to set the L1 cost formula intercept
78+
- `l1CostFastlzCoef` (`int32`): system configurable to set the L1 cost formula FastLZ coefficient
79+
- `l1CostTxSizeCoef` (`int32`): system configurable to set the L1 cost formula transaction size coefficient
80+
81+
The function called by the L1 attributes transaction depends on the network upgrade:
82+
83+
- Before the Fjord activation:
84+
- `setL1BlockValuesEcotone` is called, following the pre-Fjord L1 attributes rules.
85+
- At the Fjord activation block:
86+
- `setL1BlockValuesEcotone` function MUST be called, except if activated at genesis.
87+
The contract is upgraded later in this block, to support `setL1BlockValuesFjord`.
88+
- After the Fjord activation:
89+
- `setL1BlockValuesEcotone` function is deprecated and MUST never be called.
90+
- `setL1BlockValuesFjord` MUST be called with the new Fjord attributes.
91+
92+
`setL1BlockValuesFjord` uses a tightly packed encoding for its parameters, which is described in
93+
[L1 Attributes - Fjord](#l1-attributes---fjord).

specs/fjord/derivation.md

+206
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# Deriving Payload Attributes
2+
3+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
4+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
5+
**Table of Contents**
6+
7+
- [Deriving the Transaction List](#deriving-the-transaction-list)
8+
- [Network upgrade automation transactions](#network-upgrade-automation-transactions)
9+
- [Fjord](#fjord)
10+
- [L1Block Deployment - Fjord](#l1block-deployment---fjord)
11+
- [GasPriceOracle Deployment - Fjord](#gaspriceoracle-deployment---fjord)
12+
- [L1Block Proxy Update - Fjord](#l1block-proxy-update---fjord)
13+
- [GasPriceOracle Proxy Update - Fjord](#gaspriceoracle-proxy-update---fjord)
14+
- [GasPriceOracle Enable Fjord](#gaspriceoracle-enable-fjord)
15+
16+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
17+
18+
## Deriving the Transaction List
19+
20+
### Network upgrade automation transactions
21+
22+
#### Fjord
23+
24+
The Fjord hardfork activation block, contains the following transactions in this order:
25+
26+
- L1 Attributes Transaction, using the pre-Fjord `setL1BlockValuesEcotone`
27+
- User deposits from L1
28+
- Network Upgrade Transactions
29+
- L1Block deployment
30+
- GasPriceOracle deployment
31+
- Update L1Block Proxy ERC-1967 Implementation Slot
32+
- Update GasPriceOracle Proxy ERC-1967 Implementation Slot
33+
- GasPriceOracle Enable Fjord
34+
35+
To not modify or interrupt the system behavior around gas computation, this block will not include any sequenced
36+
transactions by setting `noTxPool: true`.
37+
38+
##### L1Block Deployment - Fjord
39+
40+
The `L1Block` contract is upgraded to store the new Fjord Fast LZ parameters.
41+
42+
To perform this upgrade, a deposit transaction is derived with the following attributes:
43+
44+
- `from`: `0x4210000000000000000000000000000000000002`
45+
- `to`: `null`
46+
- `mint`: `0`
47+
- `value`: `0`
48+
- `gasLimit`: `420,000`
49+
- `data`: `0x60806040523...` ([full bytecode](../static/bytecode/fjord-l1-block-deployment.txt))
50+
- `sourceHash`: `0x402f75bf100f605f36c2e2b8d5544a483159e26f467a9a555c87c125e7ab09f3`,
51+
computed with the "Upgrade-deposited" type, with `intent = "Fjord: L1 Block Deployment"
52+
53+
This results in the Fjord L1Block contract being deployed to `0xa919894851548179A0750865e7974DA599C0Fac7`, to verify:
54+
55+
```bash
56+
cast compute-address --nonce=0 0x4210000000000000000000000000000000000002
57+
Computed Address: 0xa919894851548179A0750865e7974DA599C0Fac7
58+
```
59+
60+
Verify `sourceHash`:
61+
62+
```bash
63+
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: L1 Block Deployment"))
64+
# 0x402f75bf100f605f36c2e2b8d5544a483159e26f467a9a555c87c125e7ab09f3
65+
```
66+
67+
Verify `data`:
68+
69+
```bash
70+
git checkout TODO (update once merged)
71+
pnpm clean && pnpm install && pnpm build
72+
jq -r ".bytecode.object" packages/contracts-bedrock/forge-artifacts/L1Block.sol/L1Block.json
73+
```
74+
75+
This transaction MUST deploy a contract with the following code hash
76+
`0x12e89c50902af815d85608f9a2a35579a74e9491077b94211c96f79ef265bf9c`.
77+
78+
##### GasPriceOracle Deployment - Fjord
79+
80+
The `GasPriceOracle` contract is upgraded to support the new Fjord L1 data fee computation. Post fork this contract
81+
will use FastLZ to compute the L1 data fee.
82+
83+
To perform this upgrade, a deposit transaction is derived with the following attributes:
84+
85+
- `from`: `0x4210000000000000000000000000000000000003`
86+
- `to`: `null`,
87+
- `mint`: `0`
88+
- `value`: `0`
89+
- `gasLimit`: `1,450,000`
90+
- `data`: `0x60806040523...` ([full bytecode](../static/bytecode/fjord-gas-price-oracle-deployment.txt))
91+
- `sourceHash`: `0x86122c533fdcb89b16d8713174625e44578a89751d96c098ec19ab40a51a8ea3`
92+
computed with the "Upgrade-deposited" type, with `intent = "Fjord: Gas Price Oracle Deployment"
93+
94+
This results in the Fjord GasPriceOracle contract being deployed to `0xFf256497D61dcd71a9e9Ff43967C13fdE1F72D12`,
95+
to verify:
96+
97+
```bash
98+
cast compute-address --nonce=0 0x4210000000000000000000000000000000000003
99+
Computed Address: 0xFf256497D61dcd71a9e9Ff43967C13fdE1F72D12
100+
```
101+
102+
Verify `sourceHash`:
103+
104+
```bash
105+
❯ cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: Gas Price Oracle Deployment"))
106+
# 0x86122c533fdcb89b16d8713174625e44578a89751d96c098ec19ab40a51a8ea3
107+
```
108+
109+
Verify `data`:
110+
111+
```bash
112+
git checkout TODO (update once merged)
113+
pnpm clean && pnpm install && pnpm build
114+
jq -r ".bytecode.object" packages/contracts-bedrock/forge-artifacts/GasPriceOracle.sol/GasPriceOracle.json
115+
```
116+
117+
This transaction MUST deploy a contract with the following code hash
118+
`0xcb82de8a527fee307214950192bf0ff5b2701c6b6eda2fbd025cf6d4075fbe38`.
119+
120+
##### L1Block Proxy Update - Fjord
121+
122+
This transaction updates the L1Block Proxy ERC-1967 implementation slot to point to the new L1Block deployment.
123+
124+
A deposit transaction is derived with the following attributes:
125+
126+
- `from`: `0x0000000000000000000000000000000000000000`
127+
- `to`: `0x4200000000000000000000000000000000000015` (L1Block Proxy)
128+
- `mint`: `0`
129+
- `value`: `0`
130+
- `gasLimit`: `50,000`
131+
- `data`: `0x3659cfe6000000000000000000000000a919894851548179a0750865e7974da599c0fac7`
132+
- `sourceHash`: `0x0fefb8cb7f44b866e21a59f647424cee3096de3475e252eb3b79fa3f733cee2d`
133+
computed with the "Upgrade-deposited" type, with `intent = "Fjord: L1 Block Proxy Update"
134+
135+
Verify data:
136+
137+
```bash
138+
cast concat-hex $(cast sig "upgradeTo(address)") $(cast abi-encode "upgradeTo(address)" 0xa919894851548179A0750865e7974DA599C0Fac7)
139+
0x3659cfe6000000000000000000000000a919894851548179a0750865e7974da599c0fac7
140+
```
141+
142+
Verify `sourceHash`:
143+
144+
```bash
145+
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: L1 Block Proxy Update"))
146+
# 0x0fefb8cb7f44b866e21a59f647424cee3096de3475e252eb3b79fa3f733cee2d
147+
```
148+
149+
##### GasPriceOracle Proxy Update - Fjord
150+
151+
This transaction updates the GasPriceOracle Proxy ERC-1967 implementation slot to point to the new GasPriceOracle
152+
deployment.
153+
154+
A deposit transaction is derived with the following attributes:
155+
156+
- `from`: `0x0000000000000000000000000000000000000000`
157+
- `to`: `0x420000000000000000000000000000000000000F` (Gas Price Oracle Proxy)
158+
- `mint`: `0`
159+
- `value`: `0`
160+
- `gasLimit`: `50,000`
161+
- `data`: `0x3659cfe6000000000000000000000000ff256497d61dcd71a9e9ff43967c13fde1f72d12`
162+
- `sourceHash`: `0x1e6bb0c28bfab3dc9b36ffb0f721f00d6937f33577606325692db0965a7d58c6`
163+
computed with the "Upgrade-deposited" type, with `intent = "Fjord: Gas Price Oracle Proxy Update"`
164+
165+
Verify data:
166+
167+
```bash
168+
cast concat-hex $(cast sig "upgradeTo(address)") $(cast abi-encode "upgradeTo(address)" 0xFf256497D61dcd71a9e9Ff43967C13fdE1F72D12)
169+
0x3659cfe6000000000000000000000000ff256497d61dcd71a9e9ff43967c13fde1f72d12
170+
```
171+
172+
Verify `sourceHash`:
173+
174+
```bash
175+
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: Gas Price Oracle Proxy Update"))
176+
# 0x1e6bb0c28bfab3dc9b36ffb0f721f00d6937f33577606325692db0965a7d58c6
177+
```
178+
179+
##### GasPriceOracle Enable Fjord
180+
181+
This transaction informs the GasPriceOracle to start using the Fjord gas calculation formula.
182+
183+
A deposit transaction is derived with the following attributes:
184+
185+
- `from`: `0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001` (Depositer Account)
186+
- `to`: `0x420000000000000000000000000000000000000F` (Gas Price Oracle Proxy)
187+
- `mint`: `0`
188+
- `value`: `0`
189+
- `gasLimit`: `80,000`
190+
- `data`: `0x8e98b106`
191+
- `sourceHash`: `0xbac7bb0d5961cad209a345408b0280a0d4686b1b20665e1b0f9cdafd73b19b6b`,
192+
computed with the "Upgrade-deposited" type, with `intent = "Fjord: Gas Price Oracle Set Fjord"
193+
194+
Verify data:
195+
196+
```bash
197+
cast sig "setFjord()"
198+
0x8e98b106
199+
```
200+
201+
Verify `sourceHash`:
202+
203+
```bash
204+
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: Gas Price Oracle Set Fjord"))
205+
# 0xbac7bb0d5961cad209a345408b0280a0d4686b1b20665e1b0f9cdafd73b19b6b
206+
```

0 commit comments

Comments
 (0)