@agoric/casting 0.4.3-u12.0 → 0.4.3-u13.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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ### [0.4.3-u13.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/casting@0.4.3-u12.0...@agoric/casting@0.4.3-u13.0) (2023-12-07)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **casting:** dont crash on bad capdata ([3f01369](https://github.com/Agoric/agoric-sdk/commit/3f0136994c0b4033c872f9593cabb19bab05f01c))
12
+ * **casting:** properly follow an unpopulated state entry ([48296f7](https://github.com/Agoric/agoric-sdk/commit/48296f78f783e8e5ae1e5fbe92ae10e5e7880837))
13
+
14
+
15
+
6
16
  ### [0.4.3-u12.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/casting@0.4.3-u11wf.0...@agoric/casting@0.4.3-u12.0) (2023-11-10)
7
17
 
8
18
  **Note:** Version bump only for package @agoric/casting
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/casting",
3
- "version": "0.4.3-u12.0",
3
+ "version": "0.4.3-u13.0",
4
4
  "description": "Agoric's OCap broadcasting system",
5
5
  "type": "module",
6
6
  "main": "src/main.js",
@@ -22,10 +22,10 @@
22
22
  "author": "Agoric",
23
23
  "license": "Apache-2.0",
24
24
  "dependencies": {
25
- "@agoric/internal": "^0.4.0-u12.0",
26
- "@agoric/notifier": "^0.6.3-u12.0",
27
- "@agoric/spawner": "^0.6.9-u12.0",
28
- "@agoric/store": "^0.9.3-u12.0",
25
+ "@agoric/internal": "^0.4.0-u13.0",
26
+ "@agoric/notifier": "^0.6.3-u13.0",
27
+ "@agoric/spawner": "^0.6.9-u13.0",
28
+ "@agoric/store": "^0.9.3-u13.0",
29
29
  "@cosmjs/encoding": "^0.30.1",
30
30
  "@cosmjs/proto-signing": "^0.30.1",
31
31
  "@cosmjs/stargate": "^0.30.1",
@@ -58,5 +58,5 @@
58
58
  "timeout": "20m",
59
59
  "workerThreads": false
60
60
  },
61
- "gitHead": "ee5a5fdad9187a6b1b7b26b772b6564c0db3062e"
61
+ "gitHead": "5a6cdeb0c18ae9700d706445acf402f8d1e873c3"
62
62
  }
@@ -1 +1 @@
1
- {"version":3,"file":"follower-cosmjs.d.ts","sourceRoot":"","sources":["follower-cosmjs.js"],"names":[],"mappings":"AAiGO,+CALI,GAAG,gJAyeb;+BAnjByB,OAAO,YAAY,EAAE,QAAQ,CAAC,OAAO,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;;iCAIxF;IACZ,QAAY,CAAC,KAAK,EAAE,UAAU,CAAC;IAC/B,QAAY,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB"}
1
+ {"version":3,"file":"follower-cosmjs.d.ts","sourceRoot":"","sources":["follower-cosmjs.js"],"names":[],"mappings":"AAiGO,+CALI,GAAG,gJAgfb;+BA1jByB,OAAO,YAAY,EAAE,QAAQ,CAAC,OAAO,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;;iCAIxF;IACZ,QAAY,CAAC,KAAK,EAAE,UAAU,CAAC;IAC/B,QAAY,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB"}
@@ -330,11 +330,16 @@ export const makeCosmjsFollower = (
330
330
  blockHeight,
331
331
  currentBlockHeight,
332
332
  ) => {
333
- // AWAIT
334
- const value = await /** @type {T} */ (
335
- unserializer ? E(unserializer).fromCapData(data) : data
336
- );
337
- return { value, blockHeight, currentBlockHeight };
333
+ await null;
334
+ try {
335
+ // AWAIT
336
+ const value = await /** @type {T} */ (
337
+ unserializer ? E(unserializer).fromCapData(data) : data
338
+ );
339
+ return { value, blockHeight, currentBlockHeight };
340
+ } catch (e) {
341
+ return { blockHeight, currentBlockHeight, error: e, value: undefined };
342
+ }
338
343
  };
339
344
 
340
345
  /**
@@ -442,10 +447,12 @@ export const makeCosmjsFollower = (
442
447
  // If the block has no corresponding data, wait for the first block to
443
448
  // contain data.
444
449
  for (;;) {
445
- ({ value: cursorData, height: cursorBlockHeight } = await getDataAtHeight(
450
+ let thisHeight;
451
+ ({ value: cursorData, height: thisHeight } = await getDataAtHeight(
446
452
  cursorBlockHeight,
447
453
  ));
448
454
  if (cursorData.length !== 0) {
455
+ cursorBlockHeight = thisHeight;
449
456
  const cursorStreamCell = streamCellForData(
450
457
  cursorBlockHeight,
451
458
  cursorData,
package/src/types.d.ts CHANGED
@@ -21,11 +21,16 @@ export type Follower<T> = {
21
21
  getEachIterable: (options?: IterateEachOptions) => Promise<AsyncIterable<T>>;
22
22
  getReverseIterable: (options?: IterateEachOptions) => Promise<AsyncIterable<T>>;
23
23
  };
24
- export type ValueFollowerElement<T> = {
25
- value: T;
24
+ export type ValueFollowerBase = {
26
25
  blockHeight: number;
27
26
  currentBlockHeight: number;
28
27
  };
28
+ export type ValueFollowerElement<T> = ValueFollowerBase & ({
29
+ value: T;
30
+ } | {
31
+ value: undefined;
32
+ error: any;
33
+ });
29
34
  export type Unserializer = Pick<import('@endo/marshal').Marshal<unknown>, 'fromCapData' | 'unserialize'>;
30
35
  export type Crasher = {
31
36
  crash: (...args: unknown[]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"sBAO0B,OAAO,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;;6BAIvB,MAAM,OAAO,GAAG,YAAY,MAAM,KAAK,QAAQ,IAAI,CAAC;sBAC5D,MAAM,KAAK,QAAQ,IAAI,CAAC;2BACxB,MAAM,KAAK,QAAQ,OAAO,CAAC;;;;YAMnC,UAAU,EAAE;;;mBAKJ,MAAM,SAAS,GAAG,YAAY,MAAM,KAAK,QAAQ,IAAI,CAAC;oBACtD,MAAM,KAAK,QAAQ,IAAI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C,CAAC,CAAC;mCAChD,kBAAkB,KAAK,QAAQ,cAAc,CAAC,CAAC,CAAC;;;iBAK3D,MAAM;wBACN,MAAM;;sCAMP,iBAAiB,GAAG,CAAC;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAAC;2BAIrE,KAAK,OAAO,eAAe,EAAE,OAAO,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,aAAa,CAAC;;qBAKlE,OAAO,EAAE,KAAK,IAAI;;;;qBAMrB,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;iBAuBrB,MAAM;YACN,MAAM,CAAC,CAAC"}
package/src/types.js CHANGED
@@ -40,14 +40,17 @@ export {};
40
40
  */
41
41
 
42
42
  /**
43
- * @see {ChangeFollower}
44
- * @template T
45
- * @typedef {object} ValueFollowerElement
46
- * @property {T} value
43
+ * @typedef {object} ValueFollowerBase
47
44
  * @property {number} blockHeight
48
45
  * @property {number} currentBlockHeight
49
46
  */
50
47
 
48
+ /**
49
+ * @see {ChangeFollower}
50
+ * @template T
51
+ * @typedef {ValueFollowerBase & ({ value: T } | { value: undefined, error: any })} ValueFollowerElement
52
+ */
53
+
51
54
  /**
52
55
  * @typedef {Pick<import('@endo/marshal').Marshal<unknown>, 'fromCapData' | 'unserialize'>} Unserializer
53
56
  */
package/test/test-mvp.js CHANGED
@@ -1,5 +1,8 @@
1
1
  // @ts-nocheck
2
2
  // eslint-disable-next-line import/order
3
+ import './lockdown.js';
4
+
5
+ import { makeMarshal } from '@endo/marshal';
3
6
  import { test } from './prepare-test-env-ava.js';
4
7
 
5
8
  import {
@@ -167,6 +170,59 @@ test('unrecognized proof', async t => {
167
170
  );
168
171
  });
169
172
 
173
+ test('yields error on bad capdata without terminating', async t => {
174
+ const marshal = makeMarshal();
175
+ const improperlyMarshalledData = { bad: 'data' };
176
+ const properlyMarshalledData = { foo: 'bar' };
177
+ const fakeValues = [
178
+ improperlyMarshalledData,
179
+ marshal.toCapData(harden(properlyMarshalledData)),
180
+ ];
181
+ t.plan(4);
182
+ const options = { batchSize: 1, marshaller: { toCapData: data => data } };
183
+ const { controller, PORT } = await t.context.startFakeServer(
184
+ t,
185
+ fakeValues,
186
+ options,
187
+ );
188
+ controller.advance(0);
189
+ /** @type {import('../src/types.js').LeaderOptions} */
190
+ const lo = {
191
+ retryCallback: null, // fail fast, no retries
192
+ keepPolling: () => delay(1000).then(() => true), // poll really quickly
193
+ jitter: null, // no jitter
194
+ };
195
+ /** @type {import('../src/types.js').FollowerOptions} */
196
+ const so = {
197
+ proof: 'none',
198
+ };
199
+
200
+ const leader = makeLeader(`http://localhost:${PORT}/network-config`, lo);
201
+ const castingSpec = makeCastingSpec(':mailbox.agoric1foobarbaz');
202
+ const follower = await makeFollower(castingSpec, leader, so);
203
+ let i = 0;
204
+ // eslint-disable-next-line no-unreachable-loop
205
+ for await (const { value, error } of iterateEach(follower)) {
206
+ if (i === 0) {
207
+ t.log(`value from follower, should be undefined:`, value);
208
+ t.log(`error from follower, should be defined:`, error);
209
+
210
+ t.deepEqual(value, undefined);
211
+ t.assert(typeof error === 'object');
212
+
213
+ i += 1;
214
+ controller.advance(1);
215
+ } else if (i === 1) {
216
+ t.log(`value from follower, should be defined:`, value);
217
+ t.log(`error from follower, should be undefined:`, error);
218
+
219
+ t.deepEqual(value, properlyMarshalledData);
220
+ t.deepEqual(error, undefined);
221
+ break;
222
+ }
223
+ }
224
+ });
225
+
170
226
  test.before(t => {
171
227
  t.context.cleanups = [];
172
228
  t.context.startFakeServer = startFakeServer;