Skip to content

Commit 5bd72f6

Browse files
author
Roberto Bayardo
authored
Holocene extensions to L1Block.sol (ethereum-optimism#12096)
1 parent 909d7fd commit 5bd72f6

12 files changed

Lines changed: 327 additions & 12 deletions

File tree

packages/contracts-bedrock/.gas-snapshot

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7567)
2-
GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5567)
3-
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175677)
1+
GasBenchMark_L1BlockInterop_DepositsComplete:test_depositsComplete_benchmark() (gas: 7589)
2+
GasBenchMark_L1BlockInterop_DepositsComplete_Warm:test_depositsComplete_benchmark() (gas: 5589)
3+
GasBenchMark_L1BlockInterop_SetValuesInterop:test_setL1BlockValuesInterop_benchmark() (gas: 175655)
44
GasBenchMark_L1BlockInterop_SetValuesInterop_Warm:test_setL1BlockValuesInterop_benchmark() (gas: 5099)
55
GasBenchMark_L1Block_SetValuesEcotone:test_setL1BlockValuesEcotone_benchmark() (gas: 158531)
66
GasBenchMark_L1Block_SetValuesEcotone_Warm:test_setL1BlockValuesEcotone_benchmark() (gas: 7597)

packages/contracts-bedrock/semver-lock.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@
8080
"sourceCodeHash": "0x4f21025d4b5c9c74cf7040db6f8e9ce605b82931e3012fee51d3f5d9fbd7b73f"
8181
},
8282
"src/L2/L1Block.sol": {
83-
"initCodeHash": "0xd12353c5bf71c6765cc9292eecf262f216e67f117f4ba6287796a5207dbca00f",
84-
"sourceCodeHash": "0xfe3a9585d9bfca8428e12759cab68a3114374e5c37371cfe08bb1976a9a5a041"
83+
"initCodeHash": "0x48d118de2a69fb0fbf6a8da4603025e12da1360da8fb70a5e56342ba64b3ff5f",
84+
"sourceCodeHash": "0x04d25cbf0c4ea5025b0dd3f79f0a32f6623ddb869cff35649072ab3ad964b310"
8585
},
8686
"src/L2/L1BlockInterop.sol": {
87-
"initCodeHash": "0x77b3b2151fe14ea36a640469115a5e4de27f7654a9606a9d0701522c6a4ad887",
88-
"sourceCodeHash": "0x7417677643e1df1ae1782513b94c7821097b9529d3f8626c3bcb8b3a9ae0d180"
87+
"initCodeHash": "0x7f87e0b8be9801cb242c469ec7999eb80221f65063aedd4ca4923a5e0fb0e5a7",
88+
"sourceCodeHash": "0x722071a9d08dcbeda9cdaadeb2dd679a8bc192563e4a0439f4cd74439fa75581"
8989
},
9090
"src/L2/L1FeeVault.sol": {
9191
"initCodeHash": "0x3bfcd57e25ad54b66c374f63e24e33a6cf107044aa8f5f69ef21202c380b5c5b",

packages/contracts-bedrock/snapshots/abi/L1Block.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,32 @@
7777
"stateMutability": "view",
7878
"type": "function"
7979
},
80+
{
81+
"inputs": [],
82+
"name": "eip1559Denominator",
83+
"outputs": [
84+
{
85+
"internalType": "uint64",
86+
"name": "",
87+
"type": "uint64"
88+
}
89+
],
90+
"stateMutability": "view",
91+
"type": "function"
92+
},
93+
{
94+
"inputs": [],
95+
"name": "eip1559Elasticity",
96+
"outputs": [
97+
{
98+
"internalType": "uint64",
99+
"name": "",
100+
"type": "uint64"
101+
}
102+
],
103+
"stateMutability": "view",
104+
"type": "function"
105+
},
80106
{
81107
"inputs": [],
82108
"name": "gasPayingToken",
@@ -282,6 +308,13 @@
282308
"stateMutability": "nonpayable",
283309
"type": "function"
284310
},
311+
{
312+
"inputs": [],
313+
"name": "setL1BlockValuesHolocene",
314+
"outputs": [],
315+
"stateMutability": "nonpayable",
316+
"type": "function"
317+
},
285318
{
286319
"inputs": [],
287320
"name": "timestamp",

packages/contracts-bedrock/snapshots/abi/L1BlockInterop.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,32 @@
9797
"stateMutability": "nonpayable",
9898
"type": "function"
9999
},
100+
{
101+
"inputs": [],
102+
"name": "eip1559Denominator",
103+
"outputs": [
104+
{
105+
"internalType": "uint64",
106+
"name": "",
107+
"type": "uint64"
108+
}
109+
],
110+
"stateMutability": "view",
111+
"type": "function"
112+
},
113+
{
114+
"inputs": [],
115+
"name": "eip1559Elasticity",
116+
"outputs": [
117+
{
118+
"internalType": "uint64",
119+
"name": "",
120+
"type": "uint64"
121+
}
122+
],
123+
"stateMutability": "view",
124+
"type": "function"
125+
},
100126
{
101127
"inputs": [],
102128
"name": "gasPayingToken",
@@ -352,6 +378,13 @@
352378
"stateMutability": "nonpayable",
353379
"type": "function"
354380
},
381+
{
382+
"inputs": [],
383+
"name": "setL1BlockValuesHolocene",
384+
"outputs": [],
385+
"stateMutability": "nonpayable",
386+
"type": "function"
387+
},
355388
{
356389
"inputs": [],
357390
"name": "setL1BlockValuesInterop",

packages/contracts-bedrock/snapshots/storageLayout/L1Block.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,5 +75,19 @@
7575
"offset": 0,
7676
"slot": "7",
7777
"type": "uint256"
78+
},
79+
{
80+
"bytes": "8",
81+
"label": "eip1559Denominator",
82+
"offset": 0,
83+
"slot": "8",
84+
"type": "uint64"
85+
},
86+
{
87+
"bytes": "8",
88+
"label": "eip1559Elasticity",
89+
"offset": 8,
90+
"slot": "8",
91+
"type": "uint64"
7892
}
7993
]

