-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: contractGovernor can change params after contract is upgraded #10163
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e747531
fix: contractGovernor can change params after contract is upgraded
Chris-Hibbert 5aeac6d
feat: upgrade auction and vaults to use the new governor
Chris-Hibbert 6161427
refactor: use restoreRef() in manifests to install bundles
Chris-Hibbert 4034ab3
chore: lint wants .js extension on imports; drop unused
Chris-Hibbert 25d3578
chore: renaming
Chris-Hibbert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
packages/boot/test/bootstrapTests/updateUpgradedVaultParams.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
/** | ||
* @file The goal of this test is to show that #9982 is fixed | ||
* We change a parameter so that provideParamGovernance() is called once, and | ||
* paramGoverance has been set. Then upgrade vaultFactory, so any ephemeral | ||
* objects from the contract held by the governor are gone, then try to change | ||
* param again, to show that the bug is fixedd. | ||
*/ | ||
import { test as anyTest } from '@agoric/zoe/tools/prepare-test-env-ava.js'; | ||
|
||
import type { TestFn } from 'ava'; | ||
import { makeAgoricNamesRemotesFromFakeStorage } from '@agoric/vats/tools/board-utils'; | ||
import { Fail } from '@endo/errors'; | ||
|
||
import { makeSwingsetTestKit } from '../../tools/supports.js'; | ||
import { | ||
makeGovernanceDriver, | ||
makeWalletFactoryDriver, | ||
} from '../../tools/drivers.js'; | ||
import { updateVaultManagerParams } from '../tools/changeVaultParams.js'; | ||
|
||
const makeDefaultTestContext = async t => { | ||
console.time('DefaultTestContext'); | ||
const swingsetTestKit = await makeSwingsetTestKit(t.log); | ||
|
||
const { runUtils, storage } = swingsetTestKit; | ||
console.timeLog('DefaultTestContext', 'swingsetTestKit'); | ||
const { EV } = runUtils; | ||
|
||
// Wait for ATOM to make it into agoricNames | ||
await EV.vat('bootstrap').consumeItem('vaultFactoryKit'); | ||
console.timeLog('DefaultTestContext', 'vaultFactoryKit'); | ||
|
||
// has to be late enough for agoricNames data to have been published | ||
const agoricNamesRemotes = makeAgoricNamesRemotesFromFakeStorage( | ||
swingsetTestKit.storage, | ||
); | ||
agoricNamesRemotes.brand.ATOM || Fail`ATOM missing from agoricNames`; | ||
console.timeLog('DefaultTestContext', 'agoricNamesRemotes'); | ||
|
||
const walletFactoryDriver = await makeWalletFactoryDriver( | ||
runUtils, | ||
storage, | ||
agoricNamesRemotes, | ||
); | ||
console.timeLog('DefaultTestContext', 'walletFactoryDriver'); | ||
|
||
console.timeEnd('DefaultTestContext'); | ||
|
||
const gd = await makeGovernanceDriver( | ||
swingsetTestKit, | ||
agoricNamesRemotes, | ||
walletFactoryDriver, | ||
[ | ||
'agoric1ldmtatp24qlllgxmrsjzcpe20fvlkp448zcuce', | ||
'agoric140dmkrz2e42ergjj7gyvejhzmjzurvqeq82ang', | ||
'agoric1w8wktaur4zf8qmmtn3n7x3r0jhsjkjntcm3u6h', | ||
], | ||
); | ||
|
||
return { ...swingsetTestKit, agoricNamesRemotes, gd }; | ||
}; | ||
|
||
const test = anyTest as TestFn< | ||
Awaited<ReturnType<typeof makeDefaultTestContext>> | ||
>; | ||
|
||
test.before(async t => { | ||
t.context = await makeDefaultTestContext(t); | ||
}); | ||
test.after.always(t => { | ||
return t.context.shutdown && t.context.shutdown(); | ||
}); | ||
|
||
const outcome = { | ||
bids: [{ payouts: { Bid: 0, Collateral: 1.800828 } }], | ||
}; | ||
|
||
test('restart vaultFactory, change params', async t => { | ||
const { runUtils, gd, agoricNamesRemotes } = t.context; | ||
const { EV } = runUtils; | ||
const vaultFactoryKit = | ||
await EV.vat('bootstrap').consumeItem('vaultFactoryKit'); | ||
|
||
const { ATOM } = agoricNamesRemotes.brand; | ||
ATOM || Fail`ATOM missing from agoricNames`; | ||
|
||
const reserveKit = await EV.vat('bootstrap').consumeItem('reserveKit'); | ||
const bootstrapVat = EV.vat('bootstrap'); | ||
const electorateCreatorFacet = await bootstrapVat.consumeItem( | ||
'economicCommitteeCreatorFacet', | ||
); | ||
|
||
const poserInvitation = await EV(electorateCreatorFacet).getPoserInvitation(); | ||
const creatorFacet1 = await EV.get(reserveKit).creatorFacet; | ||
const shortfallInvitation = | ||
await EV(creatorFacet1).makeShortfallReportingInvitation(); | ||
|
||
const zoe: ZoeService = await EV.vat('bootstrap').consumeItem('zoe'); | ||
const brands = await EV(zoe).getBrands(vaultFactoryKit.instance); | ||
const getDebtLimitValue = async () => { | ||
const params = await EV(vaultFactoryKit.publicFacet).getGovernedParams({ | ||
collateralBrand: brands.ATOM, | ||
}); | ||
|
||
// @ts-expect-error getGovernedParams doesn't declare these fields | ||
return params.DebtLimit.value.value; | ||
}; | ||
|
||
// Change the value of a param before the upgrade so paramGovernance is set | ||
t.is(await getDebtLimitValue(), 1_000_000_000n); | ||
await updateVaultManagerParams(t, gd, ATOM, 50_000_000n); | ||
|
||
t.is(await getDebtLimitValue(), 50_000_000n); | ||
|
||
const privateArgs = { | ||
// @ts-expect-error cast XXX missing from type | ||
...vaultFactoryKit.privateArgs, | ||
initialPoserInvitation: poserInvitation, | ||
initialShortfallInvitation: shortfallInvitation, | ||
}; | ||
|
||
const vfAdminFacet = await EV( | ||
vaultFactoryKit.governorCreatorFacet, | ||
).getAdminFacet(); | ||
|
||
t.log('awaiting VaultFactory restartContract'); | ||
const upgradeResult = await EV(vfAdminFacet).restartContract(privateArgs); | ||
t.deepEqual(upgradeResult, { incarnationNumber: 1 }); | ||
|
||
await updateVaultManagerParams(t, gd, ATOM, 150_000_000n); | ||
t.is(await getDebtLimitValue(), 150_000_000n); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're installing the governor from two places. So we'll get 2 installation handles.
Does it matter whether the governor for VaultFactory has an identical installation handle to the one from the auctioneer instance? Does it matter that only one of them can be checked against
agoricNames.installation
to see whether it's the "right" one?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We discussed the possibility of only using this mechanism in 1 place and waiting for it in the other. (take care to not just wait for
consume.installation.contractGovernor
, since that's already resolved)It doesn't seem that either option is catastrophic, so I'll leave it at your discretion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a separate issue: #10248. I'd like to fix it before this gets to the chain, but I think it's second priority, and there's other work to get done.