generated from bgd-labs/bgd-forge-template
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado <[email protected]> * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado <[email protected]> * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado <[email protected]> * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado <[email protected]> * Update src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md Co-authored-by: Ernesto Boado <[email protected]> * fix: use address book libs * fix: added extra scroll ccc test --------- Co-authored-by: Ernesto Boado <[email protected]>
- Loading branch information
Showing
6 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...eV3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
...3Ethereum_RegisterADIScrollAdapter/AaveV3Ethereum_RegisterADIScrollAdapter_20240122.t.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/). |
58 changes: 58 additions & 0 deletions
58
src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/RegisterADIScrollAdapter_20240122.s.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' | ||
) | ||
); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/20240122_AaveV3Ethereum_RegisterADIScrollAdapter/config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}}}, | ||
}; |
f700e63
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foundry report
Build log
Test success 🌈