Skip to content

Commit

Permalink
fix: cleanUp
Browse files Browse the repository at this point in the history
  • Loading branch information
EviLord032 committed Apr 11, 2024
1 parent 61fa54e commit df2532c
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 406 deletions.

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions deployments/mainnet/weth/relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default {
}
}
},
// 'AppProxyUpgradeable': {
// artifact: 'contracts/ERC20.sol:ERC20',
// }
'AppProxyUpgradeable': {
artifact: 'contracts/ERC20.sol:ERC20',
}
};
27 changes: 1 addition & 26 deletions plugins/scenario/Runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,49 +97,25 @@ export class Runner<T, U, R> {
// a forker could be added back to the env if needed to support that
let ctx: T = await env.initializer(world);

// console.log({combo, ctx});

try {
// apply each solution in the combo, then check they all still hold
let i = 0
let i = 0;

Check failure on line 103 in plugins/scenario/Runner.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'i' is assigned a value but never used. Allowed unused vars must match /^_/u
for (const solution of combo) {
ctx = (await solution(ctx, world)) || ctx;
// console.log({i, ctx: {
// world: {
// base: (ctx as any).world.base,
// deploymentManager: (ctx as any).world.deploymentManager,
// snapshotDeploymentManager: (ctx as any).world.snapshotDeploymentManager
// },
// actors: {
// admin: (ctx as any).actors.admin,
// pauseGuardian: (ctx as any).actors.pauseGuardian,
// albert: (ctx as any).actors.albert,
// betty: (ctx as any).actors.betty,
// charles: (ctx as any).actors.charles,
// signer: (ctx as any).actors.signer,
// },
// assets: { WETH: (ctx as any).assets.WETH, ezETH: (ctx as any).assets.ezETH, COMP: (ctx as any).assets.COMP }
// }})
i+=1;
}

for (const constraint of constraints) {
// console.log({1: scenario.requirements, ctx, world})
await constraint.check(scenario.requirements, ctx, world);
}

// console.log('after')

// requirements met, run the property
let txnReceipt = await scenario.property(await env.transformer(ctx), ctx, world);
// console.log({txnReceipt})
if (txnReceipt) {
cumulativeGas += txnReceipt.cumulativeGasUsed.toNumber();
// console.log({cumulativeGas})
}
numSolutionSets++;
} catch (e) {
console.log('here', {e})
// TODO: Include the specific solution (set of states) that failed in the result
return this.generateResult(base, scenario, startTime, 0, ++numSolutionSets, e);
} finally {
Expand Down Expand Up @@ -217,7 +193,6 @@ export async function runScenarios(bases: ForkSpec[]) {
console.log(`[${base.name}] Running ${scenario.name} ...`);
try {
const result = await runner.run(scenario, context), N = result.numSolutionSets;
// console.log({result, scenario, context, N})
if (N) {
console.log(`[${base.name}] ... ran ${scenario.name}`);
console.log(`[${base.name}] ⛽ consumed ${result.gasUsed} gas on average over ${pluralize(N, 'solution', 'solutions')}`);
Expand Down
10 changes: 5 additions & 5 deletions scenario/BulkerScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { expectBase, isRewardSupported, isBulkerSupported, getExpectedBaseBalanc
import { exp } from '../test/helpers';

// XXX properly handle cases where asset0 is WETH
scenario.only(
scenario(
'Comet#bulker > (non-WETH base) all non-reward actions in one txn',
{
filter: async (ctx) =>
Expand All @@ -27,9 +27,9 @@ scenario.only(
const baseScale = (await comet.baseScale()).toBigInt();
// console.log('we are here')
const numAssets = await comet.numAssets();

Check failure on line 29 in scenario/BulkerScenario.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

'numAssets' is assigned a value but never used. Allowed unused vars must match /^_/u
console.log({numAssets});
// console.log({numAssets});
// console.log({comet})
console.log({comet: await comet.getAssetInfo(0)});
// console.log({comet: await comet.getAssetInfo(0)});
const { asset: collateralAssetAddress, scale: scaleBN } = await comet.getAssetInfo(0);
const collateralAsset = context.getAssetByAddress(collateralAssetAddress);
const collateralScale = scaleBN.toBigInt();
Expand Down Expand Up @@ -165,10 +165,10 @@ scenario(
);

// XXX properly handle cases where asset0 is WETH
scenario.only(
scenario(
'Comet#bulker > (non-WETH base) all actions in one txn',
{
filter: async (ctx) => await isBulkerSupported(ctx) && await isRewardSupported(ctx) && !matchesDeployment(ctx, [{deployment: 'weth'}, { network: 'linea-goerli' }]),
filter: async (ctx) => await isBulkerSupported(ctx) && await isRewardSupported(ctx) && !matchesDeployment(ctx, [{deployment: 'weth'}, { network: 'linea-goerli' }, {deployment: 'weth-lrt', network: 'mainnet'}]),
supplyCaps: {
$asset0: 3000,
},
Expand Down
10 changes: 0 additions & 10 deletions scenario/ConfiguratorScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,9 @@ import { expectRevertCustom } from './utils';
import { expect } from 'chai';


//
scenario('upgrade governor', {}, async ({ comet, configurator, timelock, actors }, context) => {
const { admin, albert } = actors;

console.log({admin, albert})
console.log({1: await comet.governor()})
console.log({2: timelock.address})
console.log({3: (await configurator.getConfiguration(comet.address))})
console.log({4: (await configurator.getConfiguration(comet.address)).governor})
console.log({5: configurator.address})
console.log({6: comet.address})


expect(await comet.governor()).to.equal(timelock.address);
expect((await configurator.getConfiguration(comet.address)).governor).to.equal(timelock.address);

Expand Down
2 changes: 0 additions & 2 deletions scenario/GovernanceScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ scenario('upgrade Comet implementation and initialize', {filter: async (ctx) =>
// 1. Set the new factory address in Configurator
// 2. Deploy and upgrade to the new implementation of Comet
// 3. Call initialize(address) on the new version of Comet
console.log('x')
const setFactoryCalldata = utils.defaultAbiCoder.encode(['address', 'address'], [comet.address, cometModifiedFactory.address]);
const deployAndUpgradeToCalldata = utils.defaultAbiCoder.encode(['address', 'address'], [configurator.address, comet.address]);
const initializeCalldata = utils.defaultAbiCoder.encode(['address'], [constants.AddressZero]);
Expand All @@ -28,7 +27,6 @@ scenario('upgrade Comet implementation and initialize', {filter: async (ctx) =>
['setFactory(address,address)', 'deployAndUpgradeTo(address,address)', 'initialize(address)'],
[setFactoryCalldata, deployAndUpgradeToCalldata, initializeCalldata]
);
console.log('xxx')
// LiquidatorPoints.numAbsorbs for address ZERO should now be set as UInt32.MAX
expect((await comet.liquidatorPoints(constants.AddressZero)).numAbsorbs).to.be.equal(2 ** 32 - 1);
});
Expand Down
3 changes: 2 additions & 1 deletion scenario/LiquidationBotScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ scenario(
},
};

scenario.only(
scenario(
`LiquidationBot > reverts when price slippage is too high`,
{
upgrade: {
Expand Down Expand Up @@ -797,6 +797,7 @@ scenario(

const baseToken = await comet.baseToken();
const { asset: collateralAssetAddress } = await comet.getAssetInfo(0);

const initialRecipientBalance = await betty.getErc20Balance(baseToken);
const [initialNumAbsorbs, initialNumAbsorbed] = await comet.liquidatorPoints(betty.address);

Expand Down
4 changes: 0 additions & 4 deletions scenario/WithdrawScenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,9 @@ scenario(
},
async ({ comet, actors }, context) => {
const { albert } = actors;
console.log('before')
const { asset: asset0Address, scale: scaleBN } = await comet.getAssetInfo(0);
console.log({asset0Address, scaleBN})
const collateralAsset = context.getAssetByAddress(asset0Address);
console.log({collateralAsset})
const scale = scaleBN.toBigInt();
console.log({scale})

await expectRevertCustom(
albert.withdrawAsset({
Expand Down
2 changes: 0 additions & 2 deletions scenario/constraints/CometBalanceConstraint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ export class CometBalanceConstraint<T extends CometContext, R extends Requiremen
const cometBalance = (await comet.collateralBalanceOf(actor.address, asset.address)).toBigInt();
const decimals = await asset.token.decimals();
const toTransfer = getToTransferAmount(amount, cometBalance, decimals);
console.log({actor, amount, cometBalance, decimals, toTransfer})
if (toTransfer > 0) {
// Case: Supply asset
// 1. Source tokens to user
console.log({toTransfer, 1: asset.address, 2: actor.address})
await context.sourceTokens(toTransfer, asset.address, actor.address);
// 2. Supply tokens to Comet
// Note: but will interest rates cause supply/borrow to not exactly match the desired amount?
Expand Down
9 changes: 0 additions & 9 deletions scenario/context/CometContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ export class CometContext {
}

async sourceTokens(amount: number | bigint, asset: CometAsset | string, recipient: AddressLike) {
console.log('NEEDED',{ amount: amount.toString(), asset, recipient});
const { world } = this;
const recipientAddress = resolveAddress(recipient);
const cometAsset = typeof asset === 'string' ? this.getAssetByAddress(asset) : asset;
Expand All @@ -282,21 +281,13 @@ export class CometContext {
if (amountRemaining != 0n) {
// Source from logs (expensive, in terms of node API limits)
debug('Source Tokens: sourcing from logs...', amountRemaining, cometAsset.address);
console.log({
// dm: this.world.deploymentManager,
amount: amountRemaining,
asset: cometAsset.address,
address: recipientAddress,
blacklist: [comet.address],
});
await sourceTokens({
dm: this.world.deploymentManager,
amount: amountRemaining,
asset: cometAsset.address,
address: recipientAddress,
blacklist: [comet.address],
});
console.log('DOSHOL');
}
}

Expand Down
22 changes: 2 additions & 20 deletions src/deploy/Network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export async function deployNetworkComet(
} = await getConfiguration(deploymentManager, configOverrides);

/* Deploy contracts */

const cometAdmin = await deploymentManager.deploy(
'cometAdmin',
'CometProxyAdmin.sol',
Expand All @@ -139,7 +140,6 @@ export async function deployNetworkComet(
name32: ethers.utils.formatBytes32String(name),
symbol32: ethers.utils.formatBytes32String(symbol)
};

const cometExt = await deploymentManager.deploy(
'comet:implementation:implementation',
'CometExt.sol',
Expand Down Expand Up @@ -178,31 +178,20 @@ export async function deployNetworkComet(
assetConfigs,
};

// console.log({configuration})
// console.log('tmpCometImpl')

const tmpCometImpl = await deploymentManager.deploy(
'comet:implementation',
'Comet.sol',
[configuration],
maybeForce(),
);

// console.log('tmpCometImpl')

// console.log('before proxy deploy')

// console.log('cometProxy')
const cometProxy = await deploymentManager.deploy(
'comet',
'vendor/proxy/transparent/TransparentUpgradeableProxy.sol',
[tmpCometImpl.address, cometAdmin.address, []], // NB: temporary implementation contract
maybeForce(),
);

// console.log('cometProxy')
// console.log('configuratorImpl')

const configuratorImpl = await deploymentManager.deploy(
'configurator:implementation',
'Configurator.sol',
Expand All @@ -215,16 +204,13 @@ export async function deployNetworkComet(
// If we deploy a new proxy, we initialize it to the current/new impl
// If its an existing proxy, the impl we got for the alias must already be current
// In other words, we shan't have deployed an impl in the last step unless there was no proxy too
// console.log('configuratorProxy', configuratorImpl.address, cometAdmin.address, (await configuratorImpl.populateTransaction.initialize(admin.address)).data) // 0x316f9708bB98af7dA9c68C1C3b5e79039cD336E3
const configuratorProxy = await deploymentManager.deploy(
'configurator',
'ConfiguratorProxy.sol',
[configuratorImpl.address, cometAdmin.address, (await configuratorImpl.populateTransaction.initialize(admin.address)).data],
maybeForce()
);

// console.log('configuratorProxy', configuratorProxy.address)

const rewards = await deploymentManager.deploy(
'rewards',
'CometRewards.sol',
Expand All @@ -237,7 +223,6 @@ export async function deployNetworkComet(
// Now configure the configurator and actually deploy comet
// Note: the success of these calls is dependent on who the admin is and if/when its been transferred
// scenarios can pass in an impersonated signer, but real deploys may require proposals for some states
// console.log('configurator')
const configurator = configuratorImpl.attach(configuratorProxy.address);

// Also get a handle for Comet, although it may not *actually* support the interface yet
Expand All @@ -260,7 +245,6 @@ export async function deployNetworkComet(
const $configuratorImpl = await cometAdmin.getProxyImplementation(configurator.address);
const $cometImpl = await cometAdmin.getProxyImplementation(comet.address);

// console.log({$configuratorImpl, $cometImpl})
const isTmpImpl = sameAddress($cometImpl, tmpCometImpl.address);
// Note: these next setup steps may require a follow-up proposal to complete, if we cannot admin here
await deploymentManager.idempotent(
Expand All @@ -280,9 +264,7 @@ export async function deployNetworkComet(
);

await deploymentManager.idempotent(
async () => {
return amAdmin && (isTmpImpl || deploySpec.all || deploySpec.cometMain || deploySpec.cometExt)
},
async () => amAdmin && (isTmpImpl || deploySpec.all || deploySpec.cometMain || deploySpec.cometExt),
async () => {
trace(`Setting configuration in Configurator for ${comet.address} (${isTmpImpl})`);
trace(await wait(configurator.connect(admin).setConfiguration(comet.address, configuration)));
Expand Down

0 comments on commit df2532c

Please sign in to comment.