-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
484 additions
and
399 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Deposits | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
**Table of Contents** | ||
|
||
- [L1 Attributes Deposited Transaction](#l1-attributes-deposited-transaction) | ||
- [L1 Attributes Deposited Transaction Calldata](#l1-attributes-deposited-transaction-calldata) | ||
- [L1 Attributes - Fjord](#l1-attributes---fjord) | ||
- [Special Accounts on L2](#special-accounts-on-l2) | ||
- [L1 Attributes Predeployed Contract](#l1-attributes-predeployed-contract) | ||
- [Fjord L1Block upgrade](#fjord-l1block-upgrade) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
## L1 Attributes Deposited Transaction | ||
|
||
### L1 Attributes Deposited Transaction Calldata | ||
|
||
#### L1 Attributes - Fjord | ||
|
||
On the Fjord activation block, and if Fjord is not activated at Genesis, | ||
the L1 Attributes Transaction includes a call to `setL1BlockValuesEcotone()` | ||
because the L1 Attributes transaction precedes the [Fjord Upgrade Transactions][fjord-upgrade-txs], | ||
meaning that `setL1BlockValuesFjord` is not guaranteed to exist yet. | ||
|
||
Every subsequent L1 Attributes transaction should include a call to the `setL1BlockValuesFjord()` function. | ||
The input args are no longer ABI encoded function parameters, | ||
but are instead packed into 5 32-byte aligned segments and one 12-byte segment (starting after the function selector). | ||
Each signed and unsigned integer argument is encoded as big-endian using a number of bytes corresponding to the | ||
underlying type. The overall calldata layout is as follows: | ||
|
||
[fjord-upgrade-txs]: derivation.md#fjord | ||
|
||
| Input arg | Type | Calldata bytes | Segment | | ||
|-------------------|---------|----------------|---------| | ||
| {0x850c16d8} | | 0-3 | n/a | | ||
| baseFeeScalar | uint32 | 4-7 | 1 | | ||
| blobBaseFeeScalar | uint32 | 8-11 | | | ||
| sequenceNumber | uint64 | 12-19 | | | ||
| l1BlockTimestamp | uint64 | 20-27 | | | ||
| l1BlockNumber | uint64 | 28-35 | | | ||
| basefee | uint256 | 36-67 | 2 | | ||
| blobBaseFee | uint256 | 68-99 | 3 | | ||
| l1BlockHash | bytes32 | 100-131 | 4 | | ||
| batcherHash | bytes32 | 132-163 | 5 | | ||
| l1CostIntercept | int32 | 164-167 | 6 | | ||
| l1CostFastlzCoef | int32 | 168-171 | | | ||
| l1CostTxSizeCoef | int32 | 172-175 | | | ||
|
||
Total calldata length MUST be exactly 176 bytes. | ||
|
||
In the first L2 block after the Fjord activation block, the Fjord L1 attributes are first used. | ||
|
||
The pre-Fjord values are migrated over 1:1. | ||
Blocks after the Fjord activation block contain all pre-Fjord values 1:1, | ||
and also set the following new attributes: | ||
|
||
- The `l1CostIntercept` is set to `0`. | ||
- The `l1CostFastlzCoef` is set to `0`. | ||
- The `l1CostTxSizeCoef` is set to `1e6`. | ||
|
||
## Special Accounts on L2 | ||
|
||
### L1 Attributes Predeployed Contract | ||
|
||
- With the Fjord upgrade, the predeploy additionally stores: | ||
- `l1CostIntercept` (`int32`): system configurable to set the L1 cost formula intercept | ||
- `l1CostFastlzCoef` (`int32`): system configurable to set the L1 cost formula FastLZ coefficient | ||
- `l1CostTxSizeCoef` (`int32`): system configurable to set the L1 cost formula transaction size coefficient | ||
|
||
#### Fjord L1Block upgrade | ||
|
||
The L1 Attributes Predeployed contract, `L1Block.sol`, is upgraded as part of the Fjord upgrade. | ||
The version is incremented to `1.3.0`, and one existing slot begins to store additional data: | ||
|
||
- `l1CostIntercept` (`int32`): system configurable to set the L1 cost formula intercept | ||
- `l1CostFastlzCoef` (`int32`): system configurable to set the L1 cost formula FastLZ coefficient | ||
- `l1CostTxSizeCoef` (`int32`): system configurable to set the L1 cost formula transaction size coefficient | ||
|
||
The function called by the L1 attributes transaction depends on the network upgrade: | ||
|
||
- Before the Fjord activation: | ||
- `setL1BlockValuesEcotone` is called, following the pre-Fjord L1 attributes rules. | ||
- At the Fjord activation block: | ||
- `setL1BlockValuesEcotone` function MUST be called, except if activated at genesis. | ||
The contract is upgraded later in this block, to support `setL1BlockValuesFjord`. | ||
- After the Fjord activation: | ||
- `setL1BlockValuesEcotone` function is deprecated and MUST never be called. | ||
- `setL1BlockValuesFjord` MUST be called with the new Fjord attributes. | ||
|
||
`setL1BlockValuesFjord` uses a tightly packed encoding for its parameters, which is described in | ||
[L1 Attributes - Fjord](#l1-attributes---fjord). |
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,206 @@ | ||
# Deriving Payload Attributes | ||
|
||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
**Table of Contents** | ||
|
||
- [Deriving the Transaction List](#deriving-the-transaction-list) | ||
- [Network upgrade automation transactions](#network-upgrade-automation-transactions) | ||
- [Fjord](#fjord) | ||
- [L1Block Deployment - Fjord](#l1block-deployment---fjord) | ||
- [GasPriceOracle Deployment - Fjord](#gaspriceoracle-deployment---fjord) | ||
- [L1Block Proxy Update - Fjord](#l1block-proxy-update---fjord) | ||
- [GasPriceOracle Proxy Update - Fjord](#gaspriceoracle-proxy-update---fjord) | ||
- [GasPriceOracle Enable Fjord](#gaspriceoracle-enable-fjord) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
|
||
## Deriving the Transaction List | ||
|
||
### Network upgrade automation transactions | ||
|
||
#### Fjord | ||
|
||
The Fjord hardfork activation block, contains the following transactions in this order: | ||
|
||
- L1 Attributes Transaction, using the pre-Fjord `setL1BlockValuesEcotone` | ||
- User deposits from L1 | ||
- Network Upgrade Transactions | ||
- L1Block deployment | ||
- GasPriceOracle deployment | ||
- Update L1Block Proxy ERC-1967 Implementation Slot | ||
- Update GasPriceOracle Proxy ERC-1967 Implementation Slot | ||
- GasPriceOracle Enable Fjord | ||
|
||
To not modify or interrupt the system behavior around gas computation, this block will not include any sequenced | ||
transactions by setting `noTxPool: true`. | ||
|
||
##### L1Block Deployment - Fjord | ||
|
||
The `L1Block` contract is upgraded to store the new Fjord Fast LZ parameters. | ||
|
||
To perform this upgrade, a deposit transaction is derived with the following attributes: | ||
|
||
- `from`: `0x4210000000000000000000000000000000000002` | ||
- `to`: `null` | ||
- `mint`: `0` | ||
- `value`: `0` | ||
- `gasLimit`: `420,000` | ||
- `data`: `0x60806040523...` ([full bytecode](../static/bytecode/fjord-l1-block-deployment.txt)) | ||
- `sourceHash`: `0x402f75bf100f605f36c2e2b8d5544a483159e26f467a9a555c87c125e7ab09f3`, | ||
computed with the "Upgrade-deposited" type, with `intent = "Fjord: L1 Block Deployment" | ||
|
||
This results in the Fjord L1Block contract being deployed to `0xa919894851548179A0750865e7974DA599C0Fac7`, to verify: | ||
|
||
```bash | ||
cast compute-address --nonce=0 0x4210000000000000000000000000000000000002 | ||
Computed Address: 0xa919894851548179A0750865e7974DA599C0Fac7 | ||
``` | ||
|
||
Verify `sourceHash`: | ||
|
||
```bash | ||
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: L1 Block Deployment")) | ||
# 0x402f75bf100f605f36c2e2b8d5544a483159e26f467a9a555c87c125e7ab09f3 | ||
``` | ||
|
||
Verify `data`: | ||
|
||
```bash | ||
git checkout TODO (update once merged) | ||
pnpm clean && pnpm install && pnpm build | ||
jq -r ".bytecode.object" packages/contracts-bedrock/forge-artifacts/L1Block.sol/L1Block.json | ||
``` | ||
|
||
This transaction MUST deploy a contract with the following code hash | ||
`0x12e89c50902af815d85608f9a2a35579a74e9491077b94211c96f79ef265bf9c`. | ||
|
||
##### GasPriceOracle Deployment - Fjord | ||
|
||
The `GasPriceOracle` contract is upgraded to support the new Fjord L1 data fee computation. Post fork this contract | ||
will use FastLZ to compute the L1 data fee. | ||
|
||
To perform this upgrade, a deposit transaction is derived with the following attributes: | ||
|
||
- `from`: `0x4210000000000000000000000000000000000003` | ||
- `to`: `null`, | ||
- `mint`: `0` | ||
- `value`: `0` | ||
- `gasLimit`: `1,450,000` | ||
- `data`: `0x60806040523...` ([full bytecode](../static/bytecode/fjord-gas-price-oracle-deployment.txt)) | ||
- `sourceHash`: `0x86122c533fdcb89b16d8713174625e44578a89751d96c098ec19ab40a51a8ea3` | ||
computed with the "Upgrade-deposited" type, with `intent = "Fjord: Gas Price Oracle Deployment" | ||
|
||
This results in the Fjord GasPriceOracle contract being deployed to `0xFf256497D61dcd71a9e9Ff43967C13fdE1F72D12`, | ||
to verify: | ||
|
||
```bash | ||
cast compute-address --nonce=0 0x4210000000000000000000000000000000000003 | ||
Computed Address: 0xFf256497D61dcd71a9e9Ff43967C13fdE1F72D12 | ||
``` | ||
|
||
Verify `sourceHash`: | ||
|
||
```bash | ||
❯ cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: Gas Price Oracle Deployment")) | ||
# 0x86122c533fdcb89b16d8713174625e44578a89751d96c098ec19ab40a51a8ea3 | ||
``` | ||
|
||
Verify `data`: | ||
|
||
```bash | ||
git checkout TODO (update once merged) | ||
pnpm clean && pnpm install && pnpm build | ||
jq -r ".bytecode.object" packages/contracts-bedrock/forge-artifacts/GasPriceOracle.sol/GasPriceOracle.json | ||
``` | ||
|
||
This transaction MUST deploy a contract with the following code hash | ||
`0xcb82de8a527fee307214950192bf0ff5b2701c6b6eda2fbd025cf6d4075fbe38`. | ||
|
||
##### L1Block Proxy Update - Fjord | ||
|
||
This transaction updates the L1Block Proxy ERC-1967 implementation slot to point to the new L1Block deployment. | ||
|
||
A deposit transaction is derived with the following attributes: | ||
|
||
- `from`: `0x0000000000000000000000000000000000000000` | ||
- `to`: `0x4200000000000000000000000000000000000015` (L1Block Proxy) | ||
- `mint`: `0` | ||
- `value`: `0` | ||
- `gasLimit`: `50,000` | ||
- `data`: `0x3659cfe6000000000000000000000000a919894851548179a0750865e7974da599c0fac7` | ||
- `sourceHash`: `0x0fefb8cb7f44b866e21a59f647424cee3096de3475e252eb3b79fa3f733cee2d` | ||
computed with the "Upgrade-deposited" type, with `intent = "Fjord: L1 Block Proxy Update" | ||
|
||
Verify data: | ||
|
||
```bash | ||
cast concat-hex $(cast sig "upgradeTo(address)") $(cast abi-encode "upgradeTo(address)" 0xa919894851548179A0750865e7974DA599C0Fac7) | ||
0x3659cfe6000000000000000000000000a919894851548179a0750865e7974da599c0fac7 | ||
``` | ||
|
||
Verify `sourceHash`: | ||
|
||
```bash | ||
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: L1 Block Proxy Update")) | ||
# 0x0fefb8cb7f44b866e21a59f647424cee3096de3475e252eb3b79fa3f733cee2d | ||
``` | ||
|
||
##### GasPriceOracle Proxy Update - Fjord | ||
|
||
This transaction updates the GasPriceOracle Proxy ERC-1967 implementation slot to point to the new GasPriceOracle | ||
deployment. | ||
|
||
A deposit transaction is derived with the following attributes: | ||
|
||
- `from`: `0x0000000000000000000000000000000000000000` | ||
- `to`: `0x420000000000000000000000000000000000000F` (Gas Price Oracle Proxy) | ||
- `mint`: `0` | ||
- `value`: `0` | ||
- `gasLimit`: `50,000` | ||
- `data`: `0x3659cfe6000000000000000000000000ff256497d61dcd71a9e9ff43967c13fde1f72d12` | ||
- `sourceHash`: `0x1e6bb0c28bfab3dc9b36ffb0f721f00d6937f33577606325692db0965a7d58c6` | ||
computed with the "Upgrade-deposited" type, with `intent = "Fjord: Gas Price Oracle Proxy Update"` | ||
|
||
Verify data: | ||
|
||
```bash | ||
cast concat-hex $(cast sig "upgradeTo(address)") $(cast abi-encode "upgradeTo(address)" 0xFf256497D61dcd71a9e9Ff43967C13fdE1F72D12) | ||
0x3659cfe6000000000000000000000000ff256497d61dcd71a9e9ff43967c13fde1f72d12 | ||
``` | ||
|
||
Verify `sourceHash`: | ||
|
||
```bash | ||
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: Gas Price Oracle Proxy Update")) | ||
# 0x1e6bb0c28bfab3dc9b36ffb0f721f00d6937f33577606325692db0965a7d58c6 | ||
``` | ||
|
||
##### GasPriceOracle Enable Fjord | ||
|
||
This transaction informs the GasPriceOracle to start using the Fjord gas calculation formula. | ||
|
||
A deposit transaction is derived with the following attributes: | ||
|
||
- `from`: `0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001` (Depositer Account) | ||
- `to`: `0x420000000000000000000000000000000000000F` (Gas Price Oracle Proxy) | ||
- `mint`: `0` | ||
- `value`: `0` | ||
- `gasLimit`: `80,000` | ||
- `data`: `0x8e98b106` | ||
- `sourceHash`: `0xbac7bb0d5961cad209a345408b0280a0d4686b1b20665e1b0f9cdafd73b19b6b`, | ||
computed with the "Upgrade-deposited" type, with `intent = "Fjord: Gas Price Oracle Set Fjord" | ||
|
||
Verify data: | ||
|
||
```bash | ||
cast sig "setFjord()" | ||
0x8e98b106 | ||
``` | ||
|
||
Verify `sourceHash`: | ||
|
||
```bash | ||
cast keccak $(cast concat-hex 0x0000000000000000000000000000000000000000000000000000000000000002 $(cast keccak "Fjord: Gas Price Oracle Set Fjord")) | ||
# 0xbac7bb0d5961cad209a345408b0280a0d4686b1b20665e1b0f9cdafd73b19b6b | ||
``` |
Oops, something went wrong.