diff --git a/docs/zilbridge_to_xbridge.md b/docs/zilbridge_to_xbridge.md index cff000b..534bccf 100644 --- a/docs/zilbridge_to_xbridge.md +++ b/docs/zilbridge_to_xbridge.md @@ -75,16 +75,20 @@ forge script script/bsc/deploy/02_deployZilbridgeTokenManagers.s.sol --rpc-url $ forge script script/bsc/deploy/03_registerLockProxy.s.sol --rpc-url ${BSC_RPC_URL} --broadcast --chain-id 56 --verify --legacy ``` -## pol +## pol, arb -This requires the core to be deployed as well as the token managers. +These requires the core to be deployed as well as the token managers; just run the deployments one by one. ``` export ETHERSCAN_API_KEY=... export POL_RPC_URL=.. forge script script/pol/deploy/02_deployCoreUpgradeable.s.sol --rpc-url ${POL_RPC_URL} --broadcast --chain-id 137 --verify +``` +``` +forge script script/arb/deploy/04_registerTokenManagers.s.sol --rpc-url ${ARB_RPC_URL} --broadcast --chain-id 42161 --verify +``` diff --git a/smart-contracts/foundry.toml b/smart-contracts/foundry.toml index aa69951..88f621f 100644 --- a/smart-contracts/foundry.toml +++ b/smart-contracts/foundry.toml @@ -9,4 +9,4 @@ auto_detect_solc = true build_info = true extra_output = ["storageLayout"] solc = "0.8.20" -evm_version = "london" \ No newline at end of file +#evm_version = "london" diff --git a/smart-contracts/script/arb/deploy/deployLockProxyProxy.s.sol b/smart-contracts/script/arb/deploy/01_deployLockProxyProxy.s.sol similarity index 100% rename from smart-contracts/script/arb/deploy/deployLockProxyProxy.s.sol rename to smart-contracts/script/arb/deploy/01_deployLockProxyProxy.s.sol diff --git a/smart-contracts/script/arb/deploy/02_deployCoreUpgradeable.s.sol b/smart-contracts/script/arb/deploy/02_deployCoreUpgradeable.s.sol new file mode 100644 index 0000000..065fee3 --- /dev/null +++ b/smart-contracts/script/arb/deploy/02_deployCoreUpgradeable.s.sol @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: MIT OR Apache-2.0 +pragma solidity ^0.8.20; + +import {Script} from "forge-std/Script.sol"; +import {ValidatorManagerUpgradeable} from "contracts/core-upgradeable/ValidatorManagerUpgradeable.sol"; +import {ChainGatewayUpgradeable} from "contracts/core-upgradeable/ChainGatewayUpgradeable.sol"; +import {ERC1967Proxy} from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol"; +import "forge-std/console.sol"; + +contract Deployment is Script { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_OWNER"); + address owner = vm.addr(deployerPrivateKey); + console.log("Owner is %s", owner); + address validator = address(0x250572Ed005BaD64Ff24FbDc0d41875dAF58944f); + console.log("Validator is %s", validator); + + address[] memory validators = new address[](1); + validators[0] = owner; + + vm.startBroadcast(deployerPrivateKey); + + // Deploy Validator Manager + address vmImplementation = address( + new ValidatorManagerUpgradeable{salt: "arb"}() + ); + bytes memory vmInitCall = abi.encodeWithSelector( + ValidatorManagerUpgradeable.initialize.selector, + owner, + validators + ); + address vmProxy = address( + new ERC1967Proxy{salt: "arb"}(vmImplementation, vmInitCall) + ); + ValidatorManagerUpgradeable validatorManager = ValidatorManagerUpgradeable( + vmProxy + ); + console.log( + "ValidatorManager Deployed: %s, owner is validator: %s, and size %s", + address(validatorManager), + validatorManager.isValidator(validators[0]), + validatorManager.validatorsSize() + ); + + // Deploy Chain Gateway + address cgImplementation = address( + new ChainGatewayUpgradeable{salt: "arb"}() + ); + bytes memory cgInitCall = abi.encodeWithSelector( + ChainGatewayUpgradeable.initialize.selector, + address(validatorManager), + owner + ); + address cgProxy = address( + new ERC1967Proxy{salt: "arb"}(cgImplementation, cgInitCall) + ); + ChainGatewayUpgradeable chainGateway = ChainGatewayUpgradeable(cgProxy); + console.log( + "ChainGateway Deployed: %s, with validatorManager %s", + address(chainGateway), + address(chainGateway.validatorManager()) + ); + + console.log("arbChainGatewayAddress = %s;", address(chainGateway)); + console.log("arbValidatorManager = %s;", address(validatorManager)); + + vm.stopBroadcast(); + } +} diff --git a/smart-contracts/script/arb/deploy/03_deployTokenManagers.s.sol b/smart-contracts/script/arb/deploy/03_deployTokenManagers.s.sol new file mode 100644 index 0000000..cf263e6 --- /dev/null +++ b/smart-contracts/script/arb/deploy/03_deployTokenManagers.s.sol @@ -0,0 +1,23 @@ +// 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 {LockProxyTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockProxyTokenManagerUpgradeableV3.sol"; +import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseOrNativeTokenManagerUpgradeableV3.sol"; +import { MainnetConfig } from "script/mainnetConfig.s.sol"; +import { TokenManagerDeployerUtil } from "script/tokenManagerDeployerUtil.s.sol"; + +contract deployZilbridgeTokenManagers is Script, MainnetConfig, TokenManagerDeployerUtil { + function run() external { + // 0.00025 ZIL + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_OWNER"); + uint fees = 0.00025 ether; + vm.startBroadcast(deployerPrivateKey); + LockAndReleaseOrNativeTokenManagerUpgradeableV3 lockAndReleaseOrNativeTokenManager = deployLockAndReleaseOrNativeTokenManager(arbChainGatewayAddress, fees); + LockProxyTokenManagerUpgradeableV3 lockProxyTokenManager = deployLockProxyTokenManager(arbChainGatewayAddress, fees); + console.log(" arbLockAndReleaseOrNativeTokenManagerUpgradeable = %s;", address(lockAndReleaseOrNativeTokenManager)); + console.log(" arbLockProxyTokenManager = %s;", address(lockProxyTokenManager)); + vm.stopBroadcast(); + } +} diff --git a/smart-contracts/script/arb/deploy/04_registerTokenManagers.s.sol b/smart-contracts/script/arb/deploy/04_registerTokenManagers.s.sol new file mode 100644 index 0000000..2f32818 --- /dev/null +++ b/smart-contracts/script/arb/deploy/04_registerTokenManagers.s.sol @@ -0,0 +1,26 @@ +// 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 {LockProxyTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockProxyTokenManagerUpgradeableV3.sol"; +import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseOrNativeTokenManagerUpgradeableV3.sol"; +import {ChainGatewayUpgradeable} from "contracts/core-upgradeable/ChainGatewayUpgradeable.sol"; +import { MainnetConfig } from "script/mainnetConfig.s.sol"; + +contract registerLockProxy is Script, MainnetConfig { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_OWNER"); + vm.startBroadcast(deployerPrivateKey); + // The lock proxy token manager needs to know where its lock proxy is. + LockProxyTokenManagerUpgradeableV3 lockProxyTokenManager = LockProxyTokenManagerUpgradeableV3(payable(arbLockProxyTokenManager)); + LockAndReleaseOrNativeTokenManagerUpgradeableV3 lockAndReleaseOrNativeTokenManager = LockAndReleaseOrNativeTokenManagerUpgradeableV3(payable(arbLockAndReleaseOrNativeTokenManagerUpgradeable)); + ChainGatewayUpgradeable chainGateway = ChainGatewayUpgradeable(arbChainGatewayAddress); + + lockProxyTokenManager.setLockProxyData(polLockProxy, polLockProxyProxy); + chainGateway.register(address(lockProxyTokenManager)); + chainGateway.register(address(lockAndReleaseOrNativeTokenManager)); + vm.stopBroadcast(); + } + +} diff --git a/smart-contracts/script/arb/deploy/05_registerTokenManagerWithLockProxyProxy.s.sol b/smart-contracts/script/arb/deploy/05_registerTokenManagerWithLockProxyProxy.s.sol new file mode 100644 index 0000000..fa67d23 --- /dev/null +++ b/smart-contracts/script/arb/deploy/05_registerTokenManagerWithLockProxyProxy.s.sol @@ -0,0 +1,22 @@ +// 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 {LockProxyTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockProxyTokenManagerUpgradeableV3.sol"; +import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseOrNativeTokenManagerUpgradeableV3.sol"; +import {LockProxyProxy} from "contracts/periphery/LockProxyProxy.sol"; +import {ChainGatewayUpgradeable} from "contracts/core-upgradeable/ChainGatewayUpgradeable.sol"; +import { MainnetConfig } from "script/mainnetConfig.s.sol"; + +contract registerLockProxy is Script, MainnetConfig { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_OWNER"); + vm.startBroadcast(deployerPrivateKey); + // The lock proxy token manager needs to know where its lock proxy is. + LockProxyTokenManagerUpgradeableV3 lockProxyTokenManager = LockProxyTokenManagerUpgradeableV3(payable(arbLockProxyTokenManager)); + LockProxyProxy lockProxyProxy = LockProxyProxy(payable(arbLockProxyProxy)); + lockProxyProxy.addCaller(address(lockProxyTokenManager)); + vm.stopBroadcast(); + } +} diff --git a/smart-contracts/script/bsc/deploy/04_registerTokenManagerWithLockProxyProxy.s.sol b/smart-contracts/script/bsc/deploy/04_registerTokenManagerWithLockProxyProxy.s.sol new file mode 100644 index 0000000..2bdf376 --- /dev/null +++ b/smart-contracts/script/bsc/deploy/04_registerTokenManagerWithLockProxyProxy.s.sol @@ -0,0 +1,22 @@ +// 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 {LockProxyTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockProxyTokenManagerUpgradeableV3.sol"; +import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseOrNativeTokenManagerUpgradeableV3.sol"; +import {LockProxyProxy} from "contracts/periphery/LockProxyProxy.sol"; +import {ChainGatewayUpgradeable} from "contracts/core-upgradeable/ChainGatewayUpgradeable.sol"; +import { MainnetConfig } from "script/mainnetConfig.s.sol"; + +contract registerLockProxy is Script, MainnetConfig { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_OWNER"); + vm.startBroadcast(deployerPrivateKey); + // The lock proxy token manager needs to know where its lock proxy is. + LockProxyTokenManagerUpgradeableV3 lockProxyTokenManager = LockProxyTokenManagerUpgradeableV3(payable(bscLockProxyTokenManager)); + LockProxyProxy lockProxyProxy = LockProxyProxy(payable(bscLockProxyProxy)); + lockProxyProxy.addCaller(address(lockProxyTokenManager)); + vm.stopBroadcast(); + } +} diff --git a/smart-contracts/script/mainnetConfig.s.sol b/smart-contracts/script/mainnetConfig.s.sol index ec4f077..177bb0a 100644 --- a/smart-contracts/script/mainnetConfig.s.sol +++ b/smart-contracts/script/mainnetConfig.s.sol @@ -28,12 +28,13 @@ abstract contract MainnetConfig { address public constant polLockAndReleaseOrNativeTokenManagerUpgradeable = 0x7519550ae8b6f9d32E9c1A939Fb5C186f660BE5b; address public constant polLockProxyTokenManager = 0x3faC7cb5b45A3B59d76b6926bc704Cf3cc522437; - - address public constant arbLockProxy = 0xb1E6F8820826491FCc5519f84fF4E2bdBb6e3Cad; - address public constant arbLockProxyProxy = 0x405e42de24Dc4894dB22595D041EBb170dC21D60; + address public constant arbLockProxyProxy = 0x405e42de24Dc4894dB22595D041EBb170dC21D60; + address public constant arbChainGatewayAddress = 0xA5AD439b10c3d7FBa00492745cA599250aC21619; + address public constant arbValidatorManager = 0x2f275Df0f73649E47F1805edFfd86E6135297175; + address public constant arbLockAndReleaseOrNativeTokenManagerUpgradeable = 0x4345472A0c6164F35808CDb7e7eCCd3d326CC50b; + address public constant arbLockProxyTokenManager = 0x4fa6148C9DAbC7A737422fb1b3AB9088c878d26C; + address public constant ethLockProxy = 0x9a016Ce184a22DbF6c17daA59Eb7d3140DBd1c54; address public constant ethLockProxyProxy = 0x405e42de24Dc4894dB22595D041EBb170dC21D60; - - } diff --git a/smart-contracts/script/pol/deploy/05_registerTokenManagerWithLockProxyProxy.s.sol b/smart-contracts/script/pol/deploy/05_registerTokenManagerWithLockProxyProxy.s.sol new file mode 100644 index 0000000..64ee4cf --- /dev/null +++ b/smart-contracts/script/pol/deploy/05_registerTokenManagerWithLockProxyProxy.s.sol @@ -0,0 +1,22 @@ +// 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 {LockProxyTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockProxyTokenManagerUpgradeableV3.sol"; +import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseOrNativeTokenManagerUpgradeableV3.sol"; +import {LockProxyProxy} from "contracts/periphery/LockProxyProxy.sol"; +import {ChainGatewayUpgradeable} from "contracts/core-upgradeable/ChainGatewayUpgradeable.sol"; +import { MainnetConfig } from "script/mainnetConfig.s.sol"; + +contract registerLockProxy is Script, MainnetConfig { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_OWNER"); + vm.startBroadcast(deployerPrivateKey); + // The lock proxy token manager needs to know where its lock proxy is. + LockProxyTokenManagerUpgradeableV3 lockProxyTokenManager = LockProxyTokenManagerUpgradeableV3(payable(polLockProxyTokenManager)); + LockProxyProxy lockProxyProxy = LockProxyProxy(payable(polLockProxyProxy)); + lockProxyProxy.addCaller(address(lockProxyTokenManager)); + vm.stopBroadcast(); + } +} diff --git a/smart-contracts/script/zq/deploy/04_registerTokenManagerWithLockProxyProxy.s.sol b/smart-contracts/script/zq/deploy/04_registerTokenManagerWithLockProxyProxy.s.sol new file mode 100644 index 0000000..bb7a3bb --- /dev/null +++ b/smart-contracts/script/zq/deploy/04_registerTokenManagerWithLockProxyProxy.s.sol @@ -0,0 +1,22 @@ +// 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 {LockProxyTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockProxyTokenManagerUpgradeableV3.sol"; +import {LockAndReleaseOrNativeTokenManagerUpgradeableV3} from "contracts/periphery/TokenManagerV3/LockAndReleaseOrNativeTokenManagerUpgradeableV3.sol"; +import {LockProxyProxy} from "contracts/periphery/LockProxyProxy.sol"; +import {ChainGatewayUpgradeable} from "contracts/core-upgradeable/ChainGatewayUpgradeable.sol"; +import { MainnetConfig } from "script/mainnetConfig.s.sol"; + +contract registerLockProxy is Script, MainnetConfig { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY_OWNER"); + vm.startBroadcast(deployerPrivateKey); + // The lock proxy token manager needs to know where its lock proxy is. + LockProxyTokenManagerUpgradeableV3 lockProxyTokenManager = LockProxyTokenManagerUpgradeableV3(payable(zilLockProxyTokenManager)); + LockProxyProxy lockProxyProxy = LockProxyProxy(payable(zilUnrestrictedLockProxyProxy)); + lockProxyProxy.addCaller(address(lockProxyTokenManager)); + vm.stopBroadcast(); + } +}