-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8821 from Agoric/8113-provision-names
fix(provisioning): export useful namesByAddress
- Loading branch information
Showing
4 changed files
with
91 additions
and
2 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
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,23 @@ | ||
// @ts-check | ||
|
||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { getManifestForProvisioning } from '@agoric/vats/src/proposals/namesByAddress-fix-proposal.js'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */ | ||
export const defaultProposalBuilder = async ({ publishRef, install }) => | ||
harden({ | ||
sourceSpec: '@agoric/vats/src/proposals/namesByAddress-fix-proposal.js', | ||
getManifestCall: [ | ||
getManifestForProvisioning.name, | ||
{ | ||
provisioningRef: publishRef( | ||
install('@agoric/vats/src/vat-provisioning.js'), | ||
), | ||
}, | ||
], | ||
}); | ||
|
||
export default async (homeP, endowments) => { | ||
const { writeCoreProposal } = await makeHelpers(homeP, endowments); | ||
await writeCoreProposal('gov-provisioning', defaultProposalBuilder); | ||
}; |
55 changes: 55 additions & 0 deletions
55
packages/vats/src/proposals/namesByAddress-fix-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,55 @@ | ||
/** @file core eval proposal to fix namesByAddress by upgrading vat-provisioning */ | ||
import { E } from '@endo/far'; | ||
|
||
const vatUpgrade = /** @type {const} */ ({ | ||
name: 'provisioning', | ||
opts: { | ||
// vatParameters not used by provisioning vat | ||
upgradeMessage: 'fix namesByAddress', | ||
}, | ||
}); | ||
|
||
/** | ||
* Upgrade provisioning vat and replace namesByAddress in bootstrap promise | ||
* space | ||
* | ||
* @param {BootstrapPowers} powers | ||
* @param {object} options | ||
* @param {{ provisioningRef: { bundleID: string } }} options.options | ||
* | ||
* @typedef {string} BundleID | ||
*/ | ||
export const upgradeProvisioningVat = async (powers, options) => { | ||
console.log('upgradeProvisioningVat...'); | ||
const { vatStore, vatAdminSvc } = powers.consume; | ||
const { namesByAddress: resolver } = powers.produce; | ||
|
||
const { name, opts } = vatUpgrade; | ||
const { bundleID } = options.options.provisioningRef; | ||
const vatInfo = await E(vatStore).get(name); | ||
console.log(vatUpgrade.name, vatInfo, bundleID); | ||
const { root, adminNode } = vatInfo; | ||
const bundleCap = await E(vatAdminSvc).getBundleCap(bundleID); | ||
const incarnation = await E(adminNode).upgrade(bundleCap, opts); | ||
console.log({ ...vatUpgrade, incarnation }); | ||
|
||
const { namesByAddress } = await E(root).getNamesByAddressKit(); | ||
resolver.reset(); | ||
resolver.resolve(namesByAddress); | ||
}; | ||
|
||
export const getManifestForProvisioning = (_powers, { provisioningRef }) => ({ | ||
/** @type {import('../core/lib-boot').BootstrapManifest} */ | ||
manifest: { | ||
[upgradeProvisioningVat.name]: { | ||
consume: { | ||
vatStore: true, | ||
vatAdminSvc: true, | ||
}, | ||
produce: { | ||
namesByAddress: true, | ||
}, | ||
}, | ||
}, | ||
options: { provisioningRef }, | ||
}); |
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