-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: a docker test for the zoe/zcf upgrade
chore: generate upgrade bundles and check hashes
- Loading branch information
1 parent
3a7ade3
commit 9eb583a
Showing
15 changed files
with
241 additions
and
52 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
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
96 changes: 96 additions & 0 deletions
96
...upgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade/run-prober-script.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,96 @@ | ||
// @ts-no-check | ||
/* global E */ | ||
|
||
// to turn on ts-check: | ||
// Xmport { E } from '@endo/far'; | ||
|
||
const PROBER_BUNDLE_ID = | ||
'b1-4487fd5e18a225a77ca882890d8faae905ca46fda617877f6e1f969e624db3edf0a4f490d735963f025eb3d772840caec157986f4367c0f66385d919f3f5a56c'; | ||
|
||
console.info('running zcf prober'); | ||
|
||
const sub = (a, v) => { | ||
return { brand: a.brand, value: a.value - v }; | ||
}; | ||
|
||
const probeReallocation = async ( | ||
value, | ||
payment, | ||
creatorFacet, | ||
zoe, | ||
ducatIssuer, | ||
) => { | ||
const stagingInv = await E(creatorFacet).makeProbeStagingInvitation(); | ||
|
||
const stagingSeat = await E(zoe).offer( | ||
stagingInv, | ||
{ give: { Ducats: value } }, | ||
{ Ducats: payment }, | ||
); | ||
const helperPayments = await E(stagingSeat).getPayouts(); | ||
|
||
const helperInv = await E(creatorFacet).makeProbeHelperInvitation(); | ||
const helperSeat = await E(zoe).offer( | ||
helperInv, | ||
{ give: { Ducats: sub(value, 1n) } }, | ||
{ Ducats: helperPayments.Ducats }, | ||
); | ||
const internalPayments = await E(helperSeat).getPayouts(); | ||
const ducatAmount = await E(ducatIssuer).getAmountOf(internalPayments.Ducats); | ||
|
||
const internalInv = await E(creatorFacet).makeProbeInternalInvitation(); | ||
const internalSeat = await E(zoe).offer( | ||
internalInv, | ||
{ give: { Ducats: ducatAmount } }, | ||
{ Ducats: internalPayments.Ducats }, | ||
); | ||
const leftoverPayments = await E(internalSeat).getPayouts(); | ||
|
||
return { | ||
stagingResult: await E(stagingSeat).getOfferResult(), | ||
helperResult: await E(helperSeat).getOfferResult(), | ||
internalResult: await E(internalSeat).getOfferResult(), | ||
leftoverPayments, | ||
}; | ||
}; | ||
|
||
/* | ||
* Test a full upgrade of Zoe and ZCF. | ||
* This will include a change to Zoe's code, and a call to Zoe to change the ZCF | ||
* code that will get used for new and upgraded contracts. | ||
*/ | ||
const runProber = async powers => { | ||
console.info('install prober'); | ||
const { | ||
consume: { zoe, chainStorage }, | ||
} = powers; | ||
|
||
const installation = await E(zoe).installBundleID(PROBER_BUNDLE_ID); | ||
const storageNode = await E(chainStorage).makeChildNode('prober-asid9a'); | ||
|
||
const { instance, creatorFacet } = await E(zoe).startInstance( | ||
installation, | ||
undefined, | ||
undefined, | ||
{ storageNode }, | ||
'probe', | ||
); | ||
|
||
const issuers = await E(zoe).getIssuers(instance); | ||
|
||
const faucetInv = await E(creatorFacet).makeFaucetInvitation(); | ||
const seat = await E(zoe).offer(faucetInv); | ||
const payoutDucats = await E(seat).getPayout('Ducats'); | ||
const faucetAmount = await E(issuers.Ducats).getAmountOf(payoutDucats); | ||
|
||
const result1 = await probeReallocation( | ||
faucetAmount, | ||
payoutDucats, | ||
creatorFacet, | ||
zoe, | ||
issuers.Ducats, | ||
); | ||
console.info('PROBE results', result1); | ||
}; | ||
|
||
runProber; |
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
25 changes: 25 additions & 0 deletions
25
...pgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade/zcf-upgrade-driver.sh
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,25 @@ | ||
#!/bin/bash | ||
|
||
. ./upgrade-test-scripts/env_setup.sh | ||
|
||
set -euo pipefail | ||
|
||
# This shows how to upgrade Zoe and ZCF on a running chain. It presumes that | ||
# the bundles for Zoe and ZCF have been installed, and their hashes updated in | ||
# zcf-upgrade-script.js. Instructions for updating the bundles are available | ||
# in ../actions.sh | ||
|
||
here='upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade' | ||
|
||
agd --chain-id=agoriclocal \ | ||
tx gov submit-proposal swingset-core-eval \ | ||
${here}/zcf-upgrade-permit.json ${here}/zcf-upgrade-script.js \ | ||
--title="Zoe Upgrade" --description="zoe upgrade test" \ | ||
--deposit=10000000ubld \ | ||
--gas=auto --gas-adjustment=1.2 \ | ||
--yes -o json --from=validator --keyring-backend=test -b block | ||
|
||
agd --chain-id=agoriclocal query gov proposals --output json | \ | ||
jq -c '.proposals[] | [.proposal_id,.voting_end_time,.status]'; | ||
|
||
voteLatestProposalAndWait |
8 changes: 8 additions & 0 deletions
8
...rade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade/zcf-upgrade-permit.json
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,8 @@ | ||
{ | ||
"consume": { | ||
"vatStore": true, | ||
"vatAdminSvc": true, | ||
"zoe": true, | ||
"chainStorage": true | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...pgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-full-upgrade/zcf-upgrade-script.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,33 @@ | ||
// to turn on ts-check: | ||
/* global E */ | ||
|
||
// import { E } from "@endo/far"; | ||
|
||
const ZCF_BUNDLE_ID = | ||
'b1-102c585d2efe825e0ff17441dcdfc28c1cd83c866ad6497230446d19d0021de88f49f6786b225693ccca1ec913d86309e83094e5a0b0b0da42bc6684d3d7f808'; | ||
const ZOE_BUNDLE_ID = | ||
'b1-9b02c49613fc09ec8ae9138d6345fa589739c86d7d71044a002080dcc5450583b39b3d4d814924f654474398e23ff459af51f850890fabc109a3106d577732a1'; | ||
|
||
console.info('zoe upgrade: evaluating script'); | ||
|
||
/* | ||
* Test a full upgrade of Zoe and ZCF. | ||
* This will include a change to Zoe's code, and a call to Zoe to change the ZCF | ||
* code that will get used for new and upgraded contracts. | ||
*/ | ||
const upgradeZoeAndZcf = async powers => { | ||
console.info('upgradeZoeAndZcf'); | ||
const { | ||
consume: { vatStore, vatAdminSvc }, | ||
} = powers; | ||
|
||
const newZoeBundleCap = await E(vatAdminSvc).getBundleCap(ZOE_BUNDLE_ID); | ||
const { adminNode, root: zoeRoot } = await E(vatStore).get('zoe'); | ||
|
||
await E(adminNode).upgrade(newZoeBundleCap, {}); | ||
|
||
const zoeConfigFacet = await E(zoeRoot).getZoeConfigFacet(); | ||
await E(zoeConfigFacet).updateZcfBundleId(ZCF_BUNDLE_ID); | ||
}; | ||
|
||
upgradeZoeAndZcf; |
6 changes: 0 additions & 6 deletions
6
...t/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-upgrade/zoe-upgrade-permit.json
This file was deleted.
Oops, something went wrong.
32 changes: 0 additions & 32 deletions
32
...ent/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-upgrade/zoe-upgrade-script.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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