Skip to content

Commit fb5f82e

Browse files
docs: docs mismatch review draft-v31 (#4847)
1 parent c1a07a2 commit fb5f82e

14 files changed

Lines changed: 101 additions & 120 deletions

File tree

docs/src/guides/advanced/11_compression.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ validation, and compressing it.
7272

7373
For bytecode to be considered valid it must satisfy the following:
7474

75-
1. Bytecode length must be less than 2097120 ((2^16 - 1) \* 32) bytes.
75+
1. Bytecode length must be at most 2097120 ((2^16 - 1) \* 32) bytes
7676
2. Bytecode length must be a multiple of 32.
7777
3. Number of words cannot be even.
7878

docs/src/specs/contracts/chain_management/admin_role.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Generally all the functionality of chain admin should be treated with maximal se
2020

2121
### Setting validators for a chain
2222

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.
2424

2525
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.
2626

docs/src/specs/contracts/chain_management/bridgehub.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Note sure what CTM is? Check our the [overview](./chain_type_manager.md).
1515

1616
> This document will not cover how ZK Gateway works, you can check it out in [a separate doc](../gateway/overview.md).
1717
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).
1919

2020
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:
2121

docs/src/specs/contracts/chain_management/chain_type_manager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ In the current release, each chain will be an instance of ZKsync Era and so the
6262

6363
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.
6464

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.
6666

6767
### Issues & caveats
6868

docs/src/specs/contracts/chain_management/overview.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ be able to leverage them when available).
7777
- `ChainTypeRegistry` The chain type is shared for multiple chains, so initialization and upgrades have to be the same for all
7878
chains. Registration is not permissionless but happens based on the registrations in the bridgehub’s `Registry`. At
7979
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
8281
- Upgrade Mechanism The system requires all chains to be up-to-date with the latest implementation, so whenever an
8382
update is needed, we have to “force” each chain to update, but due to decentralization, we have to give each chain a
8483
time frame. This is done in the update mechanism contract, this is where the bootloader and system contracts are

docs/src/specs/contracts/gateway/chain_migration.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
## Ecosystem Setup
44

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.
66

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:
88

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.
1010

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.
1212

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.
1414

1515
![image.png](./img/ctm_gw_registration.png)
1616

docs/src/specs/contracts/gateway/l2_gw_l1_messaging.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ The structure has the following recursive format:
3030
- `settledMessageRoot = keccak256(LocalRoot, AggregatedRoot)`
3131
- `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.
3232
- `AggregatedRoot` — the root of the binary merkle tree over `ChainIdLeaf[]`.
33-
- `ChainIdLeaf = keccak256(CHAIN_ID_LEAF_PADDING, chain_id, ChainIdRoot`)
33+
- `ChainIdLeaf = keccak256(CHAIN_ID_LEAF_PADDING, ChainIdRoot, chain_id)`
3434
- `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.
3535
- `chain_id` — the chain id of the chain the batches of which are aggregated.
3636
- `ChainIdRoot` = the root of the binary merkle tree `BatchRootLeaf[]`.
37-
- `BatchRootLeaf = keccak256(BATCH_LEAF_HASH_PADDING, batch_number, SettledRootOfBatch).`
37+
- `BatchRootLeaf = keccak256(BATCH_LEAF_PADDING, SettledRootOfBatch, batch_number).`
3838

3939
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`.
4040

@@ -97,9 +97,13 @@ This function will be internally used by the existing `_proveL2LogInclusion` fun
9797

9898
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):
9999

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):
101101

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.
103107

104108
Then, the following happens:
105109

@@ -109,10 +113,10 @@ If the settlement layer of the chain is the chain itself, we can just end here b
109113

110114
If the chain is not a settlement layer of itself, we then need to calculate:
111115

112-
- `BatchRootLeaf = keccak256(BATCH_LEAF_HASH_PADDING, SettledRootOfBatch, batch_number).`
116+
- `BatchRootLeaf = keccak256(BATCH_LEAF_PADDING, SettledRootOfBatch, batch_number).`
113117
- Consume one element from the `_proofs` array to get the mask for the merkle path of the batch leaf in the chain id tree.
114118
- 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`)
116120

117121
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.
118122

@@ -178,7 +182,7 @@ In order to ease the server migration, we support legacy format of L2→L1 logs
178182

179183
To differentiate between legacy format and the one, the following approach is used;
180184

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.
183187

184188
In the next release the old format will be removed.

docs/src/specs/contracts/settlement_contracts/data_availability/custom_da.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ This allows for a general-purpose solution that ensures DA consistency and verif
6565
- `L2_DA_VALIDATOR_OUTPUT_HASH_KEY` (the commitment)
6666

6767
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.

docs/src/specs/contracts/settlement_contracts/data_availability/pubdata.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pre-Boojum system these are represented as separate fields while for boojum they
1313
array. Once 4844 gets integrated this bytes array will move from being part of the calldata to blob data.
1414

1515
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
1818
is that a committed or even proven block can be reverted but an executed one cannot). Once we have all the committed
1919
batches that have been executed, we then will pull the transaction input and the relevant fields, applying them in order
2020
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
6565
| Emitted by VM via an opcode. | VM knows nothing about them. |
6666
| 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. |
6767
| 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) |
6969
| In EIP4844 they will remain part of the calldata. | In EIP4844 they will become part of the blobs. |
7070

7171
#### Backwards-compatibility
@@ -194,7 +194,7 @@ all concatenated together to yield the final compressed version.
194194

195195
For bytecode to be considered valid it must satisfy the following:
196196

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
198198
2. Bytecode length must be a multiple of 32.
199199
3. Number of 32-byte words cannot be even.
200200

@@ -429,7 +429,7 @@ With Boojum, the interface for committing batches is the following one:
429429
/// @param bootloaderHeapInitialContentsHash Hash of the initial contents of the bootloader heap. In practice it serves as the commitment to the transactions in the batch.
430430
/// @param eventsQueueStateHash Hash of the events queue state. In practice it serves as the commitment to the events in the batch.
431431
/// @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).
433433
struct CommitBatchInfo {
434434
uint64 batchNumber;
435435
uint64 timestamp;
@@ -440,7 +440,7 @@ struct CommitBatchInfo {
440440
bytes32 bootloaderHeapInitialContentsHash;
441441
bytes32 eventsQueueStateHash;
442442
bytes systemLogs;
443-
bytes totalL2ToL1Pubdata;
443+
bytes operatorDAInput;
444444
}
445445
446446
```

0 commit comments

Comments
 (0)