Skip to content

Commit

Permalink
feat(vats): upgrade the orchestration core
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Aug 24, 2024
1 parent 4117643 commit 798937c
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 4 deletions.
2 changes: 1 addition & 1 deletion a3p-integration/proposals/e:upgrade-next/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ add-LEMONS/
add-OLIVES/
upgrade-bank/
upgrade-provisionPool/

upgrade-orch-core/
2 changes: 1 addition & 1 deletion a3p-integration/proposals/e:upgrade-next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"coreProposals": []
},
"sdk-generate": [
"vats/upgrade-orch-core.js upgrade-orch-core",
"vats/test-localchain.js localchaintest-submission",
"vats/upgrade-bank.js upgrade-bank",
"vats/upgrade-provisionPool.js upgrade-provisionPool",
"testing/add-LEMONS.js add-LEMONS",
"testing/add-OLIVES.js add-OLIVES"
Expand Down
6 changes: 4 additions & 2 deletions golang/cosmos/app/upgrade.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gaia

import (

"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -37,7 +36,10 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
if isFirstTimeUpgradeOfThisVersion(app, ctx) {
// Each CoreProposalStep runs sequentially, and can be constructed from
// one or more modules executing in parallel within the step.
CoreProposalSteps = []vm.CoreProposalStep{}
CoreProposalSteps = []vm.CoreProposalStep{
// Upgrade orch-core to the latest version.
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgrade-orch-core.js"),
}
}

app.upgradeDetails = &upgradeDetails{
Expand Down
23 changes: 23 additions & 0 deletions packages/builders/scripts/vats/upgrade-orch-core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { makeHelpers } from '@agoric/deploy-script-support';

/** @type {import('@agoric/deploy-script-support/src/externalTypes.js').CoreEvalBuilder} */
export const defaultProposalBuilder = async ({ publishRef, install }) =>
harden({
sourceSpec: '@agoric/vats/src/proposals/upgrade-orch-core-proposal.js',
getManifestCall: [
'getManifestForUpgradingOrchCore',
{
bundleRefs: {
ibc: publishRef(install('@agoric/vats/src/vat-ibc.js')),
network: publishRef(install('@agoric/vats/src/vat-network.js')),
localchain: publishRef(install('@agoric/vats/src/vat-localchain.js')),
transfer: publishRef(install('@agoric/vats/src/vat-transfer.js')),
},
},
],
});

export default async (homeP, endowments) => {
const { writeCoreProposal } = await makeHelpers(homeP, endowments);
await writeCoreProposal('upgrade-network', defaultProposalBuilder);
};
43 changes: 43 additions & 0 deletions packages/vats/src/proposals/upgrade-orch-core-proposal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { E } from '@endo/far';

/**
* @param {BootstrapPowers & {
* consume: {
* vatAdminSvc: VatAdminSvc;
* vatStore: MapStore<
* string,
* import('@agoric/swingset-vat').CreateVatResults
* >;
* };
* }} powers
* @param {object} options
* @param {{ ibcRef: VatSourceRef; networkRef: VatSourceRef }} options.options
*/
export const upgradeOrchCore = async (
{ consume: { vatAdminSvc, vatStore } },
options,
) => {
const { bundleRefs } = options.options;

for await (const [name, ref] of Object.entries(bundleRefs)) {
assert(ref.bundleID, `bundleID missing for ${name}`);
console.log(name, `BUNDLE ID: `, ref.bundleID);
const bundleCap = await E(vatAdminSvc).getBundleCap(ref.bundleID);

const { adminNode } = await E(vatStore).get(name);
await E(adminNode).upgrade(bundleCap, {});
}
};

export const getManifestForUpgradingOrchCore = (_powers, { bundleRefs }) => ({
manifest: {
[upgradeOrchCore.name]: {
consume: {
vatAdminSvc: 'vatAdminSvc',
vatStore: 'vatStore',
},
produce: {},
},
},
options: { bundleRefs },
});

0 comments on commit 798937c

Please sign in to comment.