From c42ed8c7f8329d7d9f67a7715008790a02a09054 Mon Sep 17 00:00:00 2001 From: jordaniza Date: Fri, 8 Mar 2024 17:57:48 +0400 Subject: [PATCH] wip: debugging the build tests --- .env.example | 2 +- packages/contracts/src/TokenVotingSetup.sol | 22 ++++++- .../22_setup-processing.ts | 12 ++-- .../20_integration-testing/test-helpers.ts | 62 ++++++++++++++----- 4 files changed, 72 insertions(+), 26 deletions(-) diff --git a/.env.example b/.env.example index d277cd52..4e144373 100644 --- a/.env.example +++ b/.env.example @@ -1,7 +1,7 @@ # GENERAL ## The network used for testing purposes -NETWORK_NAME="sepolia" # ["mainnet", "sepolia", "polygon", "polygonMumbai", "base", "baseSepolia", "arbitrum", "arbitrumSepolia"] +NETWORK_NAME="polygon" # ["mainnet", "sepolia", "polygon", "polygonMumbai", "base", "baseSepolia", "arbitrum", "arbitrumSepolia"] # CONTRACTS diff --git a/packages/contracts/src/TokenVotingSetup.sol b/packages/contracts/src/TokenVotingSetup.sol index 81b17d9f..c85fa582 100644 --- a/packages/contracts/src/TokenVotingSetup.sol +++ b/packages/contracts/src/TokenVotingSetup.sol @@ -15,7 +15,7 @@ import {GovernanceWrappedERC20} from "./ERC20/governance/GovernanceWrappedERC20. import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol"; import {PermissionLib} from "@aragon/osx-commons-contracts/src/permission/PermissionLib.sol"; import {IPluginSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/IPluginSetup.sol"; -import {PluginSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/PluginSetup.sol"; +import {PluginUpgradeableSetup} from "@aragon/osx-commons-contracts/src/plugin/setup/PluginUpgradeableSetup.sol"; import {MajorityVotingBase} from "./MajorityVotingBase.sol"; import {TokenVoting} from "./TokenVoting.sol"; @@ -27,7 +27,7 @@ import {ProxyLib} from "@aragon/osx-commons-contracts/src/utils/deployment/Proxy /// @notice The setup contract of the `TokenVoting` plugin. /// @dev v1.3 (Release 1, Build 3) /// @custom:security-contact sirt@aragon.org -contract TokenVotingSetup is PluginSetup { +contract TokenVotingSetup is PluginUpgradeableSetup { using Address for address; using Clones for address; using ERC165Checker for address; @@ -79,7 +79,7 @@ contract TokenVotingSetup is PluginSetup { constructor( GovernanceERC20 _governanceERC20Base, GovernanceWrappedERC20 _governanceWrappedERC20Base - ) PluginSetup(address(new TokenVoting())) { + ) PluginUpgradeableSetup(address(new TokenVoting())) { tokenVotingBase = TokenVoting(IMPLEMENTATION); governanceERC20Base = address(_governanceERC20Base); governanceWrappedERC20Base = address(_governanceWrappedERC20Base); @@ -208,6 +208,22 @@ contract TokenVotingSetup is PluginSetup { preparedSetupData.permissions = permissions; } + /// @inheritdoc IPluginSetup + /// @dev Nothing needs to happen for the update. + function prepareUpdate( + address _dao, + uint16 _currentBuild, + SetupPayload calldata _payload + ) + external + pure + override + returns (bytes memory initData, PreparedSetupData memory preparedSetupData) + // solhint-disable-next-line no-empty-blocks + { + + } + /// @inheritdoc IPluginSetup function prepareUninstallation( address _dao, diff --git a/packages/contracts/test/20_integration-testing/22_setup-processing.ts b/packages/contracts/test/20_integration-testing/22_setup-processing.ts index 93778eac..29ec23fa 100644 --- a/packages/contracts/test/20_integration-testing/22_setup-processing.ts +++ b/packages/contracts/test/20_integration-testing/22_setup-processing.ts @@ -1,10 +1,8 @@ import {METADATA, VERSION} from '../../plugin-settings'; -import {governance} from '../../typechain/@openzeppelin/contracts-upgradeable'; import {getProductionNetworkName, findPluginRepo} from '../../utils/helpers'; import { DEFAULT_VOTING_SETTINGS, TokenVotingSettings, - spreadSettings, } from '../test-utils/token-voting-constants'; import { GovernanceERC20__factory, @@ -24,10 +22,8 @@ import { import { DAO_PERMISSIONS, PLUGIN_SETUP_PROCESSOR_PERMISSIONS, - TIME, UnsupportedNetworkError, getNamedTypesFromMetadata, - pctToRatio, } from '@aragon/osx-commons-sdk'; import { PluginSetupProcessor, @@ -134,7 +130,7 @@ async function fixture(): Promise { }; } -describe(`PluginSetup processing on network '${productionNetworkName}'`, function () { +describe.only(`PluginSetup processing on network '${productionNetworkName}'`, function () { it('installs & uninstalls the current build with a token', async () => { const { alice, @@ -216,7 +212,7 @@ describe(`PluginSetup processing on network '${productionNetworkName}'`, functio }); it('installs & uninstalls the current build without a token', async () => { - const {alice, bob, deployer, psp, dao, pluginSetupRefLatestBuild} = + const {alice, deployer, psp, dao, pluginSetupRefLatestBuild} = await loadFixture(fixture); // Grant deployer all required permissions @@ -288,7 +284,7 @@ describe(`PluginSetup processing on network '${productionNetworkName}'`, functio ); }); - it.only('updates from build 1 to the current build', async () => { + it('updates from build 1 to the current build', async () => { const { deployer, psp, @@ -316,7 +312,7 @@ describe(`PluginSetup processing on network '${productionNetworkName}'`, functio ); }); - it('updates from build 2 to the current build', async () => { + it.only('updates from build 2 to the current build', async () => { const { deployer, psp, diff --git a/packages/contracts/test/20_integration-testing/test-helpers.ts b/packages/contracts/test/20_integration-testing/test-helpers.ts index 6d177fcc..08d1d263 100644 --- a/packages/contracts/test/20_integration-testing/test-helpers.ts +++ b/packages/contracts/test/20_integration-testing/test-helpers.ts @@ -1,7 +1,7 @@ import {METADATA, VERSION} from '../../plugin-settings'; import { IPlugin, - PluginSetup__factory, + PluginUpgradeableSetup__factory, ProxyFactory__factory, } from '../../typechain'; import {ProxyCreatedEvent} from '../../typechain/@aragon/osx-commons-contracts/src/utils/deployment/ProxyFactory'; @@ -153,6 +153,7 @@ export async function updatePlugin( pluginSetupRefUpdate.pluginSetupRepo ); + console.log('2a'); const prepareTx = await psp.connect(signer).prepareUpdate(dao.address, { currentVersionTag: pluginSetupRefCurrent.versionTag, newVersionTag: pluginSetupRefUpdate.versionTag, @@ -170,7 +171,7 @@ export async function updatePlugin( ); const preparedPermissions = preparedEvent.args.preparedSetupData.permissions; - + console.log('2b'); await checkPermissions( preparedPermissions, dao, @@ -178,7 +179,7 @@ export async function updatePlugin( signer, PLUGIN_SETUP_PROCESSOR_PERMISSIONS.APPLY_UPDATE_PERMISSION_ID ); - + console.log('2c'); const applyTx = await psp.connect(signer).applyUpdate(dao.address, { plugin: plugin.address, pluginSetupRef: pluginSetupRefUpdate, @@ -186,6 +187,7 @@ export async function updatePlugin( permissions: preparedPermissions, helpersHash: hashHelpers(preparedEvent.args.preparedSetupData.helpers), }); + console.log('2d'); const appliedEvent = await findEvent( applyTx, @@ -285,7 +287,7 @@ export async function updateFromBuildTest( ); // Check that the implementation of the plugin proxy matches the latest build - const implementationBuild1 = await PluginSetup__factory.connect( + const implementationBuild1 = await PluginUpgradeableSetup__factory.connect( ( await pluginRepo['getVersion((uint8,uint16))']( pluginSetupRefBuild1.versionTag @@ -294,7 +296,6 @@ export async function updateFromBuildTest( deployer ).implementation(); - console.log('3'); expect(await plugin.implementation()).to.equal(implementationBuild1); // Grant the PSP the permission to upgrade the plugin implementation. @@ -306,7 +307,39 @@ export async function updateFromBuildTest( PLUGIN_UUPS_UPGRADEABLE_PERMISSIONS.UPGRADE_PLUGIN_PERMISSION_ID ); - // Update build 1 to the latest build + // Update build to the latest build + await updatePlugin( + deployer, + psp, + dao, + plugin, + installationResults.preparedEvent.args.preparedSetupData.helpers, + pluginSetupRefBuild1, + pluginSetupRefLatestBuild, + ethers.utils.defaultAbiCoder.encode( + getNamedTypesFromMetadata( + METADATA.build.pluginSetup.prepareUpdate[1].inputs + ), + updateInputs + ) + ); + + await updatePlugin( + deployer, + psp, + dao, + plugin, + installationResults.preparedEvent.args.preparedSetupData.helpers, + pluginSetupRefBuild1, + pluginSetupRefLatestBuild, + ethers.utils.defaultAbiCoder.encode( + getNamedTypesFromMetadata( + METADATA.build.pluginSetup.prepareUpdate[1].inputs + ), + updateInputs + ) + ); + await expect( updatePlugin( deployer, @@ -326,14 +359,15 @@ export async function updateFromBuildTest( ).to.not.be.reverted; // Check that the implementation of the plugin proxy matches the latest build - const implementationLatestBuild = await PluginSetup__factory.connect( - ( - await pluginRepo['getVersion((uint8,uint16))']( - pluginSetupRefLatestBuild.versionTag - ) - ).pluginSetup, - deployer - ).implementation(); + const implementationLatestBuild = + await PluginUpgradeableSetup__factory.connect( + ( + await pluginRepo['getVersion((uint8,uint16))']( + pluginSetupRefLatestBuild.versionTag + ) + ).pluginSetup, + deployer + ).implementation(); expect(await plugin.implementation()).to.equal(implementationLatestBuild); }