-
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 #7793 from Agoric/dc-zoe-system-upgrade
test: zoe null upgrade by swingset.CoreEval governance decision
- Loading branch information
Showing
7 changed files
with
194 additions
and
1 deletion.
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
12 changes: 12 additions & 0 deletions
12
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/pre_test.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,12 @@ | ||
#!/bin/bash | ||
|
||
. ./upgrade-test-scripts/env_setup.sh | ||
|
||
echo Wait for upgrade to settle | ||
waitForBlock 5 | ||
|
||
# CWD is agoric-sdk | ||
here=./upgrade-test-scripts/agoric-upgrade-11 | ||
|
||
# zoe vat is at incarnation 0 | ||
test_val "$(yarn --silent node $here/zoe-upgrade/vat-status.mjs zoe)" "0" "zoe vat incarnation" |
12 changes: 12 additions & 0 deletions
12
packages/deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/test.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,12 @@ | ||
#!/bin/bash | ||
|
||
. ./upgrade-test-scripts/env_setup.sh | ||
|
||
echo Wait for actions to settle | ||
waitForBlock 2 | ||
|
||
# CWD is agoric-sdk | ||
here=./upgrade-test-scripts/agoric-upgrade-11 | ||
|
||
# zoe vat is at incarnation 1 | ||
test_val "$(yarn --silent node $here/zoe-upgrade/vat-status.mjs zoe)" "1" "zoe vat incarnation" |
105 changes: 105 additions & 0 deletions
105
...deployment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-upgrade/vat-status.mjs
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,105 @@ | ||
// @ts-check | ||
import processAmbient from 'process'; | ||
import dbOpenAmbient from 'better-sqlite3'; | ||
|
||
/** | ||
* @file look up vat incarnation from kernel DB | ||
* @see {main} | ||
*/ | ||
|
||
const swingstorePath = '~/.agoric/data/agoric/swingstore.sqlite'; | ||
|
||
/** | ||
* SQL short-hand | ||
* | ||
* @param {import('better-sqlite3').Database} db | ||
*/ | ||
const dbTool = db => { | ||
const prepare = (strings, ...params) => { | ||
const dml = strings.join('?'); | ||
return { stmt: db.prepare(dml), params }; | ||
}; | ||
const sql = (strings, ...args) => { | ||
const { stmt, params } = prepare(strings, ...args); | ||
return stmt.all(...params); | ||
}; | ||
sql.get = (strings, ...args) => { | ||
const { stmt, params } = prepare(strings, ...args); | ||
return stmt.get(...params); | ||
}; | ||
return sql; | ||
}; | ||
|
||
/** | ||
* @param {import('better-sqlite3').Database} db | ||
*/ | ||
const makeSwingstore = db => { | ||
const sql = dbTool(db); | ||
|
||
/** @param {string} key */ | ||
const kvGet = key => sql.get`select * from kvStore where key = ${key}`.value; | ||
/** @param {string} key */ | ||
const kvGetJSON = key => JSON.parse(kvGet(key)); | ||
|
||
/** @param {string} vatID */ | ||
const lookupVat = vatID => { | ||
return Object.freeze({ | ||
source: () => kvGetJSON(`${vatID}.source`), | ||
options: () => kvGetJSON(`${vatID}.options`), | ||
currentSpan: () => | ||
sql.get`select * from transcriptSpans where isCurrent = 1 and vatID = ${vatID}`, | ||
}); | ||
}; | ||
|
||
return Object.freeze({ | ||
/** @param {string} vatName */ | ||
findVat: vatName => { | ||
/** @type {string[]} */ | ||
const dynamicIDs = kvGetJSON('vat.dynamicIDs'); | ||
const targetVat = dynamicIDs.find( | ||
vatID => lookupVat(vatID).options().name === vatName, | ||
); | ||
if (!targetVat) throw Error(vatName); | ||
return targetVat; | ||
}, | ||
lookupVat, | ||
}); | ||
}; | ||
|
||
/** @type {<T>(val: T | undefined) => T} */ | ||
const NonNullish = val => { | ||
if (!val) throw Error('required'); | ||
return val; | ||
}; | ||
|
||
/** | ||
* @param {string[]} argv | ||
* @param {{ dbOpen: typeof import('better-sqlite3'), HOME?: string }} io | ||
*/ | ||
const main = async (argv, { dbOpen, HOME }) => { | ||
const [_node, _script, vatName] = argv; | ||
if (!vatName) throw Error('vatName required'); | ||
|
||
const fullPath = swingstorePath.replace(/^~/, NonNullish(HOME)); | ||
const kStore = makeSwingstore(dbOpen(fullPath, { readonly: true })); | ||
|
||
const vatID = kStore.findVat(vatName); | ||
const vatInfo = kStore.lookupVat(vatID); | ||
|
||
const source = vatInfo.source(); | ||
const { incarnation } = vatInfo.currentSpan(); | ||
|
||
// misc info to stderr | ||
console.error(JSON.stringify({ vatName, vatID, incarnation, ...source })); | ||
|
||
// incarnation to stdout | ||
console.log(incarnation); | ||
}; | ||
|
||
main(processAmbient.argv, { | ||
dbOpen: dbOpenAmbient, | ||
HOME: processAmbient.env.HOME, | ||
}).catch(err => { | ||
console.error(err); | ||
processAmbient.exit(1); | ||
}); |
22 changes: 22 additions & 0 deletions
22
...ent/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-upgrade/zoe-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,22 @@ | ||
#!/bin/bash | ||
|
||
. ./upgrade-test-scripts/env_setup.sh | ||
|
||
set -euo pipefail | ||
|
||
here='upgrade-test-scripts/agoric-upgrade-11/zoe-upgrade' | ||
|
||
agd --chain-id=agoriclocal \ | ||
tx gov submit-proposal swingset-core-eval \ | ||
${here}/zoe-upgrade-permit.json ${here}/zoe-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 | ||
|
||
# then tes some stuff??? |
6 changes: 6 additions & 0 deletions
6
...t/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-upgrade/zoe-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,6 @@ | ||
{ | ||
"consume": { | ||
"vatStore": true, | ||
"vatAdminSvc": true | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ent/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/zoe-upgrade/zoe-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,32 @@ | ||
// @ts-no-check | ||
/* global E */ | ||
|
||
// to turn on ts-check: | ||
// Xmport { E } from '@endo/far'; | ||
|
||
console.info('zoe upgrade: evaluating script'); | ||
|
||
/** | ||
* Test "upgrading" zoe. | ||
* It's a so-called "null" upgrade, since we don't mean to change the code. | ||
* This (re-)uses the code originally bundled at swingset bootstrap. | ||
* | ||
* @param { BootstrapPowers } powers | ||
*/ | ||
const restartZoe = async powers => { | ||
console.info('restartZoe()'); | ||
const { | ||
consume: { vatStore, vatAdminSvc }, | ||
} = powers; | ||
console.info('restartZoe - destructured powers'); | ||
|
||
const bundleName = 'zoe'; | ||
const bundleCap = await E(vatAdminSvc).getNamedBundleCap(bundleName); | ||
const { adminNode } = await E(vatStore).get('zoe'); | ||
console.info('restartZoe', { bundleName, bundleCap, adminNode }); | ||
|
||
const result = await E(adminNode).upgrade(bundleCap, {}); | ||
console.info('restartZoe', { result }); | ||
}; | ||
|
||
restartZoe; |