@agoric/cosmic-swingset 0.41.4-dev-d1a4a53.0 → 0.41.4-dev-35e67be.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +12 -11
- package/src/helpers/json.js +19 -0
- package/src/launch-chain.js +81 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmic-swingset",
|
|
3
|
-
"version": "0.41.4-dev-
|
|
3
|
+
"version": "0.41.4-dev-35e67be.0+35e67be",
|
|
4
4
|
"description": "Agoric's Cosmos blockchain integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,15 +22,16 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/assert": "0.6.1-dev-
|
|
26
|
-
"@agoric/cosmos": "0.34.2-dev-
|
|
27
|
-
"@agoric/deploy-script-support": "0.10.4-dev-
|
|
28
|
-
"@agoric/internal": "0.3.3-dev-
|
|
29
|
-
"@agoric/store": "0.9.3-dev-
|
|
30
|
-
"@agoric/swing-store": "0.9.2-dev-
|
|
31
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
32
|
-
"@agoric/telemetry": "0.6.3-dev-
|
|
33
|
-
"@agoric/vm-config": "0.1.1-dev-
|
|
25
|
+
"@agoric/assert": "0.6.1-dev-35e67be.0+35e67be",
|
|
26
|
+
"@agoric/cosmos": "0.34.2-dev-35e67be.0+35e67be",
|
|
27
|
+
"@agoric/deploy-script-support": "0.10.4-dev-35e67be.0+35e67be",
|
|
28
|
+
"@agoric/internal": "0.3.3-dev-35e67be.0+35e67be",
|
|
29
|
+
"@agoric/store": "0.9.3-dev-35e67be.0+35e67be",
|
|
30
|
+
"@agoric/swing-store": "0.9.2-dev-35e67be.0+35e67be",
|
|
31
|
+
"@agoric/swingset-vat": "0.32.3-dev-35e67be.0+35e67be",
|
|
32
|
+
"@agoric/telemetry": "0.6.3-dev-35e67be.0+35e67be",
|
|
33
|
+
"@agoric/vm-config": "0.1.1-dev-35e67be.0+35e67be",
|
|
34
|
+
"@endo/bundle-source": "^2.5.2",
|
|
34
35
|
"@endo/far": "^0.2.19",
|
|
35
36
|
"@endo/import-bundle": "^0.3.5",
|
|
36
37
|
"@endo/init": "^0.5.57",
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
],
|
|
62
63
|
"timeout": "20m"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "35e67bed9eae0896e32b549ad0d1fd02fb83a905"
|
|
65
66
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses JSON and, if necessary, throws exceptions that include the location
|
|
5
|
+
* of the offending file.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} source
|
|
8
|
+
* @param {string} location
|
|
9
|
+
*/
|
|
10
|
+
export const parseLocatedJson = (source, location) => {
|
|
11
|
+
try {
|
|
12
|
+
return JSON.parse(source);
|
|
13
|
+
} catch (error) {
|
|
14
|
+
if (error instanceof SyntaxError) {
|
|
15
|
+
throw SyntaxError(`Cannot parse JSON from ${location}, ${error}`);
|
|
16
|
+
}
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
};
|
package/src/launch-chain.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import anylogger from 'anylogger';
|
|
4
4
|
|
|
5
5
|
import { E } from '@endo/far';
|
|
6
|
+
import bundleSource from '@endo/bundle-source';
|
|
7
|
+
|
|
6
8
|
import {
|
|
7
9
|
buildMailbox,
|
|
8
10
|
buildMailboxStateMap,
|
|
@@ -22,6 +24,7 @@ import { makeWithQueue } from '@agoric/internal/src/queue.js';
|
|
|
22
24
|
import * as ActionType from '@agoric/internal/src/action-types.js';
|
|
23
25
|
|
|
24
26
|
import { extractCoreProposalBundles } from '@agoric/deploy-script-support/src/extract-proposal.js';
|
|
27
|
+
import { fileURLToPath } from 'url';
|
|
25
28
|
|
|
26
29
|
import {
|
|
27
30
|
makeDefaultMeterProvider,
|
|
@@ -38,6 +41,7 @@ import {
|
|
|
38
41
|
import { parseParams } from './params.js';
|
|
39
42
|
import { makeQueue } from './helpers/make-queue.js';
|
|
40
43
|
import { exportStorage } from './export-storage.js';
|
|
44
|
+
import { parseLocatedJson } from './helpers/json.js';
|
|
41
45
|
|
|
42
46
|
const console = anylogger('launch-chain');
|
|
43
47
|
const blockManagerConsole = anylogger('block-manager');
|
|
@@ -67,7 +71,7 @@ const getHostKey = path => `host.${path}`;
|
|
|
67
71
|
* @param {Map<*, *>} mailboxStorage
|
|
68
72
|
* @param {undefined | ((dstID: string, obj: any) => any)} bridgeOutbound
|
|
69
73
|
* @param {SwingStoreKernelStorage} kernelStorage
|
|
70
|
-
* @param {string | (() => string | Promise<string>)} vatconfig absolute path
|
|
74
|
+
* @param {string | (() => string | Promise<string>)} vatconfig absolute path or thunk
|
|
71
75
|
* @param {unknown} bootstrapArgs JSON-serializable data
|
|
72
76
|
* @param {{}} env
|
|
73
77
|
* @param {*} options
|
|
@@ -398,10 +402,10 @@ export async function launch({
|
|
|
398
402
|
bridgeInbound(source, body);
|
|
399
403
|
}
|
|
400
404
|
|
|
401
|
-
async function installBundle(
|
|
405
|
+
async function installBundle(bundleJson) {
|
|
402
406
|
let bundle;
|
|
403
407
|
try {
|
|
404
|
-
bundle = JSON.parse(
|
|
408
|
+
bundle = JSON.parse(bundleJson);
|
|
405
409
|
} catch (e) {
|
|
406
410
|
blockManagerConsole.warn('INSTALL_BUNDLE warn:', e);
|
|
407
411
|
return;
|
|
@@ -733,7 +737,14 @@ export async function launch({
|
|
|
733
737
|
blockTime,
|
|
734
738
|
upgradePlan,
|
|
735
739
|
});
|
|
736
|
-
//
|
|
740
|
+
// Process upgrade plan
|
|
741
|
+
const upgradedAction = {
|
|
742
|
+
type: ActionType.ENACTED_UPGRADE,
|
|
743
|
+
upgradePlan,
|
|
744
|
+
blockHeight,
|
|
745
|
+
blockTime,
|
|
746
|
+
};
|
|
747
|
+
await doBlockingSend(upgradedAction);
|
|
737
748
|
controller.writeSlogObject({
|
|
738
749
|
type: 'cosmic-swingset-upgrade-finish',
|
|
739
750
|
blockHeight,
|
|
@@ -744,6 +755,72 @@ export async function launch({
|
|
|
744
755
|
return true;
|
|
745
756
|
}
|
|
746
757
|
|
|
758
|
+
case ActionType.ENACTED_UPGRADE: {
|
|
759
|
+
// Install and execute new core proposals.
|
|
760
|
+
const {
|
|
761
|
+
upgradePlan: { info: upgradeInfoJson = null } = {},
|
|
762
|
+
blockHeight,
|
|
763
|
+
blockTime,
|
|
764
|
+
} = action;
|
|
765
|
+
const upgradePlanInfo =
|
|
766
|
+
upgradeInfoJson &&
|
|
767
|
+
parseLocatedJson(upgradeInfoJson, 'ENACTED_UPGRADE upgradePlan.info');
|
|
768
|
+
|
|
769
|
+
// Handle the planned core proposals as just another action.
|
|
770
|
+
const { coreProposals = [] } = upgradePlanInfo || {};
|
|
771
|
+
|
|
772
|
+
if (!coreProposals.length) {
|
|
773
|
+
// Nothing to do.
|
|
774
|
+
return undefined;
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
// Find scripts relative to our location.
|
|
778
|
+
const myFilename = fileURLToPath(import.meta.url);
|
|
779
|
+
const { bundles, code: coreEvalCode } =
|
|
780
|
+
await extractCoreProposalBundles(coreProposals, myFilename, {
|
|
781
|
+
handleToBundleSpec: async (handle, source, _sequence, _piece) => {
|
|
782
|
+
const bundle = await bundleSource(source);
|
|
783
|
+
const { endoZipBase64Sha512: hash } = bundle;
|
|
784
|
+
const bundleID = `b1-${hash}`;
|
|
785
|
+
handle.bundleID = bundleID;
|
|
786
|
+
harden(handle);
|
|
787
|
+
return harden([`${bundleID}: ${source}`, bundle]);
|
|
788
|
+
},
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
for (const [meta, bundle] of Object.entries(bundles)) {
|
|
792
|
+
await controller
|
|
793
|
+
.validateAndInstallBundle(bundle)
|
|
794
|
+
.catch(e => Fail`Cannot validate and install ${meta}: ${e}`);
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
// Now queue the code for evaluation.
|
|
798
|
+
//
|
|
799
|
+
// TODO: Once SwingSet sprouts some tools for preemption, we should use
|
|
800
|
+
// them to help the upgrade process finish promptly.
|
|
801
|
+
const coreEvalAction = {
|
|
802
|
+
type: ActionType.CORE_EVAL,
|
|
803
|
+
blockHeight,
|
|
804
|
+
blockTime,
|
|
805
|
+
evals: [
|
|
806
|
+
{
|
|
807
|
+
json_permits: 'true',
|
|
808
|
+
js_code: coreEvalCode,
|
|
809
|
+
},
|
|
810
|
+
],
|
|
811
|
+
};
|
|
812
|
+
highPriorityQueue.push({
|
|
813
|
+
context: {
|
|
814
|
+
blockHeight,
|
|
815
|
+
txHash: 'x/upgrade',
|
|
816
|
+
msgIdx: 0,
|
|
817
|
+
},
|
|
818
|
+
action: coreEvalAction,
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
return undefined;
|
|
822
|
+
}
|
|
823
|
+
|
|
747
824
|
case ActionType.COMMIT_BLOCK: {
|
|
748
825
|
const { blockHeight, blockTime } = action;
|
|
749
826
|
verboseBlocks &&
|