Skip to content

Commit

Permalink
Rename hyperchain -> ZK chain (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavBreadless authored Sep 5, 2024
1 parent 42933cd commit 4a062d0
Show file tree
Hide file tree
Showing 97 changed files with 587 additions and 576 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/l1-contracts-foundry-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ jobs:
working-directory: ./l1-contracts
run: forge script ./deploy-scripts/DeployErc20.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
# TODO restore scripts verification
# - name: Run RegisterHyperchain script
# - name: Run RegisterZKChain script
# working-directory: ./l1-contracts
# run: |
# cat ./script-out/output-deploy-l1.toml >> ./script-config/register-hyperchain.toml
# forge script ./deploy-scripts/RegisterHyperchain.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
# cat ./script-out/output-deploy-l1.toml >> ./script-config/register-zk-chain.toml
# forge script ./deploy-scripts/RegisterZKChain.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
# - name: Run InitializeL2WethToken script
# working-directory: ./l1-contracts-foundry
# run: forge script ./deploy-scripts/InitializeL2WethToken.s.sol --ffi --rpc-url $ANVIL_RPC_URL --broadcast --private-key $ANVIL_PRIVATE_KEY
2 changes: 1 addition & 1 deletion docs/Overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ this trick:
#### L1 -> L2 Transaction filtering

There is a mechanism for applying custom filters to the L1 -> L2 communication. It is achieved by having an address of
the `TransactionFilterer` contract in the `ZkSyncHyperchainStorage`. If the filterer exists, it is being called in
the `TransactionFilterer` contract in the `ZkSyncZKChainStorage`. If the filterer exists, it is being called in
the `Mailbox` facet with the tx details and has to return whether the transaction can be executed or not. The filterer
has to implement the `ITransactionFilterer` interface. The ones intended to use this feature, have to deploy the
contract that implements `ITransactionFilterer` and use `setTransactionFilterer` function of `AdminFacet` to set the
Expand Down
4 changes: 2 additions & 2 deletions docs/gateway/contracts-review-gateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Known issues, and features that still need to be implemented:
- Bridgehub setAssetHandlerAddress `address sender` might be an issue.
- MessageRoot should be renamed to MessageRootAggregator

![Untitled](./Hyperchain-scheme.png)
![Untitled](./ZKChain-scheme.png)

## Initial Scope

Expand Down Expand Up @@ -63,6 +63,6 @@ The majority of the rest of the changes. This makes the scope quite big, so plea
- ChainTypeManager.sol
- ValidatorTimelock.sol
- DiamondInit.sol
- ZkSyncHyperchainStorage.sol
- ZKChainStorage.sol
- Admin.sol
- L1GenesisUpgrade.sol
2 changes: 1 addition & 1 deletion gas-bound-caller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"test-node": "hardhat node-zksync --tag v0.0.1-vm1.5.0",
"check-canonical-bytecode": "ts-node ./scripts/check-canonical-bytecode.ts",
"verify": "hardhat run scripts/verify.ts",
"deploy-on-hyperchain": "ts-node ./scripts/deploy-on-hyperchain.ts",
"deploy-on-zk-chain": "ts-node ./scripts/deploy-on-zk-chain.ts",
"deploy-on-localhost": "hardhat deploy --network localhost"
}
}
4 changes: 2 additions & 2 deletions gas-bound-caller/scripts/deploy-on-hyperchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ async function main() {

program
.version("0.1.0")
.name("Deploy on hyperchain")
.description("Deploys the GasBoundCaller on a predetermined Hyperchain network")
.name("Deploy on ZK chain")
.description("Deploys the GasBoundCaller on a predetermined ZK chain network")
.option("--private-key <private-key>")
.option("--l2Rpc <l2Rpc>")
.action(async (cmd) => {
Expand Down
6 changes: 3 additions & 3 deletions l1-contracts/.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ CONTRACTS_VALIDATOR_TIMELOCK_EXECUTION_DELAY=0
ETH_SENDER_SENDER_OPERATOR_COMMIT_ETH_ADDR=0x0000000000000000000000000000000000000000
ETH_SENDER_SENDER_OPERATOR_BLOBS_ETH_ADDR=0x0000000000000000000000000000000000000001
CONTRACTS_SHARED_BRIDGE_UPGRADE_STORAGE_SWITCH=0
CONTRACTS_MAX_NUMBER_OF_HYPERCHAINS=100
CONTRACTS_MAX_NUMBER_OF_ZK_CHAINS=100
L1_CONFIG=/script-config/config-deploy-l1.toml
L1_OUTPUT=/script-out/output-deploy-l1.toml
TOKENS_CONFIG=/script-config/config-deploy-erc20.toml
HYPERCHAIN_CONFIG=/script-config/register-hyperchain.toml
HYPERCHAIN_OUTPUT=/script-out/output-deploy-hyperchain-era.toml
ZK_CHAIN_CONFIG=/script-config/register-zk-chain.toml
ZK_CHAIN_OUTPUT=/script-out/output-deploy-zk-chain-era.toml
FORCE_DEPLOYMENTS_CONFIG=/script-config/generate-force-deployments-data.toml
127 changes: 68 additions & 59 deletions l1-contracts/contracts/bridgehub/Bridgehub.sol

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions l1-contracts/contracts/bridgehub/IBridgehub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ interface IBridgehub is IL1AssetHandler {
event SettlementLayerRegistered(uint256 indexed chainId, bool indexed isWhitelisted);

/// @notice Emitted when the bridging to the chain is started.
/// @param chainId Chain ID of the hyperchain
/// @param assetId Asset ID of the token for the hyperchain's CTM
/// @param chainId Chain ID of the ZK chain
/// @param assetId Asset ID of the token for the zkChain's CTM
/// @param settlementLayerChainId The chain id of the settlement layer the chain migrates to.
event MigrationStarted(uint256 indexed chainId, bytes32 indexed assetId, uint256 indexed settlementLayerChainId);

/// @notice Emitted when the bridging to the chain is complete.
/// @param chainId Chain ID of the hyperchain
/// @param assetId Asset ID of the token for the hyperchain's CTM
/// @param hyperchain The address of the hyperchain on the chain where it is migrated to.
event MigrationFinalized(uint256 indexed chainId, bytes32 indexed assetId, address indexed hyperchain);
/// @param chainId Chain ID of the ZK chain
/// @param assetId Asset ID of the token for the zkChain's CTM
/// @param zkChain The address of the ZK chain on the chain where it is migrated to.
event MigrationFinalized(uint256 indexed chainId, bytes32 indexed assetId, address indexed zkChain);

/// @notice Starts the transfer of admin rights. Only the current admin or owner can propose a new pending one.
/// @notice New admin can accept admin rights by calling `acceptAdmin` function.
Expand All @@ -108,11 +108,11 @@ interface IBridgehub is IL1AssetHandler {

function messageRoot() external view returns (IMessageRoot);

function getHyperchain(uint256 _chainId) external view returns (address);
function getZKChain(uint256 _chainId) external view returns (address);

function getAllHyperchains() external view returns (address[] memory);
function getAllZKChains() external view returns (address[] memory);

function getAllHyperchainChainIDs() external view returns (uint256[] memory);
function getAllZKChainChainIDs() external view returns (uint256[] memory);

function migrationPaused() external view returns (bool);

Expand Down Expand Up @@ -201,7 +201,7 @@ interface IBridgehub is IL1AssetHandler {
// address _sharedBridge,
// address _admin,
// uint256 _expectedProtocolVersion,
// HyperchainCommitment calldata _commitment,
// ZKChainCommitment calldata _commitment,
// bytes calldata _diamondCut
// ) external;

Expand Down
6 changes: 3 additions & 3 deletions l1-contracts/contracts/bridgehub/MessageRoot.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {FullMerkle} from "../common/libraries/FullMerkle.sol";

import {MessageHashing} from "../common/libraries/MessageHashing.sol";

import {MAX_NUMBER_OF_HYPERCHAINS} from "../common/Config.sol";
import {MAX_NUMBER_OF_ZK_CHAINS} from "../common/Config.sol";

// Chain tree consists of batch commitments as their leaves. We use hash of "new bytes(96)" as the hash of an empty leaf.
bytes32 constant CHAIN_TREE_EMPTY_ENTRY_HASH = bytes32(
Expand Down Expand Up @@ -66,7 +66,7 @@ contract MessageRoot is IMessageRoot, ReentrancyGuard {
/// @notice only the bridgehub can call
/// @param _chainId the chainId of the chain
modifier onlyChain(uint256 _chainId) {
require(msg.sender == BRIDGE_HUB.getHyperchain(_chainId), "MR: only chain");
require(msg.sender == BRIDGE_HUB.getZKChain(_chainId), "MR: only chain");
_;
}

Expand Down Expand Up @@ -145,7 +145,7 @@ contract MessageRoot is IMessageRoot, ReentrancyGuard {
/// @param _chainId the chainId of the chain
function _addNewChain(uint256 _chainId) internal {
uint256 cachedChainCount = chainCount;
require(cachedChainCount < MAX_NUMBER_OF_HYPERCHAINS, "MR: too many chains");
require(cachedChainCount < MAX_NUMBER_OF_ZK_CHAINS, "MR: too many chains");

++chainCount;
chainIndex[_chainId] = cachedChainCount;
Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/contracts/common/Config.sol
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bytes32 constant TWO_BRIDGES_MAGIC_VALUE = bytes32(uint256(keccak256("TWO_BRIDGE
address constant BRIDGEHUB_MIN_SECOND_BRIDGE_ADDRESS = address(uint160(type(uint16).max));

/// @dev the maximum number of supported chains, this is an arbitrary limit.
uint256 constant MAX_NUMBER_OF_HYPERCHAINS = 100;
uint256 constant MAX_NUMBER_OF_ZK_CHAINS = 100;

/// @dev Used as the `msg.sender` for transactions that relayed via a settlement layer.
address constant SETTLEMENT_LAYER_RELAY_SENDER = address(uint160(0x1111111111111111111111111111111111111111));
Expand All @@ -128,7 +128,7 @@ struct PriorityTreeCommitment {
}

// Info that allows to restore a chain.
struct HyperchainCommitment {
struct ZKChainCommitment {
/// @notice Total number of executed batches i.e. batches[totalBatchesExecuted] points at the latest executed batch
/// (batch 0 is genesis)
uint256 totalBatchesExecuted;
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/contracts/common/L1ContractErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ error HashedLogIsDefault();
// 0x0b08d5be
error HashMismatch(bytes32 expected, bytes32 actual);
// 0xb615c2b1
error HyperchainLimitReached();
error ZKChainLimitReached();
// 0x826fb11e
error InsufficientChainBalance();
// 0x356680b7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.21;

/**
* @author Matter Labs
* @notice System smart contract that is responsible for deploying other smart contracts on a ZKsync hyperchain.
* @notice System smart contract that is responsible for deploying other smart contracts on a ZK chain.
*/
interface IL2ContractDeployer {
/// @notice A struct that describes a forced deployment on an address.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
pragma solidity 0.8.24;

import {Diamond} from "../../state-transition/libraries/Diamond.sol";
import {ZkSyncHyperchainBase} from "../../state-transition/chain-deps/facets/ZkSyncHyperchainBase.sol";
import {ZKChainBase} from "../../state-transition/chain-deps/facets/ZKChainBase.sol";

contract DiamondProxyTest is ZkSyncHyperchainBase {
contract DiamondProxyTest is ZKChainBase {
// add this to be excluded from coverage report
function test() internal virtual {}

Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/contracts/dev-contracts/test/DummyAdminFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

pragma solidity 0.8.24;

import {ZkSyncHyperchainBase} from "../../state-transition/chain-deps/facets/ZkSyncHyperchainBase.sol";
import {ZKChainBase} from "../../state-transition/chain-deps/facets/ZKChainBase.sol";

contract DummyAdminFacet is ZkSyncHyperchainBase {
contract DummyAdminFacet is ZKChainBase {
// add this to be excluded from coverage report
function test() internal virtual {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
pragma solidity 0.8.24;

import {Diamond} from "../../state-transition/libraries/Diamond.sol";
import {ZkSyncHyperchainBase} from "../../state-transition/chain-deps/facets/ZkSyncHyperchainBase.sol";
import {ZKChainBase} from "../../state-transition/chain-deps/facets/ZKChainBase.sol";
import {IL1AssetRouter} from "../../bridge/interfaces/IL1AssetRouter.sol";
import {DataEncoding} from "../../common/libraries/DataEncoding.sol";

/// selectors do not overlap with normal facet selectors (getName does not count)
contract DummyAdminFacetNoOverlap is ZkSyncHyperchainBase {
contract DummyAdminFacetNoOverlap is ZKChainBase {
// add this to be excluded from coverage report
function test() internal virtual {}

Expand Down
8 changes: 4 additions & 4 deletions l1-contracts/contracts/dev-contracts/test/DummyBridgehub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {IGetters} from "../../state-transition/chain-interfaces/IGetters.sol";
contract DummyBridgehub {
IMessageRoot public messageRoot;

address public hyperchain;
address public zkChain;

// add this to be excluded from coverage report
function test() internal virtual {}
Expand All @@ -34,11 +34,11 @@ contract DummyBridgehub {
messageRoot = IMessageRoot(_messageRoot);
}

function setHyperchain(uint256, address _hyperchain) external {
hyperchain = _hyperchain;
function setZKChain(uint256, address _zkChain) external {
zkChain = _zkChain;
}

function getHyperchain(uint256) external view returns (address) {
function getZKChain(uint256) external view returns (address) {
return address(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ contract DummyBridgehubSetter is Bridgehub {
constructor(
uint256 _l1ChainId,
address _owner,
uint256 _maxNumberOfHyperchains
) Bridgehub(_l1ChainId, _owner, _maxNumberOfHyperchains) {}
uint256 _maxNumberOfZKChains
) Bridgehub(_l1ChainId, _owner, _maxNumberOfZKChains) {}

function setHyperchain(uint256 _chainId, address _hyperchain) external {
_registerNewHyperchain(_chainId, _hyperchain);
function setZKChain(uint256 _chainId, address _zkChain) external {
_registerNewZKChain(_chainId, _zkChain);
}

function setCTM(uint256 _chainId, address _ctm) external {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ contract DummyChainTypeManager is ChainTypeManager {
// add this to be excluded from coverage report
function test() internal virtual {}

address hyperchain;
address zkChain;

/// @notice Constructor
constructor() ChainTypeManager(address(0)) {}

function setHyperchain(uint256 _chainId, address _hyperchain) external {
hyperchain = _hyperchain;
function setZKChain(uint256 _chainId, address _zkChain) external {
zkChain = _zkChain;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ contract DummyChainTypeManagerForValidatorTimelock {
function test() internal virtual {}

address public chainAdmin;
address public hyperchainAddress;
address public zkChainAddress;

constructor(address _chainAdmin, address _hyperchain) {
constructor(address _chainAdmin, address _zkChain) {
chainAdmin = _chainAdmin;
hyperchainAddress = _hyperchain;
zkChainAddress = _zkChain;
}

function getChainAdmin(uint256) external view returns (address) {
return chainAdmin;
}

function getHyperchain(uint256) external view returns (address) {
return hyperchainAddress;
function getZKChain(uint256) external view returns (address) {
return zkChainAddress;
}

function setHyperchain(uint256, address _hyperchain) external {
hyperchainAddress = _hyperchain;
function setZKChain(uint256, address _zkChain) external {
zkChainAddress = _zkChain;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {ChainTypeManager} from "../../state-transition/ChainTypeManager.sol";
contract DummyChainTypeManagerWBH is ChainTypeManager {
using EnumerableMap for EnumerableMap.UintToAddressMap;

address hyperchain;
address zkChain;
/// @notice Constructor
constructor(address bridgeHub) ChainTypeManager(bridgeHub) {}

function setHyperchain(uint256 _chainId, address _hyperchain) external {
hyperchain = _hyperchain;
function setZKChain(uint256 _chainId, address _zkChain) external {
zkChain = _zkChain;
}

// add this to be excluded from coverage report
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract DummySharedBridge is PausableUpgradeable {

bytes32 dummyL2DepositTxHash;

/// @dev Maps token balances for each chain to prevent unauthorized spending across hyperchains.
/// @dev Maps token balances for each chain to prevent unauthorized spending across zkChains.
/// This serves as a security measure until hyperbridging is implemented.
mapping(uint256 chainId => mapping(address l1Token => uint256 balance)) public chainBalance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity 0.8.24;

import {MailboxFacet} from "../../state-transition/chain-deps/facets/Mailbox.sol";
import {FeeParams, PubdataPricingMode} from "../../state-transition/chain-deps/ZkSyncHyperchainStorage.sol";
import {FeeParams, PubdataPricingMode} from "../../state-transition/chain-deps/ZKChainStorage.sol";

contract DummyHyperchain is MailboxFacet {
contract DummyZKChain is MailboxFacet {
constructor(
address bridgeHubAddress,
uint256 _eraChainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity 0.8.24;

import {ExecutorFacet} from "../../state-transition/chain-deps/facets/Executor.sol";
import {PubdataPricingMode} from "../../state-transition/chain-deps/ZkSyncHyperchainStorage.sol";
import {PubdataPricingMode} from "../../state-transition/chain-deps/ZKChainStorage.sol";
import {LogProcessingOutput} from "../../state-transition/chain-interfaces/IExecutor.sol";
import {LogProcessingOutput} from "../../state-transition/chain-interfaces/IExecutor.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pragma solidity 0.8.24;

import {FeeParams} from "../../state-transition/chain-deps/ZkSyncHyperchainStorage.sol";
import {FeeParams} from "../../state-transition/chain-deps/ZKChainStorage.sol";
import {MailboxFacet} from "../../state-transition/chain-deps/facets/Mailbox.sol";
import {REQUIRED_L2_GAS_PRICE_PER_PUBDATA} from "../../common/Config.sol";

Expand Down
4 changes: 2 additions & 2 deletions l1-contracts/contracts/dev-contracts/test/MockExecutor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

pragma solidity 0.8.24;

import {ZkSyncHyperchainBase} from "../../state-transition/chain-deps/facets/ZkSyncHyperchainBase.sol";
import {ZKChainBase} from "../../state-transition/chain-deps/facets/ZKChainBase.sol";

contract MockExecutorFacet is ZkSyncHyperchainBase {
contract MockExecutorFacet is ZKChainBase {
// add this to be excluded from coverage report
function test() internal virtual {}

Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/contracts/governance/Governance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {ZeroAddress, Unauthorized, OperationMustBeReady, OperationMustBePending,
/// @notice This contract manages operations (calls with preconditions) for governance tasks.
/// The contract allows for operations to be scheduled, executed, and canceled with
/// appropriate permissions and delays. It is used for managing and coordinating upgrades
/// and changes in all ZKsync hyperchain governed contracts.
/// and changes in all ZK chain governed contracts.
///
/// Operations can be proposed as either fully transparent upgrades with on-chain data,
/// or "shadow" upgrades where upgrade data is not published on-chain before execution. Proposed operations
Expand Down
Loading

0 comments on commit 4a062d0

Please sign in to comment.