From c16e2f06d6246ed6284546d1af353412e54bd1a9 Mon Sep 17 00:00:00 2001 From: 0xtekgrinder <72015889+0xtekgrinder@users.noreply.github.com> Date: Thu, 13 Jun 2024 15:15:38 +0200 Subject: [PATCH] feat: mode deployment (#35) * feat: mode deployment * chore: add into ci downlaod of vyper * feat: set evm version to cancun * chore: set evm version to shangai * chore: remove specific evm version * chore: add debug * chore: debug in ci * feat: upgrade vyper version to 0.3.10 * chore: update ci-deep * chore: remove debug session from ci * chore: update ci with vyper installed everywhere * fix: right version of slither ci * chore: try to skip test and scripts for slither * chore: try slither without action * chore: ignore compile and fail * chore: change slither version --- .github/workflows/ci-deep.yml | 39 ++++++++++++--- .github/workflows/ci.yml | 49 ++++++++++++++++--- foundry.toml | 2 +- lib/forge-std | 2 +- lib/utils | 2 +- package.json | 4 +- scripts/Utils.s.sol | 37 +------------- .../DeploySideChainGovernance.s.sol | 18 ++++--- test/external/veANGLE.vy | 22 ++++----- test/unit/SimulationSetup.t.sol | 7 +-- yarn.lock | 20 ++++---- 11 files changed, 115 insertions(+), 87 deletions(-) diff --git a/.github/workflows/ci-deep.yml b/.github/workflows/ci-deep.yml index 21ce474..c5a5be1 100644 --- a/.github/workflows/ci-deep.yml +++ b/.github/workflows/ci-deep.yml @@ -55,11 +55,28 @@ jobs: with: submodules: "recursive" + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + + - name: Install viper + shell: bash + run: pip install vyper==0.3.10 + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: version: nightly + - name: Setup repo + uses: ./.github/actions/setup-repo + with: + registry-token: ${{ secrets.GH_REGISTRY_ACCESS_TOKEN }} + + - name: Setup upterm session + uses: lhotari/action-upterm@v1 + - name: Compile foundry run: yarn compile --sizes @@ -70,6 +87,7 @@ jobs: path: | cache-forge out + node_modules - name: "Add build summary" run: | @@ -92,6 +110,15 @@ jobs: out key: "build-${{ github.sha }}" + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + + - name: Install viper + shell: bash + run: pip install vyper==0.3.10 + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: @@ -128,12 +155,12 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.10' cache: 'pip' # caching pip dependencies - + - name: Install viper shell: bash - run: pip install vyper==0.3.0 + run: pip install vyper==0.3.10 - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 @@ -173,12 +200,12 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.10' cache: 'pip' # caching pip dependencies - + - name: Install viper shell: bash - run: pip install vyper==0.3.0 + run: pip install vyper==0.3.10 - name: Install Foundry diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 105158a..bf78017 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -44,6 +44,15 @@ jobs: with: submodules: "recursive" + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + + - name: Install viper + shell: bash + run: pip install vyper==0.3.10 + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: @@ -88,6 +97,15 @@ jobs: node_modules key: "build-${{ github.sha }}" + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + + - name: Install viper + shell: bash + run: pip install vyper==0.3.10 + - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 with: @@ -125,12 +143,12 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.10' cache: 'pip' # caching pip dependencies - name: Install viper shell: bash - run: pip install vyper==0.3.0 + run: pip install vyper==0.3.10 - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 @@ -171,12 +189,12 @@ jobs: - uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.10' cache: 'pip' # caching pip dependencies - name: Install viper shell: bash - run: pip install vyper==0.3.0 + run: pip install vyper==0.3.10 - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 @@ -205,6 +223,15 @@ jobs: with: submodules: "recursive" + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + + - name: Install viper + shell: bash + run: pip install vyper==0.3.10 + - name: "Install Foundry" uses: "foundry-rs/foundry-toolchain@v1" @@ -256,16 +283,26 @@ jobs: with: version: nightly + - uses: actions/setup-python@v4 + with: + python-version: '3.10' + cache: 'pip' # caching pip dependencies + + - name: Install viper + shell: bash + run: pip install vyper==0.3.10 + - name: Compile foundry - run: forge build --build-info --force + run: forge build --build-info --skip */test/** */scripts/** --force - name: "Run Slither analysis" - uses: "crytic/slither-action@v0.3.0" + uses: "crytic/slither-action@v0.3.2" id: slither with: fail-on: "none" sarif: "results.sarif" ignore-compile: true + slither-version: "0.10.1" - name: "Upload SARIF file to GitHub code scanning" uses: "github/codeql-action/upload-sarif@v2" diff --git a/foundry.toml b/foundry.toml index f05c506..ed31cdc 100644 --- a/foundry.toml +++ b/foundry.toml @@ -34,7 +34,7 @@ polygonzkevm = "${ETH_NODE_URI_POLYGON_ZKEVM}" bsc = "${ETH_NODE_URI_BSC}" base = "${ETH_NODE_URI_BASE}" linea = "${ETH_NODE_URI_LINEA}" - +mode = "${ETH_NODE_URI_MODE}" [etherscan] arbitrum = { key = "${ARBITRUM_ETHERSCAN_API_KEY}" } diff --git a/lib/forge-std b/lib/forge-std index 2f11269..6e05729 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 2f112697506eab12d433a65fdc31a639548fe365 +Subproject commit 6e05729b76f1ae0d437e74951aef1ca987788ab3 diff --git a/lib/utils b/lib/utils index e33f4b9..4a734f6 160000 --- a/lib/utils +++ b/lib/utils @@ -1 +1 @@ -Subproject commit e33f4b9f042704eb02f37e32d93c108f5005cd3f +Subproject commit 4a734f605e58f0636fdb7b2a132823ae9424a1fa diff --git a/package.json b/package.json index b2af0ea..97329d4 100644 --- a/package.json +++ b/package.json @@ -42,8 +42,8 @@ "url": "https://github.com/AngleProtocol/boilerplate/issues" }, "devDependencies": { - "@angleprotocol/sdk": "^0.25.0", - "@layerzerolabs/lz-sdk": "^0.0.30", + "@angleprotocol/sdk": "^v2.10.2", + "@layerzerolabs/lz-sdk": "^0.0.75", "discord.js": "^14.14.1", "prettier": "^2.0.0", "prettier-plugin-solidity": "^1.1.3", diff --git a/scripts/Utils.s.sol b/scripts/Utils.s.sol index 09f7b82..42b68f7 100644 --- a/scripts/Utils.s.sol +++ b/scripts/Utils.s.sol @@ -14,19 +14,6 @@ import "./Constants.s.sol"; /// @title Utils /// @author Angle Labs, Inc. contract Utils is Script, CommonUtils { - mapping(uint256 => uint256) internal forkIdentifier; - uint256 public arbitrumFork; - uint256 public avalancheFork; - uint256 public ethereumFork; - uint256 public optimismFork; - uint256 public polygonFork; - uint256 public gnosisFork; - uint256 public bnbFork; - uint256 public celoFork; - uint256 public polygonZkEVMFork; - uint256 public baseFork; - uint256 public lineaFork; - bytes[] private calldatas; string private description; address[] private targets; @@ -34,29 +21,7 @@ contract Utils is Script, CommonUtils { uint256[] private chainIds; function setUp() public virtual { - arbitrumFork = vm.createFork(vm.envString("ETH_NODE_URI_ARBITRUM")); - avalancheFork = vm.createFork(vm.envString("ETH_NODE_URI_AVALANCHE")); - ethereumFork = vm.createFork(vm.envString("ETH_NODE_URI_MAINNET")); - optimismFork = vm.createFork(vm.envString("ETH_NODE_URI_OPTIMISM")); - polygonFork = vm.createFork(vm.envString("ETH_NODE_URI_POLYGON")); - gnosisFork = vm.createFork(vm.envString("ETH_NODE_URI_GNOSIS")); - bnbFork = vm.createFork(vm.envString("ETH_NODE_URI_BSC")); - celoFork = vm.createFork(vm.envString("ETH_NODE_URI_CELO")); - polygonZkEVMFork = vm.createFork(vm.envString("ETH_NODE_URI_POLYGON_ZKEVM")); - baseFork = vm.createFork(vm.envString("ETH_NODE_URI_BASE")); - lineaFork = vm.createFork(vm.envString("ETH_NODE_URI_LINEA")); - - forkIdentifier[CHAIN_ARBITRUM] = arbitrumFork; - forkIdentifier[CHAIN_AVALANCHE] = avalancheFork; - forkIdentifier[CHAIN_ETHEREUM] = ethereumFork; - forkIdentifier[CHAIN_OPTIMISM] = optimismFork; - forkIdentifier[CHAIN_POLYGON] = polygonFork; - forkIdentifier[CHAIN_GNOSIS] = gnosisFork; - forkIdentifier[CHAIN_BNB] = bnbFork; - forkIdentifier[CHAIN_CELO] = celoFork; - forkIdentifier[CHAIN_POLYGONZKEVM] = polygonZkEVMFork; - forkIdentifier[CHAIN_BASE] = baseFork; - forkIdentifier[CHAIN_LINEA] = lineaFork; + setUpForks(); } function _deserializeJson() diff --git a/scripts/deployment/DeploySideChainGovernance.s.sol b/scripts/deployment/DeploySideChainGovernance.s.sol index 2912796..7dfe4f1 100644 --- a/scripts/deployment/DeploySideChainGovernance.s.sol +++ b/scripts/deployment/DeploySideChainGovernance.s.sol @@ -23,27 +23,29 @@ contract DeploySideChainGovernance is Utils { TimelockControllerWithCounter public timelock; function run() external { - uint256 deployerPrivateKey = vm.deriveKey(vm.envString("MNEMONIC_POLYGON"), "m/44'/60'/0'/0/", 0); + uint256 deployerPrivateKey = vm.deriveKey(vm.envString("MNEMONIC_MAINNET"), "m/44'/60'/0'/0/", 0); vm.startBroadcast(deployerPrivateKey); address deployer = vm.addr(deployerPrivateKey); vm.label(deployer, "Deployer"); // TODO can be modified to deploy on any chain uint256 srcChainId = CHAIN_ETHEREUM; - uint256 destChainId = CHAIN_LINEA; + uint256 destChainId = CHAIN_MODE; + address destSafeMultiSig = 0x7DE8289038DF0b89FFEC71Ee48a2BaD572549027; // guardian // END - address destSafeMultiSig = _chainToContract(destChainId, ContractType.GuardianMultisig); ProposalSender proposalSender = ProposalSender(_chainToContract(srcChainId, ContractType.ProposalSender)); // Deploy relayer receiver and Timelock on end chain address[] memory proposers = new address[](0); address[] memory executors = new address[](1); - executors[0] = destSafeMultiSig; // Means everyone can execute + executors[0] = address(0); // Means everyone can execute + + timelock = new TimelockControllerWithCounter(timelockDelay, proposers, executors, deployer); + console.log("Timelock address: ", address(timelock)); + + proposalReceiver = new ProposalReceiver(address(_lzEndPoint(destChainId))); + console.log("ProposalReceiver address: ", address(proposalReceiver)); - // timelock = new TimelockControllerWithCounter(timelockDelay, proposers, executors, deployer); - // proposalReceiver = new ProposalReceiver(address(_lzEndPoint(destChainId))); - timelock = TimelockControllerWithCounter(payable(0xd23B51d6F2cB3eC7ca9599D4332a2F10C3CFDF85)); - proposalReceiver = ProposalReceiver(payable(0x4A44f77978Daa3E92Eb3D97210bd11645cF935Ab)); timelock.grantRole(timelock.PROPOSER_ROLE(), address(proposalReceiver)); timelock.grantRole(timelock.CANCELLER_ROLE(), destSafeMultiSig); timelock.renounceRole(timelock.DEFAULT_ADMIN_ROLE(), deployer); diff --git a/test/external/veANGLE.vy b/test/external/veANGLE.vy index b2fbe56..67940b6 100644 --- a/test/external/veANGLE.vy +++ b/test/external/veANGLE.vy @@ -1,4 +1,4 @@ -# @version 0.3.0 +# @version 0.3.10 """ @title Voting Escrow @author Angle Protocol @@ -138,7 +138,7 @@ def initialize(_admin: address, token_addr: address, _smart_wallet_checker: addr """ assert self.initialized == False #dev: contract is already initialized self.initialized = True - assert _admin!= ZERO_ADDRESS #dev: admin cannot be the 0 address + assert _admin!= empty(address) #dev: admin cannot be the 0 address self.admin = _admin self.token = token_addr self.smart_wallet_checker = _smart_wallet_checker @@ -160,7 +160,7 @@ def commit_transfer_ownership(addr: address): @param addr Address to have ownership transferred to """ assert msg.sender == self.admin # dev: admin only - assert addr != ZERO_ADDRESS # dev: future admin cannot be the 0 address + assert addr != empty(address) # dev: future admin cannot be the 0 address self.future_admin = addr log CommitOwnership(addr) @@ -182,7 +182,7 @@ def apply_transfer_ownership(): """ assert msg.sender == self.admin # dev: admin only _admin: address = self.future_admin - assert _admin != ZERO_ADDRESS # dev: admin not set + assert _admin != empty(address) # dev: admin not set self.admin = _admin log ApplyOwnership(_admin) @@ -214,7 +214,7 @@ def assert_not_contract(addr: address): """ if addr != tx.origin: checker: address = self.smart_wallet_checker - if checker != ZERO_ADDRESS: + if checker != empty(address): if SmartWalletChecker(checker).check(addr): return raise "Smart contract depositors not allowed" @@ -269,14 +269,14 @@ def _checkpoint(addr: address, old_locked: LockedBalance, new_locked: LockedBala new_dslope: int128 = 0 _epoch: uint256 = self.epoch - if addr != ZERO_ADDRESS: + if addr != empty(address): # Calculate slopes and biases # Kept at zero when they have to if old_locked.end > block.timestamp and old_locked.amount > 0: - u_old.slope = old_locked.amount / MAXTIME + u_old.slope = old_locked.amount / convert(MAXTIME, int128) u_old.bias = u_old.slope * convert(old_locked.end - block.timestamp, int128) if new_locked.end > block.timestamp and new_locked.amount > 0: - u_new.slope = new_locked.amount / MAXTIME + u_new.slope = new_locked.amount / convert(MAXTIME, int128) u_new.bias = u_new.slope * convert(new_locked.end - block.timestamp, int128) # Read values of scheduled changes in the slope @@ -333,7 +333,7 @@ def _checkpoint(addr: address, old_locked: LockedBalance, new_locked: LockedBala self.epoch = _epoch # Now point_history is filled until t=now - if addr != ZERO_ADDRESS: + if addr != empty(address): # If last point was in this block, the slope change has been applied already # But in such case we have 0 slope(s) last_point.slope += (u_new.slope - u_old.slope) @@ -346,7 +346,7 @@ def _checkpoint(addr: address, old_locked: LockedBalance, new_locked: LockedBala # Record the changed point into history self.point_history[_epoch] = last_point - if addr != ZERO_ADDRESS: + if addr != empty(address): # Schedule the slope changes (slope is going down) # We subtract new_user_slope from [new_locked.end] # and add old_user_slope to [old_locked.end] @@ -410,7 +410,7 @@ def checkpoint(): """ @notice Record global data to checkpoint """ - self._checkpoint(ZERO_ADDRESS, empty(LockedBalance), empty(LockedBalance)) + self._checkpoint(empty(address), empty(LockedBalance), empty(LockedBalance)) @external diff --git a/test/unit/SimulationSetup.t.sol b/test/unit/SimulationSetup.t.sol index bfb29c8..ef88db5 100644 --- a/test/unit/SimulationSetup.t.sol +++ b/test/unit/SimulationSetup.t.sol @@ -33,7 +33,6 @@ contract SimulationSetup is Test, CommonUtils { uint256[] chainIds; // To list every needed chainId mapping(uint256 => string) mapChainIds; - mapping(uint256 => uint256) forkIdentifier; mapping(uint256 => TimelockControllerWithCounter) internal _timelocks; mapping(uint256 => ProposalReceiver) internal _proposalReceivers; ProposalSender internal _proposalSender; @@ -50,6 +49,8 @@ contract SimulationSetup is Test, CommonUtils { mapChainIds[1] = "MAINNET"; mapChainIds[137] = "POLYGON"; mapChainIds[10] = "OPTIMISM"; + + setUpForks(); // TODO Complete with all deployed chains veANGLEDelegation = new VeANGLEVotingDelegation(address(veANGLE), "veANGLE Delegation", "1"); @@ -60,10 +61,6 @@ contract SimulationSetup is Test, CommonUtils { string memory baseURI = "ETH_NODE_URI_"; for (uint256 i; i < chainIds.length; i++) { - forkIdentifier[chainIds[i]] = vm.createFork( - vm.envString(baseURI.toSlice().concat(mapChainIds[chainIds[i]].toSlice())) - ); - /// TODO Remove this part after deployment if (chainIds[i] == 1) { vm.selectFork(forkIdentifier[chainIds[i]]); diff --git a/yarn.lock b/yarn.lock index f019f33..5362962 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,10 +2,10 @@ # yarn lockfile v1 -"@angleprotocol/sdk@^0.25.0": - version "0.25.0" - resolved "https://npm.pkg.github.com/download/@angleprotocol/sdk/0.25.0/5ae64a565f6bfc3459ce1442360539fc9438decc#5ae64a565f6bfc3459ce1442360539fc9438decc" - integrity sha512-AX3MAfmLOrPnP/rfhWF6djEWlcFOIL/mEEKIJY6h8kKUMJjVm2NQyGmrryJD0aCyi5/0MaB9dQNOAqj5yhkx+w== +"@angleprotocol/sdk@^v2.10.2": + version "2.10.3" + resolved "https://npm.pkg.github.com/download/@angleprotocol/sdk/2.10.3/b44247bf23db46a6f1bd32cee1b5210b9f7e3e33#b44247bf23db46a6f1bd32cee1b5210b9f7e3e33" + integrity sha512-/1kQaJOPjA9AeHIVZvGIcor0FjsP+88U/QIAu9pjIINBVUuPOEWUkkgQQogMJZPP2hdJbKP+dbxjE9GpHhyh9w== dependencies: "@apollo/client" "^3.7.17" "@typechain/ethers-v5" "^10.0.0" @@ -18,7 +18,7 @@ lodash "^4.17.21" merkletreejs "^0.3.10" tiny-invariant "^1.1.0" - typechain "^8.0.0" + typechain "^8.3.2" "@apollo/client@^3.7.17": version "3.8.8" @@ -491,10 +491,10 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== -"@layerzerolabs/lz-sdk@^0.0.30": - version "0.0.30" - resolved "https://registry.yarnpkg.com/@layerzerolabs/lz-sdk/-/lz-sdk-0.0.30.tgz#c86d41d5d535eb6f4d830431db55d5cf37c089ac" - integrity sha512-3mjxv5loBfiBtPFa3qthgZBxkgq3ac0t0299gayt1XOkBI0QB9Ti1dKb0qYYs4VavqrKXmJVTDkta+xSdJS0sw== +"@layerzerolabs/lz-sdk@^0.0.75": + version "0.0.75" + resolved "https://registry.yarnpkg.com/@layerzerolabs/lz-sdk/-/lz-sdk-0.0.75.tgz#e8e2d1ba4704020b8c876b94b965da8a55a96f27" + integrity sha512-s8HCMwhPpXfSLkZDeWJ281q8sMZRSQlC5LieCmqIHnYAquCAke3/w+nRHuvnu/KtgE9i5Y9dc+mbOqNUTNGv2g== "@noble/curves@1.1.0", "@noble/curves@~1.1.0": version "1.1.0" @@ -1726,7 +1726,7 @@ tslib@2.6.2, tslib@^2.1.0, tslib@^2.3.0, tslib@^2.6.2: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae" integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== -typechain@^8.0.0: +typechain@^8.3.2: version "8.3.2" resolved "https://registry.yarnpkg.com/typechain/-/typechain-8.3.2.tgz#1090dd8d9c57b6ef2aed3640a516bdbf01b00d73" integrity sha512-x/sQYr5w9K7yv3es7jo4KTX05CLxOf7TRWwoHlrjRh8H82G64g+k7VuWPJlgMo6qrjfCulOdfBjiaDtmhFYD/Q==