Skip to content

Commit

Permalink
feat: upgrade v7-board and test it (#10516)
Browse files Browse the repository at this point in the history
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
Chris-Hibbert authored Nov 28, 2024
1 parent 17503a9 commit d8a109e
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 14 deletions.
1 change: 1 addition & 0 deletions a3p-integration/proposals/p:upgrade-19/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
replaceFeeDistributor/
testUpgradedBoard/
9 changes: 8 additions & 1 deletion a3p-integration/proposals/p:upgrade-19/eval.sh
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
5 changes: 4 additions & 1 deletion a3p-integration/proposals/p:upgrade-19/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"agoricProposal": {
"type": "/agoric.swingset.CoreEvalProposal",
"sdk-generate": [
"testing/replace-feeDistributor-short.js replaceFeeDistributor"
"testing/replace-feeDistributor-short.js replaceFeeDistributor",
"vats/upgrade-paRegistry.js",
"vats/upgrade-board.js",
"testing/test-upgraded-board.js testUpgradedBoard"
]
},
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions a3p-integration/proposals/p:upgrade-19/test.sh
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 a3p-integration/proposals/p:upgrade-19/upgradedBoard.test.js
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();
});
22 changes: 13 additions & 9 deletions golang/cosmos/app/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,19 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
),
)

// CoreProposals for Upgrade 19
CoreProposalSteps = append(CoreProposalSteps,
vm.CoreProposalStepForModules(
"@agoric/builders/scripts/inter-protocol/replace-feeDistributor.js",
),
vm.CoreProposalStepForModules(
"@agoric/builders/scripts/vats/upgrade-paRegistry.js",
),
)
// // CoreProposals for Upgrade 19. These should not be introduced
// // before upgrade 18 is done because they would be run in n:upgrade-next
// CoreProposalSteps = append(CoreProposalSteps,
// vm.CoreProposalStepForModules(
// "@agoric/builders/scripts/inter-protocol/replace-feeDistributor.js",
// ),
// vm.CoreProposalStepForModules(
// "@agoric/builders/scripts/vats/upgrade-paRegistry.js",
// ),
// vm.CoreProposalStepForModules(
// "@agoric/builders/scripts/vats/upgrade-board.js",
// ),
// )
}

app.upgradeDetails = &upgradeDetails{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SECONDS_PER_HOUR } from '@agoric/inter-protocol/src/proposals/econ-beha

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async (_, opts) => {
console.log('OPTS', opts);
console.log('feeDist OPTS', opts);
return harden({
sourceSpec:
'@agoric/inter-protocol/src/proposals/replace-fee-distributor.js',
Expand All @@ -16,7 +16,7 @@ export const defaultProposalBuilder = async (_, opts) => {
export default async (homeP, endowments) => {
const { writeCoreEval } = await makeHelpers(homeP, endowments);

await writeCoreEval('replace-feeDistributor-testing', utils =>
await writeCoreEval('replace-feeDistributor', utils =>
defaultProposalBuilder(utils, {
collectionInterval: 1n * SECONDS_PER_HOUR,
keywordShares: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { makeHelpers } from '@agoric/deploy-script-support';
import { getManifestForReplaceFeeDistributor } from '@agoric/inter-protocol/src/proposals/replace-fee-distributor.js';

/**
* @file
* a Variant of ../inter-protocol/replace-feeDistributor.js that shortens the
* collectionInterval for testing
*/

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async (_, opts) => {
console.log('OPTS', opts);
console.log('feeDist OPTS', opts);
return harden({
sourceSpec:
'@agoric/inter-protocol/src/proposals/replace-fee-distributor.js',
Expand Down
15 changes: 15 additions & 0 deletions packages/builders/scripts/testing/test-upgraded-board.js
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);
};
20 changes: 20 additions & 0 deletions packages/builders/scripts/vats/upgrade-board.js
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);
};
35 changes: 35 additions & 0 deletions packages/vats/src/proposals/testUpgradedBoard.js
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 },
},
},
},
});
50 changes: 50 additions & 0 deletions packages/vats/src/proposals/upgrade-board-proposal.js
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 },
});

0 comments on commit d8a109e

Please sign in to comment.