Skip to content

Commit d936ada

Browse files
authored
chore(proposals): add ymax-alpha4 (#293)
1 parent eca190e commit d936ada

15 files changed

+4531
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
tx.json
2+
txs.json
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

proposals/106:ymax-alpha4/Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This Makefile is here to help you find out what went on the
2+
# chain for a CoreEval proposal such as #100 for Ymax-alpha-1.
3+
PROPOSAL=106
4+
5+
ARCHIVE_NODE ?= https://main-a.rpc.agoric.net:443
6+
7+
##
8+
# Find the proposal transaction
9+
10+
# Get proposer's transaction history.
11+
txs.json:
12+
agd --node $(ARCHIVE_NODE) query txs --query="submit_proposal.proposal_id='$(PROPOSAL)'" -o json >$@
13+
14+
# pick out their most recent CoreEvalProposal
15+
tx.json: txs.json
16+
jq -e '.txs | .[] | select(.tx.body.messages[0].content["@type"] == "/agoric.swingset.CoreEvalProposal")' \
17+
$< >$@
18+
19+
# A CoreEval proposal has a sequence of json_permits,js_code pairs.
20+
# We happen to know there were 1 in this case.
21+
22+
EVALS=submission/ymaxControl-permit.json submission/ymaxControl.js
23+
24+
core-evals: $(EVALS)
25+
26+
# Now pick out their contents from the transaction.
27+
submission/ymaxControl-permit.json: tx.json
28+
jq -e -r '.tx.body.messages[0].content.evals[0].json_permits' $< >$@
29+
submission/ymaxControl.js: tx.json
30+
jq -e -r '.tx.body.messages[0].content.evals[0].js_code' $< | sed s/agoric1e80twfutmrm3wrk3fysjcnef4j82mq8dn6nmcq/agoric15u29seyj3c9rdwg7gwkc97uttrk6j9fl4jkuyh/ >$@; \
31+
echo '// HACK! b1-078729b9683de5f81afe8b14bd163f0165b8dd803f587413df8dff76b557d56e5d0d67f8f654bc920b5bb3a734d7d7644791692efbbc08c08984e37c6e0e6c88' >>$@ # hack to force `evalBundles` to publish the latest ymax bundle
32+
33+
# clean up locally computed files
34+
clean:
35+
rm -f $(EVALS)
36+
37+
# clean up files cached from the network as well
38+
realclean: clean
39+
rm -f txs.json tx.json
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"agoricProposal": {
3+
"type": "/agoric.swingset.CoreEvalProposal"
4+
},
5+
"type": "module",
6+
"dependencies": {
7+
"@agoric/synthetic-chain": "~0.6.1"
8+
},
9+
"packageManager": "[email protected]",
10+
"devDependencies": {
11+
"ava": "^6.4.1"
12+
}
13+
}

proposals/106:ymax-alpha4/submission/b1-078729b9683de5f81afe8b14bd163f0165b8dd803f587413df8dff76b557d56e5d0d67f8f654bc920b5bb3a734d7d7644791692efbbc08c08984e37c6e0e6c88.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

proposals/106:ymax-alpha4/submission/b1-376c98ef85078bacb39dcac6128613f802d6dd44174424a97d4fa2dda7f1529ffdbaf93dd2c11997d478deae9cea402ec35022e20c8a867c9e10f992e53cff0a.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

