{"aip":28,"title":"Polygon Cross-chain Governance Test","status":"Proposed","author":"Steven Valeri (@stevenvaleri)","shortDescription":"Test the Aave Polygon governance bridge contract prior to setting it as owner of the Aave Polygon market","discussions":"N/A","created":"2021-07-30T00:00:00.000Z","updated (*optional)":"N/A","requires (*optional)":"N/A","preview":"## Simple Summary\n\nThe intention of this AIP is to test a …","basename":"AIP-28","description":"\n\n## Simple Summary\n\nThe intention of this AIP is to test a cross-chain transaction workflow that would enable the Ethereum based smart contract for governance for the Aave Protocol (the \"Aave Ethereum Governance\") to control the deployment of the Aave Protocol on Polygon (the \"Aave Polygon market\"). The proposal is written as a transaction that would make updates to a **mock** Aave Polygon market. If approved, the transaction would trigger a cross-chain message, flowing from Aave's Ethereum Governance, to a new contract - the `PolygonBridgeExecutor`. The `PolygonBridgeExecutor` would store the proposed market updates for a delay window, and then allow for the updates to be executed on the **mock** Aave Polygon market.\n\nThis proposal will allow testing the end-to-end crosschain transaction workflow for Polygon market governance using both the Ethereum and Polygon mainnet contracts in a way that cannot be replicated in another manner. This test will support the case in the future to transfer ownership of the Aave Polygon Market to Aave's Ethereum  governance.\n\n**In-Scope:**\nA test of the governance cross-chain bridge functionality on a **mock** Aave Polygon market.\n\n**Out-of-Scope:**\nTransferring ownership of the Aave Polygon Market to the Aave Ethereum Governance \n\n## Abstract\n\nTest an implementation of a cross-chain governance workflow, allowing Aave's Ethereum Governance to execute a transaction updating a **mock** Aave market deployed on Polygon.\n\n## Motivation\n\nBefore anyone in the community or otherwise can make a proposal to transfer ownership of the Aave Polygon market to a cross-chain bridge workflow, it is necessary that any smart contracts be tested as thoroughly as possible. This AIP is a `real world` test using the Aave Ethereum Governance contract to test the cross-chain bridge contracts on a **mock** Aave Polygon Market. The main reasons for testing to this extent are:\n\n+ Cross-chain / bridge transactions are relatively new and complex\n+ The risk of this workflow being deployed and not operating correctly would have a HIGH impact\n\nThe transfer of ownership of the Aave Polygon Market to Aave's Ethereum Governance is **not** in-scope of this AIP, but understanding the motivation behind that desired change is important to understanding the motivation for this test.\n\nThe current owner of the Aave Polygon Market a multi-sig wallet due to the time needed to build a cross-chain governance platform, as well as ensuring security for a new deployment on a new network.\n\nGiven the overarching goal that any deployment of the Aave Protocol be owned by decentralized governance, transferring ownership of the Aave Polygon market contracts to Aave Ethereum Governance, is an important next step. Additionally, we have developed and deployed a cross-chain governance platform aimed at providing a broad solution for cross-chain governance. After appropriate testing (including this AIP) and auditing of the cross-chain bridge contract, anyone can create a future AIP to remove the multi-sig over the Aave Polygon market and transfer ownership of those smart contracts to Aave Ethereum Governance.\n\n## Specification\n\nA detailed specification of the crosschain-bridge contract and workflow is outlined in the repo here\n\nhttps://github.com/Aave/governance-crosschain-bridges\n\nFor this test specifically, the test would flow from Aave Ethereum Governance, through a cross chain transaction to the `PolygonBridgeExecutor` contract. Then after a delay, the proposal would be executed on Polygon to make updates to the **mock** Aave Polygon market.\n\nThe general flow of this test will be\n\n1. Propose cross-chain test transactions (Aave governance-v2)\n2. Vote on cross-chain test transactions (Aave governance-v2)\n3. Queue test transactions\n4. Execute cross-chain test transactions\\\n4a. Execute transaction from Aave Governance (Aave governance-v2)\\\n4b. Bridge the test transactions to Polygon  (Polygon fxPortal and Polygon Inherent Bridge Functionality)\\\n4c. Receive bridged message on Polygon       (Polygon fxPortal and Polygon Inherent Bridge Functionality)\\\n4d. Queue transactions for execution in PolygonBridgeExecutor (Aave governance-crosschain-bridges)\\\n5. Wait for delay\n6. Execute queued transactions in the PolygonBridgeExecutor   (Aave governance-crosschain-bridges)\\\n6a. Turn off borrowing for the **mock** Dai reserve\\\n6b. Transfer POOL_ADMIN rights to a dummy address\\\n6c. Transfer ownership of the **mock** Aave market to a dummy address\\\n7. Confirm the expected updates have been made on **mock** Aave market\n\n## Rationale\n\nThis AIP will not make any actual changes in the current Aave Polygon market ecosystem or in any other deployment of the Aave Protocol. It is merely a test of a contract and workflow that, in the future, could enable the Aave Ethereum Governance to control the Aave Polygon Market.\n\nTesting the contracts that enable this cross-chain bridging as thoroughly as possible, including via this proposed test are rationale, despite their cost, given the critical role the cross-chain bridging will play if deployed and used for cross-chain governance.\n\n## Test Cases\n\nA full suit of tests with 100% coverage is included in the repo https://github.com/Aave/governance-crosschain-bridges. The cross-chain workflow has also successfully been tested on the Goerli-Mumbai test networks.\n\n## Implementation\n\nA mock implementation of this proposed test can be found here:\n\nhttps://github.com/Aave/governance-crosschain-bridges/tree/feat/mainnet-test\n\nAfter setting up the repository: \n\n`npm run hardhat mock-mainnet-proposal-delegate`\nruns on Ethereum fork to makes sure everything is encoded correctly to be submitted for the proposal\n\n\n`npm run hardhat mock-Polygon-test-delegate`\nset a .env variable `Polygon_FORK = \"true\"` to run the test updating the Polygon market via the mainnet PolygonBridgeExecutor on a Polygon fork\n\nTwo helper contracts have been deployed to support this proposal. `PolygonMessageSender` has been deployed on Ethereum and `PolygonMarketUpdate` has been deployed on Polygon.\n\nThis proposal, if executed, calls the function sendMessage() on the `PolygonMessageSender` contract on Ethereum mainnet via a delegatecall. The sendMessage function encodes a delegatecall to the function executeUpate() on the contract `MarketUpdate` deployed on the Polygon network and then sends that encoded action to the `PolygonBridgeExecutor` on the Polygon network via Polygon's FxPortal. When that action is received in the PolygonBridgeExecutor, it will be queued. After a delay, that action can be executed, calling the function executeUpate() which will make three updates to a mock aave market deployed on Polygon:\n\n1. disable the mock dai reserve via the LendingPoolConfigurator contract\n2. Set the pool admin to the address `0x000000000000000000000000000000000000dEaD` via the LendingPoolAddressesProvider contract\n3. Transfer ownership of the pool to the address `0x0000000000000000000000000000000000000001` via the LendingPoolAddressesProvider contract\n\n**Related Contracts:**\n\n*Ethereum PolygonMessageSender Contract*\nPolygonMessageSender: `0xf442C0faE2E9A157cD0202BD63bf9b932D3aa4C8` \\\nhttps://etherscan.io/address/0xf442C0faE2E9A157cD0202BD63bf9b932D3aa4C8#code \\\n\n*Polygon FxPortal Bridge Contracts*\\\nFxRoot: `0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2` \\\nhttps://etherscan.io/address/0xfe5e5D361b2ad62c541bAb87C45a0B9B018389a2#code \\\nStateSender: `0x28e4F3a7f651294B9564800b2D01f35189A5bFbE` \\\nhttps://etherscan.io/address/0x28e4f3a7f651294b9564800b2d01f35189a5bfbe#code \\\nFxChild: `0x8397259c983751DAf40400790063935a11afa28a` \\\nhttps://polygonscan.com/address/0x8397259c983751DAf40400790063935a11afa28a#code\n\n*Polygon Bridge Executor Contracts*\\\nPolygonBridgeExecutor: `0x60966EA42764c7c538Af9763Bc11860eB2556E6B`\\\nhttps://polygonscan.com/address/0xd63b6b5e0f043e9779c784ee1c14ffcbffb98b70#code\n\n*Polygon Market Update*\\\nMarketUpdate: `0x5b494b94faf0bb63254dba26f17483bcf57f6d6a` \\\nhttps://polygonscan.com/address/0x5b494b94faf0bb63254dba26f17483bcf57f6d6a#code\n\n*Mock Polygon Market Contracts*\\\nLendingPoolAddressProviderAddress = `0x240de965908e06a76e1937310627b709b5045bd6`\\\nhttps://polygonscan.com/address/0x240de965908e06a76e1937310627b709b5045bd6#code \\\nLendingPoolConfiguratorAddress (proxy)= `0xd63B6B5E0F043e9779C784Ee1c14fFcBffB98b70` \\\nhttps://polygonscan.com/address/0xd63b6b5e0f043e9779c784ee1c14ffcbffb98b70#writeContract#code \\\nLendingPoolConfiguratorAddress (implementation)= `0xADA061366575324945c7a097F829349acA6C9aB9` \\\nhttps://polygonscan.com/address/0xADA061366575324945c7a097F829349acA6C9aB9#code\n\n\n## Copyright\n\nCopyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).\n"}