packages/contracts-bedrock/snapshots/storageLayout/L1BlockInterop.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,25 @@
7676
"slot": "7",
7777
"type": "uint256"
7878
},
79+
{
80+
"bytes": "8",
81+
"label": "eip1559Denominator",
82+
"offset": 0,
83+
"slot": "8",
84+
"type": "uint64"
85+
},
86+
{
87+
"bytes": "8",
88+
"label": "eip1559Elasticity",
89+
"offset": 8,
90+
"slot": "8",
91+
"type": "uint64"
92+
},
7993
{
8094
"bytes": "64",
8195
"label": "dependencySet",
8296
"offset": 0,
83-
"slot": "8",
97+
"slot": "9",
8498
"type": "struct EnumerableSet.UintSet"
8599
}
86100
]

packages/contracts-bedrock/src/L2/L1Block.sol

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ contract L1Block is ISemver, IGasToken {
5757
/// @notice The latest L1 blob base fee.
5858
uint256 public blobBaseFee;
5959

60-
/// @custom:semver 1.5.1-beta.2
60+
/// @notice The eip-1550 base fee change denominator value.
61+
uint64 public eip1559Denominator;
62+
63+
/// @notice The eip-1550 base fee change elasticity value.
64+
uint64 public eip1559Elasticity;
65+
66+
/// @custom:semver 1.5.1-beta.3
6167
function version() public pure virtual returns (string memory) {
62-
return "1.5.1-beta.2";
68+
return "1.5.1-beta.3";
6369
}
6470

6571
/// @notice Returns the gas paying token, its decimals, name and symbol.
@@ -168,6 +174,59 @@ contract L1Block is ISemver, IGasToken {
168174
}
169175
}
170176

