-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: upgrade v8, the priceAuthorityRegistry (#10418)
closes: #10401 ## Description Upgrade the priceAuthorityRegistry ### Security Considerations N/A ### Scaling Considerations N/A ### Documentation Considerations Does need to be mentioned in the upgrade description. ### Testing Considerations As issue #10401 directs, we verify that `quoteWanted()` continues to work. Existing tests in `z:acceptance` verify that prices continue to be received by vaults. ### Upgrade Considerations This should be included in upgrade 19.
- Loading branch information
1 parent
419df4e
commit 1d5cb99
Showing
4 changed files
with
101 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @ts-check | ||
import test from 'ava'; | ||
import '@endo/init/debug.js'; | ||
|
||
import { | ||
getDetailsMatchingVats, | ||
getIncarnation, | ||
} from '@agoric/synthetic-chain'; | ||
|
||
/** | ||
* @file | ||
* A test of upgrading vat-priceAuthority, which is planned to ship in Upgrade 9 | ||
*/ | ||
|
||
test('priceAuthorityRegistry upgrade', async t => { | ||
t.is(await getIncarnation('priceAuthority'), 1); | ||
|
||
const priceAuthorityVats = await getDetailsMatchingVats('priceAuthority'); | ||
t.is(priceAuthorityVats.length, 1); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async ({ publishRef, install }) => | ||
harden({ | ||
sourceSpec: '@agoric/vats/src/proposals/upgrade-paRegistry-proposal.js', | ||
getManifestCall: [ | ||
'getManifestForUpgradingRegistry', | ||
{ | ||
registryRef: publishRef( | ||
install('@agoric/vats/src/vat-priceAuthority.js'), | ||
), | ||
}, | ||
], | ||
}); | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('upgrade-paRegistry', defaultProposalBuilder); | ||
}; |
57 changes: 57 additions & 0 deletions
57
packages/vats/src/proposals/upgrade-paRegistry-proposal.js
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,57 @@ | ||
// @ts-check | ||
import { E } from '@endo/far'; | ||
import { AmountMath } from '@agoric/ertp'; | ||
import { Stable } from '@agoric/internal/src/tokens.js'; | ||
|
||
/** | ||
* @param {BootstrapPowers} powers | ||
* @param {object} options | ||
* @param {{ registryRef: VatSourceRef }} options.options | ||
*/ | ||
export const upgradePriceAuthorityRegistry = async ( | ||
{ | ||
consume: { vatAdminSvc, vatStore, priceAuthority, agoricNames }, | ||
brand: { | ||
consume: { [Stable.symbol]: stableBrandP }, | ||
}, | ||
}, | ||
options, | ||
) => { | ||
const { registryRef } = options.options; | ||
|
||
assert(registryRef.bundleID); | ||
console.log(`PriceAuthorityRegistry BUNDLE ID: `, registryRef.bundleID); | ||
|
||
const [{ adminNode }, stableBrand, atomBrand, bundleCap] = await Promise.all([ | ||
E(vatStore).get('priceAuthority'), | ||
stableBrandP, | ||
E(agoricNames).lookup('brand', 'ATOM'), | ||
E(vatAdminSvc).getBundleCap(registryRef.bundleID), | ||
]); | ||
|
||
await E(adminNode).upgrade(bundleCap, {}); | ||
|
||
const oneATOM = AmountMath.make(atomBrand, 1_000_000n); | ||
const quoteAtom = await E(priceAuthority).quoteGiven(oneATOM, stableBrand); | ||
console.log('paRegistry quote', quoteAtom); | ||
|
||
assert(quoteAtom.quoteAmount.value, 'insist on getting a quote'); | ||
}; | ||
|
||
const par = 'paRegistry'; | ||
export const getManifestForUpgradingRegistry = (_powers, { registryRef }) => ({ | ||
manifest: { | ||
[upgradePriceAuthorityRegistry.name]: { | ||
consume: { | ||
agoricNames: par, | ||
vatAdminSvc: par, | ||
vatStore: par, | ||
priceAuthority: par, | ||
}, | ||
brand: { consume: { [Stable.symbol]: par } }, | ||
}, | ||
}, | ||
options: { | ||
registryRef, | ||
}, | ||
}); |