-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
328 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"evals": [ | ||
{ | ||
"permit": "restart-kread-permit.json", | ||
"script": "restart-kread.js" | ||
} | ||
], | ||
"bundles": [ | ||
"/Users/turadg/.agoric/cache/b1-1711dfe7b92654ebfcce3a700736d66f51a6b1d401c14eefda9e8acc7eb04cd28ced726a63117f629e94bdc1421b30fdef53dd34773ac5a4958bcb17e8f78102.json" | ||
] | ||
} |
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,21 @@ | ||
{ | ||
"consume": { | ||
"chainTimerService": true, | ||
"chainStorage": true, | ||
"board": true, | ||
"kreadKit": true, | ||
"agoricNamesAdmin": "makeCoreProposalBehavior", | ||
"vatAdminSvc": "makeCoreProposalBehavior", | ||
"zoe": "makeCoreProposalBehavior" | ||
}, | ||
"produce": {}, | ||
"evaluateBundleCap": "makeCoreProposalBehavior", | ||
"installation": { | ||
"produce": "makeCoreProposalBehavior" | ||
}, | ||
"modules": { | ||
"utils": { | ||
"runModuleBehaviors": "makeCoreProposalBehavior" | ||
} | ||
} | ||
} |
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,131 @@ | ||
// This is generated by writeCoreProposal; please edit! | ||
/* eslint-disable */ | ||
|
||
const manifestBundleRef = {bundleID:"b1-1711dfe7b92654ebfcce3a700736d66f51a6b1d401c14eefda9e8acc7eb04cd28ced726a63117f629e94bdc1421b30fdef53dd34773ac5a4958bcb17e8f78102"}; | ||
const getManifestCall = harden([ | ||
"getManifestForRestart", | ||
]); | ||
const overrideManifest = { | ||
restartKread: { | ||
consume: { | ||
board: true, | ||
chainStorage: true, | ||
chainTimerService: true, | ||
kreadKit: true, | ||
}, | ||
produce: {}, | ||
}, | ||
}; | ||
|
||
// Make the behavior the completion value. | ||
(({ | ||
manifestBundleRef, | ||
getManifestCall, | ||
overrideManifest, | ||
E, | ||
log = console.info, | ||
restoreRef: overrideRestoreRef, | ||
}) => { | ||
const { entries, fromEntries } = Object; | ||
|
||
// deeplyFulfilled is a bit overkill for what we need. | ||
const shallowlyFulfilled = async obj => { | ||
if (!obj) { | ||
return obj; | ||
} | ||
const ents = await Promise.all( | ||
entries(obj).map(async ([key, valueP]) => { | ||
const value = await valueP; | ||
return [key, value]; | ||
}), | ||
); | ||
return fromEntries(ents); | ||
}; | ||
|
||
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} allPowers */ | ||
const behavior = async allPowers => { | ||
// NOTE: If updating any of these names extracted from `allPowers`, you must | ||
// change `permits` above to reflect their accessibility. | ||
const { | ||
consume: { vatAdminSvc, zoe, agoricNamesAdmin }, | ||
evaluateBundleCap, | ||
installation: { produce: produceInstallations }, | ||
modules: { | ||
utils: { runModuleBehaviors }, | ||
}, | ||
} = allPowers; | ||
const [exportedGetManifest, ...manifestArgs] = getManifestCall; | ||
|
||
/** @type {(ref: import\('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */ | ||
const defaultRestoreRef = async ref => { | ||
// extract-proposal.js creates these records, and bundleName is | ||
// the name under which the bundle was installed into | ||
// config.bundles | ||
const p = | ||
'bundleName' in ref | ||
? E(vatAdminSvc).getBundleIDByName(ref.bundleName) | ||
: ref.bundleID; | ||
const bundleID = await p; | ||
const label = bundleID.slice(0, 8); | ||
return E(zoe).installBundleID(bundleID, label); | ||
}; | ||
const restoreRef = overrideRestoreRef || defaultRestoreRef; | ||
|
||
// Get the on-chain installation containing the manifest and behaviors. | ||
console.info('evaluateBundleCap', { | ||
manifestBundleRef, | ||
exportedGetManifest, | ||
vatAdminSvc, | ||
}); | ||
let bcapP; | ||
if ('bundleName' in manifestBundleRef) { | ||
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName); | ||
} else { | ||
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID); | ||
} | ||
const bundleCap = await bcapP; | ||
|
||
const manifestNS = await evaluateBundleCap(bundleCap); | ||
|
||
console.error('execute', { | ||
exportedGetManifest, | ||
behaviors: Object.keys(manifestNS), | ||
}); | ||
const { | ||
manifest, | ||
options: rawOptions, | ||
installations: rawInstallations, | ||
} = await manifestNS[exportedGetManifest]( | ||
harden({ restoreRef }), | ||
...manifestArgs, | ||
); | ||
|
||
// Await references in the options or installations. | ||
const [options, installations] = await Promise.all( | ||
[rawOptions, rawInstallations].map(shallowlyFulfilled), | ||
); | ||
|
||
// Publish the installations for behavior dependencies. | ||
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation'); | ||
await Promise.all( | ||
entries(installations || {}).map(([key, value]) => { | ||
produceInstallations[key].resolve(value); | ||
return E(installAdmin).update(key, value); | ||
}), | ||
); | ||
|
||
// Evaluate the manifest for our behaviors. | ||
return runModuleBehaviors({ | ||
allPowers, | ||
behaviors: manifestNS, | ||
manifest: overrideManifest || manifest, | ||
makeConfig: (name, _permit) => { | ||
log('coreProposal:', name); | ||
return { options }; | ||
}, | ||
}); | ||
}; | ||
|
||
// Make the behavior the completion value. | ||
return behavior; | ||
})({ manifestBundleRef, getManifestCall, overrideManifest, E }); |
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
11 changes: 11 additions & 0 deletions
11
...grade-test/upgrade-test-scripts/agoric-upgrade-11/upgradeProposal/restart-kread-info.json
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,11 @@ | ||
{ | ||
"evals": [ | ||
{ | ||
"permit": "restart-kread-permit.json", | ||
"script": "restart-kread.js" | ||
} | ||
], | ||
"bundles": [ | ||
"/Users/turadg/.agoric/cache/b1-1711dfe7b92654ebfcce3a700736d66f51a6b1d401c14eefda9e8acc7eb04cd28ced726a63117f629e94bdc1421b30fdef53dd34773ac5a4958bcb17e8f78102.json" | ||
] | ||
} |
21 changes: 21 additions & 0 deletions
21
...ade-test/upgrade-test-scripts/agoric-upgrade-11/upgradeProposal/restart-kread-permit.json
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,21 @@ | ||
{ | ||
"consume": { | ||
"chainTimerService": true, | ||
"chainStorage": true, | ||
"board": true, | ||
"kreadKit": true, | ||
"agoricNamesAdmin": "makeCoreProposalBehavior", | ||
"vatAdminSvc": "makeCoreProposalBehavior", | ||
"zoe": "makeCoreProposalBehavior" | ||
}, | ||
"produce": {}, | ||
"evaluateBundleCap": "makeCoreProposalBehavior", | ||
"installation": { | ||
"produce": "makeCoreProposalBehavior" | ||
}, | ||
"modules": { | ||
"utils": { | ||
"runModuleBehaviors": "makeCoreProposalBehavior" | ||
} | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
...ment/upgrade-test/upgrade-test-scripts/agoric-upgrade-11/upgradeProposal/restart-kread.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,131 @@ | ||
// This is generated by writeCoreProposal; please edit! | ||
/* eslint-disable */ | ||
|
||
const manifestBundleRef = {bundleID:"b1-1711dfe7b92654ebfcce3a700736d66f51a6b1d401c14eefda9e8acc7eb04cd28ced726a63117f629e94bdc1421b30fdef53dd34773ac5a4958bcb17e8f78102"}; | ||
const getManifestCall = harden([ | ||
"getManifestForRestart", | ||
]); | ||
const overrideManifest = { | ||
restartKread: { | ||
consume: { | ||
board: true, | ||
chainStorage: true, | ||
chainTimerService: true, | ||
kreadKit: true, | ||
}, | ||
produce: {}, | ||
}, | ||
}; | ||
|
||
// Make the behavior the completion value. | ||
(({ | ||
manifestBundleRef, | ||
getManifestCall, | ||
overrideManifest, | ||
E, | ||
log = console.info, | ||
restoreRef: overrideRestoreRef, | ||
}) => { | ||
const { entries, fromEntries } = Object; | ||
|
||
// deeplyFulfilled is a bit overkill for what we need. | ||
const shallowlyFulfilled = async obj => { | ||
if (!obj) { | ||
return obj; | ||
} | ||
const ents = await Promise.all( | ||
entries(obj).map(async ([key, valueP]) => { | ||
const value = await valueP; | ||
return [key, value]; | ||
}), | ||
); | ||
return fromEntries(ents); | ||
}; | ||
|
||
/** @param {ChainBootstrapSpace & BootstrapPowers & { evaluateBundleCap: any }} allPowers */ | ||
const behavior = async allPowers => { | ||
// NOTE: If updating any of these names extracted from `allPowers`, you must | ||
// change `permits` above to reflect their accessibility. | ||
const { | ||
consume: { vatAdminSvc, zoe, agoricNamesAdmin }, | ||
evaluateBundleCap, | ||
installation: { produce: produceInstallations }, | ||
modules: { | ||
utils: { runModuleBehaviors }, | ||
}, | ||
} = allPowers; | ||
const [exportedGetManifest, ...manifestArgs] = getManifestCall; | ||
|
||
/** @type {(ref: import\('./externalTypes.js').ManifestBundleRef) => Promise<Installation<unknown>>} */ | ||
const defaultRestoreRef = async ref => { | ||
// extract-proposal.js creates these records, and bundleName is | ||
// the name under which the bundle was installed into | ||
// config.bundles | ||
const p = | ||
'bundleName' in ref | ||
? E(vatAdminSvc).getBundleIDByName(ref.bundleName) | ||
: ref.bundleID; | ||
const bundleID = await p; | ||
const label = bundleID.slice(0, 8); | ||
return E(zoe).installBundleID(bundleID, label); | ||
}; | ||
const restoreRef = overrideRestoreRef || defaultRestoreRef; | ||
|
||
// Get the on-chain installation containing the manifest and behaviors. | ||
console.info('evaluateBundleCap', { | ||
manifestBundleRef, | ||
exportedGetManifest, | ||
vatAdminSvc, | ||
}); | ||
let bcapP; | ||
if ('bundleName' in manifestBundleRef) { | ||
bcapP = E(vatAdminSvc).getNamedBundleCap(manifestBundleRef.bundleName); | ||
} else { | ||
bcapP = E(vatAdminSvc).getBundleCap(manifestBundleRef.bundleID); | ||
} | ||
const bundleCap = await bcapP; | ||
|
||
const manifestNS = await evaluateBundleCap(bundleCap); | ||
|
||
console.error('execute', { | ||
exportedGetManifest, | ||
behaviors: Object.keys(manifestNS), | ||
}); | ||
const { | ||
manifest, | ||
options: rawOptions, | ||
installations: rawInstallations, | ||
} = await manifestNS[exportedGetManifest]( | ||
harden({ restoreRef }), | ||
...manifestArgs, | ||
); | ||
|
||
// Await references in the options or installations. | ||
const [options, installations] = await Promise.all( | ||
[rawOptions, rawInstallations].map(shallowlyFulfilled), | ||
); | ||
|
||
// Publish the installations for behavior dependencies. | ||
const installAdmin = E(agoricNamesAdmin).lookupAdmin('installation'); | ||
await Promise.all( | ||
entries(installations || {}).map(([key, value]) => { | ||
produceInstallations[key].resolve(value); | ||
return E(installAdmin).update(key, value); | ||
}), | ||
); | ||
|
||
// Evaluate the manifest for our behaviors. | ||
return runModuleBehaviors({ | ||
allPowers, | ||
behaviors: manifestNS, | ||
manifest: overrideManifest || manifest, | ||
makeConfig: (name, _permit) => { | ||
log('coreProposal:', name); | ||
return { options }; | ||
}, | ||
}); | ||
}; | ||
|
||
// Make the behavior the completion value. | ||
return behavior; | ||
})({ manifestBundleRef, getManifestCall, overrideManifest, E }); |