From 33b70ebad42196caef3f952d8572da268ab2e2cc Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 13 Mar 2024 10:41:09 +0100 Subject: [PATCH 01/19] CCIP update templating --- ...ImplementationAndCCIPAdapters_20240313.sol | 135 +++----------- ...ImplementationAndCCIPAdapters_20240313.sol | 83 ++------- ...ImplementationAndCCIPAdapters_20240313.sol | 166 +++--------------- ...ImplementationAndCCIPAdapters_20240313.sol | 136 +++----------- .../BaseAdaptersUpdatePayload.sol | 162 +++++++++++++++++ .../BaseCCCImplementationUpdatePayload.sol | 31 ++++ 6 files changed, 289 insertions(+), 424 deletions(-) create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayload.sol diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 79c9aab43..2e46138f2 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -1,133 +1,46 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; -import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; -import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; import {MiscAvalanche} from 'aave-address-book/MiscAvalanche.sol'; import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol'; -import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; - -import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; +import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; /** - * @title Update a.DI implementation and CCIP adapters + * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs * - Snapshot: TODO * - Discussion: TODO */ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313 is - IProposalGenericExecutor + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscAvalanche.PROXY_ADMIN, + newCCCImplementation: 0x5Ef80c5eB6CF65Dab8cD1C0ee258a6D2bD38Bd22, + ccipNewAdapter: 0x2b88C83727B0E290B76EB3F6133994fF81B7f355, + ccipAdapterToRemove: 0x3F006299eC88985c18E6e885EeA29A49eC579882 + }) + ) { - address public constant CCIP_ADAPTER_TO_REMOVE = 0x3F006299eC88985c18E6e885EeA29A49eC579882; - address public constant CCIP_NEW_ADAPTER = 0x2b88C83727B0E290B76EB3F6133994fF81B7f355; - address public constant DESTINATION_CCIP_NEW_ADAPTER = 0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29; - address public constant NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION = - 0x5Ef80c5eB6CF65Dab8cD1C0ee258a6D2bD38Bd22; - - function execute() external { - // Update CrossChainController implementation - ProxyAdmin(MiscAvalanche.PROXY_ADMIN).upgradeAndCall( - TransparentUpgradeableProxy(payable(GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER)), - NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION, - abi.encodeWithSignature('initializeRevision()') - ); - - // remove old Receiver bridge adapter - ICrossChainReceiver(GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER) - .disallowReceiverBridgeAdapters(_getReceiverBridgeAdaptersToRemove()); - - // remove forwarding adapters - ICrossChainForwarder(GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER).disableBridgeAdapters( - _getForwarderBridgeAdaptersToRemove() - ); - - // add receiver adapters - ICrossChainReceiver(GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters( - _getReceiverBridgeAdaptersToAllow() - ); - - // add forwarding adapters - ICrossChainForwarder(GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER).enableBridgeAdapters( - _getForwarderBridgeAdaptersToEnable() - ); - } - - function _getReceiverBridgeAdaptersToRemove() - internal - pure - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - uint256[] memory chainIds = new uint256[](1); - chainIds[0] = ChainIds.MAINNET; - - // remove old Receiver bridge adapter - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); - - bridgeAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, - chainIds: chainIds - }); - - return bridgeAdaptersToRemove; - } - - function _getForwarderBridgeAdaptersToRemove() - internal - pure - returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) - { - uint256[] memory chainIds = new uint256[](1); - chainIds[0] = ChainIds.MAINNET; - - ICrossChainForwarder.BridgeAdapterToDisable[] - memory forwarderAdaptersToRemove = new ICrossChainForwarder.BridgeAdapterToDisable[](1); - - forwarderAdaptersToRemove[0] = ICrossChainForwarder.BridgeAdapterToDisable({ - bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, - chainIds: chainIds - }); - - return forwarderAdaptersToRemove; - } - - function _getReceiverBridgeAdaptersToAllow() - internal - pure - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - uint256[] memory chainIds = new uint256[](1); - chainIds[0] = ChainIds.MAINNET; - - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); - - bridgeAdapterConfig[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: CCIP_NEW_ADAPTER, - chainIds: chainIds - }); - - return bridgeAdapterConfig; + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; } - function _getForwarderBridgeAdaptersToEnable() - internal + function getDestinationAdapters() + public pure - returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) + override + returns (BaseAdaptersUpdatePayload.DestinationAdaptersInput[] memory) { - ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] - memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( - 1 - ); + BaseAdaptersUpdatePayload.DestinationAdaptersInput[] + memory destinationAdapters = new BaseAdaptersUpdatePayload.DestinationAdaptersInput[](1); - bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ - currentChainBridgeAdapter: CCIP_NEW_ADAPTER, - destinationBridgeAdapter: DESTINATION_CCIP_NEW_ADAPTER, - destinationChainId: ChainIds.MAINNET - }); + destinationAdapters[0].adapter = 0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29; + destinationAdapters[0].chainId = ChainIds.MAINNET; - return bridgeAdaptersToEnable; + return destinationAdapters; } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 9f81ee3ea..54221d243 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -1,80 +1,31 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; -import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; -import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; import {MiscBNB} from 'aave-address-book/MiscBNB.sol'; import {GovernanceV3BNB} from 'aave-address-book/GovernanceV3BNB.sol'; -import {ICrossChainReceiver} from 'aave-address-book/common/ICrossChainController.sol'; +import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; /** - * @title Update a.DI implementation and CCIP adapters + * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs * - Snapshot: TODO * - Discussion: TODO */ -contract AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313 is IProposalGenericExecutor { - address public constant CCIP_ADAPTER_TO_REMOVE = 0x746c675dAB49Bcd5BB9Dc85161f2d7Eb435009bf; - address public constant CCIP_NEW_ADAPTER = 0xAE93BEa44dcbE52B625169588574d31e36fb3A67; - address public constant NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION = - 0xf41193E25408F652AF878c47E4401A01B5E4B682; - - function execute() external { - // Update CrossChainController implementation - ProxyAdmin(MiscBNB.PROXY_ADMIN).upgradeAndCall( - TransparentUpgradeableProxy(payable(GovernanceV3BNB.CROSS_CHAIN_CONTROLLER)), - NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION, - abi.encodeWithSignature('initializeRevision()') - ); - - // remove old Receiver bridge adapter - ICrossChainReceiver(GovernanceV3BNB.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters( - _getReceiverBridgeAdaptersToRemove() - ); - - // add receiver adapters - ICrossChainReceiver(GovernanceV3BNB.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters( - _getReceiverBridgeAdaptersToAllow() - ); - } - - function _getReceiverBridgeAdaptersToRemove() - internal - pure - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - uint256[] memory chainIds = new uint256[](1); - chainIds[0] = ChainIds.MAINNET; - - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); - - bridgeAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, - chainIds: chainIds - }); - - return bridgeAdaptersToRemove; - } - - function _getReceiverBridgeAdaptersToAllow() - internal - pure - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - uint256[] memory chainIds = new uint256[](1); - chainIds[0] = ChainIds.MAINNET; - - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); - - bridgeAdapterConfig[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: CCIP_NEW_ADAPTER, - chainIds: chainIds - }); - - return bridgeAdapterConfig; +contract AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3BNB.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscBNB.PROXY_ADMIN, + newCCCImplementation: 0xf41193E25408F652AF878c47E4401A01B5E4B682, + ccipNewAdapter: 0xAE93BEa44dcbE52B625169588574d31e36fb3A67, + ccipAdapterToRemove: 0x746c675dAB49Bcd5BB9Dc85161f2d7Eb435009bf + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol index c6eb56b3d..8c5578bc4 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -1,161 +1,53 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; -import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; -import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; -import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; +import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; /** - * @title Update a.DI implementation and CCIP adapters + * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs * - Snapshot: TODO * - Discussion: TODO */ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313 is - IProposalGenericExecutor + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscEthereum.PROXY_ADMIN, + newCCCImplementation: 0x28559c2F4B038b1E836fA419DCcDe7454d8Fe215, + ccipNewAdapter: 0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29, + ccipAdapterToRemove: 0xDB8953194810b1942544fA528791278D458719D5 + }) + ) { - //receiver adapters to remove - address public constant CCIP_ADAPTER_TO_REMOVE = 0xDB8953194810b1942544fA528791278D458719D5; - // forwarder-receiver adapter pairs to add - address public constant CCIP_NEW_ADAPTER = 0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29; - - address public constant DESTINATION_CCIP_NEW_ADAPTER_AVALANCHE = - 0x2b88C83727B0E290B76EB3F6133994fF81B7f355; - address public constant DESTINATION_CCIP_NEW_ADAPTER_POLYGON = - 0xe79757D55a1600eF28D816a893E78E9FCDE2019E; - address public constant DESTINATION_CCIP_NEW_ADAPTER_BNB = - 0xAE93BEa44dcbE52B625169588574d31e36fb3A67; - - address public constant NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION = - 0x28559c2F4B038b1E836fA419DCcDe7454d8Fe215; - - function execute() external { - // Update CrossChainController implementation - ProxyAdmin(MiscEthereum.PROXY_ADMIN).upgradeAndCall( - TransparentUpgradeableProxy(payable(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER)), - NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION, - abi.encodeWithSignature('initializeRevision()') - ); - // add receiver adapters - ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters( - _getReceiverBridgeAdaptersToAllow() - ); - - // add forwarding adapters - ICrossChainForwarder(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).enableBridgeAdapters( - _getForwarderBridgeAdaptersToEnable() - ); - - // remove old Receiver bridge adapter - ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters( - _getReceiverBridgeAdaptersToRemove() - ); - - // remove forwarding adapters - ICrossChainForwarder(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).disableBridgeAdapters( - _getForwarderBridgeAdaptersToRemove() - ); - } - - function _getReceiverBridgeAdaptersToRemove() - internal - pure - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory receiverAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]( - 1 - ); - - uint256[] memory receiverChainIds = new uint256[](1); - receiverChainIds[0] = ChainIds.POLYGON; - receiverChainIds[1] = ChainIds.AVALANCHE; - - receiverAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, - chainIds: receiverChainIds - }); - - return receiverAdaptersToRemove; + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](2); + chains[0] = ChainIds.AVALANCHE; + chains[1] = ChainIds.POLYGON; + return chains; } - function _getForwarderBridgeAdaptersToRemove() - internal + function getDestinationAdapters() + public pure - returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + override + returns (BaseAdaptersUpdatePayload.DestinationAdaptersInput[] memory) { - ICrossChainForwarder.BridgeAdapterToDisable[] - memory forwarderAdaptersToRemove = new ICrossChainForwarder.BridgeAdapterToDisable[](1); + BaseAdaptersUpdatePayload.DestinationAdaptersInput[] + memory destinationAdapters = new BaseAdaptersUpdatePayload.DestinationAdaptersInput[](3); - uint256[] memory forwarderCCIPChainIds = new uint256[](3); - forwarderCCIPChainIds[0] = ChainIds.AVALANCHE; - forwarderCCIPChainIds[1] = ChainIds.POLYGON; - forwarderCCIPChainIds[2] = ChainIds.BNB; - - forwarderAdaptersToRemove[0] = ICrossChainForwarder.BridgeAdapterToDisable({ - bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, - chainIds: forwarderCCIPChainIds - }); - - return forwarderAdaptersToRemove; - } - - function _getReceiverBridgeAdaptersToAllow() - internal - pure - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - uint256[] memory receiverChainIds = new uint256[](2); - receiverChainIds[0] = ChainIds.AVALANCHE; - receiverChainIds[1] = ChainIds.POLYGON; - - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory receiverAdaptersToAllow = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]( - 1 - ); - - receiverAdaptersToAllow[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: CCIP_NEW_ADAPTER, - chainIds: receiverChainIds - }); - - return receiverAdaptersToAllow; - } - - function _getForwarderBridgeAdaptersToEnable() - internal - pure - returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) - { - ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] - memory forwarderAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( - 3 - ); - // avalanche path - forwarderAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ - currentChainBridgeAdapter: CCIP_NEW_ADAPTER, - destinationBridgeAdapter: DESTINATION_CCIP_NEW_ADAPTER_AVALANCHE, - destinationChainId: ChainIds.AVALANCHE - }); + destinationAdapters[0].adapter = 0x2b88C83727B0E290B76EB3F6133994fF81B7f355; + destinationAdapters[0].chainId = ChainIds.AVALANCHE; - // polygon path - forwarderAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ - currentChainBridgeAdapter: CCIP_NEW_ADAPTER, - destinationBridgeAdapter: DESTINATION_CCIP_NEW_ADAPTER_POLYGON, - destinationChainId: ChainIds.POLYGON - }); + destinationAdapters[1].adapter = 0xe79757D55a1600eF28D816a893E78E9FCDE2019E; + destinationAdapters[1].chainId = ChainIds.POLYGON; - // binance path - forwarderAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ - currentChainBridgeAdapter: CCIP_NEW_ADAPTER, - destinationBridgeAdapter: DESTINATION_CCIP_NEW_ADAPTER_BNB, - destinationChainId: ChainIds.BNB - }); + destinationAdapters[2].adapter = 0xAE93BEa44dcbE52B625169588574d31e36fb3A67; + destinationAdapters[2].chainId = ChainIds.BNB; - return forwarderAdaptersToEnable; + return destinationAdapters; } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 9847ecbb5..a39145b4a 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -1,130 +1,46 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; -import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; -import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; import {MiscPolygon} from 'aave-address-book/MiscPolygon.sol'; -import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; +import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; /** - * @title Update a.DI implementation and CCIP adapters + * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs * - Snapshot: TODO * - Discussion: TODO */ -contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 is IProposalGenericExecutor { - address public constant CCIP_ADAPTER_TO_REMOVE = 0x95Fa2c817169E26956AB8795c84a225b55d7db5B; - address public constant CCIP_NEW_ADAPTER = 0xe79757D55a1600eF28D816a893E78E9FCDE2019E; - address public constant DESTINATION_CCIP_NEW_ADAPTER = 0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29; - address public constant NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION = - 0x87a95917DE670088d81B9a8B30E3B36704Ba3043; - - function execute() external { - // Update CrossChainController implementation - ProxyAdmin(MiscPolygon.PROXY_ADMIN).upgradeAndCall( - TransparentUpgradeableProxy(payable(GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER)), - NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION, - abi.encodeWithSignature('initializeRevision()') - ); - - // remove old Receiver bridge adapter - ICrossChainReceiver(GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters( - _getReceiverBridgeAdaptersToRemove() - ); - - // remove forwarding adapters - ICrossChainForwarder(GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER).disableBridgeAdapters( - _getForwarderBridgeAdaptersToRemove() - ); - - // add receiver adapters - ICrossChainReceiver(GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters( - _getReceiverBridgeAdaptersToAllow() - ); - - // add forwarding adapters - ICrossChainForwarder(GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER).enableBridgeAdapters( - _getForwarderBridgeAdaptersToEnable() - ); - } - - function _getReceiverBridgeAdaptersToRemove() - internal - pure - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - uint256[] memory chainIds = new uint256[](1); - chainIds[0] = ChainIds.MAINNET; - - // remove old Receiver bridge adapter - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); - - bridgeAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, - chainIds: chainIds - }); - - return bridgeAdaptersToRemove; - } - - function _getForwarderBridgeAdaptersToRemove() - internal - pure - returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) - { - uint256[] memory chainIds = new uint256[](1); - chainIds[0] = ChainIds.MAINNET; - - ICrossChainForwarder.BridgeAdapterToDisable[] - memory forwarderAdaptersToRemove = new ICrossChainForwarder.BridgeAdapterToDisable[](1); - - forwarderAdaptersToRemove[0] = ICrossChainForwarder.BridgeAdapterToDisable({ - bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, - chainIds: chainIds - }); - - return forwarderAdaptersToRemove; - } - - function _getReceiverBridgeAdaptersToAllow() - internal - pure - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - uint256[] memory chainIds = new uint256[](1); - chainIds[0] = ChainIds.MAINNET; - - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); - - bridgeAdapterConfig[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: CCIP_NEW_ADAPTER, - chainIds: chainIds - }); - - return bridgeAdapterConfig; +contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscPolygon.PROXY_ADMIN, + newCCCImplementation: 0x87a95917DE670088d81B9a8B30E3B36704Ba3043, + ccipNewAdapter: 0xe79757D55a1600eF28D816a893E78E9FCDE2019E, + ccipAdapterToRemove: 0x95Fa2c817169E26956AB8795c84a225b55d7db5B + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; } - function _getForwarderBridgeAdaptersToEnable() - internal + function getDestinationAdapters() + public pure - returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) + override + returns (BaseAdaptersUpdatePayload.DestinationAdaptersInput[] memory) { - ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] - memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( - 1 - ); + BaseAdaptersUpdatePayload.DestinationAdaptersInput[] + memory destinationAdapters = new BaseAdaptersUpdatePayload.DestinationAdaptersInput[](1); - bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ - currentChainBridgeAdapter: CCIP_NEW_ADAPTER, - destinationBridgeAdapter: DESTINATION_CCIP_NEW_ADAPTER, - destinationChainId: ChainIds.MAINNET - }); + destinationAdapters[0].adapter = 0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29; + destinationAdapters[0].chainId = ChainIds.MAINNET; - return bridgeAdaptersToEnable; + return destinationAdapters; } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol new file mode 100644 index 000000000..6cbc1f1f0 --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; + +import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol'; + +/** + * @title Base payload aDI and bridge adapters update + * @author BGD Labs @bgdlabs + */ +abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayload { + struct ConstructorInput { + address proxyAdmin; + address ccc; + address newCCCImplementation; + address ccipAdapterToRemove; + address ccipNewAdapter; + } + struct DestinationAdaptersInput { + address adapter; + uint256 chainId; + } + + address public immutable CCIP_ADAPTER_TO_REMOVE; + address public immutable CCIP_NEW_ADAPTER; + + constructor( + ConstructorInput memory constructorInput + ) + public + BaseAdaptersUpdatePayload( + CCCImplementationUpdateInput({ + proxyAdmin: constructorInput.proxyAdmin, + ccc: constructorInput.ccc, + newCCCImplementation: constructorInput.newCCCImplementation + }) + ) + { + CCIP_ADAPTER_TO_REMOVE = constructorInput.ccipAdapterToRemove; + CCIP_NEW_ADAPTER = constructorInput.ccipNewAdapter; + } + + function execute() external { + super.execute(); + // remove old Receiver bridge adapter + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters( + getReceiverBridgeAdaptersToRemove() + ); + + // remove forwarding adapters + ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).disableBridgeAdapters( + getForwarderBridgeAdaptersToRemove() + ); + + uint256[] memory chainsToSend = getChainsToSend(); + + if (chainsToSend.length != 0) { + // add receiver adapters + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters( + getReceiverBridgeAdaptersToAllow() + ); + + // add forwarding adapters + ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).enableBridgeAdapters( + getForwarderBridgeAdaptersToEnable() + ); + } + } + + function getDestinationAdapters() + public + pure + virtual + returns (DestinationAdaptersInput[] memory) + { + DestinationAdaptersInput[] memory destinationAdapters; + return destinationAdapters; + } + + function getChainsToReceive() public pure virtual returns (uint256[] memory); + + function getChainsToSend() public pure returns (uint256[] memory) { + DestinationAdaptersInput[] memory destinationAdapters = getDestinationAdapters(); + uint256[] memory chainsToSend = new uint256[](destinationAdapters.length); + for (uint256 i = 0; i < destinationAdapters.length; i++) { + chainsToSend[i] = destinationAdapters[i]; + } + return chainsToSend; + } + + function getReceiverBridgeAdaptersToRemove() + public + pure + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + // remove old Receiver bridge adapter + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory bridgeAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); + + bridgeAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ + bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, + chainIds: getChainsToReceive() + }); + + return bridgeAdaptersToRemove; + } + + function getForwarderBridgeAdaptersToRemove() + public + pure + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + ICrossChainForwarder.BridgeAdapterToDisable[] + memory forwarderAdaptersToRemove = new ICrossChainForwarder.BridgeAdapterToDisable[](1); + + forwarderAdaptersToRemove[0] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: CCIP_ADAPTER_TO_REMOVE, + chainIds: getChainsToSend() + }); + + return forwarderAdaptersToRemove; + } + + function getReceiverBridgeAdaptersToAllow() + internal + pure + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); + + bridgeAdapterConfig[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ + bridgeAdapter: CCIP_NEW_ADAPTER, + chainIds: getChainsToReceive() + }); + + return bridgeAdapterConfig; + } + + function getForwarderBridgeAdaptersToEnable() + internal + pure + returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) + { + DestinationAdaptersInput[] memory destinationAdapters = getDestinationAdapters(); + + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + destinationAdapters.length + ); + + for (uint256 i = 0; i < destinationAdapters.length; i++) { + bridgeAdaptersToEnable[i] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: CCIP_NEW_ADAPTER, + destinationBridgeAdapter: destinationAdapters[i].adapter, + destinationChainId: destinationAdapters[i].chainId + }); + } + + return bridgeAdaptersToEnable; + } +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayload.sol new file mode 100644 index 000000000..ff8d90a7e --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayload.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; +import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; + +contract BaseCCCImplementationUpdatePayload is IProposalGenericExecutor { + struct CCCImplementationUpdateInput { + address proxyAdmin; + address ccc; + address newCCCImplementation; + } + address public immutable CROSS_CHAIN_CONTROLLER_IMPLEMENTATION; + address public immutable CROSS_CHAIN_CONTROLLER; + address public immutable PROXY_ADMIN; + + constructor(CCCImplementationUpdateInput memory updateInput) { + PROXY_ADMIN = updateInput.proxyAdmin; + CROSS_CHAIN_CONTROLLER = updateInput.ccc; + CROSS_CHAIN_CONTROLLER_IMPLEMENTATION = updateInput.newCCCImplementation; + } + + function execute() public virtual { + // Update CrossChainController implementation + ProxyAdmin(PROXY_ADMIN).upgradeAndCall( + TransparentUpgradeableProxy(payable(CROSS_CHAIN_CONTROLLER)), + CROSS_CHAIN_CONTROLLER_IMPLEMENTATION, + abi.encodeWithSignature('initializeRevision()') + ); + } +} From b79c4cad94269e0afa82ca0cf4a10028bbe3bf0f Mon Sep 17 00:00:00 2001 From: sendra Date: Wed, 13 Mar 2024 10:54:56 +0100 Subject: [PATCH 02/19] fix: added missing chain id --- .../BaseAdaptersUpdatePayload.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol index 6cbc1f1f0..72215054c 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol @@ -83,7 +83,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa DestinationAdaptersInput[] memory destinationAdapters = getDestinationAdapters(); uint256[] memory chainsToSend = new uint256[](destinationAdapters.length); for (uint256 i = 0; i < destinationAdapters.length; i++) { - chainsToSend[i] = destinationAdapters[i]; + chainsToSend[i] = destinationAdapters[i].chainId; } return chainsToSend; } From 02ee087be80d39bda314158f7d35bf5e6a916272 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 13 Mar 2024 10:57:53 +0100 Subject: [PATCH 03/19] fix compilation issues --- ...che_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol | 1 + .../BaseAdaptersUpdatePayload.sol | 5 ++--- .../BaseCCCImplementationUpdatePayload.sol | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 56eb15392..7edf7ef62 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -5,6 +5,7 @@ import {AaveV3Avalanche} from 'aave-address-book/AaveV3Avalanche.sol'; import {MiscAvalanche} from 'aave-address-book/MiscAvalanche.sol'; import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; + import './BaseTest.sol'; import {AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol index 72215054c..16cfb1065 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol @@ -27,8 +27,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa constructor( ConstructorInput memory constructorInput ) - public - BaseAdaptersUpdatePayload( + BaseCCCImplementationUpdatePayload( CCCImplementationUpdateInput({ proxyAdmin: constructorInput.proxyAdmin, ccc: constructorInput.ccc, @@ -40,7 +39,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa CCIP_NEW_ADAPTER = constructorInput.ccipNewAdapter; } - function execute() external { + function execute() public override { super.execute(); // remove old Receiver bridge adapter ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayload.sol index ff8d90a7e..41d78c09c 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayload.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayload.sol @@ -10,6 +10,7 @@ contract BaseCCCImplementationUpdatePayload is IProposalGenericExecutor { address ccc; address newCCCImplementation; } + address public immutable CROSS_CHAIN_CONTROLLER_IMPLEMENTATION; address public immutable CROSS_CHAIN_CONTROLLER; address public immutable PROXY_ADMIN; From 071287b503dbc19f6c6ae7f0c0362764897edc86 Mon Sep 17 00:00:00 2001 From: sendra Date: Wed, 13 Mar 2024 11:20:53 +0100 Subject: [PATCH 04/19] fix: fixed compilation error --- ...plementationAndCCIPAdapters_20240313.t.sol | 40 ++++---- ...plementationAndCCIPAdapters_20240313.t.sol | 92 ++++++++----------- ...plementationAndCCIPAdapters_20240313.t.sol | 40 ++++---- .../BaseAdaptersUpdatePayload.sol | 8 +- .../BaseTest.sol | 64 +++++++++---- 5 files changed, 125 insertions(+), 119 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 7edf7ef62..6e3e058ef 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -39,10 +39,6 @@ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313_Test is return adapterNames; } - function _checkCorrectPathConfiguration() internal override { - assertEq(ethereumPayload.CCIP_NEW_ADAPTER(), payload.DESTINATION_CCIP_NEW_ADAPTER()); - } - function _getTrustedRemotes() internal view override returns (TrustedRemote[] memory) { TrustedRemote[] memory trustedRemotes = new TrustedRemote[](1); trustedRemotes[0] = TrustedRemote({ @@ -54,24 +50,24 @@ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313_Test is return trustedRemotes; } - function _getForwarderAdaptersByChain( - bool afterExecution - ) internal view override returns (ForwarderAdapters[] memory) { - ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](1); - - ICrossChainForwarder.ChainIdBridgeConfig[] - memory adapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - adapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - - if (afterExecution) { - adapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - adapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER(); - } - forwarderAdapters[0].adapters = adapters; - forwarderAdapters[0].chainId = ChainIds.MAINNET; - - return forwarderAdapters; - } + // function _getForwarderAdaptersByChain( + // bool afterExecution + // ) internal view override returns (ForwarderAdapters[] memory) { + // ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](1); + // + // ICrossChainForwarder.ChainIdBridgeConfig[] + // memory adapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); + // adapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); + // + // if (afterExecution) { + // adapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); + // adapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER(); + // } + // forwarderAdapters[0].adapters = adapters; + // forwarderAdapters[0].chainId = ChainIds.MAINNET; + // + // return forwarderAdapters; + // } function _getReceiverAdaptersByChain( bool afterExecution diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 292f4368a..d9e59a807 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -18,9 +18,6 @@ import {AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313} from './ */ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseTest { AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313 internal payload; - AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 internal avalanchePayload; - AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313 internal bnbPayload; - AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 internal polygonPayload; constructor() BaseTest( @@ -34,9 +31,6 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is function setUp() public override { super.setUp(); payload = new AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313(); - avalanchePayload = new AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313(); - bnbPayload = new AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313(); - polygonPayload = new AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313(); payloadAddress = address(payload); } @@ -47,12 +41,6 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is return adapterNames; } - function _checkCorrectPathConfiguration() internal override { - assertEq(payload.DESTINATION_CCIP_NEW_ADAPTER_AVALANCHE(), avalanchePayload.CCIP_NEW_ADAPTER()); - assertEq(payload.DESTINATION_CCIP_NEW_ADAPTER_BNB(), bnbPayload.CCIP_NEW_ADAPTER()); - assertEq(payload.DESTINATION_CCIP_NEW_ADAPTER_POLYGON(), polygonPayload.CCIP_NEW_ADAPTER()); - } - function _getTrustedRemotes() internal view override returns (TrustedRemote[] memory) { TrustedRemote[] memory trustedRemotes = new TrustedRemote[](2); trustedRemotes[0] = TrustedRemote({ @@ -91,46 +79,46 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is return receiverAdaptersByChain; } - function _getForwarderAdaptersByChain( - bool afterExecution - ) internal view override returns (ForwarderAdapters[] memory) { - ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](3); - - ICrossChainForwarder.ChainIdBridgeConfig[] - memory polygonAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - ICrossChainForwarder.ChainIdBridgeConfig[] - memory avalancheAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - ICrossChainForwarder.ChainIdBridgeConfig[] - memory binanceAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - - // polygon - polygonAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - // avalanche - avalancheAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - // binance - binanceAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - - if (afterExecution) { - // polygon - polygonAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - polygonAdapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER_POLYGON(); - // avalanche - avalancheAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - avalancheAdapters[0].destinationBridgeAdapter = payload - .DESTINATION_CCIP_NEW_ADAPTER_AVALANCHE(); - // binance - binanceAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - binanceAdapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER_BNB(); - } - forwarderAdapters[0].adapters = polygonAdapters; - forwarderAdapters[0].chainId = ChainIds.POLYGON; - forwarderAdapters[1].adapters = avalancheAdapters; - forwarderAdapters[1].chainId = ChainIds.AVALANCHE; - forwarderAdapters[2].adapters = binanceAdapters; - forwarderAdapters[2].chainId = ChainIds.BNB; - - return forwarderAdapters; - } + // function _getForwarderAdaptersByChain( + // bool afterExecution + // ) internal view override returns (ForwarderAdapters[] memory) { + // ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](3); + // + // ICrossChainForwarder.ChainIdBridgeConfig[] + // memory polygonAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); + // ICrossChainForwarder.ChainIdBridgeConfig[] + // memory avalancheAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); + // ICrossChainForwarder.ChainIdBridgeConfig[] + // memory binanceAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); + // + // // polygon + // polygonAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); + // // avalanche + // avalancheAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); + // // binance + // binanceAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); + // + // if (afterExecution) { + // // polygon + // polygonAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); + // polygonAdapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER_POLYGON(); + // // avalanche + // avalancheAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); + // avalancheAdapters[0].destinationBridgeAdapter = payload + // .DESTINATION_CCIP_NEW_ADAPTER_AVALANCHE(); + // // binance + // binanceAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); + // binanceAdapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER_BNB(); + // } + // forwarderAdapters[0].adapters = polygonAdapters; + // forwarderAdapters[0].chainId = ChainIds.POLYGON; + // forwarderAdapters[1].adapters = avalancheAdapters; + // forwarderAdapters[1].chainId = ChainIds.AVALANCHE; + // forwarderAdapters[2].adapters = binanceAdapters; + // forwarderAdapters[2].chainId = ChainIds.BNB; + // + // return forwarderAdapters; + // } function _getAdapterByChain( bool afterExecution diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index db5fe6fb2..b513c9eec 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -37,10 +37,6 @@ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313_Test is B return adapterNames; } - function _checkCorrectPathConfiguration() internal override { - assertEq(ethereumPayload.CCIP_NEW_ADAPTER(), payload.DESTINATION_CCIP_NEW_ADAPTER()); - } - function _getTrustedRemotes() internal view override returns (TrustedRemote[] memory) { TrustedRemote[] memory trustedRemotes = new TrustedRemote[](1); trustedRemotes[0] = TrustedRemote({ @@ -52,24 +48,24 @@ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313_Test is B return trustedRemotes; } - function _getForwarderAdaptersByChain( - bool afterExecution - ) internal view override returns (ForwarderAdapters[] memory) { - ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](1); - - ICrossChainForwarder.ChainIdBridgeConfig[] - memory adapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - adapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - - if (afterExecution) { - adapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - adapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER(); - } - forwarderAdapters[0].adapters = adapters; - forwarderAdapters[0].chainId = ChainIds.MAINNET; - - return forwarderAdapters; - } + // function _getForwarderAdaptersByChain( + // bool afterExecution + // ) internal view override returns (ForwarderAdapters[] memory) { + // ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](1); + // + // ICrossChainForwarder.ChainIdBridgeConfig[] + // memory adapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); + // adapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); + // + // if (afterExecution) { + // adapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); + // adapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER(); + // } + // forwarderAdapters[0].adapters = adapters; + // forwarderAdapters[0].chainId = ChainIds.MAINNET; + // + // return forwarderAdapters; + // } function _getReceiverAdaptersByChain( bool afterExecution diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol index 16cfb1065..ff9618d11 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol @@ -89,7 +89,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa function getReceiverBridgeAdaptersToRemove() public - pure + view returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) { // remove old Receiver bridge adapter @@ -106,7 +106,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa function getForwarderBridgeAdaptersToRemove() public - pure + view returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) { ICrossChainForwarder.BridgeAdapterToDisable[] @@ -122,7 +122,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa function getReceiverBridgeAdaptersToAllow() internal - pure + view returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) { ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] @@ -138,7 +138,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa function getForwarderBridgeAdaptersToEnable() internal - pure + view returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { DestinationAdaptersInput[] memory destinationAdapters = getDestinationAdapters(); diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index 649c2f227..0060a64a9 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -8,6 +8,10 @@ import {ChainIds} from 'aave-helpers/ChainIds.sol'; import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; import {IBaseAdapter} from 'aave-address-book/common/IBaseAdapter.sol'; import {AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; +import {AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; struct AdapterName { address adapter; @@ -49,6 +53,9 @@ abstract contract BaseTest is ProtocolV3TestBase { uint256 public blockNumber; AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313 internal ethereumPayload; + AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 internal polygonPayload; + AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313 internal avalanchePayload; + AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313 internal binancePayload; constructor(address ccc, address proxyAdmin, string memory _network, uint256 _blockNumber) { CROSS_CHAIN_CONTROLLER = ccc; @@ -60,6 +67,9 @@ abstract contract BaseTest is ProtocolV3TestBase { function setUp() public virtual { vm.createSelectFork(vm.rpcUrl(network), blockNumber); ethereumPayload = new AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313(); + polygonPayload = new AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313(); + avalanchePayload = new AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313(); + binancePayload = new AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313(); } /** @@ -69,10 +79,10 @@ abstract contract BaseTest is ProtocolV3TestBase { _checkTrustedRemotes(); _checkCorrectPathConfiguration(); _checkCorrectAdapterNames(); - - _checkCurrentReceiversState(false); - _checkAllReceiversAreRepresented(false); - _checkAllForwarderAdaptersAreRepresented(false); + // + // _checkCurrentReceiversState(false); + // _checkAllReceiversAreRepresented(false); + // _checkAllForwarderAdaptersAreRepresented(false); _checkImplementationAddress( Payload(payloadAddress).NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), false @@ -84,9 +94,9 @@ abstract contract BaseTest is ProtocolV3TestBase { AdaptersByChain[] memory afterBeforeExecution = _getCurrentReceiverAdaptersByChain(); - _checkCurrentReceiversState(true); - _checkAllReceiversAreRepresented(true); - _checkAllForwarderAdaptersAreRepresented(true); + // _checkCurrentReceiversState(true); + // _checkAllReceiversAreRepresented(true); + // _checkAllForwarderAdaptersAreRepresented(true); _checkImplementationAddress( Payload(payloadAddress).NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), true @@ -94,7 +104,23 @@ abstract contract BaseTest is ProtocolV3TestBase { } // -------------- virtual methods -------------------------- - function _checkCorrectPathConfiguration() internal virtual {} + function _checkCorrectPathConfiguration() internal { + BaseAdaptersUpdatePayload.DestinationAdaptersInput[] + memory destinationConfigs = BaseAdaptersUpdatePayload(payloadAddress) + .getDestinationAdapters(); + + for (uint256 i; i < destinationConfigs.length; i++) { + if (destinationConfigs[i].chainId == ChainIds.MAINNET) { + assertEq(ethereumPayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); + } else if (destinationConfigs[i].chainId == ChainIds.POLYGON) { + assertEq(polygonPayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); + } else if (destinationConfigs[i].chainId == ChainIds.BNB) { + assertEq(binancePayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); + } else if (destinationConfigs[i].chainId == ChainIds.AVALANCHE) { + assertEq(avalanchePayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); + } + } + } function _getAdapterNames() internal view virtual returns (AdapterName[] memory); @@ -116,17 +142,17 @@ abstract contract BaseTest is ProtocolV3TestBase { ) internal view virtual returns (AdaptersByChain[] memory); // ------------------------ checks ------------- - function _checkAllForwarderAdaptersAreRepresented(bool afterExecution) internal { - ForwarderAdapters[] memory forwarderAdapters = _getForwarderAdaptersByChain(afterExecution); - - for (uint256 i = 0; i < forwarderAdapters.length; i++) { - _testForwarderAdapterCorrectness( - forwarderAdapters[i].chainId, - forwarderAdapters[i].adapters, - afterExecution - ); - } - } + // function _checkAllForwarderAdaptersAreRepresented(bool afterExecution) internal { + // ForwarderAdapters[] memory forwarderAdapters = _getForwarderAdaptersByChain(afterExecution); + // + // for (uint256 i = 0; i < forwarderAdapters.length; i++) { + // _testForwarderAdapterCorrectness( + // forwarderAdapters[i].chainId, + // forwarderAdapters[i].adapters, + // afterExecution + // ); + // } + // } function _checkAllReceiversAreRepresented(bool afterExecution) internal virtual { AdaptersByChain[] memory receiverAdaptersByChain = _getReceiverAdaptersByChain(afterExecution); From 77c0da66dfb00182b7551ba592de80ce7f7ed023 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 13 Mar 2024 11:25:57 +0100 Subject: [PATCH 05/19] remove redundant DestinationAdaptersInput path --- ...anche_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 5 ++--- ...ereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 5 ++--- ...lygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 5 ++--- .../BaseAdaptersUpdatePayload.sol | 1 + 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 2e46138f2..f4f13a117 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -33,10 +33,9 @@ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313 is public pure override - returns (BaseAdaptersUpdatePayload.DestinationAdaptersInput[] memory) + returns (DestinationAdaptersInput[] memory) { - BaseAdaptersUpdatePayload.DestinationAdaptersInput[] - memory destinationAdapters = new BaseAdaptersUpdatePayload.DestinationAdaptersInput[](1); + DestinationAdaptersInput[] memory destinationAdapters = new DestinationAdaptersInput[](1); destinationAdapters[0].adapter = 0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29; destinationAdapters[0].chainId = ChainIds.MAINNET; diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 8c5578bc4..5f1fc2927 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -34,10 +34,9 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313 is public pure override - returns (BaseAdaptersUpdatePayload.DestinationAdaptersInput[] memory) + returns (DestinationAdaptersInput[] memory) { - BaseAdaptersUpdatePayload.DestinationAdaptersInput[] - memory destinationAdapters = new BaseAdaptersUpdatePayload.DestinationAdaptersInput[](3); + DestinationAdaptersInput[] memory destinationAdapters = new DestinationAdaptersInput[](3); destinationAdapters[0].adapter = 0x2b88C83727B0E290B76EB3F6133994fF81B7f355; destinationAdapters[0].chainId = ChainIds.AVALANCHE; diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol index a39145b4a..acbe0ba6f 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -33,10 +33,9 @@ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 is public pure override - returns (BaseAdaptersUpdatePayload.DestinationAdaptersInput[] memory) + returns (DestinationAdaptersInput[] memory) { - BaseAdaptersUpdatePayload.DestinationAdaptersInput[] - memory destinationAdapters = new BaseAdaptersUpdatePayload.DestinationAdaptersInput[](1); + DestinationAdaptersInput[] memory destinationAdapters = new DestinationAdaptersInput[](1); destinationAdapters[0].adapter = 0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29; destinationAdapters[0].chainId = ChainIds.MAINNET; diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol index ff9618d11..b03558eb0 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol @@ -41,6 +41,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa function execute() public override { super.execute(); + // remove old Receiver bridge adapter ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters( getReceiverBridgeAdaptersToRemove() From 471507b6b6ae7c808cf43a62c3ec2c34dfac0845 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 13 Mar 2024 11:30:51 +0100 Subject: [PATCH 06/19] update readme with implementation and tests --- .../UpdateADIImplementationAndCCIPAdapters.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md index 68a6a6589..c817e323c 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md @@ -12,8 +12,9 @@ discussions: "" ## References -- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Avalanche](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3BNB](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol) -- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Avalanche](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3BNB](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol) +- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Avalanche](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Optimism](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Arbitrum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Metis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Base](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Gnosis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Scroll](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3BNB](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol) +- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Avalanche](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Optimism](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Arbitrum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Metis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Base](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Gnosis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Scroll](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3BNB](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol) +- - [Snapshot](TODO) - [Discussion](TODO) From e49953a516079103d1036cf2043456c4bf0f569c Mon Sep 17 00:00:00 2001 From: sendra Date: Wed, 13 Mar 2024 11:54:40 +0100 Subject: [PATCH 07/19] fix: test cleanup --- ...plementationAndCCIPAdapters_20240313.t.sol | 18 --- ...plementationAndCCIPAdapters_20240313.t.sol | 18 --- ...plementationAndCCIPAdapters_20240313.t.sol | 23 --- ...plementationAndCCIPAdapters_20240313.t.sol | 18 --- .../BaseAdaptersUpdatePayload.sol | 2 +- .../BaseTest.sol | 135 ++++++++++-------- 6 files changed, 79 insertions(+), 135 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 6e3e058ef..5d960a042 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -32,24 +32,6 @@ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313_Test is payloadAddress = address(payload); } - function _getAdapterNames() internal view override returns (AdapterName[] memory) { - AdapterName[] memory adapterNames = new AdapterName[](1); - adapterNames[0] = AdapterName({adapter: payload.CCIP_NEW_ADAPTER(), name: 'CCIP adapter'}); - - return adapterNames; - } - - function _getTrustedRemotes() internal view override returns (TrustedRemote[] memory) { - TrustedRemote[] memory trustedRemotes = new TrustedRemote[](1); - trustedRemotes[0] = TrustedRemote({ - adapter: payload.CCIP_NEW_ADAPTER(), - expectedRemote: GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, - remoteChainId: ChainIds.MAINNET - }); - - return trustedRemotes; - } - // function _getForwarderAdaptersByChain( // bool afterExecution // ) internal view override returns (ForwarderAdapters[] memory) { diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 7e6c0fe1c..6516db207 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -26,24 +26,6 @@ contract AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseT payloadAddress = address(payload); } - function _getAdapterNames() internal view override returns (AdapterName[] memory) { - AdapterName[] memory adapterNames = new AdapterName[](1); - adapterNames[0] = AdapterName({adapter: payload.CCIP_NEW_ADAPTER(), name: 'CCIP adapter'}); - - return adapterNames; - } - - function _getTrustedRemotes() internal view override returns (TrustedRemote[] memory) { - TrustedRemote[] memory trustedRemotes = new TrustedRemote[](1); - trustedRemotes[0] = TrustedRemote({ - adapter: payload.CCIP_NEW_ADAPTER(), - expectedRemote: GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, - remoteChainId: ChainIds.MAINNET - }); - - return trustedRemotes; - } - function _getReceiverAdaptersByChain( bool afterExecution ) internal view override returns (AdaptersByChain[] memory) { diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index d9e59a807..154504e2a 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -34,29 +34,6 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is payloadAddress = address(payload); } - function _getAdapterNames() internal view override returns (AdapterName[] memory) { - AdapterName[] memory adapterNames = new AdapterName[](1); - adapterNames[0] = AdapterName({adapter: payload.CCIP_NEW_ADAPTER(), name: 'CCIP adapter'}); - - return adapterNames; - } - - function _getTrustedRemotes() internal view override returns (TrustedRemote[] memory) { - TrustedRemote[] memory trustedRemotes = new TrustedRemote[](2); - trustedRemotes[0] = TrustedRemote({ - adapter: payload.CCIP_NEW_ADAPTER(), - expectedRemote: GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, - remoteChainId: ChainIds.POLYGON - }); - trustedRemotes[1] = TrustedRemote({ - adapter: payload.CCIP_NEW_ADAPTER(), - expectedRemote: GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, - remoteChainId: ChainIds.AVALANCHE - }); - - return trustedRemotes; - } - function _getReceiverAdaptersByChain( bool afterExecution ) internal view override returns (AdaptersByChain[] memory) { diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index b513c9eec..b7cf71192 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -30,24 +30,6 @@ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313_Test is B payloadAddress = address(payload); } - function _getAdapterNames() internal view override returns (AdapterName[] memory) { - AdapterName[] memory adapterNames = new AdapterName[](1); - adapterNames[0] = AdapterName({adapter: payload.CCIP_NEW_ADAPTER(), name: 'CCIP adapter'}); - - return adapterNames; - } - - function _getTrustedRemotes() internal view override returns (TrustedRemote[] memory) { - TrustedRemote[] memory trustedRemotes = new TrustedRemote[](1); - trustedRemotes[0] = TrustedRemote({ - adapter: payload.CCIP_NEW_ADAPTER(), - expectedRemote: GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, - remoteChainId: ChainIds.MAINNET - }); - - return trustedRemotes; - } - // function _getForwarderAdaptersByChain( // bool afterExecution // ) internal view override returns (ForwarderAdapters[] memory) { diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol index b03558eb0..c16b05ff6 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol @@ -122,7 +122,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa } function getReceiverBridgeAdaptersToAllow() - internal + public view returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) { diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index 0060a64a9..1e812a22f 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; +import 'forge-std/console.sol'; import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; @@ -13,6 +14,10 @@ import {AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313} from '. import {AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; import {AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; +import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; +import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol'; + struct AdapterName { address adapter; string name; @@ -41,7 +46,7 @@ struct ForwarderAdapters { } interface Payload { - function NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION() external returns (address); + function CROSS_CHAIN_CONTROLLER_IMPLEMENTATION() external returns (address); } abstract contract BaseTest is ProtocolV3TestBase { @@ -72,44 +77,45 @@ abstract contract BaseTest is ProtocolV3TestBase { binancePayload = new AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313(); } - /** - * @dev executes the generic test suite including e2e and config snapshots - */ - function test_defaultProposalExecution() public { - _checkTrustedRemotes(); - _checkCorrectPathConfiguration(); - _checkCorrectAdapterNames(); - // - // _checkCurrentReceiversState(false); - // _checkAllReceiversAreRepresented(false); - // _checkAllForwarderAdaptersAreRepresented(false); - _checkImplementationAddress( - Payload(payloadAddress).NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), - false - ); - - AdaptersByChain[] memory receiversBeforeExecution = _getCurrentReceiverAdaptersByChain(); - - executePayload(vm, payloadAddress); - - AdaptersByChain[] memory afterBeforeExecution = _getCurrentReceiverAdaptersByChain(); - - // _checkCurrentReceiversState(true); - // _checkAllReceiversAreRepresented(true); - // _checkAllForwarderAdaptersAreRepresented(true); - _checkImplementationAddress( - Payload(payloadAddress).NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), - true - ); + function test_trustedRemotes() public { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory receivers = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToAllow(); + + for (uint256 i = 0; i < receivers.length; i++) { + for (uint256 j = 0; j < receivers[i].chainIds.length; j++) { + if (receivers[i].chainIds[j] == ChainIds.MAINNET) { + assertEq( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( + receivers[i].chainIds[j] + ) + ); + } else if (receivers[i].chainIds[j] == ChainIds.POLYGON) { + assertEq( + GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, + IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( + receivers[i].chainIds[j] + ) + ); + } else if (receivers[i].chainIds[j] == ChainIds.AVALANCHE) { + assertEq( + GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, + IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( + receivers[i].chainIds[j] + ) + ); + } + } + } } - // -------------- virtual methods -------------------------- - function _checkCorrectPathConfiguration() internal { + function test_correctPathConfiguration() public { BaseAdaptersUpdatePayload.DestinationAdaptersInput[] memory destinationConfigs = BaseAdaptersUpdatePayload(payloadAddress) .getDestinationAdapters(); - for (uint256 i; i < destinationConfigs.length; i++) { + for (uint256 i = 0; i < destinationConfigs.length; i++) { if (destinationConfigs[i].chainId == ChainIds.MAINNET) { assertEq(ethereumPayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); } else if (destinationConfigs[i].chainId == ChainIds.POLYGON) { @@ -122,9 +128,46 @@ abstract contract BaseTest is ProtocolV3TestBase { } } - function _getAdapterNames() internal view virtual returns (AdapterName[] memory); + function test_correctAdapterNames() public { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory receivers = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToAllow(); - function _getTrustedRemotes() internal view virtual returns (TrustedRemote[] memory); + for (uint256 i = 0; i < receivers.length; i++) { + string memory adapterName = IBaseAdapter(receivers[i].bridgeAdapter).adapterName(); + assertEq(keccak256(abi.encode(adapterName)), keccak256(abi.encode('CCIP adapter'))); + } + } + + /** + * @dev executes the generic test suite including e2e and config snapshots + */ + function test_defaultProposalExecution() public { + // + // _checkCurrentReceiversState(false); + // _checkAllReceiversAreRepresented(false); + // _checkAllForwarderAdaptersAreRepresented(false); + _checkImplementationAddress( + Payload(payloadAddress).CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), + false + ); + // + // AdaptersByChain[] memory receiversBeforeExecution = _getCurrentReceiverAdaptersByChain(); + // + executePayload(vm, payloadAddress); + // + // AdaptersByChain[] memory afterBeforeExecution = _getCurrentReceiverAdaptersByChain(); + // + // // _checkCurrentReceiversState(true); + // // _checkAllReceiversAreRepresented(true); + // // _checkAllForwarderAdaptersAreRepresented(true); + _checkImplementationAddress( + Payload(payloadAddress).CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), + true + ); + } + + // -------------- virtual methods -------------------------- function _getAdapterByChain( bool afterExecution @@ -179,28 +222,6 @@ abstract contract BaseTest is ProtocolV3TestBase { } } - function _checkCorrectAdapterNames() internal { - AdapterName[] memory adapterNames = _getAdapterNames(); - - for (uint256 i = 0; i < adapterNames.length; i++) { - string memory adapterName = IBaseAdapter(adapterNames[i].adapter).adapterName(); - assertEq(keccak256(abi.encode(adapterName)), keccak256(abi.encode(adapterNames[i].name))); - } - } - - function _checkTrustedRemotes() internal { - TrustedRemote[] memory trustedRemotes = _getTrustedRemotes(); - - for (uint256 i = 0; i < trustedRemotes.length; i++) { - assertEq( - trustedRemotes[i].expectedRemote, - IBaseAdapter(trustedRemotes[i].adapter).getTrustedRemoteByChainId( - trustedRemotes[i].remoteChainId - ) - ); - } - } - function _checkImplementationAddress(address implementation, bool equal) internal { address cccImplementation = ProxyAdmin(PROXY_ADMIN).getProxyImplementation( TransparentUpgradeableProxy(payable(CROSS_CHAIN_CONTROLLER)) From 079a00e582fc1dc692951cde7b5034a3d6afde51 Mon Sep 17 00:00:00 2001 From: sendra Date: Wed, 13 Mar 2024 12:06:05 +0100 Subject: [PATCH 08/19] fix: more test cleanup --- ...plementationAndCCIPAdapters_20240313.t.sol | 22 -------- ...plementationAndCCIPAdapters_20240313.t.sol | 22 -------- ...plementationAndCCIPAdapters_20240313.t.sol | 34 ----------- ...plementationAndCCIPAdapters_20240313.t.sol | 22 -------- .../BaseTest.sol | 56 ++++++++++++------- 5 files changed, 36 insertions(+), 120 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 5d960a042..d4c236565 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -67,26 +67,4 @@ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313_Test is return receiverAdaptersByChain; } - - function _getAdapterByChain( - bool afterExecution - ) internal view override returns (AdapterAllowed[] memory) { - AdapterAllowed[] memory adaptersAllowed = new AdapterAllowed[](2); - adaptersAllowed[0] = AdapterAllowed({ - adapter: payload.CCIP_ADAPTER_TO_REMOVE(), - chainId: ChainIds.MAINNET, - allowed: true - }); - adaptersAllowed[1] = AdapterAllowed({ - adapter: payload.CCIP_NEW_ADAPTER(), - chainId: ChainIds.MAINNET, - allowed: false - }); - if (afterExecution) { - adaptersAllowed[0].allowed = false; - adaptersAllowed[1].allowed = true; - } - - return adaptersAllowed; - } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 6516db207..d43ec4696 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -42,26 +42,4 @@ contract AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseT return receiverAdaptersByChain; } - - function _getAdapterByChain( - bool afterExecution - ) internal view override returns (AdapterAllowed[] memory) { - AdapterAllowed[] memory adaptersAllowed = new AdapterAllowed[](2); - adaptersAllowed[0] = AdapterAllowed({ - adapter: payload.CCIP_ADAPTER_TO_REMOVE(), - chainId: ChainIds.MAINNET, - allowed: true - }); - adaptersAllowed[1] = AdapterAllowed({ - adapter: payload.CCIP_NEW_ADAPTER(), - chainId: ChainIds.MAINNET, - allowed: false - }); - if (afterExecution) { - adaptersAllowed[0].allowed = false; - adaptersAllowed[5].allowed = true; - } - - return adaptersAllowed; - } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 154504e2a..40afc03ac 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -96,38 +96,4 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is // // return forwarderAdapters; // } - - function _getAdapterByChain( - bool afterExecution - ) internal view override returns (AdapterAllowed[] memory) { - AdapterAllowed[] memory adaptersAllowed = new AdapterAllowed[](4); - adaptersAllowed[0] = AdapterAllowed({ - adapter: payload.CCIP_ADAPTER_TO_REMOVE(), - chainId: ChainIds.POLYGON, - allowed: true - }); - adaptersAllowed[1] = AdapterAllowed({ - adapter: payload.CCIP_ADAPTER_TO_REMOVE(), - chainId: ChainIds.AVALANCHE, - allowed: true - }); - adaptersAllowed[2] = AdapterAllowed({ - adapter: payload.CCIP_NEW_ADAPTER(), - chainId: ChainIds.POLYGON, - allowed: false - }); - adaptersAllowed[3] = AdapterAllowed({ - adapter: payload.CCIP_NEW_ADAPTER(), - chainId: ChainIds.AVALANCHE, - allowed: false - }); - if (afterExecution) { - adaptersAllowed[0].allowed = false; - adaptersAllowed[1].allowed = false; - adaptersAllowed[2].allowed = true; - adaptersAllowed[3].allowed = true; - } - - return adaptersAllowed; - } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index b7cf71192..ceb98803d 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -65,26 +65,4 @@ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313_Test is B return receiverAdaptersByChain; } - - function _getAdapterByChain( - bool afterExecution - ) internal view override returns (AdapterAllowed[] memory) { - AdapterAllowed[] memory adaptersAllowed = new AdapterAllowed[](2); - adaptersAllowed[0] = AdapterAllowed({ - adapter: payload.CCIP_ADAPTER_TO_REMOVE(), - chainId: ChainIds.MAINNET, - allowed: true - }); - adaptersAllowed[1] = AdapterAllowed({ - adapter: payload.CCIP_NEW_ADAPTER(), - chainId: ChainIds.MAINNET, - allowed: false - }); - if (afterExecution) { - adaptersAllowed[0].allowed = false; - adaptersAllowed[1].allowed = true; - } - - return adaptersAllowed; - } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index 1e812a22f..b7a9fb9c2 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -139,12 +139,47 @@ abstract contract BaseTest is ProtocolV3TestBase { } } + function test_receiversAreCorrectlySetAfterExecution() public { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory beforeReceivers = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToAllow(); + + for (uint256 i = 0; i < beforeReceivers.length; i++) { + for (uint256 j = 0; j < beforeReceivers[i].chainIds.length; j++) { + assertEq( + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( + beforeReceivers[i].bridgeAdapter, + beforeReceivers[i].chainIds[j] + ), + false + ); + } + } + + executePayload(vm, payloadAddress); + + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory receivers = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToAllow(); + + for (uint256 i = 0; i < receivers.length; i++) { + for (uint256 j = 0; j < receivers[i].chainIds.length; j++) { + assertEq( + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( + receivers[i].bridgeAdapter, + receivers[i].chainIds[j] + ), + true + ); + } + } + } + /** * @dev executes the generic test suite including e2e and config snapshots */ function test_defaultProposalExecution() public { // - // _checkCurrentReceiversState(false); // _checkAllReceiversAreRepresented(false); // _checkAllForwarderAdaptersAreRepresented(false); _checkImplementationAddress( @@ -158,7 +193,6 @@ abstract contract BaseTest is ProtocolV3TestBase { // // AdaptersByChain[] memory afterBeforeExecution = _getCurrentReceiverAdaptersByChain(); // - // // _checkCurrentReceiversState(true); // // _checkAllReceiversAreRepresented(true); // // _checkAllForwarderAdaptersAreRepresented(true); _checkImplementationAddress( @@ -169,10 +203,6 @@ abstract contract BaseTest is ProtocolV3TestBase { // -------------- virtual methods -------------------------- - function _getAdapterByChain( - bool afterExecution - ) internal view virtual returns (AdapterAllowed[] memory); - function _getForwarderAdaptersByChain( bool afterExecution ) internal view virtual returns (ForwarderAdapters[] memory) { @@ -208,20 +238,6 @@ abstract contract BaseTest is ProtocolV3TestBase { } } - function _checkCurrentReceiversState(bool afterExecution) internal { - AdapterAllowed[] memory adaptersByChain = _getAdapterByChain(afterExecution); - - for (uint256 i = 0; i < adaptersByChain.length; i++) { - assertEq( - ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( - adaptersByChain[i].adapter, - adaptersByChain[i].chainId - ), - adaptersByChain[i].allowed - ); - } - } - function _checkImplementationAddress(address implementation, bool equal) internal { address cccImplementation = ProxyAdmin(PROXY_ADMIN).getProxyImplementation( TransparentUpgradeableProxy(payable(CROSS_CHAIN_CONTROLLER)) From 01843af25a408288ad169e2153650838a9da227a Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 13 Mar 2024 12:15:28 +0100 Subject: [PATCH 09/19] add BaseCCCImplementationUpdatePayloadTest --- ...ImplementationAndCCIPAdapters_20240313.sol | 24 ++++++++ ...plementationAndCCIPAdapters_20240313.t.sol | 23 ++++++++ ...ImplementationAndCCIPAdapters_20240313.sol | 24 ++++++++ ...plementationAndCCIPAdapters_20240313.t.sol | 23 ++++++++ ...ImplementationAndCCIPAdapters_20240313.sol | 24 ++++++++ ...plementationAndCCIPAdapters_20240313.t.sol | 23 ++++++++ ...ImplementationAndCCIPAdapters_20240313.sol | 24 ++++++++ ...plementationAndCCIPAdapters_20240313.t.sol | 23 ++++++++ ...ImplementationAndCCIPAdapters_20240313.sol | 24 ++++++++ ...plementationAndCCIPAdapters_20240313.t.sol | 23 ++++++++ ...ImplementationAndCCIPAdapters_20240313.sol | 24 ++++++++ ...plementationAndCCIPAdapters_20240313.t.sol | 23 ++++++++ ...BaseCCCImplementationUpdatePayloadTest.sol | 55 +++++++++++++++++++ 13 files changed, 337 insertions(+) create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol create mode 100644 src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayloadTest.sol diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol new file mode 100644 index 000000000..d39fb2b29 --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {MiscArbitrum} from 'aave-address-book/MiscArbitrum.sol'; +import {GovernanceV3Arbitrum} from 'aave-address-book/GovernanceV3Arbitrum.sol'; +import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol'; + +/** + * @title aDI and bridge adapters update + * @author BGD Labs @bgdlabs + * - Snapshot: TODO + * - Discussion: TODO + */ +contract AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313 is + BaseCCCImplementationUpdatePayload( + BaseCCCImplementationUpdatePayload.CCCImplementationUpdateInput({ + ccc: GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscArbitrum.PROXY_ADMIN, + newCCCImplementation: 0x6e633269af45F37c44659D98f382dd0DD524E5Df + }) + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol new file mode 100644 index 000000000..7ad9133b2 --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import {MiscArbitrum} from 'aave-address-book/MiscArbitrum.sol'; +import {GovernanceV3Arbitrum} from 'aave-address-book/GovernanceV3Arbitrum.sol'; + +import {AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {BaseCCCImplementationUpdatePayloadTest} from './BaseCCCImplementationUpdatePayloadTest.sol'; + +/** + * @dev Test for AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313 + * command: make test-contract filter=AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313 + */ +contract AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is + BaseCCCImplementationUpdatePayloadTest( + GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER, + MiscArbitrum.PROXY_ADMIN, + type(AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, + 'arbitrum', + 189596312 + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol new file mode 100644 index 000000000..5e52a2b7e --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {MiscBase} from 'aave-address-book/MiscBase.sol'; +import {GovernanceV3Base} from 'aave-address-book/GovernanceV3Base.sol'; +import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol'; + +/** + * @title aDI and bridge adapters update + * @author BGD Labs @bgdlabs + * - Snapshot: TODO + * - Discussion: TODO + */ +contract AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313 is + BaseCCCImplementationUpdatePayload( + BaseCCCImplementationUpdatePayload.CCCImplementationUpdateInput({ + ccc: GovernanceV3Base.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscBase.PROXY_ADMIN, + newCCCImplementation: 0x9b6f5ef589A3DD08670Dd146C11C4Fb33E04494F + }) + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol new file mode 100644 index 000000000..88b0f61f6 --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import {MiscBase} from 'aave-address-book/MiscBase.sol'; +import {GovernanceV3Base} from 'aave-address-book/GovernanceV3Base.sol'; + +import {AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {BaseCCCImplementationUpdatePayloadTest} from './BaseCCCImplementationUpdatePayloadTest.sol'; + +/** + * @dev Test for AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313 + * command: make test-contract filter=AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313 + */ +contract AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313_Test is + BaseCCCImplementationUpdatePayloadTest( + GovernanceV3Base.CROSS_CHAIN_CONTROLLER, + MiscBase.PROXY_ADMIN, + type(AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, + 'base', + 11725901 + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol new file mode 100644 index 000000000..b0aa6dd94 --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {MiscGnosis} from 'aave-address-book/MiscGnosis.sol'; +import {GovernanceV3Gnosis} from 'aave-address-book/GovernanceV3Gnosis.sol'; +import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol'; + +/** + * @title aDI and bridge adapters update + * @author BGD Labs @bgdlabs + * - Snapshot: TODO + * - Discussion: TODO + */ +contract AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313 is + BaseCCCImplementationUpdatePayload( + BaseCCCImplementationUpdatePayload.CCCImplementationUpdateInput({ + ccc: GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscGnosis.PROXY_ADMIN, + newCCCImplementation: 0x5e06b10B3b9c3E1c0996D2544A35B9839Be02922 + }) + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol new file mode 100644 index 000000000..30d3b0c5e --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import {MiscGnosis} from 'aave-address-book/MiscGnosis.sol'; +import {GovernanceV3Gnosis} from 'aave-address-book/GovernanceV3Gnosis.sol'; + +import {AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {BaseCCCImplementationUpdatePayloadTest} from './BaseCCCImplementationUpdatePayloadTest.sol'; + +/** + * @dev Test for AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313 + * command: make test-contract filter=AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313 + */ +contract AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313_Test is + BaseCCCImplementationUpdatePayloadTest( + GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER, + MiscGnosis.PROXY_ADMIN, + type(AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, + 'gnosis', + 32897310 + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol new file mode 100644 index 000000000..0bf40587d --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {MiscMetis} from 'aave-address-book/MiscMetis.sol'; +import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Metis.sol'; +import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol'; + +/** + * @title aDI and bridge adapters update + * @author BGD Labs @bgdlabs + * - Snapshot: TODO + * - Discussion: TODO + */ +contract AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313 is + BaseCCCImplementationUpdatePayload( + BaseCCCImplementationUpdatePayload.CCCImplementationUpdateInput({ + ccc: GovernanceV3Metis.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscMetis.PROXY_ADMIN, + newCCCImplementation: 0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04 + }) + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol new file mode 100644 index 000000000..fb7beb526 --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import {MiscMetis} from 'aave-address-book/MiscMetis.sol'; +import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Metis.sol'; + +import {AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {BaseCCCImplementationUpdatePayloadTest} from './BaseCCCImplementationUpdatePayloadTest.sol'; + +/** + * @dev Test for AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313 + * command: make test-contract filter=AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313 + */ +contract AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313_Test is + BaseCCCImplementationUpdatePayloadTest( + GovernanceV3Metis.CROSS_CHAIN_CONTROLLER, + MiscMetis.PROXY_ADMIN, + type(AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, + 'metis', + 15127085 + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol new file mode 100644 index 000000000..3dcb0490f --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {MiscOptimism} from 'aave-address-book/MiscOptimism.sol'; +import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Optimism.sol'; +import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol'; + +/** + * @title aDI and bridge adapters update + * @author BGD Labs @bgdlabs + * - Snapshot: TODO + * - Discussion: TODO + */ +contract AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313 is + BaseCCCImplementationUpdatePayload( + BaseCCCImplementationUpdatePayload.CCCImplementationUpdateInput({ + ccc: GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscOptimism.PROXY_ADMIN, + newCCCImplementation: 0xa5cc218513305221201f196760E9e64e9D49d98A + }) + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol new file mode 100644 index 000000000..c9e6534ac --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import {MiscOptimism} from 'aave-address-book/MiscOptimism.sol'; +import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Optimism.sol'; + +import {AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {BaseCCCImplementationUpdatePayloadTest} from './BaseCCCImplementationUpdatePayloadTest.sol'; + +/** + * @dev Test for AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313 + * command: make test-contract filter=AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313 + */ +contract AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313_Test is + BaseCCCImplementationUpdatePayloadTest( + GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER, + MiscOptimism.PROXY_ADMIN, + type(AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, + 'optimism', + 117321235 + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol new file mode 100644 index 000000000..183df358f --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {MiscScroll} from 'aave-address-book/MiscScroll.sol'; +import {GovernanceV3Scroll} from 'aave-address-book/GovernanceV3Scroll.sol'; +import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol'; + +/** + * @title aDI and bridge adapters update + * @author BGD Labs @bgdlabs + * - Snapshot: TODO + * - Discussion: TODO + */ +contract AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313 is + BaseCCCImplementationUpdatePayload( + BaseCCCImplementationUpdatePayload.CCCImplementationUpdateInput({ + ccc: GovernanceV3Scroll.CROSS_CHAIN_CONTROLLER, + proxyAdmin: MiscScroll.PROXY_ADMIN, + newCCCImplementation: 0x5e06b10B3b9c3E1c0996D2544A35B9839Be02922 + }) + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol new file mode 100644 index 000000000..751eee27a --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import {MiscScroll} from 'aave-address-book/MiscScroll.sol'; +import {GovernanceV3Scroll} from 'aave-address-book/GovernanceV3Scroll.sol'; + +import {AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {BaseCCCImplementationUpdatePayloadTest} from './BaseCCCImplementationUpdatePayloadTest.sol'; + +/** + * @dev Test for AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313 + * command: make test-contract filter=AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313 + */ +contract AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313_Test is + BaseCCCImplementationUpdatePayloadTest( + GovernanceV3Scroll.CROSS_CHAIN_CONTROLLER, + MiscScroll.PROXY_ADMIN, + type(AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, + 'scroll', + 4063725 + ) +{ + +} diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayloadTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayloadTest.sol new file mode 100644 index 000000000..4abc257bd --- /dev/null +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayloadTest.sol @@ -0,0 +1,55 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; +import 'aave-helpers/ProtocolV3TestBase.sol'; + +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; +import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; +import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; + +import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol'; + +contract BaseCCCImplementationUpdatePayloadTest is ProtocolV3TestBase { + address public immutable CROSS_CHAIN_CONTROLLER; + address public immutable PROXY_ADMIN; + + bytes public payloadCode; + address public payloadAddress; + string public network; + uint256 public blockNumber; + + constructor( + address ccc, + address proxyAdmin, + bytes memory _payloadCode, + string memory _network, + uint256 _blockNumber + ) { + CROSS_CHAIN_CONTROLLER = ccc; + PROXY_ADMIN = proxyAdmin; + network = _network; + blockNumber = _blockNumber; + payloadCode = _payloadCode; + } + + function setUp() public { + vm.createSelectFork(vm.rpcUrl(network), blockNumber); + payloadAddress = GovV3Helpers.deployDeterministic(payloadCode); + } + + function test_implementationOfCCCUpdate() public { + address newImplementation = BaseCCCImplementationUpdatePayload(payloadAddress) + .CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(); + + address cccImplementationBefore = ProxyAdmin(PROXY_ADMIN).getProxyImplementation( + TransparentUpgradeableProxy(payable(CROSS_CHAIN_CONTROLLER)) + ); + assertTrue(cccImplementationBefore != newImplementation); + + executePayload(vm, payloadAddress); + + address cccImplementationAfter = ProxyAdmin(PROXY_ADMIN).getProxyImplementation( + TransparentUpgradeableProxy(payable(CROSS_CHAIN_CONTROLLER)) + ); + assertTrue(cccImplementationAfter == newImplementation); + } +} From c8cd88a5f3a12ace38d9476be47d8a7894dd21e6 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 13 Mar 2024 12:48:31 +0100 Subject: [PATCH 10/19] change BaseTest --- ...plementationAndCCIPAdapters_20240313.t.sol | 13 +--- ...plementationAndCCIPAdapters_20240313.t.sol | 20 +++--- ...plementationAndCCIPAdapters_20240313.t.sol | 17 ++--- ...plementationAndCCIPAdapters_20240313.t.sol | 13 +--- ...BaseCCCImplementationUpdatePayloadTest.sol | 2 +- .../BaseTest.sol | 65 ++++++++++--------- 6 files changed, 55 insertions(+), 75 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index d4c236565..1f3a0f9fb 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -15,23 +15,16 @@ import {AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313} from '. * command: make test-contract filter=AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313 */ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseTest { - AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313 internal payload; - constructor() BaseTest( GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, MiscAvalanche.PROXY_ADMIN, + type(AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, 'avalanche', 42801819 ) {} - function setUp() public override { - super.setUp(); - payload = new AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313(); - payloadAddress = address(payload); - } - // function _getForwarderAdaptersByChain( // bool afterExecution // ) internal view override returns (ForwarderAdapters[] memory) { @@ -57,10 +50,10 @@ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313_Test is address[] memory adapters = new address[](1); AdaptersByChain[] memory receiverAdaptersByChain = new AdaptersByChain[](1); - adapters[0] = payload.CCIP_ADAPTER_TO_REMOVE(); + adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); if (afterExecution) { - adapters[0] = payload.CCIP_NEW_ADAPTER(); + adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); } receiverAdaptersByChain[0].adapters = adapters; receiverAdaptersByChain[0].chainId = ChainIds.MAINNET; diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index d43ec4696..ce39d923e 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -14,28 +14,26 @@ import {AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV * command: make test-contract filter=AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313 */ contract AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseTest { - AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313 internal payload; - constructor() - BaseTest(GovernanceV3BNB.CROSS_CHAIN_CONTROLLER, MiscBNB.PROXY_ADMIN, 'bnb', 36903911) + BaseTest( + GovernanceV3BNB.CROSS_CHAIN_CONTROLLER, + MiscBNB.PROXY_ADMIN, + type(AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, + 'bnb', + 36903911 + ) {} - function setUp() public override { - super.setUp(); - payload = new AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313(); - payloadAddress = address(payload); - } - function _getReceiverAdaptersByChain( bool afterExecution ) internal view override returns (AdaptersByChain[] memory) { address[] memory adapters = new address[](1); AdaptersByChain[] memory receiverAdaptersByChain = new AdaptersByChain[](1); - adapters[0] = payload.CCIP_ADAPTER_TO_REMOVE(); + adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); if (afterExecution) { - adapters[0] = payload.CCIP_NEW_ADAPTER(); + adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); } receiverAdaptersByChain[0].adapters = adapters; receiverAdaptersByChain[0].chainId = ChainIds.MAINNET; diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 40afc03ac..f7fbe8c5b 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -17,23 +17,16 @@ import {AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313} from './ * command: make test-contract filter=AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313 */ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseTest { - AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313 internal payload; - constructor() BaseTest( GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, MiscEthereum.PROXY_ADMIN, + type(AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, 'mainnet', 19418547 ) {} - function setUp() public override { - super.setUp(); - payload = new AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313(); - payloadAddress = address(payload); - } - function _getReceiverAdaptersByChain( bool afterExecution ) internal view override returns (AdaptersByChain[] memory) { @@ -41,12 +34,12 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is address[] memory avalancheAdapters = new address[](1); AdaptersByChain[] memory receiverAdaptersByChain = new AdaptersByChain[](2); - polygonAdapters[0] = payload.CCIP_ADAPTER_TO_REMOVE(); - avalancheAdapters[0] = payload.CCIP_ADAPTER_TO_REMOVE(); + polygonAdapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); + avalancheAdapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); if (afterExecution) { - polygonAdapters[0] = payload.CCIP_NEW_ADAPTER(); - avalancheAdapters[0] = payload.CCIP_NEW_ADAPTER(); + polygonAdapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); + avalancheAdapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); } receiverAdaptersByChain[0].adapters = polygonAdapters; receiverAdaptersByChain[0].chainId = ChainIds.POLYGON; diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index ceb98803d..42f9adca6 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -13,23 +13,16 @@ import {AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313} from './A * command: make test-contract filter=AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 */ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseTest { - AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 internal payload; - constructor() BaseTest( GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, MiscPolygon.PROXY_ADMIN, + type(AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, 'polygon', 54566890 ) {} - function setUp() public override { - super.setUp(); - payload = new AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313(); - payloadAddress = address(payload); - } - // function _getForwarderAdaptersByChain( // bool afterExecution // ) internal view override returns (ForwarderAdapters[] memory) { @@ -55,10 +48,10 @@ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313_Test is B address[] memory adapters = new address[](1); AdaptersByChain[] memory receiverAdaptersByChain = new AdaptersByChain[](1); - adapters[0] = payload.CCIP_ADAPTER_TO_REMOVE(); + adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); if (afterExecution) { - adapters[0] = payload.CCIP_NEW_ADAPTER(); + adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); } receiverAdaptersByChain[0].adapters = adapters; receiverAdaptersByChain[0].chainId = ChainIds.MAINNET; diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayloadTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayloadTest.sol index 4abc257bd..14c1c2cdd 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayloadTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseCCCImplementationUpdatePayloadTest.sol @@ -31,7 +31,7 @@ contract BaseCCCImplementationUpdatePayloadTest is ProtocolV3TestBase { payloadCode = _payloadCode; } - function setUp() public { + function setUp() public virtual { vm.createSelectFork(vm.rpcUrl(network), blockNumber); payloadAddress = GovV3Helpers.deployDeterministic(payloadCode); } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index b7a9fb9c2..0cb26359d 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -13,6 +13,7 @@ import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; import {AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; import {AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; import {AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {BaseCCCImplementationUpdatePayloadTest} from './BaseCCCImplementationUpdatePayloadTest.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; @@ -49,34 +50,41 @@ interface Payload { function CROSS_CHAIN_CONTROLLER_IMPLEMENTATION() external returns (address); } -abstract contract BaseTest is ProtocolV3TestBase { - address public immutable CROSS_CHAIN_CONTROLLER; - address public immutable PROXY_ADMIN; - - address public payloadAddress; - string public network; - uint256 public blockNumber; - - AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313 internal ethereumPayload; - AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 internal polygonPayload; - AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313 internal avalanchePayload; - AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313 internal binancePayload; - - constructor(address ccc, address proxyAdmin, string memory _network, uint256 _blockNumber) { - CROSS_CHAIN_CONTROLLER = ccc; - PROXY_ADMIN = proxyAdmin; - network = _network; - blockNumber = _blockNumber; - } - - function setUp() public virtual { - vm.createSelectFork(vm.rpcUrl(network), blockNumber); +abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { + BaseAdaptersUpdatePayload internal ethereumPayload; + BaseAdaptersUpdatePayload internal polygonPayload; + BaseAdaptersUpdatePayload internal avalanchePayload; + BaseAdaptersUpdatePayload internal binancePayload; + + constructor( + address ccc, + address proxyAdmin, + bytes memory _payloadCode, + string memory _network, + uint256 _blockNumber + ) BaseCCCImplementationUpdatePayloadTest(ccc, proxyAdmin, _payloadCode, _network, _blockNumber) {} + + function setUp() public override { + super.setUp(); ethereumPayload = new AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313(); polygonPayload = new AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313(); avalanchePayload = new AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313(); binancePayload = new AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313(); } + function getPayloadByChainId(uint256 chainId) public view returns (BaseAdaptersUpdatePayload) { + if (chainId == ChainIds.MAINNET) { + return ethereumPayload; + } else if (chainId == ChainIds.POLYGON) { + return polygonPayload; + } else if (chainId == ChainIds.BNB) { + return binancePayload; + } else if (chainId == ChainIds.AVALANCHE) { + return avalanchePayload; + } + revert(); + } + function test_trustedRemotes() public { ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory receivers = BaseAdaptersUpdatePayload(payloadAddress) @@ -116,15 +124,10 @@ abstract contract BaseTest is ProtocolV3TestBase { .getDestinationAdapters(); for (uint256 i = 0; i < destinationConfigs.length; i++) { - if (destinationConfigs[i].chainId == ChainIds.MAINNET) { - assertEq(ethereumPayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); - } else if (destinationConfigs[i].chainId == ChainIds.POLYGON) { - assertEq(polygonPayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); - } else if (destinationConfigs[i].chainId == ChainIds.BNB) { - assertEq(binancePayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); - } else if (destinationConfigs[i].chainId == ChainIds.AVALANCHE) { - assertEq(avalanchePayload.CCIP_NEW_ADAPTER(), destinationConfigs[i].adapter); - } + assertEq( + getPayloadByChainId(destinationConfigs[i].chainId).CCIP_NEW_ADAPTER(), + destinationConfigs[i].adapter + ); } } From ab6166a25d484240240a8b9410bda9726534e980 Mon Sep 17 00:00:00 2001 From: sendra Date: Wed, 13 Mar 2024 12:49:06 +0100 Subject: [PATCH 11/19] fix: added tests to check that only changed necessary receivers --- .../BaseTest.sol | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index b7a9fb9c2..ae9aca8ee 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -175,6 +175,54 @@ abstract contract BaseTest is ProtocolV3TestBase { } } + function test_onlyUpdatedNeededAdapter() public { + uint256[] memory supportedChainsBefore = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) + .getSupportedChains(); + AdaptersByChain[] memory adaptersBefore = _getCurrentReceiverAdaptersByChain(); + + executePayload(vm, payloadAddress); + + uint256[] memory supportedChainsAfter = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) + .getSupportedChains(); + + assertEq(supportedChainsBefore, supportedChainsAfter); + for (uint256 i = 0; i < supportedChainsBefore.length; i++) { + assertEq(supportedChainsAfter[i], supportedChainsBefore[i]); + } + + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory adaptersToRemove = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToRemove(); + + for (uint256 i = 0; i < adaptersBefore.length; i++) { + for (uint256 j = 0; j < adaptersToRemove.length; j++) { + for (uint256 x = 0; x < adaptersToRemove[j].chainIds.length; x++) { + if (adaptersToRemove[j].chainIds[x] == adaptersBefore[i].chainId) { + for (uint256 k = 0; k < adaptersBefore[i].adapters.length; k++) { + if (adaptersBefore[i].adapters[k] == adaptersToRemove[j].bridgeAdapter) { + assertEq( + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( + adaptersToRemove[j].bridgeAdapter, + adaptersBefore[i].chainId + ), + false + ); + } else { + assertEq( + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( + adaptersBefore[i].adapters[k], + adaptersBefore[i].chainId + ), + true + ); + } + } + } + } + } + } + } + /** * @dev executes the generic test suite including e2e and config snapshots */ From fb43622214421f6ac5f1c90abd1f1b57907bcd67 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 13 Mar 2024 13:01:26 +0100 Subject: [PATCH 12/19] add getTrustedRemoteByChainId --- .../BaseTest.sol | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index ae21b1f1b..eb4df1b6c 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -85,6 +85,17 @@ abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { revert(); } + function getTrustedRemoteByChainId(uint256 chainId) public view returns (address) { + if (chainId == ChainIds.MAINNET) { + return GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER; + } else if (chainId == ChainIds.POLYGON) { + return GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER; + } else if (chainId == ChainIds.AVALANCHE) { + return GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER; + } + revert(); + } + function test_trustedRemotes() public { ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory receivers = BaseAdaptersUpdatePayload(payloadAddress) @@ -92,28 +103,12 @@ abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { for (uint256 i = 0; i < receivers.length; i++) { for (uint256 j = 0; j < receivers[i].chainIds.length; j++) { - if (receivers[i].chainIds[j] == ChainIds.MAINNET) { - assertEq( - GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, - IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( - receivers[i].chainIds[j] - ) - ); - } else if (receivers[i].chainIds[j] == ChainIds.POLYGON) { - assertEq( - GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, - IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( - receivers[i].chainIds[j] - ) - ); - } else if (receivers[i].chainIds[j] == ChainIds.AVALANCHE) { - assertEq( - GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, - IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( - receivers[i].chainIds[j] - ) - ); - } + assertEq( + getTrustedRemoteByChainId(receivers[i].chainIds[j]), + IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( + receivers[i].chainIds[j] + ) + ); } } } From d898f194de58f90323cdc72f79df08f8af49bad4 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 13 Mar 2024 13:05:26 +0100 Subject: [PATCH 13/19] formatting --- .../BaseTest.sol | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index eb4df1b6c..df9e81073 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -2,12 +2,18 @@ pragma solidity ^0.8.0; import 'forge-std/console.sol'; + import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; import {IBaseAdapter} from 'aave-address-book/common/IBaseAdapter.sol'; + +import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; +import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; +import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol'; + import {AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; import {AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; @@ -15,10 +21,6 @@ import {AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV import {AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; import {BaseCCCImplementationUpdatePayloadTest} from './BaseCCCImplementationUpdatePayloadTest.sol'; -import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; -import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; -import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol'; - struct AdapterName { address adapter; string name; @@ -66,6 +68,7 @@ abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { function setUp() public override { super.setUp(); + ethereumPayload = new AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313(); polygonPayload = new AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313(); avalanchePayload = new AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313(); From f2305cd128b0d7edb3ea7db28501c24a0f1afbdb Mon Sep 17 00:00:00 2001 From: sendra Date: Wed, 13 Mar 2024 13:06:19 +0100 Subject: [PATCH 14/19] fix: added test to check that forwarders are set --- ...plementationAndCCIPAdapters_20240313.t.sol | 17 --- ...plementationAndCCIPAdapters_20240313.t.sol | 17 --- ...plementationAndCCIPAdapters_20240313.t.sol | 22 ---- ...plementationAndCCIPAdapters_20240313.t.sol | 17 --- .../BaseAdaptersUpdatePayload.sol | 2 +- .../BaseTest.sol | 101 +++++------------- 6 files changed, 28 insertions(+), 148 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 1f3a0f9fb..80ce037fa 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -43,21 +43,4 @@ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313_Test is // // return forwarderAdapters; // } - - function _getReceiverAdaptersByChain( - bool afterExecution - ) internal view override returns (AdaptersByChain[] memory) { - address[] memory adapters = new address[](1); - AdaptersByChain[] memory receiverAdaptersByChain = new AdaptersByChain[](1); - - adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); - - if (afterExecution) { - adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); - } - receiverAdaptersByChain[0].adapters = adapters; - receiverAdaptersByChain[0].chainId = ChainIds.MAINNET; - - return receiverAdaptersByChain; - } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index ce39d923e..446319b85 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -23,21 +23,4 @@ contract AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseT 36903911 ) {} - - function _getReceiverAdaptersByChain( - bool afterExecution - ) internal view override returns (AdaptersByChain[] memory) { - address[] memory adapters = new address[](1); - AdaptersByChain[] memory receiverAdaptersByChain = new AdaptersByChain[](1); - - adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); - - if (afterExecution) { - adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); - } - receiverAdaptersByChain[0].adapters = adapters; - receiverAdaptersByChain[0].chainId = ChainIds.MAINNET; - - return receiverAdaptersByChain; - } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index f7fbe8c5b..5abcca4b7 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -27,28 +27,6 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is ) {} - function _getReceiverAdaptersByChain( - bool afterExecution - ) internal view override returns (AdaptersByChain[] memory) { - address[] memory polygonAdapters = new address[](1); - address[] memory avalancheAdapters = new address[](1); - AdaptersByChain[] memory receiverAdaptersByChain = new AdaptersByChain[](2); - - polygonAdapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); - avalancheAdapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); - - if (afterExecution) { - polygonAdapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); - avalancheAdapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); - } - receiverAdaptersByChain[0].adapters = polygonAdapters; - receiverAdaptersByChain[0].chainId = ChainIds.POLYGON; - receiverAdaptersByChain[0].adapters = avalancheAdapters; - receiverAdaptersByChain[0].chainId = ChainIds.AVALANCHE; - - return receiverAdaptersByChain; - } - // function _getForwarderAdaptersByChain( // bool afterExecution // ) internal view override returns (ForwarderAdapters[] memory) { diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 42f9adca6..bd8facf24 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -41,21 +41,4 @@ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313_Test is B // // return forwarderAdapters; // } - - function _getReceiverAdaptersByChain( - bool afterExecution - ) internal view override returns (AdaptersByChain[] memory) { - address[] memory adapters = new address[](1); - AdaptersByChain[] memory receiverAdaptersByChain = new AdaptersByChain[](1); - - adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_ADAPTER_TO_REMOVE(); - - if (afterExecution) { - adapters[0] = BaseAdaptersUpdatePayload(payloadAddress).CCIP_NEW_ADAPTER(); - } - receiverAdaptersByChain[0].adapters = adapters; - receiverAdaptersByChain[0].chainId = ChainIds.MAINNET; - - return receiverAdaptersByChain; - } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol index c16b05ff6..e23f11ccc 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol @@ -138,7 +138,7 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa } function getForwarderBridgeAdaptersToEnable() - internal + public view returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) { diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index ae21b1f1b..955561b1e 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -226,30 +226,45 @@ abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { } } + function test_forwarderAdaptersAreSet() public { + executePayload(vm, payloadAddress); + + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory forwarders = BaseAdaptersUpdatePayload(payloadAddress) + .getForwarderBridgeAdaptersToEnable(); + + for (uint256 i = 0; i < forwarders.length; i++) { + ICrossChainForwarder.ChainIdBridgeConfig[] + memory forwardersBridgeAdaptersByChain = ICrossChainForwarder(CROSS_CHAIN_CONTROLLER) + .getForwarderBridgeAdaptersByChain(forwarders[i].destinationChainId); + bool newAdapterFound; + for (uint256 j = 0; j < forwardersBridgeAdaptersByChain.length; j++) { + if ( + forwardersBridgeAdaptersByChain[j].destinationBridgeAdapter == + forwarders[i].destinationBridgeAdapter && + forwardersBridgeAdaptersByChain[j].currentChainBridgeAdapter == + forwarders[i].currentChainBridgeAdapter + ) { + newAdapterFound = true; + } + } + assertEq(newAdapterFound, true); + } + } + /** * @dev executes the generic test suite including e2e and config snapshots */ function test_defaultProposalExecution() public { - // - // _checkAllReceiversAreRepresented(false); // _checkAllForwarderAdaptersAreRepresented(false); - _checkImplementationAddress( - Payload(payloadAddress).CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), - false - ); + // // AdaptersByChain[] memory receiversBeforeExecution = _getCurrentReceiverAdaptersByChain(); // executePayload(vm, payloadAddress); // // AdaptersByChain[] memory afterBeforeExecution = _getCurrentReceiverAdaptersByChain(); - // - // // _checkAllReceiversAreRepresented(true); // // _checkAllForwarderAdaptersAreRepresented(true); - _checkImplementationAddress( - Payload(payloadAddress).CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), - true - ); } // -------------- virtual methods -------------------------- @@ -261,10 +276,6 @@ abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { return forwarderAdapters; } - function _getReceiverAdaptersByChain( - bool afterExecution - ) internal view virtual returns (AdaptersByChain[] memory); - // ------------------------ checks ------------- // function _checkAllForwarderAdaptersAreRepresented(bool afterExecution) internal { // ForwarderAdapters[] memory forwarderAdapters = _getForwarderAdaptersByChain(afterExecution); @@ -278,24 +289,6 @@ abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { // } // } - function _checkAllReceiversAreRepresented(bool afterExecution) internal virtual { - AdaptersByChain[] memory receiverAdaptersByChain = _getReceiverAdaptersByChain(afterExecution); - - for (uint256 i = 0; i < receiverAdaptersByChain.length; i++) { - _testReceiverAdaptersByChain( - receiverAdaptersByChain[i].chainId, - receiverAdaptersByChain[i].adapters - ); - } - } - - function _checkImplementationAddress(address implementation, bool equal) internal { - address cccImplementation = ProxyAdmin(PROXY_ADMIN).getProxyImplementation( - TransparentUpgradeableProxy(payable(CROSS_CHAIN_CONTROLLER)) - ); - assertEq(cccImplementation == implementation, equal); - } - //----------------------------------------------------------------- function _testForwarderAdapterCorrectness( @@ -330,46 +323,6 @@ abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { assertEq(adaptersCount, adapters.length); } - function _testReceiverAdaptersByChain(uint256 chainId, address[] memory adapters) internal { - address[] memory receiverAdapters = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) - .getReceiverBridgeAdaptersByChain(chainId); - - uint256 adaptersCount; - for (uint256 i = 0; i < receiverAdapters.length; i++) { - for (uint256 j = 0; j < adapters.length; j++) { - if (receiverAdapters[i] == adapters[j]) { - adaptersCount++; - } - } - } - assertEq(adaptersCount, adapters.length); - } - - function _testOnlyUpdatedReceiverAdapterChanges( - address[] memory previousReceivers, - address newAdapter, - uint256 chainId - ) internal { - address[] memory currentReceiverAdapters = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) - .getReceiverBridgeAdaptersByChain(chainId); - - uint256 adaptersCount; - uint256 newAdapterCount; - for (uint256 i = 0; i < currentReceiverAdapters.length; i++) { - for (uint256 j = 0; j < previousReceivers.length; j++) { - if (currentReceiverAdapters[i] == previousReceivers[j]) { - adaptersCount++; - } - if (currentReceiverAdapters[i] == newAdapter) { - newAdapterCount++; - } - } - } - - assertEq(previousReceivers.length, currentReceiverAdapters.length); - assertEq(currentReceiverAdapters.length, adaptersCount + newAdapterCount); - } - function _getCurrentReceiverAdaptersByChain() internal returns (AdaptersByChain[] memory) { uint256[] memory supportedChains = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) .getSupportedChains(); From 5c5d694ea4b7f82d212b2da9da9fa05cfd8ec167 Mon Sep 17 00:00:00 2001 From: Lukas Date: Wed, 13 Mar 2024 14:52:21 +0100 Subject: [PATCH 15/19] fix: update scripts (#248) --- ...plementationAndCCIPAdapters_20240313.s.sol | 184 +++++++++++++++++- .../config.ts | 19 +- 2 files changed, 200 insertions(+), 3 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol index 5f8270226..79bc186af 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol @@ -2,11 +2,17 @@ pragma solidity ^0.8.0; import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; -import {EthereumScript, PolygonScript, AvalancheScript, BNBScript} from 'aave-helpers/ScriptUtils.sol'; +import {EthereumScript, PolygonScript, AvalancheScript, BNBScript, BaseScript, GnosisScript, OptimismScript, ArbitrumScript, MetisScript, ScrollScript} from 'aave-helpers/ScriptUtils.sol'; import {AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; import {AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; import {AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; import {AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; +import {AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313} from './AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol'; /** * @dev Deploy Ethereum @@ -96,6 +102,138 @@ contract DeployBNB is BNBScript { } } +/** + * @dev Deploy Base + * deploy-command: make deploy-ledger contract=src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol:DeployBase chain=base + * verify-command: npx catapulta-verify -b broadcast/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol/8453/run-latest.json + */ +contract DeployBase is BaseScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Gnosis + * deploy-command: make deploy-ledger contract=src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol:DeployGnosis chain=gnosis + * verify-command: npx catapulta-verify -b broadcast/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol/100/run-latest.json + */ +contract DeployGnosis is GnosisScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Optimism + * deploy-command: make deploy-ledger contract=src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol:DeployOptimism chain=optimism + * verify-command: npx catapulta-verify -b broadcast/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol/10/run-latest.json + */ +contract DeployOptimism is OptimismScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Arbitrum + * deploy-command: make deploy-ledger contract=src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol:DeployArbitrum chain=arbitrum + * verify-command: npx catapulta-verify -b broadcast/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol/42161/run-latest.json + */ +contract DeployArbitrum is ArbitrumScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Metis + * deploy-command: make deploy-ledger contract=src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol:DeployMetis chain=metis + * verify-command: npx catapulta-verify -b broadcast/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol/1088/run-latest.json + */ +contract DeployMetis is MetisScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Scroll + * deploy-command: make deploy-ledger contract=src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol:DeployScroll chain=scroll + * verify-command: npx catapulta-verify -b broadcast/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol/534352/run-latest.json + */ +contract DeployScroll is ScrollScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + /** * @dev Create Proposal * command: make deploy-ledger contract=src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters_20240313.s.sol:CreateProposal chain=mainnet @@ -103,7 +241,7 @@ contract DeployBNB is BNBScript { contract CreateProposal is EthereumScript { function run() external { // create payloads - PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](4); + PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](10); // compose actions for validation IPayloadsControllerCore.ExecutionAction[] @@ -134,6 +272,48 @@ contract CreateProposal is EthereumScript { ); payloads[3] = GovV3Helpers.buildBNBPayload(vm, actionsBNB); + IPayloadsControllerCore.ExecutionAction[] + memory actionsBase = new IPayloadsControllerCore.ExecutionAction[](1); + actionsBase[0] = GovV3Helpers.buildAction( + type(AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + payloads[4] = GovV3Helpers.buildBasePayload(vm, actionsBase); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsGnosis = new IPayloadsControllerCore.ExecutionAction[](1); + actionsGnosis[0] = GovV3Helpers.buildAction( + type(AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + payloads[5] = GovV3Helpers.buildGnosisPayload(vm, actionsGnosis); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsOptimism = new IPayloadsControllerCore.ExecutionAction[](1); + actionsOptimism[0] = GovV3Helpers.buildAction( + type(AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + payloads[6] = GovV3Helpers.buildOptimismPayload(vm, actionsOptimism); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsArbitrum = new IPayloadsControllerCore.ExecutionAction[](1); + actionsArbitrum[0] = GovV3Helpers.buildAction( + type(AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + payloads[7] = GovV3Helpers.buildArbitrumPayload(vm, actionsArbitrum); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsMetis = new IPayloadsControllerCore.ExecutionAction[](1); + actionsMetis[0] = GovV3Helpers.buildAction( + type(AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + payloads[8] = GovV3Helpers.buildMetisPayload(vm, actionsMetis); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsScroll = new IPayloadsControllerCore.ExecutionAction[](1); + actionsScroll[0] = GovV3Helpers.buildAction( + type(AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode + ); + payloads[9] = GovV3Helpers.buildScrollPayload(vm, actionsScroll); + // create proposal vm.startBroadcast(); GovV3Helpers.createProposal( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/config.ts b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/config.ts index 307a94eba..95f74c7f3 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/config.ts +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/config.ts @@ -2,7 +2,18 @@ import {ConfigFile} from '../../generator/types'; export const config: ConfigFile = { rootOptions: { author: 'BGD Labs @bgdlabs', - pools: ['AaveV3Ethereum', 'AaveV3Polygon', 'AaveV3Avalanche', 'AaveV3BNB'], + pools: [ + 'AaveV3Ethereum', + 'AaveV3Polygon', + 'AaveV3Avalanche', + 'AaveV3BNB', + 'AaveV3Base', + 'AaveV3Gnosis', + 'AaveV3Optimism', + 'AaveV3Arbitrum', + 'AaveV3Metis', + 'AaveV3Scroll', + ], title: 'Update a.DI implementation and CCIP adapters', shortName: 'UpdateADIImplementationAndCCIPAdapters', date: '20240313', @@ -14,5 +25,11 @@ export const config: ConfigFile = { AaveV3Polygon: {configs: {OTHERS: {}}, cache: {blockNumber: 54601669}}, AaveV3Avalanche: {configs: {OTHERS: {}}, cache: {blockNumber: 42840161}}, AaveV3BNB: {configs: {OTHERS: {}}, cache: {blockNumber: 36928161}}, + AaveV3Base: {configs: {OTHERS: {}}, cache: {blockNumber: 36928161}}, + AaveV3Gnosis: {configs: {OTHERS: {}}, cache: {blockNumber: 36928161}}, + AaveV3Optimism: {configs: {OTHERS: {}}, cache: {blockNumber: 36928161}}, + AaveV3Arbitrum: {configs: {OTHERS: {}}, cache: {blockNumber: 36928161}}, + AaveV3Metis: {configs: {OTHERS: {}}, cache: {blockNumber: 36928161}}, + AaveV3Scroll: {configs: {OTHERS: {}}, cache: {blockNumber: 36928161}}, }, }; From 529e3c5e34f2d6a966f5bd6165582f2c7beffa1c Mon Sep 17 00:00:00 2001 From: sendra Date: Wed, 13 Mar 2024 18:24:25 +0100 Subject: [PATCH 16/19] fix: added test to check only changes on specified forwarders --- ...plementationAndCCIPAdapters_20240313.t.sol | 19 --- ...plementationAndCCIPAdapters_20240313.t.sol | 41 ------ ...plementationAndCCIPAdapters_20240313.t.sol | 19 --- .../BaseTest.sol | 133 ++++++++++-------- 4 files changed, 75 insertions(+), 137 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 80ce037fa..8c48f0ea8 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -24,23 +24,4 @@ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313_Test is 42801819 ) {} - - // function _getForwarderAdaptersByChain( - // bool afterExecution - // ) internal view override returns (ForwarderAdapters[] memory) { - // ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](1); - // - // ICrossChainForwarder.ChainIdBridgeConfig[] - // memory adapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - // adapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - // - // if (afterExecution) { - // adapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - // adapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER(); - // } - // forwarderAdapters[0].adapters = adapters; - // forwarderAdapters[0].chainId = ChainIds.MAINNET; - // - // return forwarderAdapters; - // } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 5abcca4b7..452cfdc2f 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -26,45 +26,4 @@ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313_Test is 19418547 ) {} - - // function _getForwarderAdaptersByChain( - // bool afterExecution - // ) internal view override returns (ForwarderAdapters[] memory) { - // ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](3); - // - // ICrossChainForwarder.ChainIdBridgeConfig[] - // memory polygonAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - // ICrossChainForwarder.ChainIdBridgeConfig[] - // memory avalancheAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - // ICrossChainForwarder.ChainIdBridgeConfig[] - // memory binanceAdapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - // - // // polygon - // polygonAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - // // avalanche - // avalancheAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - // // binance - // binanceAdapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - // - // if (afterExecution) { - // // polygon - // polygonAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - // polygonAdapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER_POLYGON(); - // // avalanche - // avalancheAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - // avalancheAdapters[0].destinationBridgeAdapter = payload - // .DESTINATION_CCIP_NEW_ADAPTER_AVALANCHE(); - // // binance - // binanceAdapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - // binanceAdapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER_BNB(); - // } - // forwarderAdapters[0].adapters = polygonAdapters; - // forwarderAdapters[0].chainId = ChainIds.POLYGON; - // forwarderAdapters[1].adapters = avalancheAdapters; - // forwarderAdapters[1].chainId = ChainIds.AVALANCHE; - // forwarderAdapters[2].adapters = binanceAdapters; - // forwarderAdapters[2].chainId = ChainIds.BNB; - // - // return forwarderAdapters; - // } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index bd8facf24..074f83b52 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -22,23 +22,4 @@ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313_Test is B 54566890 ) {} - - // function _getForwarderAdaptersByChain( - // bool afterExecution - // ) internal view override returns (ForwarderAdapters[] memory) { - // ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](1); - // - // ICrossChainForwarder.ChainIdBridgeConfig[] - // memory adapters = new ICrossChainForwarder.ChainIdBridgeConfig[](1); - // adapters[0].currentChainBridgeAdapter = payload.CCIP_ADAPTER_TO_REMOVE(); - // - // if (afterExecution) { - // adapters[0].currentChainBridgeAdapter = payload.CCIP_NEW_ADAPTER(); - // adapters[0].destinationBridgeAdapter = payload.DESTINATION_CCIP_NEW_ADAPTER(); - // } - // forwarderAdapters[0].adapters = adapters; - // forwarderAdapters[0].chainId = ChainIds.MAINNET; - // - // return forwarderAdapters; - // } } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol index 00c3032ed..ef059f78b 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseTest.sol @@ -250,75 +250,92 @@ abstract contract BaseTest is BaseCCCImplementationUpdatePayloadTest { } } - /** - * @dev executes the generic test suite including e2e and config snapshots - */ - function test_defaultProposalExecution() public { - // _checkAllForwarderAdaptersAreRepresented(false); - - // - // AdaptersByChain[] memory receiversBeforeExecution = _getCurrentReceiverAdaptersByChain(); - // + function test_onlyChangedNeededForwarders() public { + ForwarderAdapters[] + memory forwardersBridgeAdaptersByChainBefore = _getCurrentForwarderAdaptersByChain(); + + ICrossChainForwarder.BridgeAdapterToDisable[] + memory adaptersToRemove = BaseAdaptersUpdatePayload(payloadAddress) + .getForwarderBridgeAdaptersToRemove(); + executePayload(vm, payloadAddress); - // - // AdaptersByChain[] memory afterBeforeExecution = _getCurrentReceiverAdaptersByChain(); - // // _checkAllForwarderAdaptersAreRepresented(true); - } - // -------------- virtual methods -------------------------- + ForwarderAdapters[] + memory forwardersBridgeAdaptersByChainAfter = _getCurrentForwarderAdaptersByChain(); - function _getForwarderAdaptersByChain( - bool afterExecution - ) internal view virtual returns (ForwarderAdapters[] memory) { - ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](0); - return forwarderAdapters; - } + assertEq( + forwardersBridgeAdaptersByChainAfter.length, + forwardersBridgeAdaptersByChainBefore.length + ); - // ------------------------ checks ------------- - // function _checkAllForwarderAdaptersAreRepresented(bool afterExecution) internal { - // ForwarderAdapters[] memory forwarderAdapters = _getForwarderAdaptersByChain(afterExecution); - // - // for (uint256 i = 0; i < forwarderAdapters.length; i++) { - // _testForwarderAdapterCorrectness( - // forwarderAdapters[i].chainId, - // forwarderAdapters[i].adapters, - // afterExecution - // ); - // } - // } - - //----------------------------------------------------------------- - - function _testForwarderAdapterCorrectness( - uint256 chainId, - ICrossChainForwarder.ChainIdBridgeConfig[] memory adapters, - bool checkDestination - ) internal { - ICrossChainForwarder.ChainIdBridgeConfig[] - memory forwarderBridgeAdapters = ICrossChainForwarder(CROSS_CHAIN_CONTROLLER) - .getForwarderBridgeAdaptersByChain(chainId); - - uint256 adaptersCount; - for (uint256 i = 0; i < forwarderBridgeAdapters.length; i++) { - for (uint256 j = 0; j < adapters.length; j++) { + for (uint256 l = 0; l < forwardersBridgeAdaptersByChainBefore.length; l++) { + for (uint256 j = 0; j < forwardersBridgeAdaptersByChainAfter.length; j++) { if ( - forwarderBridgeAdapters[i].currentChainBridgeAdapter == - adapters[j].currentChainBridgeAdapter + forwardersBridgeAdaptersByChainBefore[l].chainId == + forwardersBridgeAdaptersByChainAfter[j].chainId ) { - if (checkDestination) { - if ( - forwarderBridgeAdapters[i].destinationBridgeAdapter == - adapters[j].destinationBridgeAdapter - ) { - adaptersCount++; + for (uint256 i = 0; i < forwardersBridgeAdaptersByChainBefore[l].adapters.length; i++) { + bool forwarderFound; + for (uint256 m = 0; m < forwardersBridgeAdaptersByChainAfter[j].adapters.length; m++) { + if ( + forwardersBridgeAdaptersByChainBefore[l].adapters[i].destinationBridgeAdapter == + forwardersBridgeAdaptersByChainAfter[j].adapters[m].destinationBridgeAdapter && + forwardersBridgeAdaptersByChainBefore[l].adapters[i].currentChainBridgeAdapter == + forwardersBridgeAdaptersByChainAfter[j].adapters[m].currentChainBridgeAdapter + ) { + forwarderFound = true; + break; + } + } + if (!forwarderFound) { + bool isAdapterToBeRemoved; + for (uint256 k = 0; k < adaptersToRemove.length; k++) { + if ( + forwardersBridgeAdaptersByChainBefore[l].adapters[i].currentChainBridgeAdapter == + adaptersToRemove[k].bridgeAdapter + ) { + for (uint256 n = 0; n < adaptersToRemove[k].chainIds.length; n++) { + if ( + forwardersBridgeAdaptersByChainBefore[l].chainId == + adaptersToRemove[k].chainIds[n] + ) { + isAdapterToBeRemoved = true; + break; + } + } + } + } + assertEq(isAdapterToBeRemoved, true); } - } else { - adaptersCount++; } } } } - assertEq(adaptersCount, adapters.length); + } + + function _getCurrentForwarderAdaptersByChain() internal returns (ForwarderAdapters[] memory) { + uint256[] memory supportedChains = new uint256[](10); + supportedChains[0] = ChainIds.POLYGON; + supportedChains[1] = ChainIds.AVALANCHE; + supportedChains[2] = ChainIds.BNB; + supportedChains[3] = ChainIds.GNOSIS; + supportedChains[4] = ChainIds.ARBITRUM; + supportedChains[5] = ChainIds.OPTIMISM; + supportedChains[6] = ChainIds.METIS; + supportedChains[7] = ChainIds.BASE; + supportedChains[8] = ChainIds.SCROLL; + supportedChains[9] = ChainIds.MAINNET; + + ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](supportedChains.length); + + for (uint256 i = 0; i < supportedChains.length; i++) { + ICrossChainForwarder.ChainIdBridgeConfig[] memory forwarders = ICrossChainForwarder( + CROSS_CHAIN_CONTROLLER + ).getForwarderBridgeAdaptersByChain(supportedChains[i]); + + forwarderAdapters[i] = ForwarderAdapters({adapters: forwarders, chainId: supportedChains[i]}); + } + return forwarderAdapters; } function _getCurrentReceiverAdaptersByChain() internal returns (AdaptersByChain[] memory) { From 586d8c6d797c3ffdef153046cb856ac8ebacfc90 Mon Sep 17 00:00:00 2001 From: sendra Date: Sun, 17 Mar 2024 17:54:15 +0100 Subject: [PATCH 17/19] fix: update readme --- .../UpdateADIImplementationAndCCIPAdapters.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md index c817e323c..e9c0c3ae6 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md @@ -6,10 +6,46 @@ discussions: "" ## Simple Summary +This proposal includes the update of the CrossChainController on all supported networks to Revision 2. +It also updates all the CCIP Bridge Adapters to version 1.2.0 on the supported networks. + ## Motivation +The main motivation of this proposal is to bring the CCIP Bridge Adapters up to date with the latest bridge provider specifications, +and updating the logic to ease and standardize off chain tracking of a.DI contracts and events. + ## Specification +- Update CCIP to v1.2.0 +- Added Adaper Name to the contracts to make it easy to track off chain. + +On the CrossChainController implementation we have updated the logic so that all bridged messages will be treated the same +even if required confirmation have already been reached. (Previously these messages where ignored) + +Updates the implementation of CrossChainController on aDI on all supported networks: + +| Network | CrossChainController Impl | +| --------- | ------------------------------------------------------------------------------------------------------------------------------------ | +| Ethereum | [](https://etherscan.io/address/) | +| Polygon | [0x87a95917DE670088d81B9a8B30E3B36704Ba3043](https://polygonscan.com/address/0x87a95917DE670088d81B9a8B30E3B36704Ba3043) | +| Avalanche | [0x5Ef80c5eB6CF65Dab8cD1C0ee258a6D2bD38Bd22](https://snowscan.xyz/address/0x5Ef80c5eB6CF65Dab8cD1C0ee258a6D2bD38Bd22) | +| Binance | [0xf41193E25408F652AF878c47E4401A01B5E4B682](https://bscscan.com/address/0xf41193E25408F652AF878c47E4401A01B5E4B682) | +| Gnosis | [0x5e06b10B3b9c3E1c0996D2544A35B9839Be02922](https://gnosisscan.io/address/0x5e06b10B3b9c3E1c0996D2544A35B9839Be02922) | +| Arbitrum | [0x6e633269af45F37c44659D98f382dd0DD524E5Df](https://arbiscan.io/address/0x6e633269af45F37c44659D98f382dd0DD524E5Df) | +| Optimism | [0xa5cc218513305221201f196760E9e64e9D49d98A](https://optimistic.etherscan.io/address/0xa5cc218513305221201f196760E9e64e9D49d98A) | +| Metis | [0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04](https://andromeda-explorer.metis.io/address/0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04) | +| Base | [0x9b6f5ef589A3DD08670Dd146C11C4Fb33E04494F](https://basescan.org/address/0x9b6f5ef589A3DD08670Dd146C11C4Fb33E04494F) | +| Scroll | [0x5e06b10B3b9c3E1c0996D2544A35B9839Be02922](https://scrollscan.com/address/0x5e06b10B3b9c3E1c0996D2544A35B9839Be02922) | + +Updates the bridge adapters used to connect between networks + +| Network | CCIP | +| --------- | ------------------------------------------------------------------------------------------------------------------------ | +| Ethereum | [0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29](https://etherscan.io/address/0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29) | +| Polygon | [0xe79757D55a1600eF28D816a893E78E9FCDE2019E](https://polygonscan.com/address/0xe79757D55a1600eF28D816a893E78E9FCDE2019E) | +| Avalanche | [0x2b88C83727B0E290B76EB3F6133994fF81B7f355](https://snowscan.xyz/address/0x2b88C83727B0E290B76EB3F6133994fF81B7f355) | +| Binance | [0xAE93BEa44dcbE52B625169588574d31e36fb3A67](https://bscscan.com/address/0xAE93BEa44dcbE52B625169588574d31e36fb3A67) | + ## References - Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Avalanche](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Optimism](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Arbitrum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Metis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Base](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Gnosis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Scroll](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3BNB](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol) From fa513d4ed20ee7bec4ecd947b5d8efc0fc4d8391 Mon Sep 17 00:00:00 2001 From: sendra Date: Sun, 17 Mar 2024 19:17:56 +0100 Subject: [PATCH 18/19] fix: add missing ccc impl address for ethereum --- .../UpdateADIImplementationAndCCIPAdapters.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md index e9c0c3ae6..79d2ed6c5 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md @@ -26,7 +26,7 @@ Updates the implementation of CrossChainController on aDI on all supported netwo | Network | CrossChainController Impl | | --------- | ------------------------------------------------------------------------------------------------------------------------------------ | -| Ethereum | [](https://etherscan.io/address/) | +| Ethereum | [0x28559c2F4B038b1E836fA419DCcDe7454d8Fe215](https://etherscan.io/address/0x28559c2F4B038b1E836fA419DCcDe7454d8Fe215) | | Polygon | [0x87a95917DE670088d81B9a8B30E3B36704Ba3043](https://polygonscan.com/address/0x87a95917DE670088d81B9a8B30E3B36704Ba3043) | | Avalanche | [0x5Ef80c5eB6CF65Dab8cD1C0ee258a6D2bD38Bd22](https://snowscan.xyz/address/0x5Ef80c5eB6CF65Dab8cD1C0ee258a6D2bD38Bd22) | | Binance | [0xf41193E25408F652AF878c47E4401A01B5E4B682](https://bscscan.com/address/0xf41193E25408F652AF878c47E4401A01B5E4B682) | From 1301c5ee9068f9015345923ff96b0ddd540c5a8a Mon Sep 17 00:00:00 2001 From: sendra Date: Mon, 18 Mar 2024 11:34:09 +0100 Subject: [PATCH 19/19] fix: updated base contract to add receivers only if receiving chains exist. Added discussion links --- ...itrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...anche_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...V3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol | 2 +- ...3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...ereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...nosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...sis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol | 2 +- ...Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...imism_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...lygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- ...croll_UpdateADIImplementationAndCCIPAdapters_20240313.sol | 3 +-- .../BaseAdaptersUpdatePayload.sol | 5 ++++- .../UpdateADIImplementationAndCCIPAdapters.md | 5 ++--- 14 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol index d39fb2b29..a3030e5bd 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -8,8 +8,7 @@ import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdateP /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseCCCImplementationUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol index f4f13a117..21c4d67a2 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -9,8 +9,7 @@ import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseAdaptersUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 54221d243..267c5cda3 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -9,8 +9,7 @@ import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseAdaptersUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 446319b85..90491cacc 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -20,7 +20,7 @@ contract AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313_Test is BaseT MiscBNB.PROXY_ADMIN, type(AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, 'bnb', - 36903911 + 37073128 ) {} } diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 5e52a2b7e..d6ed97266 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -8,8 +8,7 @@ import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdateP /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseCCCImplementationUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 5f1fc2927..72b2128e5 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -9,8 +9,7 @@ import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseAdaptersUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol index b0aa6dd94..bc9fa4b51 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -8,8 +8,7 @@ import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdateP /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseCCCImplementationUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol index 30d3b0c5e..71b99ecf0 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol @@ -16,7 +16,7 @@ contract AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313_Test is MiscGnosis.PROXY_ADMIN, type(AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313).creationCode, 'gnosis', - 32897310 + 32990165 ) { diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 0bf40587d..6913b3d4b 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -8,8 +8,7 @@ import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdateP /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseCCCImplementationUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 3dcb0490f..f1288e44b 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -8,8 +8,7 @@ import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdateP /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseCCCImplementationUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol index acbe0ba6f..c04e92853 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -9,8 +9,7 @@ import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseAdaptersUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol index 183df358f..c48042a90 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol @@ -8,8 +8,7 @@ import {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdateP /** * @title aDI and bridge adapters update * @author BGD Labs @bgdlabs - * - Snapshot: TODO - * - Discussion: TODO + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21 */ contract AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313 is BaseCCCImplementationUpdatePayload( diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol index e23f11ccc..c70ea812e 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/BaseAdaptersUpdatePayload.sol @@ -53,13 +53,16 @@ abstract contract BaseAdaptersUpdatePayload is BaseCCCImplementationUpdatePayloa ); uint256[] memory chainsToSend = getChainsToSend(); + uint256[] memory chainsToReceive = getChainsToReceive(); - if (chainsToSend.length != 0) { + if (chainsToReceive.length != 0) { // add receiver adapters ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters( getReceiverBridgeAdaptersToAllow() ); + } + if (chainsToSend.length != 0) { // add forwarding adapters ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).enableBridgeAdapters( getForwarderBridgeAdaptersToEnable() diff --git a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md index 79d2ed6c5..be2080ef5 100644 --- a/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md +++ b/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/UpdateADIImplementationAndCCIPAdapters.md @@ -1,7 +1,7 @@ --- title: "Update a.DI implementation and CCIP adapters" author: "BGD Labs @bgdlabs" -discussions: "" +discussions: "https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21" --- ## Simple Summary @@ -51,8 +51,7 @@ Updates the bridge adapters used to connect between networks - Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Avalanche](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Optimism](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Arbitrum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Metis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Base](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Gnosis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3Scroll](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.sol), [AaveV3BNB](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.sol) - Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Ethereum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Polygon_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Avalanche](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Avalanche_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Optimism](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Optimism_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Arbitrum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Metis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Metis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Base](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Base_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Gnosis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Gnosis_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3Scroll](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3Scroll_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol), [AaveV3BNB](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240313_Multi_UpdateADIImplementationAndCCIPAdapters/AaveV3BNB_UpdateADIImplementationAndCCIPAdapters_20240313.t.sol) - -- [Snapshot](TODO) -- [Discussion](TODO) +- [Discussion](https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21) ## Copyright