Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/ccip update templating #255

Merged
merged 23 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
33b70eb
CCIP update templating
kyzia551 Mar 13, 2024
9240df6
Merge branch 'feat/update-ccc-ccip' of github.com:bgd-labs/aave-propo…
sendra Mar 13, 2024
b79c4ca
fix: added missing chain id
sendra Mar 13, 2024
02ee087
fix compilation issues
kyzia551 Mar 13, 2024
071287b
fix: fixed compilation error
sendra Mar 13, 2024
77c0da6
remove redundant DestinationAdaptersInput path
kyzia551 Mar 13, 2024
471507b
update readme with implementation and tests
kyzia551 Mar 13, 2024
e49953a
fix: test cleanup
sendra Mar 13, 2024
8e81530
Merge branch 'feat/ccip-update-templating' of github.com:bgd-labs/aav…
sendra Mar 13, 2024
079a00e
fix: more test cleanup
sendra Mar 13, 2024
01843af
add BaseCCCImplementationUpdatePayloadTest
kyzia551 Mar 13, 2024
c8cd88a
change BaseTest
kyzia551 Mar 13, 2024
ab6166a
fix: added tests to check that only changed necessary receivers
sendra Mar 13, 2024
422388d
Merge branch 'feat/ccip-update-templating' of github.com:bgd-labs/aav…
sendra Mar 13, 2024
fb43622
add getTrustedRemoteByChainId
kyzia551 Mar 13, 2024
d898f19
formatting
kyzia551 Mar 13, 2024
f2305cd
fix: added test to check that forwarders are set
sendra Mar 13, 2024
4447756
Merge branch 'feat/ccip-update-templating' of github.com:bgd-labs/aav…
sendra Mar 13, 2024
5c5d694
fix: update scripts (#248)
sakulstra Mar 13, 2024
529e3c5
fix: added test to check only changes on specified forwarders
sendra Mar 13, 2024
586d8c6
fix: update readme
sendra Mar 17, 2024
fa513d4
fix: add missing ccc impl address for ethereum
sendra Mar 17, 2024
1301c5e
fix: updated base contract to add receivers only if receiving chains …
sendra Mar 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 {BaseCCCImplementationUpdatePayload} from './BaseCCCImplementationUpdatePayload.sol';

/**
* @title aDI and bridge adapters update
* @author BGD Labs @bgdlabs
* - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21
*/
contract AaveV3Arbitrum_UpdateADIImplementationAndCCIPAdapters_20240313 is
BaseCCCImplementationUpdatePayload(
BaseCCCImplementationUpdatePayload.CCCImplementationUpdateInput({
ccc: GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER,
proxyAdmin: MiscArbitrum.PROXY_ADMIN,
newCCCImplementation: 0x6e633269af45F37c44659D98f382dd0DD524E5Df
})
)
{

}
Original file line number Diff line number Diff line change
@@ -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
)
{

}
Original file line number Diff line number Diff line change
@@ -1,133 +1,44 @@
// 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
* - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/21
*/
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 (DestinationAdaptersInput[] memory)
{
ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]
memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[](
1
);
DestinationAdaptersInput[] memory destinationAdapters = new 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -14,100 +15,13 @@ 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 _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 _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({
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) {
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
) 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();

if (afterExecution) {
adapters[0] = payload.CCIP_NEW_ADAPTER();
}
receiverAdaptersByChain[0].adapters = adapters;
receiverAdaptersByChain[0].chainId = ChainIds.MAINNET;

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;
}
}
Loading
Loading