@agoric/cosmic-swingset 0.41.4-dev-fed2b5e.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.
@@ -1,8 +1,8 @@
1
1
  [
2
- "@agoric/vats/scripts/init-core.js",
3
- "@agoric/vats/scripts/init-network.js",
2
+ "@agoric/builders/scripts/vats/init-core.js",
3
+ "@agoric/builders/scripts/vats/init-network.js",
4
4
  {
5
- "module": "@agoric/inter-protocol/scripts/init-core.js",
5
+ "module": "@agoric/builders/scripts/inter-protocol/init-core.js",
6
6
  "entrypoint": "defaultProposalBuilder",
7
7
  "args": [
8
8
  {
@@ -13,9 +13,9 @@
13
13
  }
14
14
  ]
15
15
  },
16
- "@agoric/pegasus/scripts/init-core.js",
16
+ "@agoric/builders/scripts/pegasus/init-core.js",
17
17
  {
18
- "module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
18
+ "module": "@agoric/builders/scripts/inter-protocol/add-collateral-core.js",
19
19
  "entrypoint": "defaultProposalBuilder",
20
20
  "args": [
21
21
  {
@@ -30,7 +30,7 @@
30
30
  ]
31
31
  },
32
32
  {
33
- "module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
33
+ "module": "@agoric/builders/scripts/inter-protocol/add-collateral-core.js",
34
34
  "entrypoint": "psmProposalBuilder",
35
35
  "args": [
36
36
  {
@@ -44,7 +44,7 @@
44
44
  ]
45
45
  },
46
46
  {
47
- "module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
47
+ "module": "@agoric/builders/scripts/inter-protocol/add-collateral-core.js",
48
48
  "entrypoint": "psmProposalBuilder",
49
49
  "args": [
50
50
  {
@@ -58,7 +58,7 @@
58
58
  ]
59
59
  },
60
60
  {
61
- "module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
61
+ "module": "@agoric/builders/scripts/inter-protocol/add-collateral-core.js",
62
62
  "entrypoint": "psmProposalBuilder",
63
63
  "args": [
64
64
  {
@@ -72,7 +72,7 @@
72
72
  ]
73
73
  },
74
74
  {
75
- "module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
75
+ "module": "@agoric/builders/scripts/inter-protocol/add-collateral-core.js",
76
76
  "entrypoint": "psmProposalBuilder",
77
77
  "args": [
78
78
  {
@@ -86,7 +86,7 @@
86
86
  ]
87
87
  },
88
88
  {
89
- "module": "@agoric/inter-protocol/scripts/add-collateral-core.js",
89
+ "module": "@agoric/builders/scripts/inter-protocol/add-collateral-core.js",
90
90
  "entrypoint": "psmProposalBuilder",
91
91
  "args": [
92
92
  {
@@ -100,7 +100,7 @@
100
100
  ]
101
101
  },
102
102
  {
103
- "module": "@agoric/inter-protocol/scripts/price-feed-core.js",
103
+ "module": "@agoric/builders/scripts/inter-protocol/price-feed-core.js",
104
104
  "entrypoint": "defaultProposalBuilder",
105
105
  "args": [
106
106
  {
@@ -125,7 +125,7 @@
125
125
  ]
126
126
  },
127
127
  {
128
- "module": "@agoric/inter-protocol/scripts/invite-committee-core.js",
128
+ "module": "@agoric/builders/scripts/inter-protocol/invite-committee-core.js",
129
129
  "entrypoint": "defaultProposalBuilder",
130
130
  "args": [
131
131
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cosmic-swingset",
3
- "version": "0.41.4-dev-fed2b5e.0+fed2b5e",
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-fed2b5e.0+fed2b5e",
26
- "@agoric/cosmos": "0.34.2-dev-fed2b5e.0+fed2b5e",
27
- "@agoric/deploy-script-support": "0.10.4-dev-fed2b5e.0+fed2b5e",
28
- "@agoric/internal": "0.3.3-dev-fed2b5e.0+fed2b5e",
29
- "@agoric/store": "0.9.3-dev-fed2b5e.0+fed2b5e",
30
- "@agoric/swing-store": "0.9.2-dev-fed2b5e.0+fed2b5e",
31
- "@agoric/swingset-vat": "0.32.3-dev-fed2b5e.0+fed2b5e",
32
- "@agoric/telemetry": "0.6.3-dev-fed2b5e.0+fed2b5e",
33
- "@agoric/vm-config": "0.1.1-dev-fed2b5e.0+fed2b5e",
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": "fed2b5e4658fc5b55c794622aa1684a8093f1604"
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
+ };
@@ -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(bundleSource) {
405
+ async function installBundle(bundleJson) {
402
406
  let bundle;
403
407
  try {
404
- bundle = JSON.parse(bundleSource);
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
- // TODO: Process upgrade plan
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 &&