You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/specs/contracts/chain_management/admin_role.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ Generally all the functionality of chain admin should be treated with maximal se
20
20
21
21
### Setting validators for a chain
22
22
23
-
The admin of a chain can call `ValidatorTimelock` on the settlement layer to add or remove validators, i.e. addresses that have the right to `commit`/`verify`/`execute` batches etc.
23
+
The admin of a chain can call `ValidatorTimelock` on the settlement layer to add or remove validators via `addValidator`/`removeValidator` (which grant/revoke all six per-chain roles at once), or assign individual roles granularly via `addValidatorRoles`/`removeValidatorRoles`i.e. for an addresses to have the right to commit/verify/execute batches.
24
24
25
25
The system is protected against malicious validators, they can never steal funds from users. However, this role is still relatively powerful: If the DA layer is not reliable, and a batch does get executed, the funds may be frozen. This is why the chains should be [cautious about DA layers that they use](#setting-da-layer). Note, that on L1 the `ValidatorTimelock` has 3h delay, while on Gateway this timelock will not be present.
Copy file name to clipboardExpand all lines: docs/src/specs/contracts/chain_management/bridgehub.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Note sure what CTM is? Check our the [overview](./chain_type_manager.md).
15
15
16
16
> This document will not cover how ZK Gateway works, you can check it out in [a separate doc](../gateway/overview.md).
17
17
18
-
The Bridgehub is the contract where new chains can [register](./chain_genesis.md). The Bridgehub also serves as an AssetHandler for chains when migrating chains between settlement layers, read more about it[here](../gateway/chain_migration.md).
18
+
The Bridgehub is the contract where new chains can [register](./chain_genesis.md). Chain migration between settlement layers is handled by dedicated `ChainAssetHandler` contracts (`L1ChainAssetHandler` on L1, `L2ChainAssetHandler`as an L2 predeploy at `0x1000a`), not by the Bridgehub directly. The Bridgehub retains only helper hooks gated `onlyChainAssetHandler` (`forwardedBridgeBurnSetSettlementLayer`, `forwardedBridgeMint`, `forwardedBridgeConfirmTransferResult`, and `registerNewZKChain`). Read more about chain migration[here](../gateway/chain_migration.md).
19
19
20
20
Overall, it is the main registry for all the contracts. Note, that a clone of Bridgehub is also deployed on each L2 chain, it is used to start interop txs by checking that the chain is active. It is also used on settlement layers such as Gateway. All the in all, the architecture of the entire ecosystem can be seen below:
Copy file name to clipboardExpand all lines: docs/src/specs/contracts/chain_management/chain_type_manager.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ In the current release, each chain will be an instance of ZKsync Era and so the
62
62
63
63
In case of an emergency, the [security council](https://blog.zknation.io/introducing-zk-nation/) has the ability to freeze the ecosystem and conduct an emergency upgrade.
64
64
65
-
In case we are aware that some of the committed batches on a chain are dangerous to be executed, the CTM can call `revertBatches` on that chain. For faster reaction, the admin of the ChainTypeManager has the ability to do so without waiting for govenrnace approval that may take a lot of time. This action does not lead to funds being lost, so it is considered suitable for the partially trusted role of the admin of the ChainTypeManager.
65
+
In case we are aware that some of the committed batches on a chain are dangerous to be executed, the CTM can call `revertBatches` on that chain. This is performed by the CTM owner — the governance-controlled Protocol Upgrade Handler — typically as part of a freeze and emergency upgrade. This action does not lead to funds being lost. Note that reverting batches is not exclusive to the CTM: the underlying `revertBatchesSharedBridge` function on the chain is callable by both the CTM and the chain's validators (via the `REVERTER_ROLE` on the ValidatorTimelock), so a chain's operator can also revert its own not-yet-executed batches.
Copy file name to clipboardExpand all lines: docs/src/specs/contracts/chain_management/overview.md
+1-2Lines changed: 1 addition & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,8 +77,7 @@ be able to leverage them when available).
77
77
-`ChainTypeRegistry` The chain type is shared for multiple chains, so initialization and upgrades have to be the same for all
78
78
chains. Registration is not permissionless but happens based on the registrations in the bridgehub’s `Registry`. At
79
79
registration a `DiamondProxy` is deployed and initialized with the appropriate `Facets` for each ZK Chain.
80
-
-`Facets` and `Verifier` are shared across chains that relies on the same chain type: `Base`, `Executor` , `Getters`, `Admin`
81
-
, `Mailbox.`The `Verifier` is the contract that actually verifies the proof, and is called by the `Executor`.
80
+
-`Facets` and `Verifier` are shared across chains that use the same chain type. The chain diamond is initialized with `Admin`, `Getters`, `Mailbox`, `Committer`, `Executor`, and `Migrator` facets. `ZKChainBase` is an inherited base contract, not a diamond facet. The `Committer` handles batch precommit/commit logic, including L2 log processing and batch commitment creation. The `Executor` handles proving, executing, and reverting batches, and calls the `Verifier` during proof validation. The `Migrator` handles settlement-layer migration logic
82
81
- Upgrade Mechanism The system requires all chains to be up-to-date with the latest implementation, so whenever an
83
82
update is needed, we have to “force” each chain to update, but due to decentralization, we have to give each chain a
84
83
time frame. This is done in the update mechanism contract, this is where the bootloader and system contracts are
Copy file name to clipboardExpand all lines: docs/src/specs/contracts/gateway/chain_migration.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
2
2
3
3
## Ecosystem Setup
4
4
5
-
Chain migration reuses lots of logic from standard custom asset bridging which is enabled by the AssetRouter. The easiest way to imagine is that ZKChains are NFTs that are being migrated from one chain to another. Just like in case of the NFT contract, an CTM is assumed to have an `assetId := keccak256(abi.encode(L1_CHAIN_ID, address(ctmDeployer), bytes32(uint256(uint160(_ctmAddress)))))`. I.e. these are all assets with ADT = ctmDeployer contract on L1.
5
+
Chain migration reuses lots of logic from standard custom asset bridging which is enabled by the AssetRouter. The easiest way to imagine is that ZKChains are NFTs that are being migrated from one chain to another. Just like in case of the NFT contract, an CTM is assumed to have an `assetId := keccak256(abi.encode(block.chainid, address(ctmDeploymentTracker), bytes32(uint256(uint160(_ctmAddress)))))`. I.e. these are all assets with ADT = ctmDeploymentTracker contract on L1.
6
6
7
-
CTMDeployer is a very lightweight contract used to facilitate chain migration. Its main purpose is to serve as formal asset deployment tracker for CTMs. It serves two purposes:
7
+
CTMDeploymentTracker is a very lightweight contract used to facilitate chain migration. Its main purpose is to serve as formal asset deployment tracker for CTMs. It serves two purposes:
8
8
9
-
-Assign bridgehub as the asset handler for the “asset” of the CTM on the supported settlement layer.
9
+
-Register the `ChainAssetHandler` (via `registerCTMAssetOnL1`) as the asset handler for the 'asset' of the CTM on the supported settlement layer.
10
10
11
-
Currently, it can only be done by the owner of the CTMDeployer, but in the future, this method can become either permissionless or callable by the CTM owner.
11
+
Currently, it can only be done by the owner of the CTMDeploymentTracker, but in the future, this method can become either permissionless or callable by the CTM owner.
12
12
13
-
- Tell bridgehub which address on the L2 should serve as the L2 representation of the CTM on L1. Currently, it can only be done by the owner of the CTMDeployer, but in the future, this method can become callable by the CTM owner.
13
+
- Tell bridgehub which address on the L2 should serve as the L2 representation of the CTM on L1. Currently, it can only be done by the owner of the CTMDeploymentTracker, but in the future, this method can become callable by the CTM owner.
-`LocalRoot` — the root of the binary merkle tree over `UserLog[]`. (the same as the one we have now). It only contains messages from the current batch.
32
32
-`AggregatedRoot` — the root of the binary merkle tree over `ChainIdLeaf[]`.
-`CHAIN_ID_LEAF_PADDING` — it is a constant padding, needed to ensure that the preimage of the ChainIdLeaf is larger than 64 bytes and so it can not be an internal node.
35
35
-`chain_id` — the chain id of the chain the batches of which are aggregated.
36
36
-`ChainIdRoot` = the root of the binary merkle tree `BatchRootLeaf[]`.
In other words, we get the recursive structure, where for leaves of it, i.e. chains that do not aggregate any other chains, have empty `AggregatedRoot`.
40
40
@@ -97,9 +97,13 @@ This function will be internally used by the existing `_proveL2LogInclusion` fun
97
97
98
98
We want to avoid breaking changes to SDKs, so we will modify the `zks_getL2ToL1LogProof` to return the data in the following format (the results of it are directly passed into the `proveL2LeafInclusion` method, so returned value must be supported by the contract):
99
99
100
-
First `bytes32`corresponds to the metadata of the proof. The zero-th byte should tell the version of the metadata and must be equal to the `SUPPORTED_PROOF_METADATA_VERSION` (a constant of `0x01`).
100
+
The first `bytes32`element of the proof encodes the proof metadata, laid out byte by byte (byte 0 being the most significant):
101
101
102
-
Then, it should contain the number of 32-byte words that are needed to restore the current `BatchRootLeaf` , i.e. `logLeafProofLen` (it is called this way as it proves that a leaf belongs to the `SettledRootOfBatch`). The second byte contains the `batchLeafProofLen` . It is the length of the merkle path to prove that the `BatchRootLeaf` belonged to the `ChainIdRoot` .
102
+
- byte 0 — metadata version; must equal `SUPPORTED_PROOF_METADATA_VERSION` (a constant of `0x01`).
103
+
- byte 1 — `logLeafProofLen`: the number of 32-byte words needed to restore the current `BatchRootLeaf` (named this way because it proves a leaf belongs to the `SettledRootOfBatch`).
104
+
- byte 2 — `batchLeafProofLen`: the length of the Merkle path proving that the `BatchRootLeaf` belongs to the `ChainIdRoot`.
105
+
- byte 3 — `finalProofNode`: whether this proof is the last link in the chain of recursive settlement-layer proofs.
106
+
- bytes 4–31 — zero.
103
107
104
108
Then, the following happens:
105
109
@@ -109,10 +113,10 @@ If the settlement layer of the chain is the chain itself, we can just end here b
109
113
110
114
If the chain is not a settlement layer of itself, we then need to calculate:
- Consume one element from the `_proofs` array to get the mask for the merkle path of the batch leaf in the chain id tree.
114
118
- Consume `batchLeafProofLen` elements to construct the `ChainIdRoot`
115
-
- After that, we calculate the `chainIdLeaf = keccak256(CHAIN_ID_LEAF_PADDING, chainIdRoot, chainId`
119
+
- After that, we calculate the `chainIdLeaf = keccak256(CHAIN_ID_LEAF_PADDING, chainIdRoot, chainId`)
116
120
117
121
Now, we have the _supposed_`chainIdRoot` for the chain inside its settlement layer. The only thing left to prove is that this root belonged to some batch of the settlement layer.
118
122
@@ -178,7 +182,7 @@ In order to ease the server migration, we support legacy format of L2→L1 logs
178
182
179
183
To differentiate between legacy format and the one, the following approach is used;
180
184
181
-
- Except for the first 3 bytes the first word in the new format contains 0s, which is unlikely in the old format, where leaves are hashed.
182
-
- I.e. if the last 29 bytes are zeroes, then it is assumed to be the new format and vice versa.
185
+
- Except for the first 4 bytes the first word in the new format contains 0s, which is unlikely in the old format, where leaves are hashed.
186
+
- I.e. if the last 28 bytes are zeroes, then it is assumed to be the new format and vice versa.
183
187
184
188
In the next release the old format will be removed.
Copy file name to clipboardExpand all lines: docs/src/specs/contracts/settlement_contracts/data_availability/custom_da.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,4 +65,4 @@ This allows for a general-purpose solution that ensures DA consistency and verif
65
65
-`L2_DA_VALIDATOR_OUTPUT_HASH_KEY` (the commitment)
66
66
67
67
4. L1 verification
68
-
On L1 the Executor facet will call L1 DA validator, providing it with chain ID and batch number of the chain for which the DA must be verified, along with `l2DAValidatorOutputHash`, `operatorDAInput` and `_maxBlobsSupported` value. It's then L1 DA Validator job to verify the correctness of the DA on L1.
68
+
On L1 the Committer facet calls the L1 DA validator during batch commitment, providing it with chain ID and batch number of the chain for which the DA must be verified, along with `l2DAValidatorOutputHash`, `operatorDAInput` and `_maxBlobsSupported` value. It's then L1 DA Validator job to verify the correctness of the DA on L1.
Copy file name to clipboardExpand all lines: docs/src/specs/contracts/settlement_contracts/data_availability/pubdata.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,8 +13,8 @@ pre-Boojum system these are represented as separate fields while for boojum they
13
13
array. Once 4844 gets integrated this bytes array will move from being part of the calldata to blob data.
14
14
15
15
While the structure of the pubdata changes, the way in which one can go about pulling the information will remain the
16
-
same. Basically, we just need to filter all of the transactions to the L1 ZKsync contract for only the `commitBatches`
17
-
transactions where the proposed block has been referenced by a corresponding `executeBatches` call (the reason for this
16
+
same. Basically, we just need to filter all of the transactions to the L1 ZKsync contract for only the `commitBatchesSharedBridge`
17
+
transactions where the proposed block has been referenced by a corresponding `executeBatchesSharedBridge` call (the reason for this
18
18
is that a committed or even proven block can be reverted but an executed one cannot). Once we have all the committed
19
19
batches that have been executed, we then will pull the transaction input and the relevant fields, applying them in order
20
20
to reconstruct the current state of L2.
@@ -65,7 +65,7 @@ natively by VM _system_ logs. Here is a short comparison table for better unders
65
65
| Emitted by VM via an opcode. | VM knows nothing about them. |
66
66
| Consistency and correctness is enforced by the verifier on L1 (i.e. their hash is part of the block commitment. | Consistency and correctness is enforced by the L1Messenger system contract. The correctness of the behavior of the L1Messenger is enforced implicitly by prover in a sense that it proves the correctness of the execution overall. |
67
67
| We don’t calculate their Merkle root. | We calculate their Merkle root on the L1Messenger system contract. |
68
-
| We have constant small number of those. | We can have as much as possible as long as the commitBatches function on L1 remains executable (it is the job of the operator to ensure that only such transactions are selected) |
68
+
| We have constant small number of those. | We can have as much as possible as long as the commitBatchesSharedBridge function on L1 remains executable (it is the job of the operator to ensure that only such transactions are selected) |
69
69
| In EIP4844 they will remain part of the calldata. | In EIP4844 they will become part of the blobs. |
70
70
71
71
#### Backwards-compatibility
@@ -194,7 +194,7 @@ all concatenated together to yield the final compressed version.
194
194
195
195
For bytecode to be considered valid it must satisfy the following:
196
196
197
-
1. Bytecode length must be less than 2097120 ((2^16 - 1) \* 32) bytes.
197
+
1. Bytecode length must be at most 2097120 ((2^16 - 1) \* 32) bytes
198
198
2. Bytecode length must be a multiple of 32.
199
199
3. Number of 32-byte words cannot be even.
200
200
@@ -429,7 +429,7 @@ With Boojum, the interface for committing batches is the following one:
429
429
/// @param bootloaderHeapInitialContentsHash Hash of the initial contents of the bootloader heap. In practice it serves as the commitment to the transactions in the batch.
430
430
/// @param eventsQueueStateHash Hash of the events queue state. In practice it serves as the commitment to the events in the batch.
431
431
/// @param systemLogs concatenation of all L2 -> L1 system logs in the batch
432
-
/// @param totalL2ToL1Pubdata Total pubdata committed to as part of bootloader run. Contents are: l2Tol1Logs <> l2Tol1Messages <> publishedBytecodes <> stateDiffs
432
+
/// @param operatorDAInput The data-availability input provided by the operator, processed by the L1DAValidator. Its contents depend on the DA mode (for rollups: the state-diff hash, the pubdata, and blob commitment data).
0 commit comments