Skip to content

Commit

Permalink
(feat) Deployment scripts and docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
rrw-zilliqa committed Jul 15, 2024
1 parent 2a6dd20 commit f0b3f08
Show file tree
Hide file tree
Showing 8 changed files with 192 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/zilbridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,36 @@ your ZIL to `lockProxy`, we will have to recover it for you with our
admin rights, because obviously you won't be able to bridge it to
anywhere else.

## BSC Testnet Deployment

There are a group of scripts that allow you to deploy the EVM half of the ZilBridge transition code into BSC Testnet.

The `smart-contracts/README.md` contains predeployed addresses; if you
decide to redeploy you will need to change the constants in the `
scripts, since this is how the addresses of previous contracts are
baked in (sorry!).

* `mockZilBridge.s.sol` - this is basically what `ZilBridgeFixture::deployOriginalContracts()` does; it deploys via `PRIVATE_KEY_ZILBRIDGE`.
*


Run with:

```sh
export PRIVATE_KEY_ZILBRIDGE=<zilbridge_owner_privkey>
forge script script/bsc-testnet/deployMockZilBridge.s.sol --rpc-url https://bsc-testnet.bnbchain.org --broadcast

forge verify-contract <address> --rpc-url https://bsc-testnet.bnbchain.org --chain-id 97


# now put the data from ^^ into deployXBridgeOverMockZilBridge.s.sol
forge script script/bsc-testnet/deployXBridgeOverMockZilBridge.s.sol --rpc-url https://bsc-testnet.bnbchain.org --broadcast


