diff --git a/.gitmodules b/.gitmodules index b265e61..51e94c8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,7 @@ [submodule "lib/aave-delivery-infrastructure"] path = lib/aave-delivery-infrastructure url = https://github.com/bgd-labs/aave-delivery-infrastructure + branch = feat/deploy-celo [submodule "lib/aave-helpers"] path = lib/aave-helpers url = https://github.com/bgd-labs/aave-helpers diff --git a/Makefile b/Makefile index 3f8ac22..458f1f6 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ BASE_KEY = --private-key ${PRIVATE_KEY} -custom_ethereum := --with-gas-price 20000000000 # 53 gwei +custom_ethereum := --with-gas-price 12000000000 # 53 gwei #custom_polygon := --with-gas-price 190000000000 # 560 gwei #custom_avalanche := --with-gas-price 27000000000 # 27 gwei #custom_metis-testnet := --legacy --verifier-url https://goerli.explorer.metisdevops.link/api/ @@ -164,23 +164,23 @@ deploy-full: # Deploy Proxy Factories on all networks deploy-proxy-factory-test: - $(call deploy_fn,InitialDeployments,linea) + $(call deploy_fn,InitialDeployments,celo) # Deploy Cross Chain Infra on all networks deploy-cross-chain-infra-test: - $(call deploy_fn,ccc/DeployCCC,linea) + $(call deploy_fn,ccc/DeployCCC,celo) ## Deploy CCIP bridge adapters on all networks deploy-ccip-bridge-adapters-test: - $(call deploy_fn,adapters/DeployCCIP,ethereum) + $(call deploy_fn,adapters/DeployCCIPAdapter,ethereum) ## Deploy LayerZero bridge adapters on all networks deploy-lz-bridge-adapters-test: - $(call deploy_fn,adapters/DeployLZ,ethereum) + $(call deploy_fn,adapters/DeployLZ,celo) ## Deploy HyperLane bridge adapters on all networks deploy-hl-bridge-adapters-test: - $(call deploy_fn,adapters/DeployHL,ethereum) + $(call deploy_fn,adapters/DeployHL,celo) ## Deploy SameChain adapters on ethereum deploy-same-chain-adapters-test: @@ -219,11 +219,11 @@ set-ccf-sender-adapters-test: # Set the bridge adapters allowed to receive messages set-ccr-receiver-adapters-test: - $(call deploy_fn,ccc/Set_CCR_Receivers_Adapters,linea) + $(call deploy_fn,ccc/Set_CCR_Receivers_Adapters,celo) # Sets the required confirmations set-ccr-confirmations-test: - $(call deploy_fn,ccc/Set_CCR_Confirmations,linea) + $(call deploy_fn,ccc/Set_CCR_Confirmations,celo) ## Deploy and configure all contracts @@ -245,7 +245,7 @@ deploy-full-test: # ---------------------------------------------------------------------------------------------------------------------- # ----------------------------------------- HELPER SCRIPTS --------------------------------------------------------- remove-bridge-adapters: - $(call deploy_fn,helpers/RemoveBridgeAdapters,ethereum) + $(call deploy_fn,helpers/RemoveBridgeAdapters,celo) send-direct-message: $(call deploy_fn,helpers/Send_Direct_CCMessage,ethereum) @@ -266,7 +266,7 @@ send-message-via-adapter: $(call deploy_fn,helpers/Send_Message_Via_Adapter,ethereum) deploy_ccc_granular_guardian: - $(call deploy_fn,access_control/network_scripts/GranularGuardianNetworkDeploys,linea) + $(call deploy_fn,access_control/network_scripts/GranularGuardianNetworkDeploys,celo) deploy-ccc-revision-and-update: $(call deploy_fn,CCC/UpdateCCC,ethereum) @@ -283,5 +283,8 @@ deploy-zksync-path-payload: deploy-linea-path-payload: $(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum) +deploy-celo-path-payload: + $(call deploy_fn,payloads/adapters/ethereum/Network_Deployments,ethereum) + update-owners-and-guardians: $(call deploy_fn,helpers/Update_Ownership,zksync) diff --git a/deployments/celo.json b/deployments/celo.json index 5b47ef9..de3fd2c 100644 --- a/deployments/celo.json +++ b/deployments/celo.json @@ -1,29 +1,29 @@ { "arbAdapter": "0x0000000000000000000000000000000000000000", "baseAdapter": "0x0000000000000000000000000000000000000000", - "ccipAdapter": "0x0000000000000000000000000000000000000000", + "ccipAdapter": "0x3d534E8964e7aAcfc702751cc9A2BB6A9fe7d928", "chainId": 42220, "clEmergencyOracle": "0x91b21900E91CD302EBeD05E45D8f270ddAED944d", "create3Factory": "0x0000000000000000000000000000000000000000", - "crossChainController": "0x4A5f4b29C0407E5Feb323305e121f563c7bC4d79", - "crossChainControllerImpl": "0xf41193E25408F652AF878c47E4401A01B5E4B682", + "crossChainController": "0x50F4dAA86F3c747ce15C3C38bD0383200B61d6Dd", + "crossChainControllerImpl": "0xB0f963f93bb14C9c7c9061939107989c726E144d", "emergencyRegistry": "0x0000000000000000000000000000000000000000", "gnosisAdapter": "0x0000000000000000000000000000000000000000", + "granularCCCGuardian": "0xbE815420A63A413BB8D508d8022C0FF150Ea7C39", "guardian": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", - "granularCCCGuardian": "0x0000000000000000000000000000000000000000", - "hlAdapter": "0xa5cc218513305221201f196760E9e64e9D49d98A", + "hlAdapter": "0x7b065E68E70f346B18636Ab86779980287ec73e0", "lineaAdapter": "0x0000000000000000000000000000000000000000", - "lzAdapter": "0xAE93BEa44dcbE52B625169588574d31e36fb3A67", + "lzAdapter": "0x83BC62fbeA15B7Bfe11e8eEE57997afA5451f38C", "metisAdapter": "0x0000000000000000000000000000000000000000", "mockDestination": "0x0000000000000000000000000000000000000000", "opAdapter": "0x0000000000000000000000000000000000000000", "owner": "0xEAF6183bAb3eFD3bF856Ac5C058431C8592394d6", "polAdapter": "0x0000000000000000000000000000000000000000", - "proxyAdmin": "0x01d678F1bbE148C96e7501F1Ac41661904F84F61", - "proxyFactory": "0xb172a90A7C238969CE9B27cc19D13b60A91e7F00", + "proxyAdmin": "0x54BDcc37c4143f944A3EE51C892a6cBDF305E7a0", + "proxyFactory": "0xAe13e4DA0952f0B8fE04E21df53716fCF799a923", "sameChainAdapter": "0x0000000000000000000000000000000000000000", "scrollAdapter": "0x0000000000000000000000000000000000000000", "wormholeAdapter": "0x3F006299eC88985c18E6e885EeA29A49eC579882", "zkevmAdapter": "0x0000000000000000000000000000000000000000", "zksyncAdapter": "0x0000000000000000000000000000000000000000" -} +} \ No newline at end of file diff --git a/deployments/ethereum.json b/deployments/ethereum.json index 3dc87d4..7f399e6 100644 --- a/deployments/ethereum.json +++ b/deployments/ethereum.json @@ -1,7 +1,7 @@ { "arbAdapter": "0x88d6D01e08d3e64513b15fD46528dBbA7d755883", "baseAdapter": "0xa5948b0ac79f72966dFFC5C13E44f6dfDD3D58A0", - "ccipAdapter": "0xB7a6618df58626C3a122ABAFD6Ee63Af63f3Ef29", + "ccipAdapter": "0x58489B249BfBCF5ef4B30bdE2792086e83122B6f", "chainId": 1, "clEmergencyOracle": "0x0000000000000000000000000000000000000000", "create3Factory": "0xcc3C54B95f3f1867A43009B80ed4DD930E3cE2F7", diff --git a/diffs/adi_add_celo_path_to_adiethereum_before_adi_add_celo_path_to_adiethereum_after.md b/diffs/adi_add_celo_path_to_adiethereum_before_adi_add_celo_path_to_adiethereum_after.md new file mode 100644 index 0000000..6e091d1 --- /dev/null +++ b/diffs/adi_add_celo_path_to_adiethereum_before_adi_add_celo_path_to_adiethereum_after.md @@ -0,0 +1,16 @@ +## Raw diff + +```json +{ + "forwarderAdaptersByChain": { + "42220": { + "from": "", + "to": { + "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1": "0x7b065E68E70f346B18636Ab86779980287ec73e0", + "0x58489B249BfBCF5ef4B30bdE2792086e83122B6f": "0x3d534E8964e7aAcfc702751cc9A2BB6A9fe7d928", + "0x8410d9BD353b420ebA8C48ff1B0518426C280FCC": "0x83BC62fbeA15B7Bfe11e8eEE57997afA5451f38C" + } + } + } +} +``` \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index 8c7600f..31471aa 100644 --- a/foundry.toml +++ b/foundry.toml @@ -10,7 +10,7 @@ fs_permissions = [{ access = "read-write", path = "./"}] metadata="none" solc = "0.8.20" ffi = true - +evm_version = 'paris' [profile.zksync.zksync] fallback_oz = true diff --git a/lib/aave-delivery-infrastructure b/lib/aave-delivery-infrastructure index 239475f..1f1c46a 160000 --- a/lib/aave-delivery-infrastructure +++ b/lib/aave-delivery-infrastructure @@ -1 +1 @@ -Subproject commit 239475f03956173abb5e09df31ed748f996c5944 +Subproject commit 1f1c46af4dd914847849cad4fdd2d26525278821 diff --git a/lib/aave-helpers b/lib/aave-helpers index 8dffa4c..7cdcda6 160000 --- a/lib/aave-helpers +++ b/lib/aave-helpers @@ -1 +1 @@ -Subproject commit 8dffa4c19cac331895800eae90dd07a28f6ef874 +Subproject commit 7cdcda6516b6c08d3f3cee9e27b541c179e66fe3 diff --git a/scripts/access_control/network_scripts/GranularGuardianNetworkDeploys.s.sol b/scripts/access_control/network_scripts/GranularGuardianNetworkDeploys.s.sol index 22e50f9..b28e468 100644 --- a/scripts/access_control/network_scripts/GranularGuardianNetworkDeploys.s.sol +++ b/scripts/access_control/network_scripts/GranularGuardianNetworkDeploys.s.sol @@ -238,3 +238,21 @@ contract Linea is DeployGranularGuardian { return ChainIds.LINEA; } } + +contract Celo is DeployGranularGuardian { + function DEFAULT_ADMIN() internal pure override returns (address) { + return 0x1dF462e2712496373A347f8ad10802a5E95f053D; //GovernanceV3Celo.EXECUTOR_LVL_1; + } + + function RETRY_GUARDIAN() internal pure override returns (address) { + return 0xfD3a6E65e470a7D7D730FFD5D36a9354E8F9F4Ea; // bgd guardian + } + + function SOLVE_EMERGENCY_GUARDIAN() internal pure override returns (address) { + return 0x056E4C4E80D1D14a637ccbD0412CDAAEc5B51F4E; // dao governance guardian + } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.CELO; + } +} \ No newline at end of file diff --git a/scripts/adapters/DeployCCIPAdapter.s.sol b/scripts/adapters/DeployCCIPAdapter.s.sol index e14ed19..2556624 100644 --- a/scripts/adapters/DeployCCIPAdapter.s.sol +++ b/scripts/adapters/DeployCCIPAdapter.s.sol @@ -214,3 +214,26 @@ contract Binance_testnet is DeployCCIPAdapter { return remoteCCCByNetwork; } } + +contract Celo is DeployCCIPAdapter { + function CCIP_ROUTER() internal pure override returns (address) { + return 0xfB48f15480926A4ADf9116Dca468bDd2EE6C5F62; + } + + function LINK_TOKEN() internal pure override returns (address) { + return 0xd07294e6E917e07dfDcee882dd1e2565085C2ae0; + } + + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.CELO; + } + + function REMOTE_CCC_BY_NETWORK() internal view override returns (RemoteCCC[] memory) { + RemoteCCC[] memory remoteCCCByNetwork = new RemoteCCC[](1); + remoteCCCByNetwork[0].chainId = ChainIds.ETHEREUM; + remoteCCCByNetwork[0].crossChainController = _getAddresses(ChainIds.ETHEREUM) + .crossChainController; + + return remoteCCCByNetwork; + } +} \ No newline at end of file diff --git a/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol b/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol index 24cfa58..5f7e8a3 100644 --- a/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol +++ b/scripts/ccc/Set_CCR_Receivers_Adapters.s.sol @@ -303,11 +303,10 @@ contract Celo is BaseSetCCRAdapters { function getReceiverBridgeAdaptersToAllow( Addresses memory addresses ) public pure override returns (address[] memory) { - address[] memory receiverBridgeAdaptersToAllow = new address[](4); + address[] memory receiverBridgeAdaptersToAllow = new address[](3); receiverBridgeAdaptersToAllow[0] = addresses.lzAdapter; receiverBridgeAdaptersToAllow[1] = addresses.hlAdapter; - receiverBridgeAdaptersToAllow[2] = addresses.wormholeAdapter; - receiverBridgeAdaptersToAllow[3] = addresses.ccipAdapter; + receiverBridgeAdaptersToAllow[2] = addresses.ccipAdapter; return receiverBridgeAdaptersToAllow; } diff --git a/scripts/helpers/RemoveBridgeAdapters.s.sol b/scripts/helpers/RemoveBridgeAdapters.s.sol index bfa2729..0c5b3d9 100644 --- a/scripts/helpers/RemoveBridgeAdapters.s.sol +++ b/scripts/helpers/RemoveBridgeAdapters.s.sol @@ -54,17 +54,13 @@ contract Celo is BaseRemoveBridgeAdapters { chainIds[0] = ChainIds.ETHEREUM; ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdapters = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](3); + memory bridgeAdapters = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](2); bridgeAdapters[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: 0xcB1F67533DAD738E1930404bE9D4F844752773DA, + bridgeAdapter: 0xa5cc218513305221201f196760E9e64e9D49d98A, chainIds: chainIds }); bridgeAdapters[1] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: 0x2e649f6b54B07E210b31c9cC2eB8a0d5997c3D4A, - chainIds: chainIds - }); - bridgeAdapters[2] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: 0x9fE056F44510F970d724adA16903ba5D75CC4742, + bridgeAdapter: 0xAE93BEa44dcbE52B625169588574d31e36fb3A67, chainIds: chainIds }); return bridgeAdapters; diff --git a/scripts/payloads/adapters/ethereum/Ethereum_Activate_Celo_Bridge_Adapter_Payload.s.sol b/scripts/payloads/adapters/ethereum/Ethereum_Activate_Celo_Bridge_Adapter_Payload.s.sol new file mode 100644 index 0000000..cfd509a --- /dev/null +++ b/scripts/payloads/adapters/ethereum/Ethereum_Activate_Celo_Bridge_Adapter_Payload.s.sol @@ -0,0 +1,38 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import '../../../BaseDeployerScript.sol'; +import '../../../../src/adapter_payloads/Ethereum_Celo_Path_Payload.sol'; + +abstract contract Ethereum_Activate_Celo_Bridge_Adapter_Payload is BaseDeployerScript { + function _getPayloadByteCode() internal virtual returns (bytes memory); + + function PAYLOAD_SALT() internal pure virtual returns (string memory) { + return 'Add Celo path to a.DI'; + } + + function DESTINATION_CHAIN_ID() internal pure virtual returns (uint256); + + function _deployPayload(AddForwarderAdapterArgs memory args) internal returns (address) { + bytes memory payloadCode = abi.encodePacked(_getPayloadByteCode(), abi.encode(args)); + + return _deployByteCode(payloadCode, PAYLOAD_SALT()); + } + + function _execute(Addresses memory addresses) internal virtual override { + Addresses memory destinationAddresses = _getAddresses(DESTINATION_CHAIN_ID()); + + _deployPayload( + AddForwarderAdapterArgs({ + crossChainController: addresses.crossChainController, + currentChainHLBridgeAdapter: addresses.hlAdapter, + destinationChainHLBridgeAdapter: destinationAddresses.hlAdapter, + currentChainCCIPBridgeAdapter: addresses.ccipAdapter, + destinationChainCCIPBridgeAdapter: destinationAddresses.ccipAdapter, + currentChainLZBridgeAdapter: addresses.lzAdapter, + destinationChainLZBridgeAdapter: destinationAddresses.lzAdapter, + destinationChainId: DESTINATION_CHAIN_ID() + }) + ); + } +} diff --git a/scripts/payloads/adapters/ethereum/Network_Deployments.s.sol b/scripts/payloads/adapters/ethereum/Network_Deployments.s.sol index dd8fa70..67435bf 100644 --- a/scripts/payloads/adapters/ethereum/Network_Deployments.s.sol +++ b/scripts/payloads/adapters/ethereum/Network_Deployments.s.sol @@ -1,9 +1,27 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import './Ethereum_Activate_Lina_Bridge_Adapter_Payload.s.sol'; +import '../../../BaseDeployerScript.sol'; +import {Ethereum_Activate_Celo_Bridge_Adapter_Payload} from './Ethereum_Activate_Celo_Bridge_Adapter_Payload.s.sol'; +import {Ethereum_Activate_Lina_Bridge_Adapter_Payload} from './Ethereum_Activate_Lina_Bridge_Adapter_Payload.s.sol'; +import {Ethereum_Celo_Path_Payload} from '../../../../src/adapter_payloads/Ethereum_Celo_Path_Payload.sol'; +import {SimpleAddForwarderAdapter} from '../../../../src/templates/SimpleAddForwarderAdapter.sol'; -contract Ethereum is Ethereum_Activate_Lina_Bridge_Adapter_Payload { +contract Ethereum is Ethereum_Activate_Celo_Bridge_Adapter_Payload { + function TRANSACTION_NETWORK() internal pure override returns (uint256) { + return ChainIds.ETHEREUM; + } + + function _getPayloadByteCode() internal pure override returns (bytes memory) { + return type(Ethereum_Celo_Path_Payload).creationCode; + } + + function DESTINATION_CHAIN_ID() internal pure override returns (uint256) { + return ChainIds.CELO; + } +} + +contract Ethereum_Linea is Ethereum_Activate_Lina_Bridge_Adapter_Payload { function TRANSACTION_NETWORK() internal pure override returns (uint256) { return ChainIds.ETHEREUM; } @@ -15,4 +33,4 @@ contract Ethereum is Ethereum_Activate_Lina_Bridge_Adapter_Payload { function DESTINATION_CHAIN_ID() internal pure override returns (uint256) { return ChainIds.LINEA; } -} +} \ No newline at end of file diff --git a/src/adapter_payloads/Ethereum_Celo_Path_Payload.sol b/src/adapter_payloads/Ethereum_Celo_Path_Payload.sol new file mode 100644 index 0000000..2a524e8 --- /dev/null +++ b/src/adapter_payloads/Ethereum_Celo_Path_Payload.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import '../templates/BaseAdaptersUpdate.sol'; + +struct AddForwarderAdapterArgs { + address crossChainController; + address currentChainHLBridgeAdapter; + address destinationChainHLBridgeAdapter; + address currentChainLZBridgeAdapter; + address destinationChainLZBridgeAdapter; + address currentChainCCIPBridgeAdapter; + address destinationChainCCIPBridgeAdapter; + uint256 destinationChainId; +} + +/** + * @title Ethereum_Celo_Path_Payload + * @author BGD Labs @bgdlabs + * @dev this payload adds a new bridging path to adi with multiple forwarder adapters + */ +contract Ethereum_Celo_Path_Payload is BaseAdaptersUpdate { + address public immutable CURRENT_CHAIN_HL_BRIDGE_ADAPTER; + address public immutable DESTINATION_CHAIN_HL_BRIDGE_ADAPTER; + address public immutable CURRENT_CHAIN_CCIP_BRIDGE_ADAPTER; + address public immutable DESTINATION_CHAIN_CCIP_BRIDGE_ADAPTER; + address public immutable CURRENT_CHAIN_LZ_BRIDGE_ADAPTER; + address public immutable DESTINATION_CHAIN_LZ_BRIDGE_ADAPTER; + uint256 public immutable DESTINATION_CHAIN_ID; + + constructor( + AddForwarderAdapterArgs memory forwarderArgs + ) BaseAdaptersUpdate(forwarderArgs.crossChainController) { + CURRENT_CHAIN_HL_BRIDGE_ADAPTER = forwarderArgs.currentChainHLBridgeAdapter; + DESTINATION_CHAIN_HL_BRIDGE_ADAPTER = forwarderArgs.destinationChainHLBridgeAdapter; + CURRENT_CHAIN_CCIP_BRIDGE_ADAPTER = forwarderArgs.currentChainCCIPBridgeAdapter; + DESTINATION_CHAIN_CCIP_BRIDGE_ADAPTER = forwarderArgs.destinationChainCCIPBridgeAdapter; + CURRENT_CHAIN_LZ_BRIDGE_ADAPTER = forwarderArgs.currentChainLZBridgeAdapter; + DESTINATION_CHAIN_LZ_BRIDGE_ADAPTER = forwarderArgs.destinationChainLZBridgeAdapter; + DESTINATION_CHAIN_ID = forwarderArgs.destinationChainId; + } + + function getForwarderBridgeAdaptersToEnable() + public + view + override + returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) + { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory newForwarders = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[](3); + + newForwarders[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: CURRENT_CHAIN_HL_BRIDGE_ADAPTER, + destinationBridgeAdapter: DESTINATION_CHAIN_HL_BRIDGE_ADAPTER, + destinationChainId: DESTINATION_CHAIN_ID + }); + + newForwarders[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: CURRENT_CHAIN_CCIP_BRIDGE_ADAPTER, + destinationBridgeAdapter: DESTINATION_CHAIN_CCIP_BRIDGE_ADAPTER, + destinationChainId: DESTINATION_CHAIN_ID + }); + + newForwarders[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: CURRENT_CHAIN_LZ_BRIDGE_ADAPTER, + destinationBridgeAdapter: DESTINATION_CHAIN_LZ_BRIDGE_ADAPTER, + destinationChainId: DESTINATION_CHAIN_ID + }); + + return newForwarders; + } +} diff --git a/tests/adi/ADITestBase.sol b/tests/adi/ADITestBase.sol index e237f83..21923ef 100644 --- a/tests/adi/ADITestBase.sol +++ b/tests/adi/ADITestBase.sol @@ -587,7 +587,7 @@ contract ADITestBase is Test { uint256 chainId ) internal pure returns (uint256[] memory) { if (chainId == ChainIds.MAINNET) { - uint256[] memory chainIds = new uint256[](11); + uint256[] memory chainIds = new uint256[](12); chainIds[0] = ChainIds.MAINNET; chainIds[1] = ChainIds.POLYGON; chainIds[2] = ChainIds.AVALANCHE; @@ -599,6 +599,7 @@ contract ADITestBase is Test { chainIds[8] = ChainIds.BASE; chainIds[9] = ChainIds.SCROLL; chainIds[10] = ChainIds.LINEA; + chainIds[11] = ChainIds.CELO; return chainIds; } else if (chainId == ChainIds.POLYGON) { @@ -676,6 +677,8 @@ contract ADITestBase is Test { return GovernanceV3Scroll.CROSS_CHAIN_CONTROLLER; } else if (chainId == ChainIds.LINEA) { return 0x0D3f821e9741C8a8Bcac231162320251Db0cdf52; + } else if (chainId == ChainIds.CELO) { + return 0x50F4dAA86F3c747ce15C3C38bD0383200B61d6Dd; } revert(); } diff --git a/tests/payloads/ethereum/AddCeloPathTest.t.sol b/tests/payloads/ethereum/AddCeloPathTest.t.sol new file mode 100644 index 0000000..21e4744 --- /dev/null +++ b/tests/payloads/ethereum/AddCeloPathTest.t.sol @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import 'forge-std/console.sol'; +import {ADITestBase} from '../../adi/ADITestBase.sol'; +import { Addresses, Ethereum as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol'; +import {Ethereum_Celo_Path_Payload, AddForwarderAdapterArgs} from '../../../src/adapter_payloads/Ethereum_Celo_Path_Payload.sol'; + +abstract contract BaseAddCeloPathPayloadTest is ADITestBase { + address internal _payload; + address internal _crossChainController; + + string internal NETWORK; + uint256 internal immutable BLOCK_NUMBER; + + constructor(string memory network, uint256 blockNumber) { + NETWORK = network; + BLOCK_NUMBER = blockNumber; + } + + function _getDeployedPayload() internal virtual returns (address); + + function _getPayload() internal virtual returns (address); + + function _getCurrentNetworkAddresses() internal virtual returns (Addresses memory); + + function setUp() public { + vm.createSelectFork(vm.rpcUrl(NETWORK), BLOCK_NUMBER); + + Addresses memory addresses = _getCurrentNetworkAddresses(); + _crossChainController = addresses.crossChainController; + + _payload = _getPayload(); + } + + function test_defaultTest() public { + defaultTest( + string.concat('add_celo_path_to_adi', NETWORK), + _crossChainController, + address(_payload), + false, + vm + ); + } + + function test_samePayloadAddress( + ) public { + Ethereum_Celo_Path_Payload deployedPayload = Ethereum_Celo_Path_Payload(_getDeployedPayload()); + Ethereum_Celo_Path_Payload predictedPayload = Ethereum_Celo_Path_Payload(_getPayload()); + + assertEq(predictedPayload.DESTINATION_CHAIN_ID(), deployedPayload.DESTINATION_CHAIN_ID()); + assertEq(predictedPayload.CROSS_CHAIN_CONTROLLER(), deployedPayload.CROSS_CHAIN_CONTROLLER()); + assertEq( + predictedPayload.CURRENT_CHAIN_HL_BRIDGE_ADAPTER(), + deployedPayload.CURRENT_CHAIN_HL_BRIDGE_ADAPTER() + ); + assertEq( + predictedPayload.DESTINATION_CHAIN_HL_BRIDGE_ADAPTER(), + deployedPayload.DESTINATION_CHAIN_HL_BRIDGE_ADAPTER() + ); + assertEq( + predictedPayload.CURRENT_CHAIN_CCIP_BRIDGE_ADAPTER(), + deployedPayload.CURRENT_CHAIN_CCIP_BRIDGE_ADAPTER() + ); + assertEq( + predictedPayload.DESTINATION_CHAIN_CCIP_BRIDGE_ADAPTER(), + deployedPayload.DESTINATION_CHAIN_CCIP_BRIDGE_ADAPTER() + ); + assertEq( + predictedPayload.CURRENT_CHAIN_LZ_BRIDGE_ADAPTER(), + deployedPayload.CURRENT_CHAIN_LZ_BRIDGE_ADAPTER() + ); + assertEq( + predictedPayload.DESTINATION_CHAIN_LZ_BRIDGE_ADAPTER(), + deployedPayload.DESTINATION_CHAIN_LZ_BRIDGE_ADAPTER() + ); + } +} + +contract EthereumAddCeloPathPayloadTest is + PayloadEthereumScript, + BaseAddCeloPathPayloadTest('ethereum', 21586373) +{ + function _getDeployedPayload() internal pure override returns (address) { + return 0x8F7E2023686B78E148e65004Ca8AcEf9B2B46922; + } + + function _getCurrentNetworkAddresses() internal view override returns (Addresses memory) { + return _getAddresses(TRANSACTION_NETWORK()); + } + + function _getPayload() internal override returns (address) { + Addresses memory currentAddresses = _getCurrentNetworkAddresses(); + + AddForwarderAdapterArgs memory args = AddForwarderAdapterArgs({ + crossChainController: currentAddresses.crossChainController, + currentChainHLBridgeAdapter: 0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1, + destinationChainHLBridgeAdapter: 0x7b065E68E70f346B18636Ab86779980287ec73e0, + currentChainCCIPBridgeAdapter: 0x58489B249BfBCF5ef4B30bdE2792086e83122B6f, + destinationChainCCIPBridgeAdapter: 0x3d534E8964e7aAcfc702751cc9A2BB6A9fe7d928, + currentChainLZBridgeAdapter: 0x8410d9BD353b420ebA8C48ff1B0518426C280FCC, + destinationChainLZBridgeAdapter: 0x83BC62fbeA15B7Bfe11e8eEE57997afA5451f38C, + destinationChainId: DESTINATION_CHAIN_ID() + }); + return _deployPayload(args); + } +} diff --git a/tests/payloads/ethereum/AddLineaPathTest.t.sol b/tests/payloads/ethereum/AddLineaPathTest.t.sol index b84ba93..4f57b96 100644 --- a/tests/payloads/ethereum/AddLineaPathTest.t.sol +++ b/tests/payloads/ethereum/AddLineaPathTest.t.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.0; import 'forge-std/console.sol'; import {ADITestBase} from '../../adi/ADITestBase.sol'; -import {Addresses, Ethereum as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol'; -import '../../../src/templates/SimpleAddForwarderAdapter.sol'; +import {Addresses, Ethereum_Linea as PayloadEthereumScript} from '../../../scripts/payloads/adapters/ethereum/Network_Deployments.s.sol'; +import {SimpleAddForwarderAdapter, AddForwarderAdapterArgs} from '../../../src/templates/SimpleAddForwarderAdapter.sol'; abstract contract BaseAddLineaPathPayloadTest is ADITestBase { address internal _payload; @@ -33,7 +33,7 @@ abstract contract BaseAddLineaPathPayloadTest is ADITestBase { _payload = _getPayload(); } - function test_defaultTest() public { + function xtest_defaultTest() public { defaultTest( string.concat('add_linea_path_to_adi', NETWORK), _crossChainController, @@ -43,7 +43,7 @@ abstract contract BaseAddLineaPathPayloadTest is ADITestBase { ); } - function test_samePayloadAddress( + function xtest_samePayloadAddress( address currentChainAdapter, address destinationChainAdapter, address crossChainController,