From 02a96fa453dcb15a66380098c315df83441512c5 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Thu, 6 Feb 2025 23:32:26 +0200 Subject: [PATCH 1/8] fix: scenarios --- scenario/utils/scenarioHelper.ts | 13 +++++++++++++ src/deploy/index.ts | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/scenario/utils/scenarioHelper.ts b/scenario/utils/scenarioHelper.ts index 30b430b34..0253838e7 100644 --- a/scenario/utils/scenarioHelper.ts +++ b/scenario/utils/scenarioHelper.ts @@ -60,7 +60,20 @@ export function getConfigForScenario(ctx: CometContext) { config.interestSeconds = 110; } + if (ctx.world.base.network === 'arbitrum' && ctx.world.base.deployment === 'usdc') { + config.withdrawAsset = 3500; + } + + if (ctx.world.base.network === 'arbitrum' && ctx.world.base.deployment === 'usdt') { + config.withdrawAsset = 3500; + } + if (ctx.world.base.network === 'arbitrum' && ctx.world.base.deployment === 'usdc.e') { + config.withdrawAsset = 7000; + config.bulkerAsset = 10000; + config.bulkerAsset1 = 10000; + config.transferAsset = 10000; + config.transferAsset1 = 10000; config.liquidationDenominator = 84; config.liquidationBase = 100000; config.liquidationBase1 = 50000; diff --git a/src/deploy/index.ts b/src/deploy/index.ts index bc6b59b2c..39e78f982 100644 --- a/src/deploy/index.ts +++ b/src/deploy/index.ts @@ -138,6 +138,7 @@ export const WHALES = { '0x2A82Ae142b2e62Cb7D10b55E323ACB1Cab663a26', // OP whale '0x8af3827a41c26c7f32c81e93bb66e837e0210d5c', // USDC whale '0xc45A479877e1e9Dfe9FcD4056c699575a1045dAA', // wstETH whale + '0x6e57181D6b4b7c138a6F956AD16DAF4f27FC5E04', // COMP whale ], mantle: [ '0x588846213A30fd36244e0ae0eBB2374516dA836C', // USDe whale @@ -145,6 +146,10 @@ export const WHALES = { '0x651C9D1F9da787688225f49d63ad1623ba89A8D5', // FBTC whale '0xC455fE28a76da80022d4C35A37eB08FF405Eb78f', // FBTC whale '0x524db930F0886CdE7B5FFFc920Aae85e98C2abfb', // FBTC whale + '0x651C9D1F9da787688225f49d63ad1623ba89A8D5', // FBTC whale + '0x72c7d27320e042417506e594697324dB5Fbf334C', // FBTC whale + '0x3880233e78966eb13a9c2881d5f162d646633178', // FBTC whale + '0x233493E9DC68e548AC27E4933A600A3A4682c0c3', // FBTC whale '0xCd83CbBFCE149d141A5171C3D6a0F0fCCeE225Ab', // COMP whale ], }; From 0707d18eedb5db2196c539e6c43e8012103b2017 Mon Sep 17 00:00:00 2001 From: Dmitriy Babenko <159453675+dmitriy-woof-software@users.noreply.github.com> Date: Fri, 7 Feb 2025 00:10:29 -0600 Subject: [PATCH 2/8] Trigger actions --- .github/workflows/deploy-market.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-market.yaml b/.github/workflows/deploy-market.yaml index 4864dddbe..a13798e02 100644 --- a/.github/workflows/deploy-market.yaml +++ b/.github/workflows/deploy-market.yaml @@ -68,7 +68,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 == ''] }} @@ -87,4 +87,4 @@ jobs: git config user.email "<>" git add deployments/\*/roots.json git commit -m "Modified deployment roots from GitHub Actions" - git push origin \ No newline at end of file + git push origin From ff81ff3547ab16c1979c6525342653dab691318f Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Fri, 7 Feb 2025 12:21:12 +0200 Subject: [PATCH 3/8] fix: remove repeatable deployments issue --- plugins/deployment_manager/Deploy.ts | 46 +++++++++++++++++++++------- plugins/deployment_manager/Spider.ts | 5 ++- src/deploy/Network.ts | 4 +-- tasks/deployment_manager/task.ts | 4 +-- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/plugins/deployment_manager/Deploy.ts b/plugins/deployment_manager/Deploy.ts index c4c45570c..01bf459de 100644 --- a/plugins/deployment_manager/Deploy.ts +++ b/plugins/deployment_manager/Deploy.ts @@ -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 { @@ -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, 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( name: string, @@ -105,16 +126,19 @@ export async function deploy( 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); diff --git a/plugins/deployment_manager/Spider.ts b/plugins/deployment_manager/Spider.ts index 62e36570d..3af246c9a 100644 --- a/plugins/deployment_manager/Spider.ts +++ b/plugins/deployment_manager/Spider.ts @@ -1,4 +1,4 @@ -import { Contract } from 'ethers'; +import { Contract, constants } from 'ethers'; import { HardhatRuntimeEnvironment as HRE } from 'hardhat/types'; import { Cache } from './Cache'; @@ -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}`); } diff --git a/src/deploy/Network.ts b/src/deploy/Network.ts index 1d351086c..b3fcfa9c3 100644 --- a/src/deploy/Network.ts +++ b/src/deploy/Network.ts @@ -226,7 +226,7 @@ export async function deployNetworkComet( 'configurator:implementation', 'Configurator.sol', [], - maybeForce(deploySpec.cometMain) + maybeForce() ); // If we deploy a new proxy, we initialize it to the current/new impl @@ -338,5 +338,5 @@ export async function deployNetworkComet( } ); - return { comet, configurator, rewards }; + return { comet, configurator, rewards, cometFactory }; } diff --git a/tasks/deployment_manager/task.ts b/tasks/deployment_manager/task.ts index 5715a19a2..89446812c 100644 --- a/tasks/deployment_manager/task.ts +++ b/tasks/deployment_manager/task.ts @@ -74,7 +74,7 @@ task('deploy', 'Deploys market') maybeForkEnv, { writeCacheToDisk: !simulate || overwrite, // Don't write to disk when simulating, unless overwrite is set - verificationStrategy: 'lazy', + verificationStrategy: simulate? 'lazy' : 'eager', } ); @@ -261,7 +261,7 @@ task('deploy_and_migrate', 'Runs deploy and migration') maybeForkEnv, { writeCacheToDisk: !simulate || overwrite, // Don't write to disk when simulating, unless overwrite is set - verificationStrategy: 'lazy', + verificationStrategy: simulate? 'lazy' : 'eager', } ); From a82a1b0bcc1b880d34379412a0ac28a46f70fc26 Mon Sep 17 00:00:00 2001 From: Mikhailo Shabodyash Date: Fri, 7 Feb 2025 19:27:46 +0200 Subject: [PATCH 4/8] fix: base usds contract support and scroll prepare fix --- .github/workflows/prepare-migration.yaml | 1 + .github/workflows/run-scenarios.yaml | 2 +- deployments/mainnet/usdc/relations.ts | 9 ++++++++- deployments/mainnet/usdc/roots.json | 1 + scenario/SupplyScenario.ts | 2 ++ scenario/utils/isBridgeProposal.ts | 5 ++++- scenario/utils/relayBaseMessage.ts | 6 ++++-- 7 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.github/workflows/prepare-migration.yaml b/.github/workflows/prepare-migration.yaml index 8bb619662..938fc2537 100644 --- a/.github/workflows/prepare-migration.yaml +++ b/.github/workflows/prepare-migration.yaml @@ -14,6 +14,7 @@ on: - base - optimism - mantle + - scroll deployment: description: Deployment Name (e.g. "usdc") required: true diff --git a/.github/workflows/run-scenarios.yaml b/.github/workflows/run-scenarios.yaml index cf4575205..3b4e5131b 100644 --- a/.github/workflows/run-scenarios.yaml +++ b/.github/workflows/run-scenarios.yaml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - bases: [ development, mainnet, mainnet-weth, mainnet-usdt, mainnet-wsteth, mainnet-usds, sepolia-usdc, sepolia-weth, fuji, polygon, polygon-usdt, arbitrum-usdc.e, arbitrum-usdc, arbitrum-weth, arbitrum-usdt, base-usdbc, base-weth, base-usdc, base-aero, base-usds, optimism-usdc, optimism-usdt, optimism-weth, mantle-usde, scroll-usdc] + bases: [ development, mainnet, mainnet-weth, mainnet-usdt, mainnet-wsteth, mainnet-usds, sepolia-usdc, sepolia-weth, fuji, polygon, polygon-usdt, arbitrum-usdc.e, arbitrum-usdc, arbitrum-weth, arbitrum-usdt, base-usdbc, base-weth, base-usdc, base-aero, optimism-usdc, optimism-usdt, optimism-weth, mantle-usde, scroll-usdc] name: Run scenarios env: ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }} diff --git a/deployments/mainnet/usdc/relations.ts b/deployments/mainnet/usdc/relations.ts index 2387c8daa..7efab0f0c 100644 --- a/deployments/mainnet/usdc/relations.ts +++ b/deployments/mainnet/usdc/relations.ts @@ -92,5 +92,12 @@ export default { slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' } } - } + }, + baseL1USDSBridge: { + delegates: { + field: { + slot: '0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc' + } + } + }, }; diff --git a/deployments/mainnet/usdc/roots.json b/deployments/mainnet/usdc/roots.json index de52796a2..bad5faa50 100644 --- a/deployments/mainnet/usdc/roots.json +++ b/deployments/mainnet/usdc/roots.json @@ -11,6 +11,7 @@ "CCTPMessageTransmitter": "0x0a992d191deec32afe36203ad87d7d289a738f81", "baseL1CrossDomainMessenger": "0x866E82a600A1414e583f7F13623F1aC5d58b0Afa", "baseL1StandardBridge": "0x3154Cf16ccdb4C6d922629664174b904d80F2C35", + "baseL1USDSBridge": "0xA5874756416Fa632257eEA380CAbd2E87cED352A", "opL1CrossDomainMessenger": "0x25ace71c97B33Cc4729CF772ae268934F7ab5fA1", "opL1StandardBridge": "0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1", "mantleL1CrossDomainMessenger": "0x676A795fe6E43C17c668de16730c3F690FEB7120", diff --git a/scenario/SupplyScenario.ts b/scenario/SupplyScenario.ts index e12d04a31..04ef7d31c 100644 --- a/scenario/SupplyScenario.ts +++ b/scenario/SupplyScenario.ts @@ -510,6 +510,7 @@ scenario( symbol === 'wstETH' ? /0xc2139725/ : /.^/, symbol === 'WMATIC' ? /Transaction reverted without a reason string/ : /.^/, symbol === 'WPOL' ? /Transaction reverted without a reason string/ : /.^/, + symbol === 'sUSDS' ? /SUsds\/insufficient-allowance/ : /.^/, ] ); } @@ -597,6 +598,7 @@ scenario( symbol === 'wstETH' ? /0x00b284f2/ : /.^/, symbol === 'WMATIC' ? /Transaction reverted without a reason string/ : /.^/, symbol === 'WPOL' ? /Transaction reverted without a reason string/ : /.^/, + symbol === 'sUSDS' ? /SUsds\/insufficient-balance/ : /.^/, ] ); } diff --git a/scenario/utils/isBridgeProposal.ts b/scenario/utils/isBridgeProposal.ts index bcfcb0acb..1f9860bc0 100644 --- a/scenario/utils/isBridgeProposal.ts +++ b/scenario/utils/isBridgeProposal.ts @@ -34,8 +34,11 @@ export async function isBridgeProposal( const baseL1StandardBridge = await governanceDeploymentManager.getContractOrThrow( 'baseL1StandardBridge' ); - const bridgeContracts = [baseL1CrossDomainMessenger.address, baseL1StandardBridge.address]; + const baseL1USDSBridge = await governanceDeploymentManager.getContractOrThrow( + 'baseL1USDSBridge' + ); const targets = openProposal.targets; + const bridgeContracts = [baseL1CrossDomainMessenger.address, baseL1StandardBridge.address, baseL1USDSBridge.address]; return targets.some(t => bridgeContracts.includes(t)); } // case 'linea': { diff --git a/scenario/utils/relayBaseMessage.ts b/scenario/utils/relayBaseMessage.ts index 5f1d19ee2..42f72106c 100644 --- a/scenario/utils/relayBaseMessage.ts +++ b/scenario/utils/relayBaseMessage.ts @@ -4,7 +4,6 @@ import { setNextBaseFeeToZero, setNextBlockTimestamp } from './hreUtils'; import { BigNumber, ethers } from 'ethers'; import { Log } from '@ethersproject/abstract-provider'; import { OpenBridgedProposal } from '../context/Gov'; - /* The Base relayer applies an offset to the message sender. @@ -27,6 +26,7 @@ export default async function relayBaseMessage( const bridgeReceiver = await bridgeDeploymentManager.getContractOrThrow('bridgeReceiver'); const l2CrossDomainMessenger = await bridgeDeploymentManager.getContractOrThrow('l2CrossDomainMessenger'); const l2StandardBridge = await bridgeDeploymentManager.getContractOrThrow('l2StandardBridge'); + const l2USDSBridge = await bridgeDeploymentManager.contract('l2USDSBridge'); const openBridgedProposals: OpenBridgedProposal[] = []; @@ -63,7 +63,9 @@ export default async function relayBaseMessage( // there are two types: // 1. Bridging ERC20 token or ETH // 2. Cross-chain message passing - if (target === l2StandardBridge.address) { + if (target === l2StandardBridge.address || + (l2USDSBridge ? target === l2USDSBridge.address : target.toLowerCase() === '0xee44cdb68D618d58F75d9fe0818B640BD7B8A7B7'.toLowerCase()) + ) { // Bridging ERC20 token const messageWithoutPrefix = message.slice(2); // strip out the 0x prefix const messageWithoutSigHash = '0x' + messageWithoutPrefix.slice(8); From 6788ac6d8c2c637e1fea327f66c96466a839d80d Mon Sep 17 00:00:00 2001 From: dmitriy-woof-software Date: Mon, 10 Feb 2025 22:34:46 -0600 Subject: [PATCH 5/8] update Seacrest commit hash to support scroll network --- .github/workflows/enact-migration.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/enact-migration.yaml b/.github/workflows/enact-migration.yaml index 0e799c055..178c60536 100644 --- a/.github/workflows/enact-migration.yaml +++ b/.github/workflows/enact-migration.yaml @@ -69,7 +69,7 @@ jobs: esac - name: Seacrest - uses: hayesgm/seacrest@5d8e5e3023669e93d197963273ae159ecda9d2b2 + uses: hayesgm/seacrest@42330b57a0554d5b9f4b47b186d483b5e18addbf with: wallet_connect_project_id: ${{ secrets.WALLET_CONNECT_PROJECT_ID }} requested_network: "${{ inputs.network }}" @@ -78,7 +78,7 @@ jobs: if: github.event.inputs.eth_pk == '' - name: Seacrest (governance network) - uses: hayesgm/seacrest@5d8e5e3023669e93d197963273ae159ecda9d2b2 + uses: hayesgm/seacrest@42330b57a0554d5b9f4b47b186d483b5e18addbf with: wallet_connect_project_id: ${{ secrets.WALLET_CONNECT_PROJECT_ID }} requested_network: "${{ env.GOV_NETWORK }}" @@ -91,7 +91,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: '18' + node-version: '16' - name: Install packages run: yarn install --non-interactive --frozen-lockfile From f0db6ddf960e6c32178a1503160414397c8ff4d2 Mon Sep 17 00:00:00 2001 From: dmitriy-woof-software Date: Mon, 10 Feb 2025 22:40:47 -0600 Subject: [PATCH 6/8] feat: update node version to 18 in enact script --- .github/workflows/enact-migration.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/enact-migration.yaml b/.github/workflows/enact-migration.yaml index 178c60536..1953bedfc 100644 --- a/.github/workflows/enact-migration.yaml +++ b/.github/workflows/enact-migration.yaml @@ -91,7 +91,7 @@ jobs: - uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '18' - name: Install packages run: yarn install --non-interactive --frozen-lockfile From 66342008dcc35d3bb076c5c71e0ffbc8fbc37470 Mon Sep 17 00:00:00 2001 From: dmitriy-woof-software Date: Mon, 10 Feb 2025 22:54:33 -0600 Subject: [PATCH 7/8] feat: re-use 24 collaterals comet factory and asset list factory --- ...703_update_comet_to_support_more_collaterals.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts b/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts index 9c96e10e5..c969c888e 100644 --- a/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts +++ b/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts @@ -20,16 +20,16 @@ const USDBC_EXT = '0x2F9E3953b2Ef89fA265f2a32ed9F80D00229125B'; export default migration('1735299703_update_comet_to_support_more_collaterals', { async prepare(deploymentManager: DeploymentManager) { - const _assetListFactory = await deploymentManager.deploy( + // deployed on USDS on Base + const _assetListFactory = await deploymentManager.existing( 'assetListFactory', - 'AssetListFactory.sol', - [] + '0x995e394b8b2437ac8ce61ee0bc610d617962b214' ); - const cometFactoryWithExtendedAssetList = await deploymentManager.deploy( - 'cometFactoryWithExtendedAssetList', - 'CometFactoryWithExtendedAssetList.sol', - [] + // deployed on USDS on Base + const cometFactoryWithExtendedAssetList = await deploymentManager.existing( + 'cometFactory', + '0x3D0bb1ccaB520A66e607822fC55BC921738fAFE3' ); const { comet From acd8af03467187f0c7d8bba47de6d29b6bac477e Mon Sep 17 00:00:00 2001 From: dmitriy-woof-software Date: Mon, 10 Feb 2025 23:09:32 -0600 Subject: [PATCH 8/8] feat: fix prepare --- ...1735299703_update_comet_to_support_more_collaterals.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts b/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts index c969c888e..e90306f5f 100644 --- a/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts +++ b/deployments/base/aero/migrations/1735299703_update_comet_to_support_more_collaterals.ts @@ -27,10 +27,8 @@ export default migration('1735299703_update_comet_to_support_more_collaterals', ); // deployed on USDS on Base - const cometFactoryWithExtendedAssetList = await deploymentManager.existing( - 'cometFactory', - '0x3D0bb1ccaB520A66e607822fC55BC921738fAFE3' - ); + const cometFactoryWithExtendedAssetListAddress = '0x3D0bb1ccaB520A66e607822fC55BC921738fAFE3'; + const { comet } = await deploymentManager.getContracts(); @@ -132,7 +130,7 @@ export default migration('1735299703_update_comet_to_support_more_collaterals', true ); return { - cometFactoryWithExtendedAssetList: cometFactoryWithExtendedAssetList.address, + cometFactoryWithExtendedAssetList: cometFactoryWithExtendedAssetListAddress, newCometExtAERO: _newCometExtAERO.address, newCometExtUSDC: _newCometExtUSDC.address, newCometExtWETH: _newCometExtWETH.address,