From fe726847b64948bd69c2b79eb736ac7bdd17c541 Mon Sep 17 00:00:00 2001 From: Cheyenne Atapour Date: Wed, 4 Sep 2024 11:47:27 -0700 Subject: [PATCH] Fix CI (#422) * fix: Remove deploy steward script * fix: Remove old gho steward from tests * fix: Add rpc mainnet env var to ci --- .github/workflows/node.js.yml | 1 + deploy/10_deploy_ghomanager.ts | 29 --- helpers/contract-getters.ts | 5 - tasks/main/gho-testnet-setup.ts | 8 - tasks/testnet-setup/07_add-gho-steward.ts | 36 ---- test/gho-steward.test.ts | 218 ---------------------- test/helpers/make-suite.ts | 6 - 7 files changed, 1 insertion(+), 302 deletions(-) delete mode 100644 deploy/10_deploy_ghomanager.ts delete mode 100644 tasks/testnet-setup/07_add-gho-steward.ts delete mode 100644 test/gho-steward.test.ts diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index f28925b4..4fa8eee9 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -7,6 +7,7 @@ jobs: env: ALCHEMY_KEY: '${{secrets.ALCHEMY_KEY}}' ETH_RPC_URL: 'https://eth-mainnet.g.alchemy.com/v2/${{secrets.ALCHEMY_KEY}}' + RPC_MAINNET: 'https://eth-mainnet.g.alchemy.com/v2/${{secrets.ALCHEMY_KEY}}' strategy: matrix: node-version: diff --git a/deploy/10_deploy_ghomanager.ts b/deploy/10_deploy_ghomanager.ts deleted file mode 100644 index b176f030..00000000 --- a/deploy/10_deploy_ghomanager.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { HardhatRuntimeEnvironment } from 'hardhat/types'; -import { DeployFunction } from 'hardhat-deploy/types'; -import { getPoolAddressesProvider } from '@aave/deploy-v3'; -import { getGhoToken } from '../helpers/contract-getters'; - -const func: DeployFunction = async function ({ - getNamedAccounts, - deployments, -}: HardhatRuntimeEnvironment) { - const { deploy } = deployments; - const { deployer } = await getNamedAccounts(); - - const addressesProvider = await getPoolAddressesProvider(); - const ghoToken = await getGhoToken(); - - const ghoSteward = await deploy('GhoSteward', { - from: deployer, - args: [addressesProvider.address, ghoToken.address, deployer, deployer], - log: true, - }); - console.log(`GHO Steward: ${ghoSteward.address}`); - - return true; -}; - -func.id = 'GhoSteward'; -func.tags = ['GhoSteward', 'full_gho_deploy']; - -export default func; diff --git a/helpers/contract-getters.ts b/helpers/contract-getters.ts index 648d14ff..7f74d19e 100644 --- a/helpers/contract-getters.ts +++ b/helpers/contract-getters.ts @@ -23,8 +23,6 @@ import { VariableDebtToken, StakedAaveV3, GhoFlashMinter, - GhoSteward, - GhoStableDebtToken, } from '../types'; // Prevent error HH9 when importing this file inside tasks or helpers at Hardhat config load @@ -78,9 +76,6 @@ export const getGhoStableDebtToken = async ( address || (await hre.deployments.get('GhoStableDebtToken')).address ); -export const getGhoSteward = async (address?: tEthereumAddress): Promise => - getContract('GhoSteward', address || (await hre.deployments.get('GhoSteward')).address); - export const getBaseImmutableAdminUpgradeabilityProxy = async ( address: tEthereumAddress ): Promise => diff --git a/tasks/main/gho-testnet-setup.ts b/tasks/main/gho-testnet-setup.ts index 15f48086..a457160d 100644 --- a/tasks/main/gho-testnet-setup.ts +++ b/tasks/main/gho-testnet-setup.ts @@ -43,15 +43,7 @@ task('gho-testnet-setup', 'Deploy and Configure Gho').setAction(async (params, h blankSpace(); await hre.run('upgrade-stkAave'); - /***************************************** - * ADD GhoSteward * - ******************************************/ blankSpace(); - - await hre.run('add-gho-steward'); - - console.log(`\nGho Setup Complete!\n`); - await hre.run('print-all-deployments'); }); diff --git a/tasks/testnet-setup/07_add-gho-steward.ts b/tasks/testnet-setup/07_add-gho-steward.ts deleted file mode 100644 index 3fd7854e..00000000 --- a/tasks/testnet-setup/07_add-gho-steward.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { task } from 'hardhat/config'; -import { getACLManager } from '@aave/deploy-v3'; -import { GhoSteward } from '../../../types/src/contracts/facilitators/aave/misc/GhoSteward'; -import { getGhoToken } from '../../helpers/contract-getters'; -import { ethers } from 'ethers'; - -const BUCKET_MANAGER_ROLE = ethers.utils.id('BUCKET_MANAGER_ROLE'); - -task('add-gho-steward', 'Adds ghoSteward poolAdmin role').setAction(async (_, hre) => { - const { ethers } = hre; - - const ghoSteward = (await ethers.getContract('GhoSteward')) as GhoSteward; - const aclArtifact = await getACLManager(); - const addPoolAdminTx = await aclArtifact.addPoolAdmin(ghoSteward.address); - - const addPoolAdminTxReceipt = await addPoolAdminTx.wait(); - const newPoolAdminEvents = addPoolAdminTxReceipt.events?.find((e) => { - return e.event === 'RoleGranted'; - }); - if (newPoolAdminEvents?.args) { - console.log(`Gho steward added as a poolAdmin: ${JSON.stringify(newPoolAdminEvents.args[0])}`); - } else { - throw new Error(`Error at adding entity. Check tx: ${addPoolAdminTx.hash}`); - } - - const ghoToken = await getGhoToken(); - await (await ghoToken.grantRole(BUCKET_MANAGER_ROLE, ghoSteward.address)).wait(); - const added = await ghoToken.hasRole(BUCKET_MANAGER_ROLE, ghoSteward.address); - if (added) { - console.log('Gho steward added as bucketManager'); - } else { - throw new Error(`Error at adding entity ad BUCKET_MANAGER`); - } - - return; -}); diff --git a/test/gho-steward.test.ts b/test/gho-steward.test.ts deleted file mode 100644 index 44e85fe5..00000000 --- a/test/gho-steward.test.ts +++ /dev/null @@ -1,218 +0,0 @@ -import hre from 'hardhat'; -import { expect } from 'chai'; -import { makeSuite, TestEnv } from './helpers/make-suite'; -import { - advanceTimeAndBlock, - impersonateAccountHardhat, - mine, - setBlocktime, - timeLatest, -} from '../helpers/misc-utils'; -import { ONE_ADDRESS } from '../helpers/constants'; -import { ProtocolErrors } from '@aave/core-v3'; -import { evmRevert, evmSnapshot, getPoolConfiguratorProxy } from '@aave/deploy-v3'; -import { BigNumber } from 'ethers'; -import { GhoInterestRateStrategy__factory } from '../types'; - -export const TWO_ADDRESS = '0x0000000000000000000000000000000000000002'; - -makeSuite('Gho Steward End-To-End', (testEnv: TestEnv) => { - let ethers; - - let poolSigner; - let randomSigner; - let poolConfigurator; - - const BUCKET_MANAGER_ROLE = hre.ethers.utils.id('BUCKET_MANAGER_ROLE'); - - before(async () => { - ethers = hre.ethers; - - const { pool } = testEnv; - - poolSigner = await impersonateAccountHardhat(pool.address); - randomSigner = await impersonateAccountHardhat(ONE_ADDRESS); - poolConfigurator = await getPoolConfiguratorProxy(); - }); - - it('Check GhoSteward is PoolAdmin and BucketManager', async function () { - const { gho, ghoSteward, aclManager } = testEnv; - expect(await aclManager.isPoolAdmin(ghoSteward.address)).to.be.equal(true); - expect(await gho.hasRole(BUCKET_MANAGER_ROLE, ghoSteward.address)).to.be.equal(true); - }); - - it('Extends steward expiration', async function () { - const { ghoSteward } = testEnv; - - const expirationTimeBefore = await ghoSteward.getStewardExpiration(); - const newExpirationTime = BigNumber.from(expirationTimeBefore).add( - await ghoSteward.STEWARD_LIFESPAN() - ); - - const ownerAddress = await ghoSteward.owner(); - const owner = await impersonateAccountHardhat(ownerAddress); - await expect(ghoSteward.connect(owner).extendStewardExpiration()) - .to.emit(ghoSteward, 'StewardExpirationUpdated') - .withArgs(expirationTimeBefore, newExpirationTime); - - expect(await ghoSteward.getStewardExpiration()).to.be.eq(newExpirationTime.toNumber()); - }); - - it('Tries to extend steward expiration with no authorization (revert expected)', async function () { - const { ghoSteward, users } = testEnv; - const nonPoolAdmin = users[2]; - - await expect( - ghoSteward.connect(nonPoolAdmin.signer).extendStewardExpiration() - ).to.be.revertedWith('Ownable: caller is not the owner'); - }); - - it('Updates gho variable borrow rate', async function () { - const { ghoSteward, poolAdmin, aaveDataProvider, gho, deployer } = testEnv; - const oldInterestRateStrategyAddress = await aaveDataProvider.getInterestRateStrategyAddress( - gho.address - ); - const oldRate = await GhoInterestRateStrategy__factory.connect( - oldInterestRateStrategyAddress, - deployer.signer - ).getBaseVariableBorrowRate(); - await advanceTimeAndBlock((await ghoSteward.MINIMUM_DELAY()).toNumber()); - await expect(ghoSteward.connect(poolAdmin.signer).updateBorrowRate(oldRate)).to.emit( - poolConfigurator, - 'ReserveInterestRateStrategyChanged' - ); - - expect(await aaveDataProvider.getInterestRateStrategyAddress(gho.address)).not.to.be.equal( - oldInterestRateStrategyAddress - ); - }); - - it('GhoSteward tries to update gho variable borrow rate without PoolAdmin role (revert expected)', async function () { - const { ghoSteward, poolAdmin, aclAdmin, aclManager, aaveDataProvider, deployer, gho } = - testEnv; - - const snapId = await evmSnapshot(); - - const oldInterestRateStrategyAddress = await aaveDataProvider.getInterestRateStrategyAddress( - gho.address - ); - const oldRate = await GhoInterestRateStrategy__factory.connect( - oldInterestRateStrategyAddress, - deployer.signer - ).getBaseVariableBorrowRate(); - await advanceTimeAndBlock((await ghoSteward.MINIMUM_DELAY()).toNumber()); - - expect(await aclManager.connect(aclAdmin.signer).removePoolAdmin(ghoSteward.address)); - expect(await aclManager.isPoolAdmin(ghoSteward.address)).to.be.false; - - await expect(ghoSteward.connect(poolAdmin.signer).updateBorrowRate(oldRate)).to.be.revertedWith( - ProtocolErrors.CALLER_NOT_RISK_OR_POOL_ADMIN - ); - - await evmRevert(snapId); - }); - - it('Updates facilitator bucket', async function () { - const { ghoSteward, poolAdmin, gho, aToken } = testEnv; - - const [oldCapacity] = await gho.getFacilitatorBucket(aToken.address); - await advanceTimeAndBlock((await ghoSteward.MINIMUM_DELAY()).toNumber()); - await expect(ghoSteward.connect(poolAdmin.signer).updateBucketCapacity(oldCapacity.add(1))) - .to.emit(gho, 'FacilitatorBucketCapacityUpdated') - .withArgs(aToken.address, oldCapacity, oldCapacity.add(1)); - }); - - it('GhoSteward tries to update bucket capacity without BucketManager role (revert expected)', async function () { - const { ghoSteward, poolAdmin, gho, deployer, aToken } = testEnv; - - const snapId = await evmSnapshot(); - - const [oldCapacity] = await gho.getFacilitatorBucket(aToken.address); - await advanceTimeAndBlock((await ghoSteward.MINIMUM_DELAY()).toNumber()); - expect(await gho.connect(deployer.signer).revokeRole(BUCKET_MANAGER_ROLE, ghoSteward.address)); - expect(await gho.hasRole(BUCKET_MANAGER_ROLE, ghoSteward.address)).to.be.false; - - await expect( - ghoSteward.connect(poolAdmin.signer).updateBucketCapacity(oldCapacity) - ).to.be.revertedWith( - `AccessControl: account ${ghoSteward.address.toLowerCase()} is missing role ${BUCKET_MANAGER_ROLE}` - ); - - await evmRevert(snapId); - }); - - it('Check permissions of owner modified functions (revert expected)', async () => { - const { users, ghoSteward } = testEnv; - const nonPoolAdmin = users[2]; - - const calls = [ - { fn: 'updateBorrowRate', args: [0] }, - { fn: 'updateBucketCapacity', args: [ONE_ADDRESS] }, - ]; - for (const call of calls) { - await expect( - ghoSteward.connect(nonPoolAdmin.signer)[call.fn](...call.args) - ).to.be.revertedWith('INVALID_CALLER'); - } - }); - - it('RiskCouncil updates both parameters, steward expires, expiration time extends, more updates', async function () { - const { ghoSteward, poolAdmin, gho, aToken, aaveDataProvider, deployer } = testEnv; - - const oldInterestRateStrategyAddress = await aaveDataProvider.getInterestRateStrategyAddress( - gho.address - ); - const oldRate = await GhoInterestRateStrategy__factory.connect( - oldInterestRateStrategyAddress, - deployer.signer - ).getBaseVariableBorrowRate(); - const [oldCapacity] = await gho.getFacilitatorBucket(aToken.address); - await advanceTimeAndBlock((await ghoSteward.MINIMUM_DELAY()).toNumber()); - - // Update Bucket Capacity - await expect(ghoSteward.connect(poolAdmin.signer).updateBucketCapacity(oldCapacity.add(1))); - expect((await ghoSteward.getTimelock()).bucketCapacityLastUpdated).to.be.eq(await timeLatest()); - // Update Borrow Rate - await expect(ghoSteward.connect(poolAdmin.signer).updateBorrowRate(oldRate)); - expect((await ghoSteward.getTimelock()).borrowRateLastUpdated).to.be.eq(await timeLatest()); - - // Advance until expiration - await setBlocktime(await ghoSteward.getStewardExpiration()); - await mine(); - - // Tries to update bucket capacity or borrow rate - await expect( - ghoSteward.connect(poolAdmin.signer).updateBucketCapacity(oldCapacity) - ).to.be.revertedWith('STEWARD_EXPIRED'); - await expect(ghoSteward.connect(poolAdmin.signer).updateBorrowRate(oldRate)).to.be.revertedWith( - 'STEWARD_EXPIRED' - ); - - // Extend - const ownerAddress = await ghoSteward.owner(); - const owner = await impersonateAccountHardhat(ownerAddress); - await expect(ghoSteward.connect(owner).extendStewardExpiration()).to.emit( - ghoSteward, - 'StewardExpirationUpdated' - ); - - // New updates are possible - await expect(ghoSteward.connect(poolAdmin.signer).updateBucketCapacity(oldCapacity.add(1))); - expect((await ghoSteward.getTimelock()).bucketCapacityLastUpdated).to.be.eq(await timeLatest()); - // Update Borrow Rate - await expect(ghoSteward.connect(poolAdmin.signer).updateBorrowRate(oldRate)); - expect((await ghoSteward.getTimelock()).borrowRateLastUpdated).to.be.eq(await timeLatest()); - }); - - it('Deactivate Steward', async function () { - const { gho, ghoSteward, aclManager, deployer } = testEnv; - expect(await aclManager.isPoolAdmin(ghoSteward.address)).to.be.equal(true); - expect(await gho.hasRole(BUCKET_MANAGER_ROLE, ghoSteward.address)).to.be.equal(true); - - expect(await aclManager.connect(deployer.signer).removePoolAdmin(ghoSteward.address)); - expect(await gho.connect(deployer.signer).revokeRole(BUCKET_MANAGER_ROLE, ghoSteward.address)); - - expect(await aclManager.isPoolAdmin(ghoSteward.address)).to.be.equal(false); - expect(await gho.hasRole(BUCKET_MANAGER_ROLE, ghoSteward.address)).to.be.equal(false); - }); -}); diff --git a/test/helpers/make-suite.ts b/test/helpers/make-suite.ts index f9649104..2d45c1cf 100644 --- a/test/helpers/make-suite.ts +++ b/test/helpers/make-suite.ts @@ -19,7 +19,6 @@ import { StakedAaveV3, MintableERC20, GhoFlashMinter, - GhoSteward, } from '../../types'; import { getGhoDiscountRateStrategy, @@ -31,7 +30,6 @@ import { getStakedAave, getMintableErc20, getGhoFlashMinter, - getGhoSteward, getGhoStableDebtToken, } from '../../helpers/contract-getters'; import { @@ -85,7 +83,6 @@ export interface TestEnv { aaveToken: IERC20; flashMinter: GhoFlashMinter; faucetOwner: Faucet; - ghoSteward: GhoSteward; } let HardhatSnapshotId: string = '0x1'; @@ -123,7 +120,6 @@ const testEnv: TestEnv = { aaveToken: {} as IERC20, flashMinter: {} as GhoFlashMinter, faucetOwner: {} as Faucet, - ghoSteward: {} as GhoSteward, } as TestEnv; export async function initializeMakeSuite() { @@ -166,8 +162,6 @@ export async function initializeMakeSuite() { tokenProxyAddresses.variableDebtTokenAddress ); - testEnv.ghoSteward = await getGhoSteward(); - testEnv.aTokenImplementation = await getGhoAToken(); testEnv.stableDebtTokenImplementation = await getGhoStableDebtToken(); testEnv.variableDebtTokenImplementation = await getGhoVariableDebtToken();