-
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.
feat: upgrade v7-board and test it (#10516)
closes: #10394 ## Description Upgrade v7-board. ### Security Considerations The Board is a critical vat. ### Scaling Considerations v7-Board is consuming more resources than it should. restarting it should clean up a fair amount of space. **...checking** ### Documentation Considerations None ### Testing Considerations Verify that the board doesn't lose anything. ### Upgrade Considerations Can go out in Upgrade 19.
- Loading branch information
1 parent
17503a9
commit d8a109e
Showing
13 changed files
with
171 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
replaceFeeDistributor/ | ||
testUpgradedBoard/ |
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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
#!/bin/bash | ||
|
||
# Do nothing because this is only testing the state resulting from previous proposals. | ||
# evaluate the proposals in the /submission/ directory | ||
|
||
echo "UPGRADE-19 Running proposal declared in package.json" | ||
# copy to run in the proposal package so the dependencies can be resolved | ||
cp /usr/src/upgrade-test-scripts/eval_submission.js . | ||
|
||
echo RUNNING ./eval_submission.js | ||
./eval_submission.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#!/bin/bash | ||
|
||
yarn ava replaceFeeDistributor.test.js | ||
yarn ava upgradedBoard.test.js |
15 changes: 15 additions & 0 deletions
15
a3p-integration/proposals/p:upgrade-19/upgradedBoard.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,15 @@ | ||
/* eslint-env node */ | ||
// @ts-check | ||
|
||
/** @file test that the upgraded board can store and retrieve values. */ | ||
|
||
import '@endo/init/legacy.js'; | ||
import test from 'ava'; | ||
import { evalBundles } from '@agoric/synthetic-chain'; | ||
|
||
test('test upgraded board', async t => { | ||
// agoricProposal.sdk-generate in package.json generates this proposal | ||
await evalBundles('testUpgradedBoard'); | ||
|
||
t.pass(); | ||
}); |
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
8 changes: 7 additions & 1 deletion
8
packages/builders/scripts/testing/replace-feeDistributor-short.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
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,15 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { getManifestForTestUpgradedBoard } from '@agoric/vats/src/proposals/testUpgradedBoard.js'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async () => | ||
harden({ | ||
sourceSpec: '@agoric/vats/src/proposals/testUpgradedBoard.js', | ||
getManifestCall: [getManifestForTestUpgradedBoard.name], | ||
}); | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('testUpgradedBoard', 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,20 @@ | ||
import { makeHelpers } from '@agoric/deploy-script-support'; | ||
import { getManifestForUpgradingBoard } from '@agoric/vats/src/proposals/upgrade-board-proposal.js'; | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */ | ||
export const defaultProposalBuilder = async ({ publishRef, install }) => | ||
harden({ | ||
sourceSpec: '@agoric/vats/src/proposals/upgrade-board-proposal.js', | ||
getManifestCall: [ | ||
getManifestForUpgradingBoard.name, | ||
{ | ||
boardRef: publishRef(install('@agoric/vats/src/vat-board.js')), | ||
}, | ||
], | ||
}); | ||
|
||
/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').DeployScriptFunction} */ | ||
export default async (homeP, endowments) => { | ||
const { writeCoreEval } = await makeHelpers(homeP, endowments); | ||
await writeCoreEval('upgrade-board', 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,35 @@ | ||
import { E, Far } from '@endo/far'; | ||
import { Stable } from '@agoric/internal/src/tokens.js'; | ||
|
||
export const testUpgradedBoard = async ({ | ||
consume: { board }, | ||
brand: { | ||
consume: { [Stable.symbol]: stableBrandP }, | ||
}, | ||
}) => { | ||
// /////// can we store something and get it back? //////// | ||
const thing1 = Far('thing1', {}); | ||
const thing1Id = await E(board).getId(thing1); | ||
assert(thing1Id.match(/^board0[0-9]+$/)); | ||
|
||
const marshaller = await E(board).getReadonlyMarshaller(); | ||
assert(marshaller, 'expected a marshaller'); | ||
|
||
const stableBrand = await stableBrandP; | ||
// /////// can we retrieve a well-known object via its ID? //////// | ||
const stableID = await E(board).getId(stableBrand); | ||
// /////// can we retrieve something stored long ago? //////// | ||
const stableBrandRetrieved = await E(board).getValue(stableID); | ||
assert(stableBrandRetrieved === stableBrand, 'retrieved matching brand'); | ||
}; | ||
|
||
export const getManifestForTestUpgradedBoard = () => ({ | ||
manifest: { | ||
[testUpgradedBoard.name]: { | ||
consume: { board: true }, | ||
brand: { | ||
consume: { [Stable.symbol]: true }, | ||
}, | ||
}, | ||
}, | ||
}); |
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,50 @@ | ||
import { E } from '@endo/far'; | ||
|
||
/** | ||
* @param {BootstrapPowers & { | ||
* consume: { | ||
* vatAdminSvc: VatAdminSvc; | ||
* vatStore: MapStore< | ||
* string, | ||
* import('@agoric/swingset-vat').CreateVatResults | ||
* >; | ||
* }; | ||
* }} powers | ||
* @param {object} options | ||
* @param {{ boardRef: VatSourceRef }} options.options | ||
*/ | ||
export const upgradeBoard = async ( | ||
{ consume: { board, vatAdminSvc, vatStore } }, | ||
options, | ||
) => { | ||
const { boardRef } = options.options; | ||
|
||
assert(boardRef.bundleID); | ||
const boardBundleCap = await E(vatAdminSvc).getBundleCap(boardRef.bundleID); | ||
console.log(`Board BUNDLE ID: `, boardRef.bundleID); | ||
const idsBefore = await E(board).ids(); | ||
|
||
const { adminNode } = await E(vatStore).get('board'); | ||
await E(adminNode).upgrade(boardBundleCap, {}); | ||
|
||
const idsAfter = await E(board).ids(); | ||
const same = | ||
idsBefore.length === idsAfter.length && | ||
idsBefore.every((element, index) => element === idsAfter[index]); | ||
assert(same, 'keys must stay the same'); | ||
|
||
console.log('Board upgrade complete'); | ||
}; | ||
|
||
export const getManifestForUpgradingBoard = (_powers, { boardRef }) => ({ | ||
manifest: { | ||
[upgradeBoard.name]: { | ||
consume: { | ||
board: 'board', | ||
vatAdminSvc: 'vatAdminSvc', | ||
vatStore: 'vatStore', | ||
}, | ||
}, | ||
}, | ||
options: { boardRef }, | ||
}); |