Skip to content

Commit

Permalink
update to a new version
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaShWoof committed Feb 7, 2025
1 parent b8aaf31 commit 0ac7f82
Show file tree
Hide file tree
Showing 35 changed files with 437 additions and 314 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-market.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- name: Install packages
run: yarn install --non-interactive --frozen-lockfile
Expand All @@ -69,7 +69,7 @@ jobs:
- name: Run Deploy
run: |
yarn hardhat deploy --network ${{ github.event.inputs.network }} --deployment ${{ github.event.inputs.deployment }} ${{ fromJSON('["", "--simulate"]')[github.event.inputs.simulate == 'true'] }}
env:
env:
DEBUG: true
ETH_PK: "${{ inputs.eth_pk }}"
NETWORK_PROVIDER: ${{ fromJSON('["", "http://localhost:8585"]')[github.event.inputs.eth_pk == ''] }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/enact-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- name: Install packages
run: yarn install --non-interactive --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prepare-migration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- name: Install packages
run: yarn install --non-interactive --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-contract-linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- name: Install packages
run: yarn install --non-interactive --frozen-lockfile && yarn build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version: '16'
node-version: '18'

- name: Install packages
run: yarn install --non-interactive --frozen-lockfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-eslint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version: '16'
node-version: '18'

- name: Install packages
run: yarn install --non-interactive --frozen-lockfile && yarn build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-gas-profiler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- name: Install packages
run: yarn install --non-interactive --frozen-lockfile && yarn build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-scenarios.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: 'yarn'
node-version: '16'
node-version: '18'

- name: Cache Deployments
uses: actions/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-slither.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- uses: actions/setup-python@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'

- name: Install packages
run: yarn install --non-interactive --frozen-lockfile
Expand Down
4 changes: 2 additions & 2 deletions contracts/IGovernorBravo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ interface IGovernorBravo {
function MIN_VOTING_DELAY() external view returns (uint256);
function MIN_PROPOSAL_THRESHOLD() external view returns (uint256);

function comp() external view returns (address);
function token() external view returns (address);
function proposalEta(uint256) external view returns (uint256);
function proposalCount() external view returns (uint256);
function proposals(uint256 proposalId) external view returns (Proposal memory);
function votingDelay() external view returns (uint256);
Expand All @@ -58,7 +59,6 @@ interface IGovernorBravo {
function propose(
address[] memory targets,
uint256[] memory values,
string[] memory signatures,
bytes[] memory calldatas,
string memory description
) external returns (uint256 proposalId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ let newCometExtAddressWETH: string;
let newCometExtAddressUSDCE: string;

const USDCE_COMET = '0xA5EDBDD9646f8dFF606d7448e414884C7d905dCA';
const USDCE_EXT = '0x1B2E88cC7365d90e7E81392432482925BD8437E9';
const USDT_COMET = '0xd98Be00b5D27fc98112BdE293e487f8D4cA57d07';
const USDT_EXT = '0x698A949f3b4f7a5DdE236106F25Fa0eAcA0FcEF1';
const WETH_COMET = '0x6f7D514bbD4aFf3BcD1140B7344b32f063dEe486';
Expand Down Expand Up @@ -108,16 +107,8 @@ export default migration('1735299626_update_comet_to_support_more_collaterals',
true
);

const extensionDelegateUSDCE = new Contract(
USDCE_EXT,
[
'function name() external view returns (string)',
'function symbol() external view returns (string)',
],
await deploymentManager.getSigner()
);
const nameUSDCE = await extensionDelegateUSDCE.name();
const symbolUSDCE = await extensionDelegateUSDCE.symbol();
const nameUSDCE = 'Compound USDCe';
const symbolUSDCE = 'cUSDCev3';

const _newCometExtUSDCE = await deploymentManager.deploy(
'CometExtAssetList',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default migration('1735299799_update_comet_to_support_more_collaterals',
},
];

const description = '# Update USDC, USDT and WETH Comets on Optimism to support more collaterals\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to update 4 Comets to a new version, which supports up to 24 collaterals. This proposal takes the governance steps recommended and necessary to update Compound III USDT, USDC and WETH markets on Optimism. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario).\n\nDetailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/904) and [forum discussion](https://www.comp.xyz/t/increase-amount-of-collaterals-in-comet/5465).\n\n\n## Proposal Actions\n\nThe first action sets the factory to the newly deployed factory, extension delegate to the newly deployed contract and deploys and upgrades Comet to a new version for all 3 comets: cUSDTv3, cUSDCv3 and cWETHv3.';
const description = '# Update USDC, USDT and WETH Comets on Optimism to support more collaterals\n\n## Proposal summary\n\nCompound Growth Program [AlphaGrowth] proposes to update 3 Comets to a new version, which supports up to 24 collaterals. This proposal takes the governance steps recommended and necessary to update Compound III USDT, USDC and WETH markets on Optimism. Simulations have confirmed the market’s readiness, as much as possible, using the [Comet scenario suite](https://github.com/compound-finance/comet/tree/main/scenario).\n\nDetailed information can be found on the corresponding [proposal pull request](https://github.com/compound-finance/comet/pull/904) and [forum discussion](https://www.comp.xyz/t/increase-amount-of-collaterals-in-comet/5465).\n\n\n## Proposal Actions\n\nThe first action sets the factory to the newly deployed factory, extension delegate to the newly deployed contract and deploys and upgrades Comet to a new version for all 3 comets: cUSDTv3, cUSDCv3 and cWETHv3.';
const txn = await deploymentManager.retry(async () =>
trace(
await governor.propose(...(await proposal(mainnetActions, description)))
Expand Down
9 changes: 7 additions & 2 deletions deployments/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ const relationConfigMap: RelationConfigMap = {
governor: {
artifact: 'contracts/IProxy.sol:IProxy',
delegates: {
field: async (governor) => governor.implementation(),
field: {
slot: '0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b',
}
},
relations: {
COMP: {
field: async (governor) => governor.comp(),
field: async (governor) => {
if (governor.address === '0x309a862bbC1A00e45506cB8A802D1ff10004c8C0') return governor.token();
return governor.comp();
},
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion forge/test/Comet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ pragma solidity ^0.8.13;
import "forge-std/Test.sol";
import "../../contracts/Comet.sol";
import "../../contracts/CometConfiguration.sol";
import { CometExtAssetList } from "../../contracts/CometExtAssetList.sol";
import { AssetListFactory } from "../../contracts/AssetListFactory.sol";


contract CometTest is Test {
Comet public comet;
Expand All @@ -12,7 +15,7 @@ contract CometTest is Test {
// XXX
}

function testFailXXX() public {
function test_RevertIf_Condition_XXX() public {
CometConfiguration.AssetConfig[] memory assets = new CometConfiguration.AssetConfig[](0);
CometConfiguration.Configuration memory config =
CometConfiguration.Configuration(address(0),
Expand All @@ -36,6 +39,7 @@ contract CometTest is Test {
0,
0,
assets);
vm.expectRevert();
comet = new Comet(config);
}
}
12 changes: 11 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,17 @@ const config: HardhatUserConfig = {
: { mnemonic: MNEMONIC, accountsBalance: (10n ** 36n).toString() },
// this should only be relied upon for test harnesses and coverage (which does not use viaIR flag)
allowUnlimitedContractSize: true,
hardfork: 'shanghai'
hardfork: 'cancun',
chains: networkConfigs.reduce((acc, { chainId }) => {
if (chainId === 1) return acc;
acc[chainId] = {
hardforkHistory: {
berlin: 1,
london: 2,
},
};
return acc;
}, {}),
},
},

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@
"undici": "^5.21.2"
},
"devDependencies": {
"@nomicfoundation/ethereumjs-rlp": "^5.0.4",
"@arbitrum/sdk": "^3.1.2",
"@compound-finance/hardhat-import": "^1.0.3",
"@ethersproject/experimental": "^5.6.3",
"@ethersproject/experimental": "^5.7.0",
"@nomiclabs/hardhat-ethers": "^2.0.4",
"@nomiclabs/hardhat-etherscan": "3.1.7",
"@safe-global/safe-core-sdk": "^3.3.2",
Expand All @@ -75,7 +76,7 @@
"eslint": "^8.12.0",
"ethers": "^5.7.2",
"fast-glob": "^3.2.7",
"hardhat": "^2.12.2",
"hardhat": "2.22.14",
"hardhat-chai-matchers": "https://github.com/jflatow/hardhat/releases/download/viaIR/nomicfoundation-hardhat-chai-matchers-v1.0.4.tgz",
"hardhat-change-network": "^0.0.7",
"hardhat-contract-sizer": "^2.10.0",
Expand Down
46 changes: 35 additions & 11 deletions plugins/deployment_manager/Deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { putVerifyArgs } from './VerifyArgs';
import { Cache } from './Cache';
import { storeBuildFile } from './ContractMap';
import { BuildFile, TraceFn } from './Types';
import { debug, getPrimaryContract, stringifyJson } from './Utils';
import { debug, getPrimaryContract, stringifyJson, asyncCallWithTimeout } from './Utils';
import { VerifyArgs, verifyContract, VerificationStrategy } from './Verify';

export interface DeployOpts {
Expand All @@ -20,6 +20,27 @@ export interface DeployOpts {
trace?: TraceFn; // the trace fn to use
verificationStrategy?: VerificationStrategy; // strategy for verifying contracts on etherscan
}
/**
* Call an async function with a given amount of retries
* @param fn an async function that takes a signer as an argument. The function takes a signer
* because a new instance of a signer needs to be used on each retry
* @param retries the number of times to retry the function. Default is 7 retries
* @param timeLimit time limit before timeout in milliseconds
* @param wait time to wait between tries in milliseconds
*/
async function retry(fn: () => Promise<any>, retries: number = 7, timeLimit?: number, wait: number = 500) {
try {
return await asyncCallWithTimeout(fn(), timeLimit);
} catch (e) {
if (retries === 0) throw e;

console.warn(`Retrying with retries left: ${retries}, wait: ${wait}, error is: `, e);
await this.resetSignersPendingCounts();

await new Promise(ok => setTimeout(ok, wait));
return retry(fn, retries - 1, timeLimit, wait * 2);
}
}

async function doDeploy<C extends Contract>(
name: string,
Expand Down Expand Up @@ -105,16 +126,19 @@ export async function deploy<C extends Contract>(
address: contract.address,
constructorArguments: deployArgs,
};
if (deployOpts.verificationStrategy === 'lazy') {
// Cache params for verification
await putVerifyArgs(deployOpts.cache, contract.address, verifyArgs);
} else if (deployOpts.verificationStrategy === 'eager') {
await verifyContract(
verifyArgs,
hre,
deployOpts.raiseOnVerificationFailure
);
}

await retry(async () => {
if (deployOpts.verificationStrategy === 'lazy') {
// Cache params for verification
await putVerifyArgs(deployOpts.cache, contract.address, verifyArgs);
} else if (deployOpts.verificationStrategy === 'eager') {
await verifyContract(
verifyArgs,
hre,
deployOpts.raiseOnVerificationFailure
);
}
}, 3, undefined, 5000);

await maybeStoreCache(deployOpts, contract, buildFile);

Expand Down
5 changes: 4 additions & 1 deletion plugins/deployment_manager/Spider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Contract } from 'ethers';
import { Contract, constants } from 'ethers';
import { HardhatRuntimeEnvironment as HRE } from 'hardhat/types';

import { Cache } from './Cache';
Expand Down Expand Up @@ -42,6 +42,9 @@ function maybeStore(alias: Alias, address: Address, into: Aliases): boolean {
if (maybeExists) {
if (maybeExists === address) {
return false;
} else if (maybeExists === constants.AddressZero && address !== constants.AddressZero) {
into.set(alias, address);
return true;
} else {
throw new Error(`Had ${alias} -> ${maybeExists}, not ${address}`);
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/scenario/World.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export class World {
const auxiliaryBase = hre.config.scenario.bases.find(b => b.name === this.base.auxiliaryBase);
this.auxiliaryDeploymentManager = new DeploymentManager(auxiliaryBase.network, auxiliaryBase.deployment, await hreForBase(auxiliaryBase));
this.snapshotAuxiliaryDeploymentManager = this.auxiliaryDeploymentManager;
}
}
await this.deploymentManager.hre.network.provider.send('evm_mine');
}

isRemoteFork(): boolean {
Expand Down
13 changes: 8 additions & 5 deletions plugins/scenario/utils/hreForBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export async function nonForkedHreForBase(base: ForkSpec): Promise<HardhatRuntim
}
},
ctx.tasksDSL.getTaskDefinitions(),
ctx.extendersManager.getExtenders(),
ctx.experimentalHardhatNetworkMessageTraceHooks,
ctx.environment.scopes,
ctx.environmentExtenders,
userConfig
);
}
Expand All @@ -69,6 +69,9 @@ function getBlockRollback(base: ForkSpec){
else if(base.network === 'arbitrum'){
return undefined;
}
else if(base.network === 'base'){
return 200;
}
else
return 280;
}
Expand All @@ -88,7 +91,7 @@ export async function forkedHreForBase(base: ForkSpec): Promise<HardhatRuntimeEn
const provider = new ethers.providers.JsonRpcProvider(baseNetwork.url);

// noNetwork otherwise
if(!base.blockNumber && baseNetwork.url)
if(!base.blockNumber && baseNetwork.url && getBlockRollback(base) !== undefined)
base.blockNumber = await provider.getBlockNumber() - getBlockRollback(base); // arbitrary number of blocks to go back

if (!baseNetwork) {
Expand Down Expand Up @@ -123,8 +126,8 @@ export async function forkedHreForBase(base: ForkSpec): Promise<HardhatRuntimeEn
forkedConfig,
hardhatArguments,
ctx.tasksDSL.getTaskDefinitions(),
ctx.extendersManager.getExtenders(),
ctx.experimentalHardhatNetworkMessageTraceHooks,
ctx.environment.scopes,
ctx.environmentExtenders,
userConfig
);
}
Expand Down
3 changes: 2 additions & 1 deletion scenario/AllowBySigScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ scenario(

expect(await comet.isAllowed(albert.address, betty.address)).to.be.false;

await context.mineBlocks(1); // note: in case init took a while
// await context.mineBlocks(1); // note: in case init took a while
await context.world.deploymentManager.hre.network.provider.send('evm_mine', []);
const nonce = await comet.userNonce(albert.address);
const expiry = (await world.timestamp()) + 10000;

Expand Down
4 changes: 3 additions & 1 deletion scenario/AllowScenario.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { scenario } from './context/CometContext';
import { expect } from 'chai';

scenario('Comet#allow > allows a user to authorize a manager', {}, async ({ comet, actors }) => {
scenario('Comet#allow > allows a user to authorize a manager', {}, async ({ comet, actors }, context) => {
const { albert, betty } = actors;

await context.world.deploymentManager.hre.network.provider.send('evm_mine', []);

const txn = await albert.allow(betty, true);

expect(await comet.isAllowed(albert.address, betty.address)).to.be.true;
Expand Down
Loading

0 comments on commit 0ac7f82

Please sign in to comment.