diff --git a/diffs/adi_AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md b/diffs/adi_AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md new file mode 100644 index 000000000..25e950947 --- /dev/null +++ b/diffs/adi_AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md @@ -0,0 +1,30 @@ +## Raw diff + +```json +{ + "forwarderAdaptersByChain": { + "1": { + "0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04": { + "from": "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8", + "to": null + }, + "0x617332a777780F546261247F621051d0b98975Eb": { + "from": null, + "to": "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1" + } + } + }, + "receiverAdaptersByChain": { + "1": { + "0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04": { + "from": true, + "to": null + }, + "0x617332a777780F546261247F621051d0b98975Eb": { + "from": null, + "to": true + } + } + } +} +``` \ No newline at end of file diff --git a/diffs/adi_AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md b/diffs/adi_AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md new file mode 100644 index 000000000..e9447bbc3 --- /dev/null +++ b/diffs/adi_AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md @@ -0,0 +1,18 @@ +## Raw diff + +```json +{ + "receiverAdaptersByChain": { + "1": { + "0x118DFD5418890c0332042ab05173Db4A2C1d283c": { + "from": true, + "to": null + }, + "0x3F006299eC88985c18E6e885EeA29A49eC579882": { + "from": null, + "to": true + } + } + } +} +``` \ No newline at end of file diff --git a/diffs/adi_AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md b/diffs/adi_AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md new file mode 100644 index 000000000..f67469d0d --- /dev/null +++ b/diffs/adi_AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md @@ -0,0 +1,70 @@ +## Raw diff + +```json +{ + "forwarderAdaptersByChain": { + "56": { + "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8": { + "from": "0x118DFD5418890c0332042ab05173Db4A2C1d283c", + "to": null + }, + "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1": { + "from": null, + "to": "0x3F006299eC88985c18E6e885EeA29A49eC579882" + } + }, + "100": { + "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8": { + "from": "0x4A4c73d563395ad827511F70097d4Ef82E653805", + "to": null + }, + "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1": { + "from": null, + "to": "0xA806DA549FcB2B4912a7dFFE4c1aA7A1ed0Bd5C9" + } + }, + "137": { + "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8": { + "from": "0x3c25b96fF62D21E90556869272a277eE2E229747", + "to": null + }, + "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1": { + "from": null, + "to": "0x3e72665008dC237bdd91C04C10782Ed1987a4019" + } + }, + "43114": { + "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8": { + "from": "0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04", + "to": null + }, + "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1": { + "from": null, + "to": "0x617332a777780F546261247F621051d0b98975Eb" + } + } + }, + "receiverAdaptersByChain": { + "137": { + "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8": { + "from": true, + "to": null + }, + "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1": { + "from": null, + "to": true + } + }, + "43114": { + "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8": { + "from": true, + "to": null + }, + "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1": { + "from": null, + "to": true + } + } + } +} +``` \ No newline at end of file diff --git a/diffs/adi_AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md b/diffs/adi_AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md new file mode 100644 index 000000000..761269b6a --- /dev/null +++ b/diffs/adi_AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md @@ -0,0 +1,18 @@ +## Raw diff + +```json +{ + "receiverAdaptersByChain": { + "1": { + "0x4A4c73d563395ad827511F70097d4Ef82E653805": { + "from": true, + "to": null + }, + "0xA806DA549FcB2B4912a7dFFE4c1aA7A1ed0Bd5C9": { + "from": null, + "to": true + } + } + } +} +``` \ No newline at end of file diff --git a/diffs/adi_AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md b/diffs/adi_AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md new file mode 100644 index 000000000..d2944d375 --- /dev/null +++ b/diffs/adi_AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320_before_adi_AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320_after.md @@ -0,0 +1,30 @@ +## Raw diff + +```json +{ + "forwarderAdaptersByChain": { + "1": { + "0x3c25b96fF62D21E90556869272a277eE2E229747": { + "from": "0x6Abb61beb5848B476d026C4934E8a6415e2E75a8", + "to": null + }, + "0x3e72665008dC237bdd91C04C10782Ed1987a4019": { + "from": null, + "to": "0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1" + } + } + }, + "receiverAdaptersByChain": { + "1": { + "0x3c25b96fF62D21E90556869272a277eE2E229747": { + "from": true, + "to": null + }, + "0x3e72665008dC237bdd91C04C10782Ed1987a4019": { + "from": null, + "to": true + } + } + } +} +``` \ No newline at end of file diff --git a/lib/aave-helpers b/lib/aave-helpers index ffdfec57e..76d187c55 160000 --- a/lib/aave-helpers +++ b/lib/aave-helpers @@ -1 +1 @@ -Subproject commit ffdfec57ed1b7f90afbcdb108efc1141e91bc479 +Subproject commit 76d187c555216e31ca5cccb094e011e4b7372aa3 diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.sol index 0fb1690aa..fb0faea76 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.sol @@ -1,9 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; +import 'aave-helpers/adi/SimpleOneToManyAdapterUpdate.sol'; /** * @title Hyperlane bridge adapter update to V3 @@ -12,11 +12,11 @@ import {ChainIds} from 'aave-helpers/ChainIds.sol'; * - Discussion: TODO */ contract AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320 is - BaseAdaptersUpdatePayload( - BaseAdaptersUpdatePayload.ConstructorInput({ + SimpleOneToManyAdapterUpdate( + SimpleOneToManyAdapterUpdate.ConstructorInput({ ccc: GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, - hlNewAdapter: 0x617332a777780F546261247F621051d0b98975Eb, - hlAdapterToRemove: 0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04 + newAdapter: 0x617332a777780F546261247F621051d0b98975Eb, + adapterToRemove: 0xa198Fac58E02A5C5F8F7e877895d50cFa9ad1E04 }) ) { diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol index fd1d93f57..92a68b469 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol @@ -3,19 +3,41 @@ pragma solidity ^0.8.0; import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol'; import {AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; -import './BaseTest.sol'; +import 'aave-helpers/adi/test/ADITestBase.sol'; +import {AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; /** * @dev Test for AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320 * command: make test-contract filter=AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320 */ -contract AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is BaseTest { - constructor() - BaseTest( +contract AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is ADITestBase { + AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320 public payload; + function setUp() public { + vm.createSelectFork(vm.rpcUrl('avalanche'), 43150105); + payload = new AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320(); + } + + function getDestinationPayloadsByChain() + public + view + override + returns (DestinationPayload[] memory) + { + DestinationPayload[] memory destinationPayload = new DestinationPayload[](1); + destinationPayload[0] = DestinationPayload({ + chainId: ChainIds.MAINNET, + payloadCode: type(AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode + }); + + return destinationPayload; + } + + function test_defaultTest() public { + defaultTest( + 'AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320', GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER, - type(AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode, - 'avalanche', - 43150105 - ) - {} + address(payload), + true + ); + } } diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.sol index 091091406..038ac5752 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {BaseAdaptersUpdatePayload, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import 'aave-helpers/adi/SimpleOneToManyAdapterUpdate.sol'; import {GovernanceV3BNB} from 'aave-address-book/GovernanceV3BNB.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; @@ -12,11 +12,11 @@ import {ChainIds} from 'aave-helpers/ChainIds.sol'; * - Discussion: TODO */ contract AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320 is - BaseAdaptersUpdatePayload( - BaseAdaptersUpdatePayload.ConstructorInput({ + SimpleOneToManyAdapterUpdate( + SimpleOneToManyAdapterUpdate.ConstructorInput({ ccc: GovernanceV3BNB.CROSS_CHAIN_CONTROLLER, - hlNewAdapter: 0x3F006299eC88985c18E6e885EeA29A49eC579882, - hlAdapterToRemove: 0x118DFD5418890c0332042ab05173Db4A2C1d283c + newAdapter: 0x3F006299eC88985c18E6e885EeA29A49eC579882, + adapterToRemove: 0x118DFD5418890c0332042ab05173Db4A2C1d283c }) ) { @@ -25,13 +25,4 @@ contract AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320 is chains[0] = ChainIds.MAINNET; return chains; } - - function getForwarderBridgeAdaptersToRemove() - public - pure - override - returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) - { - return new ICrossChainForwarder.BridgeAdapterToDisable[](0); - } } diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol index 26db73a46..3bb3d3db3 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol @@ -1,21 +1,28 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import './BaseTest.sol'; import {GovernanceV3BNB} from 'aave-address-book/GovernanceV3BNB.sol'; import {AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; +import 'aave-helpers/adi/test/ADITestBase.sol'; /** * @dev Test for AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320 * command: make test-contract filter=AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320 */ -contract AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is BaseTest { - constructor() - BaseTest( +contract AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is ADITestBase { + AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320 public payload; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl('bnb'), 37137492); + payload = new AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320(); + } + + function test_defaultTest() public { + defaultTest( + 'AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320', GovernanceV3BNB.CROSS_CHAIN_CONTROLLER, - type(AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode, - 'bnb', - 37137492 - ) - {} + address(payload), + true + ); + } } diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.sol index 239ffe5ed..ed4e9e8bd 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; +import 'aave-helpers/adi/SimpleOneToManyAdapterUpdate.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; @@ -12,11 +12,11 @@ import {ChainIds} from 'aave-helpers/ChainIds.sol'; * - Discussion: TODO */ contract AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320 is - BaseAdaptersUpdatePayload( - BaseAdaptersUpdatePayload.ConstructorInput({ + SimpleOneToManyAdapterUpdate( + SimpleOneToManyAdapterUpdate.ConstructorInput({ ccc: GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, - hlNewAdapter: 0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1, - hlAdapterToRemove: 0x6Abb61beb5848B476d026C4934E8a6415e2E75a8 + newAdapter: 0x01dcb90Cf13b82Cde4A0BAcC655585a83Af3cCC1, + adapterToRemove: 0x6Abb61beb5848B476d026C4934E8a6415e2E75a8 }) ) { diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol index 8fe9f05ad..1b339b835 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol @@ -1,21 +1,59 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import './BaseTest.sol'; import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; import {AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; +import 'aave-helpers/adi/test/ADITestBase.sol'; +import {AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; +import {AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; +import {AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; +import {AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; /** * @dev Test for AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320 * command: make test-contract filter=AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320 */ -contract AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is BaseTest { - constructor() - BaseTest( +contract AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is ADITestBase { + AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320 public payload; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl('mainnet'), 19661654); + payload = new AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320(); + } + + function getDestinationPayloadsByChain() + public + view + override + returns (DestinationPayload[] memory) + { + DestinationPayload[] memory destinationPayload = new DestinationPayload[](4); + destinationPayload[0] = DestinationPayload({ + chainId: ChainIds.AVALANCHE, + payloadCode: type(AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode + }); + destinationPayload[1] = DestinationPayload({ + chainId: ChainIds.POLYGON, + payloadCode: type(AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode + }); + destinationPayload[2] = DestinationPayload({ + chainId: ChainIds.BNB, + payloadCode: type(AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode + }); + destinationPayload[3] = DestinationPayload({ + chainId: ChainIds.GNOSIS, + payloadCode: type(AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode + }); + + return destinationPayload; + } + + function test_defaultTest() public { + defaultTest( + 'AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320', GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, - type(AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode, - 'mainnet', - 19476776 - ) - {} + address(payload), + true + ); + } } diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.sol index 53064d7d7..59034db87 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {BaseAdaptersUpdatePayload, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import 'aave-helpers/adi/SimpleOneToManyAdapterUpdate.sol'; import {GovernanceV3Gnosis} from 'aave-address-book/GovernanceV3Gnosis.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; @@ -12,11 +12,11 @@ import {ChainIds} from 'aave-helpers/ChainIds.sol'; * - Discussion: TODO */ contract AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320 is - BaseAdaptersUpdatePayload( - BaseAdaptersUpdatePayload.ConstructorInput({ + SimpleOneToManyAdapterUpdate( + SimpleOneToManyAdapterUpdate.ConstructorInput({ ccc: GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER, - hlNewAdapter: 0xA806DA549FcB2B4912a7dFFE4c1aA7A1ed0Bd5C9, - hlAdapterToRemove: 0x4A4c73d563395ad827511F70097d4Ef82E653805 + newAdapter: 0xA806DA549FcB2B4912a7dFFE4c1aA7A1ed0Bd5C9, + adapterToRemove: 0x4A4c73d563395ad827511F70097d4Ef82E653805 }) ) { @@ -25,13 +25,4 @@ contract AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320 is chains[0] = ChainIds.MAINNET; return chains; } - - function getForwarderBridgeAdaptersToRemove() - public - pure - override - returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) - { - return new ICrossChainForwarder.BridgeAdapterToDisable[](0); - } } diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol index ec83f95d4..771ca6312 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import './BaseTest.sol'; +import 'aave-helpers/adi/test/ADITestBase.sol'; import {GovernanceV3Gnosis} from 'aave-address-book/GovernanceV3Gnosis.sol'; import {AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; @@ -9,13 +9,20 @@ import {AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Gn * @dev Test for AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320 * command: make test-contract filter=AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320 */ -contract AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is BaseTest { - constructor() - BaseTest( +contract AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is ADITestBase { + AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320 public payload; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl('gnosis'), 33457580); + payload = new AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320(); + } + + function test_defaultTest() public { + defaultTest( + 'AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320', GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER, - type(AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode, - 'gnosis', - 33043984 - ) - {} + address(payload), + true + ); + } } diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.sol index 86e54a1c9..7a34a9df6 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; +import 'aave-helpers/adi/SimpleOneToManyAdapterUpdate.sol'; import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; import {ChainIds} from 'aave-helpers/ChainIds.sol'; @@ -12,11 +12,11 @@ import {ChainIds} from 'aave-helpers/ChainIds.sol'; * - Discussion: TODO */ contract AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320 is - BaseAdaptersUpdatePayload( - BaseAdaptersUpdatePayload.ConstructorInput({ + SimpleOneToManyAdapterUpdate( + SimpleOneToManyAdapterUpdate.ConstructorInput({ ccc: GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, - hlNewAdapter: 0x3e72665008dC237bdd91C04C10782Ed1987a4019, - hlAdapterToRemove: 0x3c25b96fF62D21E90556869272a277eE2E229747 + newAdapter: 0x3e72665008dC237bdd91C04C10782Ed1987a4019, + adapterToRemove: 0x3c25b96fF62D21E90556869272a277eE2E229747 }) ) { diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol index 6d10bd4bf..acd300ad7 100644 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol +++ b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.t.sol @@ -1,21 +1,44 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import './BaseTest.sol'; +import 'aave-helpers/adi/test/ADITestBase.sol'; import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; import {AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; +import {AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; /** * @dev Test for AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320 * command: make test-contract filter=AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320 */ -contract AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is BaseTest { - constructor() - BaseTest( +contract AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320_Test is ADITestBase { + AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320 public payload; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl('polygon'), 54882095); + payload = new AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320(); + } + + function getDestinationPayloadsByChain() + public + view + override + returns (DestinationPayload[] memory) + { + DestinationPayload[] memory destinationPayload = new DestinationPayload[](1); + destinationPayload[0] = DestinationPayload({ + chainId: ChainIds.MAINNET, + payloadCode: type(AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode + }); + + return destinationPayload; + } + + function test_defaultTest() public { + defaultTest( + 'AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320', GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, - type(AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320).creationCode, - 'polygon', - 54882095 - ) - {} + address(payload), + true + ); + } } diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/BaseAdaptersUpdatePayload.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/BaseAdaptersUpdatePayload.sol deleted file mode 100644 index e7fd1ee7d..000000000 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/BaseAdaptersUpdatePayload.sol +++ /dev/null @@ -1,154 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; -import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; - -/** - * @title Base payload aDI and bridge adapters update - * @author BGD Labs @bgdlabs - */ -abstract contract BaseAdaptersUpdatePayload is IProposalGenericExecutor { - struct ConstructorInput { - address ccc; - address hlAdapterToRemove; - address hlNewAdapter; - } - struct DestinationAdaptersInput { - address adapter; - uint256 chainId; - } - - address public immutable CROSS_CHAIN_CONTROLLER; - address public immutable HL_ADAPTER_TO_REMOVE; - address public immutable HL_NEW_ADAPTER; - - constructor(ConstructorInput memory constructorInput) { - CROSS_CHAIN_CONTROLLER = constructorInput.ccc; - HL_ADAPTER_TO_REMOVE = constructorInput.hlAdapterToRemove; - HL_NEW_ADAPTER = constructorInput.hlNewAdapter; - } - - function execute() public override { - // remove old Receiver bridge adapter - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory receiversToRemove = getReceiverBridgeAdaptersToRemove(); - if (receiversToRemove.length != 0) { - ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(receiversToRemove); - } - - // remove forwarding adapters - ICrossChainForwarder.BridgeAdapterToDisable[] - memory forwardersToRemove = getForwarderBridgeAdaptersToRemove(); - if (forwardersToRemove.length != 0) { - ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).disableBridgeAdapters(forwardersToRemove); - } - - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory receiversToAllow = getReceiverBridgeAdaptersToAllow(); - if (receiversToAllow.length != 0) { - // add receiver adapters - ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(receiversToAllow); - } - ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] - memory forwardersToEnable = getForwarderBridgeAdaptersToEnable(); - if (forwardersToEnable.length != 0) { - // add forwarding adapters - ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).enableBridgeAdapters(forwardersToEnable); - } - } - - 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].chainId; - } - return chainsToSend; - } - - function getReceiverBridgeAdaptersToRemove() - public - view - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - // remove old Receiver bridge adapter - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); - - bridgeAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: HL_ADAPTER_TO_REMOVE, - chainIds: getChainsToReceive() - }); - - return bridgeAdaptersToRemove; - } - - function getForwarderBridgeAdaptersToRemove() - public - view - virtual - returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) - { - ICrossChainForwarder.BridgeAdapterToDisable[] - memory forwarderAdaptersToRemove = new ICrossChainForwarder.BridgeAdapterToDisable[](1); - - forwarderAdaptersToRemove[0] = ICrossChainForwarder.BridgeAdapterToDisable({ - bridgeAdapter: HL_ADAPTER_TO_REMOVE, - chainIds: getChainsToSend() - }); - - return forwarderAdaptersToRemove; - } - - function getReceiverBridgeAdaptersToAllow() - public - view - returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) - { - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); - - bridgeAdapterConfig[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ - bridgeAdapter: HL_NEW_ADAPTER, - chainIds: getChainsToReceive() - }); - - return bridgeAdapterConfig; - } - - function getForwarderBridgeAdaptersToEnable() - public - view - 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: HL_NEW_ADAPTER, - destinationBridgeAdapter: destinationAdapters[i].adapter, - destinationChainId: destinationAdapters[i].chainId - }); - } - - return bridgeAdaptersToEnable; - } -} diff --git a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/BaseTest.sol b/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/BaseTest.sol deleted file mode 100644 index 793b24de9..000000000 --- a/src/20240320_Multi_HyperlaneBridgeAdapterUpdateToV3/BaseTest.sol +++ /dev/null @@ -1,374 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import 'forge-std/console.sol'; -import 'aave-helpers/ProtocolV3TestBase.sol'; - -import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.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_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; -import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; -import {AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; -import {AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; -import {AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; -import {AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320} from './AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320.sol'; - -struct AdapterName { - address adapter; - string name; -} - -struct TrustedRemote { - address adapter; - address expectedRemote; - uint256 remoteChainId; -} - -struct AdapterAllowed { - address adapter; - uint256 chainId; - bool allowed; -} - -struct AdaptersByChain { - address[] adapters; - uint256 chainId; -} - -struct ForwarderAdapters { - ICrossChainForwarder.ChainIdBridgeConfig[] adapters; - uint256 chainId; -} - -interface Payload { - function CROSS_CHAIN_CONTROLLER_IMPLEMENTATION() external returns (address); -} - -abstract contract BaseTest is ProtocolV3TestBase { - address public immutable CROSS_CHAIN_CONTROLLER; - - bytes public payloadCode; - address public payloadAddress; - string public network; - uint256 public blockNumber; - - BaseAdaptersUpdatePayload internal ethereumPayload; - BaseAdaptersUpdatePayload internal polygonPayload; - BaseAdaptersUpdatePayload internal avalanchePayload; - BaseAdaptersUpdatePayload internal binancePayload; - BaseAdaptersUpdatePayload internal gnosisPayload; - - constructor( - address ccc, - bytes memory _payloadCode, - string memory _network, - uint256 _blockNumber - ) { - CROSS_CHAIN_CONTROLLER = ccc; - network = _network; - blockNumber = _blockNumber; - payloadCode = _payloadCode; - } - - function setUp() public { - vm.createSelectFork(vm.rpcUrl(network), blockNumber); - payloadAddress = GovV3Helpers.deployDeterministic(payloadCode); - - ethereumPayload = new AaveV3Ethereum_HyperlaneBridgeAdapterUpdateToV3_20240320(); - polygonPayload = new AaveV3Polygon_HyperlaneBridgeAdapterUpdateToV3_20240320(); - avalanchePayload = new AaveV3Avalanche_HyperlaneBridgeAdapterUpdateToV3_20240320(); - binancePayload = new AaveV3BNB_HyperlaneBridgeAdapterUpdateToV3_20240320(); - gnosisPayload = new AaveV3Gnosis_HyperlaneBridgeAdapterUpdateToV3_20240320(); - } - - 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; - } else if (chainId == ChainIds.GNOSIS) { - return gnosisPayload; - } - 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) - .getReceiverBridgeAdaptersToAllow(); - - for (uint256 i = 0; i < receivers.length; i++) { - for (uint256 j = 0; j < receivers[i].chainIds.length; j++) { - assertEq( - getTrustedRemoteByChainId(receivers[i].chainIds[j]), - IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( - receivers[i].chainIds[j] - ) - ); - } - } - } - - function test_correctPathConfiguration() public { - BaseAdaptersUpdatePayload.DestinationAdaptersInput[] - memory destinationConfigs = BaseAdaptersUpdatePayload(payloadAddress) - .getDestinationAdapters(); - - for (uint256 i = 0; i < destinationConfigs.length; i++) { - assertEq( - getPayloadByChainId(destinationConfigs[i].chainId).HL_NEW_ADAPTER(), - destinationConfigs[i].adapter - ); - } - } - - function test_correctAdapterNames() public { - ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] - memory receivers = BaseAdaptersUpdatePayload(payloadAddress) - .getReceiverBridgeAdaptersToAllow(); - - for (uint256 i = 0; i < receivers.length; i++) { - string memory adapterName = IBaseAdapter(receivers[i].bridgeAdapter).adapterName(); - assertEq(keccak256(abi.encode(adapterName)), keccak256(abi.encode('Hyperlane adapter'))); - } - } - - 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 - ); - } - } - } - - 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 - ); - } - } - } - } - } - } - } - - 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); - } - } - - function test_onlyChangedNeededForwarders() public { - ForwarderAdapters[] - memory forwardersBridgeAdaptersByChainBefore = _getCurrentForwarderAdaptersByChain(); - - ICrossChainForwarder.BridgeAdapterToDisable[] - memory adaptersToRemove = BaseAdaptersUpdatePayload(payloadAddress) - .getForwarderBridgeAdaptersToRemove(); - - executePayload(vm, payloadAddress); - - ForwarderAdapters[] - memory forwardersBridgeAdaptersByChainAfter = _getCurrentForwarderAdaptersByChain(); - - assertEq( - forwardersBridgeAdaptersByChainAfter.length, - forwardersBridgeAdaptersByChainBefore.length - ); - - for (uint256 l = 0; l < forwardersBridgeAdaptersByChainBefore.length; l++) { - for (uint256 j = 0; j < forwardersBridgeAdaptersByChainAfter.length; j++) { - if ( - forwardersBridgeAdaptersByChainBefore[l].chainId == - forwardersBridgeAdaptersByChainAfter[j].chainId - ) { - 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); - } - } - } - } - } - } - - 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) { - uint256[] memory supportedChains = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) - .getSupportedChains(); - - AdaptersByChain[] memory receiverAdapters = new AdaptersByChain[](supportedChains.length); - - for (uint256 i = 0; i < supportedChains.length; i++) { - address[] memory receivers = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) - .getReceiverBridgeAdaptersByChain(supportedChains[i]); - - receiverAdapters[i] = AdaptersByChain({adapters: receivers, chainId: supportedChains[i]}); - } - - return receiverAdapters; - } -}