-
Notifications
You must be signed in to change notification settings - Fork 212
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
Repair vaultUpgrade proposal; also register replacement scaledPriceAuthority #9748
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
567b9fb
feat: repair vaultUpgrade proposal; register scaledPriceAuthority
Chris-Hibbert af752e1
chore: minor cleanups from review
Chris-Hibbert e51ae60
test: A3P only has ATOM and stTIA. drop unknown tokens
Chris-Hibbert 36db8b2
chore: drop excess promise resolution, rotate priceAuthority names
Chris-Hibbert 659c016
chore: use scaledPriceAuthority's installation rather than label
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
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
119 changes: 119 additions & 0 deletions
119
packages/inter-protocol/src/proposals/replace-scaledPriceAuthorities.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,119 @@ | ||
import { makeTracer } from '@agoric/internal'; | ||
import { E } from '@endo/far'; | ||
import { deeplyFulfilled } from '@endo/marshal'; | ||
|
||
import { startScaledPriceAuthority } from './addAssetToVault.js'; | ||
import { scaledPriceFeedName } from './utils.js'; | ||
|
||
const trace = makeTracer('replaceScaledPA', true); | ||
|
||
/** | ||
* @param {BootstrapPowers} powers | ||
* @param {object} config | ||
* @param {object} config.options | ||
*/ | ||
export const replaceScaledPriceAuthority = async (powers, { options }) => { | ||
const { | ||
instance: { produce: produceInstance }, | ||
} = powers; | ||
const { keyword, issuerName = keyword } = options.interchainAssetOptions; | ||
|
||
const spaKit = await startScaledPriceAuthority(powers, { options }); | ||
|
||
const label = scaledPriceFeedName(issuerName); | ||
produceInstance[label].reset(); | ||
|
||
// publish into agoricNames so that others can await its presence. | ||
// This must stay after registerPriceAuthority above so it's evidence of registration. | ||
produceInstance[label].resolve(spaKit.instance); | ||
}; | ||
|
||
/** | ||
* Look up the existing assets known to auctions, and replace the corresponding | ||
* scaledPriceAuthorities. The existing contracts will be left behind to be | ||
* cleaned up later. | ||
* | ||
* @param {ChainBootstrapSpace & BootstrapPowers} powers | ||
* @param {{ options: { scaledPARef: { bundleID: string } } }} options | ||
*/ | ||
export const replaceScaledPriceAuthorities = async (powers, { options }) => { | ||
trace('start'); | ||
const { | ||
consume: { agoricNamesAdmin, contractKits: contractKitsP, zoe }, | ||
} = powers; | ||
|
||
const { scaledPARef } = options; | ||
|
||
const installationsAdmin = E(agoricNamesAdmin).lookupAdmin('installation'); | ||
const [spaInstallation, contractKits] = await Promise.all([ | ||
E(E(installationsAdmin).readonly()).lookup('scaledPriceAuthority'), | ||
contractKitsP, | ||
]); | ||
|
||
const bundleID = scaledPARef.bundleID; | ||
if (scaledPARef && bundleID) { | ||
await E.when( | ||
E(zoe).installBundleID(bundleID), | ||
installation => | ||
E(installationsAdmin).update('scaledPriceAuthority', installation), | ||
err => | ||
console.error( | ||
`🚨 failed to update scaledPriceAuthority installation`, | ||
err, | ||
), | ||
); | ||
trace('installed scaledPriceAuthority bundle', bundleID); | ||
} | ||
|
||
// Ask Zoe for the installation for each kit's instance, and return all the | ||
// kits where that matches the given installation. | ||
async function selectKitsWithInstallation(kits) { | ||
/** @type {StartedInstanceKit<any>[]} */ | ||
const scaledPAKitMapP = Array.from(kits.values()).map(kit => [ | ||
kit, | ||
E(zoe).getInstallationForInstance(kit.instance), | ||
]); | ||
const scaledPAKitMap = await deeplyFulfilled(harden(scaledPAKitMapP)); | ||
const scaledPAKitEntries = []; | ||
for (const [instance, installation] of scaledPAKitMap) { | ||
if (spaInstallation === installation) { | ||
scaledPAKitEntries.push(instance); | ||
} | ||
} | ||
return scaledPAKitEntries; | ||
} | ||
const scaledPAKitEntries = await selectKitsWithInstallation(contractKits); | ||
|
||
for (const kitEntry of scaledPAKitEntries) { | ||
trace({ kitEntry }); | ||
|
||
const keyword = kitEntry.label.match(/scaledPriceAuthority-(.*)/)[1]; | ||
const interchainAssetOptions = { keyword }; | ||
await replaceScaledPriceAuthority(powers, { | ||
options: { interchainAssetOptions }, | ||
}); | ||
} | ||
}; | ||
|
||
const t = 'replaceScaledPriceAuthority'; | ||
export const getManifestForReplaceScaledPriceAuthorities = async ( | ||
_ign, | ||
upgradeSPAOptions, | ||
) => ({ | ||
manifest: { | ||
[replaceScaledPriceAuthorities.name]: { | ||
consume: { | ||
agoricNamesAdmin: t, | ||
contractKits: t, | ||
priceAuthority: t, | ||
priceAuthorityAdmin: t, | ||
zoe: t, | ||
startUpgradable: t, | ||
}, | ||
instance: { | ||
produce: t, | ||
}, | ||
}, | ||
}, | ||
options: { ...upgradeSPAOptions }, | ||
}); |
78 changes: 0 additions & 78 deletions
78
packages/inter-protocol/src/proposals/upgrade-scaledPriceAuthorities.js
This file was deleted.
Oops, something went wrong.
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.
relying on a label for correctness is awkward.
Did you consider filtering by installation?
I suppose you want the keyword from the label... another way to get that is from the children of
published.priceAuthority
... oh... but vstorage is write-only on chain. What a pain.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 agree. There seemed few enough vats at present that I could verify this produced the correct list. A slightly longer or more dynamic list and I'd have tried to find a better way.
I didn't, but it's a good idea. Added.