From f700e6370439769ffd53c3504a3ab4a0ac2792b7 Mon Sep 17 00:00:00 2001 From: sendra Date: Wed, 24 Jan 2024 12:16:18 +0100 Subject: [PATCH] Register Scroll adapter on a.DI (#176) * [WIP]: Register Scroll adapter on a.DI * fix: fixed tests. Added readme * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol Co-authored-by: Ernesto Boado * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado * fix: use address book libs * fix: added extra scroll ccc test --------- Co-authored-by: Ernesto Boado --- foundry.toml | 2 + ...reum_RegisterADIScrollAdapter_20240122.sol | 36 +++++++++ ...um_RegisterADIScrollAdapter_20240122.t.sol | 74 +++++++++++++++++++ .../RegisterADIScrollAdapter.md | 33 +++++++++ .../RegisterADIScrollAdapter_20240122.s.sol | 58 +++++++++++++++ .../config.ts | 13 ++++ 6 files changed, 216 insertions(+) create mode 100644 src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol create mode 100644 src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.t.sol create mode 100644 src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md create mode 100644 src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter_20240122.s.sol create mode 100644 src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/config.ts diff --git a/foundry.toml b/foundry.toml index 1a2e02996..0696b7d14 100644 --- a/foundry.toml +++ b/foundry.toml @@ -23,6 +23,7 @@ base = "${RPC_BASE}" zkevm = "${RPC_ZKEVM}" gnosis = "${RPC_GNOSIS}" bnb = "${RPC_BNB}" +scroll="${RPC_SCROLL}" [etherscan] mainnet = { key="${ETHERSCAN_API_KEY_MAINNET}", chainId=1 } @@ -36,5 +37,6 @@ base = { key="${ETHERSCAN_API_KEY_BASE}", chainId=8453 } zkevm = { key="${ETHERSCAN_API_KEY_ZKEVM}", chainId=1101 } gnosis = { key="${ETHERSCAN_API_KEY_GNOSIS}", chainId=100 } bnb = { key="${ETHERSCAN_API_KEY_BNB}", chainId=56 } +scroll={key="${ETHERSCAN_API_KEY_SCROLL}",chainId=534352} # See more config options https://github.com/gakonst/foundry/tree/master/config diff --git a/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol new file mode 100644 index 000000000..c30ed5c15 --- /dev/null +++ b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol @@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; +import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; +import {ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; + +/** + * @title Register a.DI Scroll adapter + * @author BGD Labs @bgdlabs + * - Snapshot: N/A (Technical maintenance proposal) + * - Forum: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/15 + */ +contract AaveV3Ethereum_RegisterADIScrollAdapter_20240122 is IProposalGenericExecutor { + address public constant SCROLL_ADAPTER_ETHEREUM = 0xb29F03cbCc646201eC83E9F2C164747beA84b162; + address public constant SCROLL_ADAPTER_SCROLL = 0x118DFD5418890c0332042ab05173Db4A2C1d283c; + uint256 public constant SCROLL_CHAIN_ID = ChainIds.SCROLL; + + function execute() external { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + 1 + ); + + bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: SCROLL_ADAPTER_ETHEREUM, + destinationBridgeAdapter: SCROLL_ADAPTER_SCROLL, + destinationChainId: SCROLL_CHAIN_ID + }); + + ICrossChainForwarder(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).enableBridgeAdapters( + bridgeAdaptersToEnable + ); + } +} diff --git a/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.t.sol b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.t.sol new file mode 100644 index 000000000..611590a60 --- /dev/null +++ b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.t.sol @@ -0,0 +1,74 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import 'forge-std/Test.sol'; +import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; +import {AaveV3Ethereum_RegisterADIScrollAdapter_20240122, ICrossChainForwarder} from './AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol'; +import {GovernanceV3Scroll} from 'aave-address-book/GovernanceV3Scroll.sol'; +import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; +import {ICrossChainReceiver} from 'aave-address-book/common/ICrossChainController.sol'; + +interface IBaseAdapter { + /** + * @notice method to get the trusted remote address from a specified chain id + * @param chainId id of the chain from where to get the trusted remote + * @return address of the trusted remote + */ + function getTrustedRemoteByChainId(uint256 chainId) external view returns (address); +} + +/** + * @dev Test for AaveV3Ethereum_RegisterADIScrollAdapter_20240122 + * command: make test-contract filter=AaveV3Ethereum_RegisterADIScrollAdapter_20240122 + */ +contract AaveV3Ethereum_RegisterADIScrollAdapter_20240122_Test is ProtocolV3TestBase { + AaveV3Ethereum_RegisterADIScrollAdapter_20240122 internal proposal; + + uint256 public ethFork; + uint256 public scrollFork; + + function setUp() public { + ethFork = vm.createFork(vm.rpcUrl('mainnet'), 19062921); + scrollFork = vm.createFork(vm.rpcUrl('scroll'), 2679843); + + vm.selectFork(ethFork); + proposal = new AaveV3Ethereum_RegisterADIScrollAdapter_20240122(); + } + + /** + * @dev executes the generic test suite including e2e and config snapshots + */ + function test_defaultProposalExecution() public { + address scroll_adapter_ethereum = proposal.SCROLL_ADAPTER_ETHEREUM(); + address scroll_adapter_scroll = proposal.SCROLL_ADAPTER_SCROLL(); + + executePayload(vm, address(proposal)); + + ICrossChainForwarder.ChainIdBridgeConfig[] memory ethConfig = ICrossChainForwarder( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER + ).getForwarderBridgeAdaptersByChain(ChainIds.SCROLL); + + assertEq(ethConfig.length, 1); + assertEq(ethConfig[0].destinationBridgeAdapter, scroll_adapter_scroll); + assertEq(ethConfig[0].currentChainBridgeAdapter, scroll_adapter_ethereum); + + vm.selectFork(scrollFork); + address[] memory scrollConfig = ICrossChainReceiver(GovernanceV3Scroll.CROSS_CHAIN_CONTROLLER) + .getReceiverBridgeAdaptersByChain(ChainIds.MAINNET); + + assertEq(scrollConfig.length, 1); + assertEq(scrollConfig[0], scroll_adapter_scroll); + + assertEq( + IBaseAdapter(scroll_adapter_scroll).getTrustedRemoteByChainId(ChainIds.MAINNET), + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER + ); + + ICrossChainReceiver.ReceiverConfiguration memory config = ICrossChainReceiver( + GovernanceV3Scroll.CROSS_CHAIN_CONTROLLER + ).getConfigurationByChain(ChainIds.MAINNET); + + assertEq(config.requiredConfirmation, uint8(1)); + } +} diff --git a/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md new file mode 100644 index 000000000..92cc34a80 --- /dev/null +++ b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md @@ -0,0 +1,33 @@ +--- +title: "Register a.DI Ethereum -> Scroll adapter" +author: "BGD Labs @bgdlabs" +discussions: "https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/15" +--- + +## Simple Summary + +Proposal to register the Scroll adapter on Ethereum a.DI, a technical requirement for an activation vote of Aave v3 Scroll. + +## Motivation + +In order to be able to pass messages from Ethereum to Scroll via a.DI (Aave Delivery Infrastructure), it is necessary to at least have one valid adapter Ethereum -> Scroll smart contract enabled in the system. + +The first case of message passing Ethereum -> Scroll is the activation proposal for an Aave v3 Scroll pool and consequently, to be able to execute on the Scroll side the payload, the Aave governance should approve in advance the a.DI adapter smart contract. + +This procedure was not required on previous activations like BNB, given that their adapter were pre-configured on the initial a.DI release, but will be needed going forward. + +## Specification + +The proposal payload simply registers a pre-deployed Scroll adapter (with the necessary configurations to communicate with the Scroll a.DI) on the Ethereum a.DI instance. + +This is done by calling the `enableBridgeAdapters()` function on the Ethereum Cross-chain Controller smart contract. + +## References + +- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol) +- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.t.sol) +- [Discussion](https://governance.aave.com/t/arfc-aave-v3-deployment-on-scroll-mainnet/16126/) + +## Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter_20240122.s.sol b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter_20240122.s.sol new file mode 100644 index 000000000..6e916e037 --- /dev/null +++ b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter_20240122.s.sol @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; +import {EthereumScript} from 'aave-helpers/ScriptUtils.sol'; +import {AaveV3Ethereum_RegisterADIScrollAdapter_20240122} from './AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol'; + +/** + * @dev Deploy Ethereum + * deploy-command: make deploy-ledger contract=src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter_20240122.s.sol:DeployEthereum chain=mainnet + * verify-command: npx catapulta-verify -b broadcast/RegisterADIScrollAdapter_20240122.s.sol/1/run-latest.json + */ +contract DeployEthereum is EthereumScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Ethereum_RegisterADIScrollAdapter_20240122).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/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter_20240122.s.sol:CreateProposal chain=mainnet + */ +contract CreateProposal is EthereumScript { + function run() external { + // create payloads + PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1); + + // compose actions for validation + IPayloadsControllerCore.ExecutionAction[] + memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); + actionsEthereum[0] = GovV3Helpers.buildAction( + type(AaveV3Ethereum_RegisterADIScrollAdapter_20240122).creationCode + ); + payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); + + // create proposal + vm.startBroadcast(); + GovV3Helpers.createProposal( + vm, + payloads, + GovV3Helpers.ipfsHashFile( + vm, + 'src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md' + ) + ); + } +} diff --git a/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/config.ts b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/config.ts new file mode 100644 index 000000000..b82196602 --- /dev/null +++ b/src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/config.ts @@ -0,0 +1,13 @@ +import {ConfigFile} from '../../generator/types'; +export const config: ConfigFile = { + rootOptions: { + author: 'BGD Labs @bgdlabs', + pools: ['AaveV3Ethereum'], + title: 'Register a.DI Scroll adapter', + shortName: 'RegisterADIScrollAdapter', + date: '20240122', + discussion: '', + snapshot: '', + }, + poolOptions: {AaveV3Ethereum: {configs: {OTHERS: {}}, cache: {blockNumber: 19062723}}}, +};