proposals/106:ymax-alpha4/submission/b1-9486f1a9b190fd5aebaeb371674567e03813d7e63f16f1c94e8ea4722eeb8d696dac171b7ed144edc2520eb49ede449205f5866835249f75ca940547665e9073.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"consume": {
3+
"startUpgradable": true,
4+
"namesByAddress": true,
5+
"localchain": true,
6+
"cosmosInterchainService": true,
7+
"chainStorage": true,
8+
"chainTimerService": true,
9+
"agoricNames": true,
10+
"board": true,
11+
"zoe": "makeCoreProposalBehavior",
12+
"agoricNamesAdmin": "makeCoreProposalBehavior",
13+
"getDepositFacet": true,
14+
"ymax0Kit": true,
15+
"vatAdminSvc": "makeCoreProposalBehavior"
16+
},
17+
"installation": {
18+
"consume": {
19+
"postalService": true
20+
},
21+
"produce": "makeCoreProposalBehavior"
22+
},
23+
"instance": {
24+
"produce": {
25+
"postalService": true
26+
},
27+
"consume": {
28+
"postalService": true
29+
}
30+
},
31+
"evaluateBundleCap": "makeCoreProposalBehavior",
32+
"modules": {
33+
"utils": {
34+
"runModuleBehaviors": "makeCoreProposalBehavior"
35+
}
36+
}
37+
}
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
// This is generated by writeCoreEval; please edit!
2+
/* eslint-disable */
3+
4+
const manifestBundleRef = {bundleID:"b1-376c98ef85078bacb39dcac6128613f802d6dd44174424a97d4fa2dda7f1529ffdbaf93dd2c11997d478deae9cea402ec35022e20c8a867c9e10f992e53cff0a"};
5+
const getManifestCall = harden([
6+
"getManifestForPortfolioControl",
7+
{
8+
installKeys: {
9+
postalService: {
10+
bundleID: "b1-9486f1a9b190fd5aebaeb371674567e03813d7e63f16f1c94e8ea4722eeb8d696dac171b7ed144edc2520eb49ede449205f5866835249f75ca940547665e9073",
11+
},
12+
},
13+
options: {
14+
ymaxControlAddress: "agoric15u29seyj3c9rdwg7gwkc97uttrk6j9fl4jkuyh",
15+
},
16+
},
17+
]);
18+
const customManifest = {
19+
delegatePortfolioContract: {
20+
consume: {
21+
agoricNames: true,
22+
agoricNamesAdmin: true,
23+
board: true,
24+
chainStorage: true,
25+
chainTimerService: true,
26+
cosmosInterchainService: true,
27+
getDepositFacet: true,
28+
localchain: true,
29+
startUpgradable: true,
30+
ymax0Kit: true,
31+
zoe: true,
32+
},
33+
instance: {
34+
consume: {
35+
postalService: true,
36+
},
37+
},
38+
},
39+
deployPostalService: {
40+
consume: {
41+
namesByAddress: true,
42+
startUpgradable: true,
43+
},
44+
installation: {
45+
consume: {
46+
postalService: true,
47+
},
48+
},
49+
instance: {
50+
produce: {
51+
postalService: true,
52+
},
53+
},
54+
},
55+
};
56+
57+
// Make a behavior function and "export" it by way of script completion value.
58+
// It is constructed by an anonymous invocation to ensure the absence of a global binding
59+
// for makeCoreProposalBehavior, which may not be necessary but preserves behavior pre-dating
60+
// https://github.com/Agoric/agoric-sdk/pull/8712 .
61+
const behavior = (({
62+
manifestBundleRef,
63+
getManifestCall: [manifestGetterName, ...manifestGetterArgs],
64+
customManifest,
65+
E,
66+
log = console.info,
67+
customRestoreRef,
68+
}) => {
69+
const { entries, fromEntries } = Object;
70+
71+
/**
72+
* Given an object whose properties may be promise-valued, return a promise
73+
* for an analogous object in which each such value has been replaced with its
74+
* fulfillment.
75+
* This is a non-recursive form of endo `deeplyFulfilled`.
76+
*
77+
* @template T
78+
* @param {{[K in keyof T]: (T[K] | Promise<T[K]>)}} obj
79+
* @returns {Promise<T>}
80+
*/
81+
const shallowlyFulfilled = async obj => {
82+
if (!obj) {
83+
return obj;
84+
}
85+
const awaitedEntries = await Promise.all(
86+
entries(obj).map(async ([key, valueP]) => {
87+
const value = await valueP;
88+
return [key, value];
89+
}),
90+
);
91+
return fromEntries(awaitedEntries);
92+
};
93+
94+
const makeRestoreRef = (vatAdminSvc, zoe) => {
95+
/** @type {(ref: import\('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */
96+
const defaultRestoreRef = async bundleRef => {
97+
// extract-proposal.js creates these records, and bundleName is
98+
// the optional name under which the bundle was installed into
99+
// config.bundles
100+
const bundleIdP =
101+
'bundleName' in bundleRef
102+
? E(vatAdminSvc).getBundleIDByName(bundleRef.bundleName)
103+
: bundleRef.bundleID;
104+
const bundleID = await bundleIdP;
105+
const label = bundleID.slice(0, 8);
106+
return E(zoe).installBundleID(bundleID, label);
107+
};
108+
return defaultRestoreRef;
109+
};
110+
111+
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} powers */
112+
const coreProposalBehavior = async powers => {
113+
// NOTE: `powers` is expected to match or be a superset of the above `permits` export,
114+
// which should therefore be kept in sync with this deconstruction code.
115+
// HOWEVER, do note that this function is invoked with at least the *union* of powers
116+
// required by individual moduleBehaviors declared by the manifest getter, which is
117+
// necessary so it can use `runModuleBehaviors` to provide the appropriate subset to
118+
// each one (see ./writeCoreEvalParts.js).
119+
// Handle `powers` with the requisite care.
120+
const {
121+
consume: { vatAdminSvc, zoe, agoricNamesAdmin },
122+
evaluateBundleCap,
123+
installation: { produce: produceInstallations },
124+
modules: {
125+
utils: { runModuleBehaviors },
126+
},
127+
} = powers;
128+
129+
// Get the on-chain installation containing the manifest and behaviors.
130+
log('evaluateBundleCap', {
131+
manifestBundleRef,
132+
manifestGetterName,
133+
vatAdminSvc,
134+
});
135+
let bcapP;
136+
if ('bundleName' in manifestBundleRef) {
137+
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName);
138+
} else if ('bundleID' in manifestBundleRef) {
139+
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID);
140+
} else {
141+
const keys = Reflect.ownKeys(manifestBundleRef).map(key =>
142+
typeof key === 'string' ? JSON.stringify(key) : String(key),
143+
);
144+
const keysStr = `[${keys.join(', ')}]`;
145+
throw Error(
146+
`bundleRef must have own bundleName or bundleID, missing in ${keysStr}`,
147+
);
148+
}
149+
const bundleCap = await bcapP;
150+
151+
const proposalNS = await evaluateBundleCap(bundleCap);
152+
153+
// Get the manifest and its metadata.
154+
log('execute', {
155+
manifestGetterName,
156+
bundleExports: Object.keys(proposalNS),
157+
});
158+
const restoreRef = customRestoreRef || makeRestoreRef(vatAdminSvc, zoe);
159+
const {
160+
manifest,
161+
options: rawOptions,
162+
installations: rawInstallations,
163+
} = await proposalNS[manifestGetterName](
164+
harden({ restoreRef }),
165+
...manifestGetterArgs,
166+
);
167+
168+
// Await promises in the returned options and installations records.
169+
const [options, installations] = await Promise.all(
170+
[rawOptions, rawInstallations].map(shallowlyFulfilled),
171+
);
172+
173+
// Publish the installations for our dependencies.
174+
const installationEntries = entries(installations || {});
175+
if (installationEntries.length > 0) {
176+
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation');
177+
await Promise.all(
178+
installationEntries.map(([key, value]) => {
179+
produceInstallations[key].reset();
180+
produceInstallations[key].resolve(value);
181+
return E(installAdmin).update(key, value);
182+
}),
183+
);
184+
}
185+
186+
// Evaluate the manifest.
187+
return runModuleBehaviors({
188+
// Remember that `powers` may be arbitrarily broad.
189+
allPowers: powers,
190+
behaviors: proposalNS,
191+
manifest: customManifest || manifest,
192+
makeConfig: (name, _permit) => {
193+
log('coreProposal:', name);
194+
return { options };
195+
},
196+
});
197+
};
198+
199+
return coreProposalBehavior;
200+
})({ manifestBundleRef, getManifestCall, customManifest, E });
201+
behavior;
202+
203+
// HACK! b1-078729b9683de5f81afe8b14bd163f0165b8dd803f587413df8dff76b557d56e5d0d67f8f654bc920b5bb3a734d7d7644791692efbbc08c08984e37c6e0e6c88

proposals/106:ymax-alpha4/test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# segregate so changing these does not invalidate the proposal image
5+
# à la https://github.com/Agoric/agoric-3-proposals/pull/213
6+
cd test
7+
8+
yarn ava

0 commit comments

Comments
 (0)