177+
/// @notice Updates the L1 block values for a Holocene upgraded chain.
178+
/// Params are packed and passed in as raw msg.data instead of ABI to reduce calldata size.
179+
/// Params are expected to be in the following order:
180+
/// 1. _baseFeeScalar L1 base fee scalar
181+
/// 2. _blobBaseFeeScalar L1 blob base fee scalar
182+
/// 3. _sequenceNumber Number of L2 blocks since epoch start.
183+
/// 4. _timestamp L1 timestamp.
184+
/// 5. _number L1 blocknumber.
185+
/// 6. _basefee L1 base fee.
186+
/// 7. _blobBaseFee L1 blob base fee.
187+
/// 8. _hash L1 blockhash.
188+
/// 9. _batcherHash Versioned hash to authenticate batcher by.
189+
/// 10. _eip1559Elasticity EIP-1559 elasticity multiplier value.
190+
/// 11. _eip1559Denominator EIP-1559 base fee change denominator value.
191+
function setL1BlockValuesHolocene() public {
192+
_setL1BlockValuesHolocene();
193+
}
194+
195+
/// @notice Updates the L1 block values for a Holocene upgraded chain.
196+
/// Params are packed and passed in as raw msg.data instead of ABI to reduce calldata size.
197+
/// Params are expected to be in the following order:
198+
/// 1. _baseFeeScalar L1 base fee scalar
199+
/// 2. _blobBaseFeeScalar L1 blob base fee scalar
200+
/// 3. _sequenceNumber Number of L2 blocks since epoch start.
201+
/// 4. _timestamp L1 timestamp.
202+
/// 5. _number L1 blocknumber.
203+
/// 6. _basefee L1 base fee.
204+
/// 7. _blobBaseFee L1 blob base fee.
205+
/// 8. _hash L1 blockhash.
206+
/// 9. _batcherHash Versioned hash to authenticate batcher by.
207+
/// 10. _eip1559Elasticity EIP-1559 elasticity multiplier value.
208+
/// 11. _eip1559Denominator EIP-1559 base fee change denominator value.
209+
function _setL1BlockValuesHolocene() internal {
210+
address depositor = DEPOSITOR_ACCOUNT();
211+
assembly {
212+
// Revert if the caller is not the depositor account.
213+
if xor(caller(), depositor) {
214+
mstore(0x00, 0x3cc50b45) // 0x3cc50b45 is the 4-byte selector of "NotDepositor()"
215+
revert(0x1C, 0x04) // returns the stored 4-byte selector from above
216+
}
217+
// sequencenum (uint64), blobBaseFeeScalar (uint32), baseFeeScalar (uint32)
218+
sstore(sequenceNumber.slot, shr(128, calldataload(4)))
219+
// number (uint64) and timestamp (uint64)
220+
sstore(number.slot, shr(128, calldataload(20)))
221+
sstore(basefee.slot, calldataload(36)) // uint256
222+
sstore(blobBaseFee.slot, calldataload(68)) // uint256
223+
sstore(hash.slot, calldataload(100)) // bytes32
224+
sstore(batcherHash.slot, calldataload(132)) // bytes32
225+
// eip1559Denominator (uint64) and eip1559Elasticity (uint64)
226+
sstore(eip1559Denominator.slot, shr(128, calldataload(164))) // uint64
227+
}
228+
}
229+
171230
/// @notice Sets the gas paying token for the L2 system. Can only be called by the special
172231
/// depositor account. This function is not called on every L2 block but instead
173232
/// only called by specially crafted L1 deposit transactions.

packages/contracts-bedrock/src/L2/L1BlockInterop.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ contract L1BlockInterop is L1Block {
4242
/// keccak256(abi.encode(uint256(keccak256("l1Block.identifier.isDeposit")) - 1)) & ~bytes32(uint256(0xff))
4343
uint256 internal constant IS_DEPOSIT_SLOT = 0x921bd3a089295c6e5540e8fba8195448d253efd6f2e3e495b499b627dc36a300;
4444

45-
/// @custom:semver +interop
45+
/// @custom:semver +interop-beta.1
4646
function version() public pure override returns (string memory) {
47-
return string.concat(super.version(), "+interop");
47+
return string.concat(super.version(), "+interop-beta.1");
4848
}
4949

5050
/// @notice Returns whether the call was triggered from a a deposit or not.

packages/contracts-bedrock/src/L2/interfaces/IL1Block.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ interface IL1Block {
3434
)
3535
external;
3636
function setL1BlockValuesEcotone() external;
37+
function setL1BlockValuesHolocene() external;
3738
function timestamp() external view returns (uint64);
3839
function version() external pure returns (string memory);
40+
function eip1559Denominator() external view returns (uint64);
41+
function eip1559Elasticity() external view returns (uint64);
3942

4043
function __constructor__() external;
4144
}

packages/contracts-bedrock/src/L2/interfaces/IL1BlockInterop.sol

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,12 @@ interface IL1BlockInterop {
5252
)
5353
external;
5454
function setL1BlockValuesEcotone() external;
55+
function setL1BlockValuesHolocene() external;
5556
function setL1BlockValuesInterop() external;
5657
function timestamp() external view returns (uint64);
5758
function version() external pure returns (string memory);
59+
function eip1559Denominator() external view returns (uint64);
60+
function eip1559Elasticity() external view returns (uint64);
5861

5962
function __constructor__() external;
6063
}

0 commit comments

Comments
 (0)