-
Notifications
You must be signed in to change notification settings - Fork 409
Zksync os with kl medium interop #1949
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: draft-v31
Are you sure you want to change the base?
Changes from all commits
1079469
d86014c
43496f7
7cdf58b
899b659
39c0970
f631ebd
fd84f92
6596331
dd0e8e7
03e2eda
6f2add9
1a36a03
f9a3f8d
4b54cc2
7eb6448
78814bf
e92cbce
a1b2090
5413ee1
4ae807f
f4faec0
4998c59
525e8d4
5d0230f
73b5800
f19fa4e
9871c24
23aa9b5
b96847e
9541399
c796de1
e6c3686
68f79ed
0741356
3fcd17d
bfa36cd
a2a51b7
df65833
32dcea8
86bd950
945dce8
fabf162
6bb00e6
f7420f9
7591987
3e51927
ce83197
2d05c30
c4a2682
3bef405
4cc035d
dbab652
1c71ed6
a722e1b
30ff978
0b5297c
4b5dfed
06a0c73
116ddef
4f1f39e
5cad79f
5743ff5
79cf25b
4e5fe70
31ba80c
82be524
5539894
59332fe
11459c2
6f92d11
3455dbd
9697e62
636b8a0
3b12138
8db59a2
64d8b60
029388d
f33634a
84aad98
40e6c85
943ad73
7f839c6
1018b72
60061f0
8b15167
939474d
51af655
5e47ab2
2d21563
e71c898
5d2258d
6be5588
1647ef0
7f48e26
1845dbd
d4793e3
206745e
f15ac8e
1470c71
4a2c69b
cf93a6c
43c8050
eea9ad1
06bad45
24ff73c
e72f8c2
744b99e
831b639
a923de1
e344fed
4dd05c1
f65345e
3d01ab7
cbbe52b
3c01c1c
fe5d832
c9288c4
9531680
0564c97
a82c44a
d215811
b26f206
39a4d03
ac45668
7e9777f
491aecc
b0cfde7
6aba3ee
fed209d
2b02114
218a18e
863e95f
b1ec936
6191808
4a93a58
fd7fede
fd877fe
d516322
bbcab97
721d654
69c1204
e407ffc
20e735a
7f572f0
9f1b1ee
04f2bd2
bbb52ea
24a1326
96145c1
4606194
84f9dd6
5ad6ee1
bc36a06
67f53e9
d0dd5e0
f170d14
cd1c922
5370643
7686468
50c464c
e71f71d
5d2d0ea
9574091
423f25b
9f7587e
693cfa4
210b87d
5437043
1e9769b
ad67a42
bdd0340
983fea6
49d9fb9
15713a3
9cf5c4f
06cecb4
4e452f4
92148e5
e652a82
e843938
807fda3
4cb2288
ee031dd
04de024
b3a3ddb
d40e207
03cfd46
99d1513
dd00940
2e1e5fa
4b359ee
4303e33
1b13c45
a8b7a0e
dcd95cd
9b75bec
9fc0ae4
9ddc915
21838df
8ae28b3
6b50496
03c4549
dd3ea59
e140699
37897b7
1fd60f9
15cc520
5e22cef
a91c4ac
da2613a
24799ed
1fffbb9
c45d4b7
dce1561
a94f4d5
22c56cb
a644f2e
d6baa72
2623093
1703987
9040c1b
057209c
2a59195
132ae4b
0137245
8c01fbc
96a7106
2b1e41d
04a185b
fcbbec6
dd42776
ebfa490
6adc8dd
04df19d
30fd113
2f0f57a
1c4d1eb
8eb48fe
eb7f45a
5c464ff
f9fd0b7
f7b280c
03d89a6
79066df
504d2b0
4bbcecc
00dd8fb
e1ce9d4
1ce5900
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| pragma solidity ^0.8.24; | ||
|
|
||
| event InteropRootAdded(uint256 indexed chainId, uint256 indexed blockNumber, bytes32[] sides); | ||
| error SidesLengthNotOne(); | ||
| error InteropRootAlreadyExists(); | ||
| error MessageRootIsZero(); | ||
|
|
||
| /** | ||
| * @author Matter Labs | ||
| * @custom:security-contact security@matterlabs.dev | ||
| * @notice InteropRootStorage contract responsible for storing the message roots of other chains on the L2. | ||
| */ | ||
| contract L2InteropRootStorage { | ||
| /// @notice Mapping of chain ID to block or batch number to message root. | ||
| mapping(uint256 chainId => mapping(uint256 blockOrBatchNumber => bytes32 interopRoot)) public interopRoots; | ||
|
|
||
| /// @dev Adds a message root to the L2InteropRootStorage contract. | ||
| /// @dev For both proof-based and commit-based interop, the `sides` parameter contains only the root. | ||
| /// @dev Once pre-commit interop is introduced, `sides` will include both the root and its associated sides. | ||
| /// @dev This interface is preserved now so that enabling pre-commit interop later requires no changes in interface. | ||
| /// @dev In proof-based and pre-commit interop, `blockOrBatchNumber` represents the block number, in commit-based interop, | ||
| /// it represents the batch number. This distinction reflects the implementation requirements of each interop finality form. | ||
| /// @param chainId The chain ID of the chain that the message root is for. | ||
| /// @param blockOrBatchNumber The block or batch number of the message root. Either of block number or batch number will be used, | ||
| /// depends on finality form of interop, mentioned above. | ||
| /// @param sides The message root sides. Note, that `sides` here are coming from `DynamicIncrementalMerkle` nomenclature. | ||
| /// @dev FIXME: for the demo purposes, remove onlyCallFromBootloader modifier | ||
| function addInteropRoot(uint256 chainId, uint256 blockOrBatchNumber, bytes32[] calldata sides) external { | ||
| // In the current code sides should only contain the Interop Root itself, as mentioned above. | ||
| if (sides.length != 1) { | ||
| revert SidesLengthNotOne(); | ||
| } | ||
| if (sides[0] == bytes32(0)) { | ||
| revert MessageRootIsZero(); | ||
| } | ||
|
|
||
| // Make sure that interopRoots for specified chainId and blockOrBatchNumber wasn't set already. | ||
| if (interopRoots[chainId][blockOrBatchNumber] != bytes32(0)) { | ||
| revert InteropRootAlreadyExists(); | ||
| } | ||
|
|
||
| // Set interopRoots for specified chainId and blockOrBatchNumber, emit event. | ||
| interopRoots[chainId][blockOrBatchNumber] = sides[0]; | ||
|
|
||
| emit InteropRootAdded(chainId, blockOrBatchNumber, sides); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -269,8 +269,9 @@ contract InteropCenter is | |
| msg.value == _totalBurnedCallsValue + _totalIndirectCallsValue, | ||
| MsgValueMismatch(_totalBurnedCallsValue + _totalIndirectCallsValue, msg.value) | ||
| ); | ||
| // FIXME: does not burn, just sends to a a bad address. | ||
| // slither-disable-next-line arbitrary-send-eth | ||
| L2_BASE_TOKEN_SYSTEM_CONTRACT.burnMsgValue{value: _totalBurnedCallsValue}(); | ||
| address(0xdeadbeef).call{value: _totalBurnedCallsValue}(""); | ||
|
Comment on lines
+272
to
+274
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In Useful? React with 👍 / 👎. |
||
| } else { | ||
| require(msg.value == _totalIndirectCallsValue, MsgValueMismatch(_totalIndirectCallsValue, msg.value)); | ||
| if (_totalBurnedCallsValue > 0) { | ||
|
|
@@ -296,7 +297,8 @@ contract InteropCenter is | |
| BundleAttributes memory _bundleAttributes, | ||
| bytes[][] memory _originalCallAttributes | ||
| ) internal returns (bytes32 bundleHash) { | ||
| require(L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT.currentSettlementLayerChainId() != L1_CHAIN_ID, NotInGatewayMode()); | ||
| // FIXME: Turned off for zksync os for now | ||
| // require(L2_SYSTEM_CONTEXT_SYSTEM_CONTRACT.currentSettlementLayerChainId() != L1_CHAIN_ID, NotInGatewayMode()); | ||
|
|
||
| // Form an InteropBundle. | ||
| InteropBundle memory bundle = InteropBundle({ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
addInteropRootis declaredexternalwith no access control, any address can set the interop root for an arbitrary(chainId, blockOrBatchNumber)once.L2MessageVerificationlater treatsL2_INTEROP_ROOT_STORAGE.interopRoots(...)as the source of truth for message inclusion, so an attacker who pre-fills a root can craft proofs that verify forged bundles/messages on L2. This is exploitable whenever a malicious party can submitaddInteropRootbefore the legitimate publisher for that pair.Useful? React with 👍 / 👎.