```




## TODO

Expand Down
20 changes: 20 additions & 0 deletions smart-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,30 @@ Deterministic deployer not available, simple CREATE was used

Deterministic deployer not available, simple CREATE was used

Zilliqa side tokens:




### BSC Testnet

- `ChainId`: 97
- `ChainGateway`: `0xa9A14C90e53EdCD89dFd201A3bF94D867f8098fE`
- `ValidatorManager`: `0xCc1CB36d981ae2907cea385F615e879434D20B1C`
- `MintAndBurnTokenManager`: `0xA6D73210AF20a59832F264fbD991D2abf28401d0`
- `BridgedTestToken`: `0x5190e8b4Bbe8C3a732BAdB600b57fD42ACbB9F4B`

ZilBridge ChainID 6, bridging to ZilBridge chain ID 18.

```
Owner: 0x29543Acb166B6044B67979B858e743701C9bd1df
ECCD: 0xd677494525D25238Fedd554796eEa5733a9B86a2
CCM: 0xff4AC43f368676765de511F82B816EED9b9D780c
CCMProxy: 0xd7a76e4454c4f4F80E6409DF361B7926a1789d93
LockProxy: 0x218D8aFE24bb2a0d1DE483Ff67aCADB45Ac8Bd2d
extendCCM: 0xF2eeaceDB35776412fe999D45aA81Ea674030aE1
zilbridge tokenmanager: 0x103617938D41f7bea62F0B5b4E8e50585083048F
```


Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*Submitted for verification at Etherscan.io on 2021-10-19
*/

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;

abstract contract Context {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

// File: eth-contracts/contracts/core/cross_chain_manager/interface/IEthCrossChainData.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;


Expand Down
45 changes: 45 additions & 0 deletions smart-contracts/script/bsc-testnet/deployMockZilBridge.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.20;

import {Script} from "forge-std/Script.sol";
import "forge-std/console.sol";
import {Tester} from "test/Tester.sol";
import {TestToken} from "test/Helpers.sol";
import { LockProxy } from "contracts/zilbridge/1/lockProxy.sol";
import { EthCrossChainManagerProxy } from "contracts/zilbridge/1/ccmProxy.sol";
import { EthCrossChainManager } from "contracts/zilbridge/1/ccmCrossChainManager.sol";
import { EthCrossChainData } from "contracts/zilbridge/1/ethCrossChainData.sol";
import { EthExtendCrossChainManager } from "contracts/zilbridge/2/ccmExtendCrossChainManager.sol";
import { LockProxyTokenManagerUpgradeableV3 } from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeableV3.sol";
import { LockProxyTokenManagerDeployer } from "test/zilbridge/TokenManagerDeployers/LockProxyTokenManagerDeployer.sol";

/*** @notice does what ZilBridgeFixture::deployOriginalContracts() does */
contract deployMockZilBridge is Script {
uint64 constant CHAIN_ID=6;
uint64 constant COUNTERPART_CHAIN_ID=18;

function run() external {
EthCrossChainManager ccm;
EthCrossChainManagerProxy ccmProxy;
EthCrossChainData eccd;
LockProxy lockProxy;
EthExtendCrossChainManager extendCCM;

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_ZILBRIDGE");
address owner = vm.addr(deployerPrivateKey);
address[] memory a = new address[](0);
bytes[] memory b = new bytes[](0);
vm.startBroadcast(deployerPrivateKey);
console.log("Owner: %s", owner);
eccd = new EthCrossChainData();
console.log("ECCD: %s", address(eccd));
ccm = new EthCrossChainManager(address(eccd), CHAIN_ID, a, b);
console.log("CCM: %s", address(ccm));
ccmProxy = new EthCrossChainManagerProxy(address(ccm));
console.log("CCMProxy: %s", address(ccmProxy));
ccm.transferOwnership(address(ccmProxy));
eccd.transferOwnership(address(ccm));
lockProxy = new LockProxy(address(ccmProxy), COUNTERPART_CHAIN_ID);
console.log("LockProxy: %s",address(lockProxy));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.20;

import {Script} from "forge-std/Script.sol";
import "forge-std/console.sol";
import {Tester} from "test/Tester.sol";
import {TestToken} from "test/Helpers.sol";
import { LockProxy } from "contracts/zilbridge/1/lockProxy.sol";
import { EthCrossChainManagerProxy } from "contracts/zilbridge/1/ccmProxy.sol";
import { EthCrossChainManager } from "contracts/zilbridge/1/ccmCrossChainManager.sol";
import { EthCrossChainData } from "contracts/zilbridge/1/ethCrossChainData.sol";
import { EthExtendCrossChainManager } from "contracts/zilbridge/2/ccmExtendCrossChainManager.sol";
import { LockProxyTokenManagerUpgradeableV3 } from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeableV3.sol";
import { LockProxyTokenManagerDeployer } from "test/zilbridge/TokenManagerDeployers/LockProxyTokenManagerDeployer.sol";

/*** @notice ZilBridgeFixture::installExtendCrossManager() */
contract deployXBridgeOverMockZilBridge is Script {
// Plug in the data from deployMockZilBridge here.
EthCrossChainData public constant eccd = EthCrossChainData(0xd677494525D25238Fedd554796eEa5733a9B86a2);
EthCrossChainManager public constant ccm = EthCrossChainManager(0xff4AC43f368676765de511F82B816EED9b9D780c);
EthCrossChainManagerProxy public constant ccmProxy = EthCrossChainManagerProxy(0xd7a76e4454c4f4F80E6409DF361B7926a1789d93);
LockProxy public constant lockProxy = LockProxy(payable(0x218D8aFE24bb2a0d1DE483Ff67aCADB45Ac8Bd2d));
EthExtendCrossChainManager extendCCM;

function run() external {
address[] memory a = new address[](0);
bytes[] memory b = new bytes[](0);
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_ZILBRIDGE");
vm.startBroadcast(deployerPrivateKey);
address owner = vm.addr(deployerPrivateKey);
extendCCM = new EthExtendCrossChainManager(address(eccd), 2, a, b);
ccmProxy.pauseEthCrossChainManager();
extendCCM.transferOwnership(address(ccmProxy));
ccmProxy.upgradeEthCrossChainManager(address(extendCCM));
ccmProxy.unpauseEthCrossChainManager();
console.log("extendCCM: %s", address(extendCCM));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity ^0.8.20;

import {Script} from "forge-std/Script.sol";
import "forge-std/console.sol";
import {Tester} from "test/Tester.sol";
import {TestToken} from "test/Helpers.sol";
import { LockProxy } from "contracts/zilbridge/1/lockProxy.sol";
import { TestingLockProxy } from "test/zilbridge/TestingLockProxy.sol";
import { EthCrossChainManagerProxy } from "contracts/zilbridge/1/ccmProxy.sol";
import { EthCrossChainManager } from "contracts/zilbridge/1/ccmCrossChainManager.sol";
import { EthCrossChainData } from "contracts/zilbridge/1/ethCrossChainData.sol";
import { EthExtendCrossChainManager } from "contracts/zilbridge/2/ccmExtendCrossChainManager.sol";
import { ChainGateway } from "contracts/core/ChainGateway.sol";
import { LockProxyTokenManagerUpgradeableV3 } from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeableV3.sol";
import { LockProxyTokenManagerDeployer } from "test/zilbridge/TokenManagerDeployers/LockProxyTokenManagerDeployer.sol";
import {LockProxyTokenManagerUpgradeableV3} from "contracts/zilbridge/2/LockProxyTokenManagerUpgradeableV3.sol";
import {LockProxyTokenManagerDeployer} from "test/zilbridge/TokenManagerDeployers/LockProxyTokenManagerDeployer.sol";
import {MintAndBurnTokenManagerDeployer} from "test/periphery/TokenManagerDeployers/MintAndBurnTokenManagerDeployer.sol";
import {LockAndReleaseTokenManagerDeployer} from "test/periphery/TokenManagerDeployers/LockAndReleaseTokenManagerDeployer.sol";
import { SwitcheoToken } from "contracts/zilbridge/token/tokens/SwitcheoTokenETH.sol";

/*** @notice Deploy token managers over the extension manager
*/
contract deployZilBridgeTokenManagers is Script, LockProxyTokenManagerDeployer {
EthExtendCrossChainManager constant extendCCM = EthExtendCrossChainManager(0xF2eeaceDB35776412fe999D45aA81Ea674030aE1);
ChainGateway constant chainGateway = ChainGateway(0xa9A14C90e53EdCD89dFd201A3bF94D867f8098fE);
LockProxy constant lockProxy = LockProxy(payable(0x218D8aFE24bb2a0d1DE483Ff67aCADB45Ac8Bd2d));
// Different from 0.00025 so that we can tell the difference!
uint fees = 0.00007 ether;

// This has to be 18, because that is what the original (ZilBridge) contracts were
// deployed with. The mainnet value is 5.
uint64 constant COUNTERPART_CHAIN_ID = 18;

function run() external {
uint256 validatorPrivateKey = vm.envUint("PRIVATE_KEY_VALIDATOR");
uint256 bridgePrivateKey = vm.envUint("PRIVATE_KEY_ZILBRIDGE");
address validator = vm.addr(validatorPrivateKey);
address bridgeOwner = vm.addr(bridgePrivateKey);
// token managers are apparently not pausable, so ..
vm.startBroadcast(validatorPrivateKey);
LockProxyTokenManagerUpgradeableV3 tokenManager = deployLatestLockProxyTokenManager(address(chainGateway), address(lockProxy), fees);
console.log("zilbridge tokenmanager: %s", address(tokenManager));
vm.stopBroadcast();
vm.startBroadcast(bridgePrivateKey);
extendCCM.forciblyAddExtension(address(lockProxy), address(tokenManager), COUNTERPART_CHAIN_ID);
vm.stopBroadcast();
vm.startBroadcast(validatorPrivateKey);
chainGateway.register(address(tokenManager));
vm.stopBroadcast();
}
}
4 changes: 4 additions & 0 deletions smart-contracts/script/config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { parseUnits } from "ethers";

// These turn out to be testnet addresses.

export const config = {
zq: {
tokenManager: "0x6D61eFb60C17979816E4cE12CD5D29054E755948",
chainGateway: "0xbA44BC29371E19117DA666B729A1c6e1b35DDb40",
token: "0x241c677D9969419800402521ae87C411897A029f",
remoteToken: "0x351dA1E7500aBA1d168b9435DCE73415718d212F",
remoteTokenManager: "0xF391A1Ee7b3ccad9a9451D2B7460Ac646F899f23",
remoteZilBridgeTokenManager: "0x103617938D41f7bea62F0B5b4E8e50585083048F",
remoteChainId: 56,
remoteRecipient: "0xb34b88220Fa1EAeDba5d50b271AF8c3eE14A24Dd",
amount: parseUnits("1000000", 12),
Expand All @@ -18,6 +21,7 @@ export const config = {
token: "0x351dA1E7500aBA1d168b9435DCE73415718d212F",
remoteToken: "0x241c677D9969419800402521ae87C411897A029f",
remoteTokenManager: "0x6D61eFb60C17979816E4cE12CD5D29054E755948",
remoteZilBridgeTokenManager: "",
remoteChainId: 32769,
remoteRecipient: "0xb34b88220Fa1EAeDba5d50b271AF8c3eE14A24Dd",
amount: parseUnits("1000000", 12),
Expand Down

0 comments on commit f0b3f08

Please sign in to comment.