Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a CoreEval proposal to a3p-integration #8801

Merged
merged 3 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions a3p-integration/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ That's probably because you don't have that image built locally. To build it,
cd packages/deployment
make docker-build-sdk
```

### UPGRADE NEEDED
```
panic: UPGRADE "UNRELEASED_UPGRADE" NEEDED at height: 1101: {"coreProposals":["@agoric/builders/scripts/vats/init-network.js"]}
```

Means your SDK image is different than the one expected by the upgrade proposal. The remedy also to rebuild it as in the case it's missing.
9 changes: 4 additions & 5 deletions a3p-integration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
"fromTag": "latest"
},
"scripts": {
"build": "./node_modules/.bin/synthetic-chain build",
"test": "./node_modules/.bin/synthetic-chain test",
"doctor": "./node_modules/.bin/synthetic-chain doctor"
"build": "yarn synthetic-chain build",
"test": "yarn synthetic-chain test",
"doctor": "yarn synthetic-chain doctor"
},
"dependencies": {
"@agoric/synthetic-chain": "^0.0.6-4",
"tsx": "^4.7.0"
"@agoric/synthetic-chain": "^0.0.6-4"
},
"packageManager": "[email protected]",
"license": "Apache-2.0"
Expand Down
1 change: 1 addition & 0 deletions a3p-integration/proposals/b:restart-vats/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
14 changes: 14 additions & 0 deletions a3p-integration/proposals/b:restart-vats/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
A demonstration of how to declare a CoreEvalProposal

The console output will show errors, because the `restart-vats` proposal is not well maintained.

Requires manually and checking in the submiission, until https:/Agoric/agoric-3-proposals/issues/87
```sh
agoric run packages/builders/scripts/vats/restart-vats.js
mkdir a3p-integration/proposals/b:restart-vats/submission
mv restart-vats* a3p-integration/proposals/b:restart-vats/submission
cp $(grep -oh '/.*b1-.*.json' restart-vats*) a3p-integration/proposals/b:restart-vats/submission
git add a3p-integration/proposals/b:restart-vats/submission
```

Then look in the
13 changes: 13 additions & 0 deletions a3p-integration/proposals/b:restart-vats/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"agoricProposal": {
"type": "/agoric.swingset.CoreEvalProposal",
"source": "subdir"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

subdir? not submission?

I'm a little surprised to see the bundle checked in, but I guess that's the current state of the art?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately yes

},
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "^0.0.6-4",
"ava": "^5.3.1"
},
"packageManager": "[email protected]"
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"consume": {
"contractKits": true,
"governedContractKits": true,
"instancePrivateArgs": true,
"loadCriticalVat": true,
"psmKit": true,
"vatStore": true,
"zoe": "zoe",
"provisioning": "provisioning",
"vaultFactoryKit": true,
"agoricNamesAdmin": "makeCoreProposalBehavior",
"vatAdminSvc": "makeCoreProposalBehavior"
},
"produce": {},
"evaluateBundleCap": "makeCoreProposalBehavior",
"installation": {
"produce": "makeCoreProposalBehavior"
},
"modules": {
"utils": {
"runModuleBehaviors": "makeCoreProposalBehavior"
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

github flags lack of a newline at end of file here.
Do we have a shop norm?
Locally, I get a lot of spurious diffs on save for this sort of thing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have .editorconfig set up to specify line endings but I think the norm is to include them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a file move of the output from agoric run. If we want the file here to have a newline, I think the proper fix is to update upstream. (I don't think it's worth it)

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "restart-vats",
"script": "restart-vats.js",
"permit": "restart-vats-permit.json",
"bundles": [
{
"entrypoint": "@agoric/vats/src/proposals/restart-vats-proposal.js",
"bundleID": "b1-23367331a30b300c84bc01bccaab0c30ad71bef57308dbc7f3ff7f1f05725d01ba9b3de4a06f937b1834622cb4b45485d2610a3e6cc7f6e5bbf7b57311f91dc1",
"fileName": "/Users/turadg/.agoric/cache/b1-23367331a30b300c84bc01bccaab0c30ad71bef57308dbc7f3ff7f1f05725d01ba9b3de4a06f937b1834622cb4b45485d2610a3e6cc7f6e5bbf7b57311f91dc1.json"
}
]
}
176 changes: 176 additions & 0 deletions a3p-integration/proposals/b:restart-vats/submission/restart-vats.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
// This is generated by writeCoreProposal; please edit!
/* eslint-disable */

const manifestBundleRef = {bundleID:"b1-23367331a30b300c84bc01bccaab0c30ad71bef57308dbc7f3ff7f1f05725d01ba9b3de4a06f937b1834622cb4b45485d2610a3e6cc7f6e5bbf7b57311f91dc1"};
const getManifestCall = harden([
"getManifestForRestart",
{
skip: [
"auctioneer",
"feeDistributor",
"scaledPriceAuthority-ATOM",
"ATOM-USD_price_feed",
],
},
]);
const customManifest = {
restartVats: {
consume: {
contractKits: true,
governedContractKits: true,
instancePrivateArgs: true,
loadCriticalVat: true,
provisioning: "provisioning",
psmKit: true,
vatStore: true,
vaultFactoryKit: true,
zoe: "zoe",
},
produce: {},
},
};

// Make a behavior function and "export" it by way of script completion value.
// It is constructed by an anonymous invocation to ensure the absence of a global binding
// for makeCoreProposalBehavior, which may not be necessary but preserves behavior pre-dating
// https:/Agoric/agoric-sdk/pull/8712 .
const behavior = (({
manifestBundleRef,
getManifestCall: [manifestGetterName, ...manifestGetterArgs],
customManifest,
E,
log = console.info,
customRestoreRef,
}) => {
const { entries, fromEntries } = Object;

/**
* Given an object whose properties may be promise-valued, return a promise
* for an analogous object in which each such value has been replaced with its
* fulfillment.
* This is a non-recursive form of endo `deeplyFulfilled`.
*
* @template T
* @param {{[K in keyof T]: (T[K] | Promise<T[K]>)}} obj
* @returns {Promise<T>}
*/
const shallowlyFulfilled = async obj => {
if (!obj) {
return obj;
}
const awaitedEntries = await Promise.all(
entries(obj).map(async ([key, valueP]) => {
const value = await valueP;
return [key, value];
}),
);
return fromEntries(awaitedEntries);
};

const makeRestoreRef = (vatAdminSvc, zoe) => {
/** @type {(ref: import\('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
const defaultRestoreRef = async bundleRef => {
// extract-proposal.js creates these records, and bundleName is
// the optional name under which the bundle was installed into
// config.bundles
const bundleIdP =
'bundleName' in bundleRef
? E(vatAdminSvc).getBundleIDByName(bundleRef.bundleName)
: bundleRef.bundleID;
const bundleID = await bundleIdP;
const label = bundleID.slice(0, 8);
return E(zoe).installBundleID(bundleID, label);
};
return defaultRestoreRef;
};

/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers */
const coreProposalBehavior = async powers => {
// NOTE: `powers` is expected to match or be a superset of the above `permits` export,
// which should therefore be kept in sync with this deconstruction code.
// HOWEVER, do note that this function is invoked with at least the *union* of powers
// required by individual moduleBehaviors declared by the manifest getter, which is
// necessary so it can use `runModuleBehaviors` to provide the appropriate subset to
// each one (see ./writeCoreProposal.js).
// Handle `powers` with the requisite care.
const {
consume: { vatAdminSvc, zoe, agoricNamesAdmin },
evaluateBundleCap,
installation: { produce: produceInstallations },
modules: {
utils: { runModuleBehaviors },
},
} = powers;

// Get the on-chain installation containing the manifest and behaviors.
log('evaluateBundleCap', {
manifestBundleRef,
manifestGetterName,
vatAdminSvc,
});
let bcapP;
if ('bundleName' in manifestBundleRef) {
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
} else if ('bundleID' in manifestBundleRef) {
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
} else {
const keys = Reflect.ownKeys(manifestBundleRef).map(key =>
typeof key === 'string' ? JSON.stringify(key) : String(key),
);
const keysStr = `[${keys.join(', ')}]`;
throw Error(
`bundleRef must have own bundleName or bundleID, missing in ${keysStr}`,
);
}
const bundleCap = await bcapP;

const proposalNS = await evaluateBundleCap(bundleCap);

// Get the manifest and its metadata.
log('execute', {
manifestGetterName,
bundleExports: Object.keys(proposalNS),
});
const restoreRef = customRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
const {
manifest,
options: rawOptions,
installations: rawInstallations,
} = await proposalNS[manifestGetterName](
harden({ restoreRef }),
...manifestGetterArgs,
);

// Await promises in the returned options and installations records.
const [options, installations] = await Promise.all(
[rawOptions, rawInstallations].map(shallowlyFulfilled),
);

// Publish the installations for our dependencies.
const installationEntries = entries(installations || {});
if (installationEntries.length > 0) {
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
await Promise.all(
installationEntries.map(([key, value]) => {
produceInstallations[key].resolve(value);
return E(installAdmin).update(key, value);
}),
);
}

// Evaluate the manifest.
return runModuleBehaviors({
// Remember that `powers` may be arbitrarily broad.
allPowers: powers,
behaviors: proposalNS,
manifest: customManifest || manifest,
makeConfig: (name, _permit) => {
log('coreProposal:', name);
return { options };
},
});
};

return coreProposalBehavior;
})({ manifestBundleRef, getManifestCall, customManifest, E });
behavior;
3 changes: 3 additions & 0 deletions a3p-integration/proposals/b:restart-vats/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo TODO test of restart-vats
Loading
Loading