-
Notifications
You must be signed in to change notification settings - Fork 212
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 #8911 from Agoric/a3p-test-zcfBundleCap
A3p test zcf bundle cap
- Loading branch information
Showing
10 changed files
with
155 additions
and
11 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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
"ava": { | ||
"concurrency": 1, | ||
"serial": true, | ||
"timeout": "1m", | ||
"files": [ | ||
"!submission" | ||
] | ||
|
36 changes: 36 additions & 0 deletions
36
a3p-integration/proposals/a:upgrade-next/probeZcfBundleCap.test.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,36 @@ | ||
import test from 'ava'; | ||
|
||
import { | ||
evalBundles, | ||
getIncarnation, | ||
getVatDetails, | ||
} from '@agoric/synthetic-chain'; | ||
|
||
const SUBMISSION_DIR = 'probe-submission'; | ||
|
||
test('upgrade Zoe to verify ZcfBundleCap endures', async t => { | ||
await null; | ||
t.assert((await getIncarnation('zoe')) === 1, 'zoe incarnation must be one'); | ||
|
||
// Before the test, the Wallet Factory should be using the legacy ZCF | ||
const detailsBefore = await getVatDetails('walletFactory'); | ||
t.true(detailsBefore.incarnation >= 2, 'wf incarnation must be >= 2'); | ||
|
||
await evalBundles(SUBMISSION_DIR); | ||
|
||
const detailsAfter = await getVatDetails('walletFactory'); | ||
t.is( | ||
detailsAfter.incarnation, | ||
detailsBefore.incarnation + 2, | ||
'wf incarnation must increase by 2', | ||
); | ||
|
||
// The test restarts the WalletFactory, so it'll use the recently assigned | ||
// ZCF bundle. It then restarts Zoe, so it'll revert to whichever ZCF bundle | ||
// made it to persistent store. We then restart the Wallet Factory and see if | ||
// it's gone back to the ZCF that Zoe initially knew about. If we could get the | ||
// ZCF bundleID here from the probe, we'd explicitly check for that. Instead, | ||
// we have to be content that it did indeed use the newly assigned bundle in | ||
// manual tests. | ||
t.not(detailsAfter.bundleID, detailsBefore.bundleID); | ||
}); |
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,22 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').ProposalBuilder} */ | ||
export const defaultProposalBuilder = async ({ publishRef, install }) => | ||
harden({ | ||
sourceSpec: '@agoric/vats/src/proposals/probeZcfBundle.js', | ||
getManifestCall: [ | ||
'getManifestForProbeZcfBundleCap', | ||
{ | ||
zoeRef: publishRef(install('@agoric/vats/src/vat-zoe.js')), | ||
zcfRef: publishRef(install('@agoric/zoe/src/contractFacet/vatRoot.js')), | ||
walletRef: publishRef( | ||
install('@agoric/smart-wallet/src/walletFactory.js'), | ||
), | ||
}, | ||
], | ||
}); | ||
|
||
export default async (homeP, endowments) => { | ||
const { writeCoreProposal } = await makeHelpers(homeP, endowments); | ||
await writeCoreProposal('probeZcfBundle', defaultProposalBuilder); | ||
}; |
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,72 @@ | ||
import { E } from '@endo/far'; | ||
import { makeStorageNodeChild } from '@agoric/internal/src/lib-chainStorage.js'; | ||
|
||
// verify that Zoe remembers the zcfBundleCap across upgrades | ||
export const probeZcfBundleCap = async ( | ||
{ | ||
consume: { | ||
vatAdminSvc, | ||
walletFactoryStartResult, | ||
provisionPoolStartResult, | ||
chainStorage, | ||
walletBridgeManager: walletBridgeManagerP, | ||
vatStore, | ||
}, | ||
}, | ||
options, | ||
) => { | ||
const { zoeRef, zcfRef, walletRef } = options.options; | ||
|
||
const { adminNode, root: zoeRoot } = await E(vatStore).get('zoe'); | ||
const zoeConfigFacet = await E(zoeRoot).getZoeConfigFacet(); | ||
|
||
// STEP 1: restart WF; it'll use the newest ZCF known to Zoe //////////////// | ||
|
||
const WALLET_STORAGE_PATH_SEGMENT = 'wallet'; | ||
const [walletBridgeManager, walletStorageNode, ppFacets] = await Promise.all([ | ||
walletBridgeManagerP, | ||
makeStorageNodeChild(chainStorage, WALLET_STORAGE_PATH_SEGMENT), | ||
provisionPoolStartResult, | ||
]); | ||
const walletReviver = await E(ppFacets.creatorFacet).getWalletReviver(); | ||
const privateArgs = { | ||
storageNode: walletStorageNode, | ||
walletBridgeManager, | ||
walletReviver, | ||
}; | ||
|
||
const { adminFacet: walletAdminFacet } = await walletFactoryStartResult; | ||
await E(walletAdminFacet).upgradeContract(walletRef.bundleID, privateArgs); | ||
|
||
// STEP 2: Set the ZCF bundle //////////////////////// | ||
await E(zoeConfigFacet).updateZcfBundleId(zcfRef.bundleID); | ||
|
||
// STEP 3: Upgrade Zoe again //////////////////////// | ||
// ////// See if Zoe forgets ZcfBundleCap ////////// | ||
|
||
const zoeBundleCap = await E(vatAdminSvc).getBundleCap(zoeRef.bundleID); | ||
await E(adminNode).upgrade(zoeBundleCap, {}); | ||
|
||
// STEP 4: restart WF //////////////////////// | ||
await E(walletAdminFacet).restartContract(privateArgs); | ||
|
||
// ////// See which zcf bundle was used ////////// | ||
}; | ||
harden(probeZcfBundleCap); | ||
|
||
export const getManifestForProbeZcfBundleCap = (_powers, options) => ({ | ||
manifest: { | ||
[probeZcfBundleCap.name]: { | ||
consume: { | ||
vatAdminSvc: true, | ||
vatStore: true, | ||
walletBridgeManager: true, | ||
walletFactoryStartResult: true, | ||
provisionPoolStartResult: true, | ||
chainStorage: true, | ||
}, | ||
}, | ||
}, | ||
options, | ||
}); | ||
harden(getManifestForProbeZcfBundleCap); |
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