@agoric/internal 0.3.3-other-dev-8f8782b.0 → 0.3.3-other-dev-fbe72e7.0.fbe72e7
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/README.md +7 -2
- package/exported.js +2 -0
- package/package.json +41 -19
- package/src/action-types.d.ts +51 -5
- package/src/action-types.d.ts.map +1 -1
- package/src/action-types.js +74 -15
- package/src/batched-deliver.d.ts +9 -6
- package/src/batched-deliver.d.ts.map +1 -1
- package/src/batched-deliver.js +9 -3
- package/src/callback.d.ts +24 -17
- package/src/callback.d.ts.map +1 -1
- package/src/callback.js +55 -61
- package/src/chain-storage-paths.d.ts +2 -3
- package/src/chain-storage-paths.d.ts.map +1 -1
- package/src/chain-storage-paths.js +2 -3
- package/src/chain-utils.d.ts +27 -0
- package/src/chain-utils.d.ts.map +1 -0
- package/src/chain-utils.js +62 -0
- package/src/cli-utils.d.ts +2 -0
- package/src/cli-utils.d.ts.map +1 -0
- package/src/cli-utils.js +21 -0
- package/src/config.d.ts +22 -12
- package/src/config.d.ts.map +1 -1
- package/src/config.js +23 -10
- package/src/debug.d.ts +1 -1
- package/src/errors.d.ts +2 -0
- package/src/errors.d.ts.map +1 -0
- package/src/errors.js +16 -0
- package/src/hex.d.ts +15 -0
- package/src/hex.d.ts.map +1 -0
- package/src/hex.js +105 -0
- package/src/index.d.ts +10 -1
- package/src/index.js +13 -2
- package/src/install-ses-debug.d.ts +2 -0
- package/src/install-ses-debug.d.ts.map +1 -0
- package/src/install-ses-debug.js +6 -0
- package/src/js-utils.d.ts +40 -0
- package/src/js-utils.d.ts.map +1 -0
- package/src/js-utils.js +237 -0
- package/src/lib-chainStorage.d.ts +59 -67
- package/src/lib-chainStorage.d.ts.map +1 -1
- package/src/lib-chainStorage.js +95 -92
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts +13 -0
- package/src/lib-nodejs/ava-unhandled-rejection.d.ts.map +1 -0
- package/src/lib-nodejs/ava-unhandled-rejection.js +66 -0
- package/src/lib-nodejs/engine-gc.d.ts +3 -0
- package/src/lib-nodejs/engine-gc.d.ts.map +1 -0
- package/src/lib-nodejs/engine-gc.js +22 -0
- package/src/lib-nodejs/gc-and-finalize.d.ts +2 -0
- package/src/lib-nodejs/gc-and-finalize.d.ts.map +1 -0
- package/src/lib-nodejs/gc-and-finalize.js +91 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts +15 -0
- package/src/lib-nodejs/spawnSubprocessWorker.d.ts.map +1 -0
- package/src/lib-nodejs/spawnSubprocessWorker.js +89 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts +2 -0
- package/src/lib-nodejs/waitUntilQuiescent.d.ts.map +1 -0
- package/src/lib-nodejs/waitUntilQuiescent.js +18 -0
- package/src/lib-nodejs/worker-protocol.d.ts +4 -0
- package/src/lib-nodejs/worker-protocol.d.ts.map +1 -0
- package/src/lib-nodejs/worker-protocol.js +54 -0
- package/src/magic-cookie-test-only.js +2 -2
- package/src/marshal.d.ts +33 -0
- package/src/marshal.d.ts.map +1 -0
- package/src/marshal.js +156 -0
- package/src/method-tools.d.ts +1 -0
- package/src/method-tools.d.ts.map +1 -1
- package/src/method-tools.js +33 -62
- package/src/metrics.d.ts +183 -0
- package/src/metrics.d.ts.map +1 -0
- package/src/metrics.js +476 -0
- package/src/module-utils.d.ts +2 -0
- package/src/module-utils.d.ts.map +1 -0
- package/src/module-utils.js +27 -0
- package/src/natural-sort.d.ts +2 -0
- package/src/natural-sort.d.ts.map +1 -0
- package/src/natural-sort.js +48 -0
- package/src/netstring.d.ts +24 -0
- package/src/netstring.d.ts.map +1 -0
- package/src/netstring.js +125 -0
- package/src/node/buffer-line-transform.d.ts +20 -16
- package/src/node/buffer-line-transform.d.ts.map +1 -1
- package/src/node/buffer-line-transform.js +12 -9
- package/src/node/createBundles.d.ts.map +1 -1
- package/src/node/createBundles.js +12 -3
- package/src/node/fs-stream.d.ts +1 -1
- package/src/node/fs-stream.d.ts.map +1 -1
- package/src/node/fs-stream.js +48 -37
- package/src/node/shutdown.d.ts.map +1 -1
- package/src/node/shutdown.js +0 -1
- package/src/priority-senders.d.ts +2 -1
- package/src/priority-senders.d.ts.map +1 -1
- package/src/priority-senders.js +10 -4
- package/src/queue.d.ts +1 -1
- package/src/queue.d.ts.map +1 -1
- package/src/queue.js +7 -8
- package/src/scratch.d.ts +1 -1
- package/src/scratch.d.ts.map +1 -1
- package/src/ses-utils.d.ts +68 -0
- package/src/ses-utils.d.ts.map +1 -0
- package/src/ses-utils.js +422 -0
- package/src/storage-test-utils.d.ts +49 -84
- package/src/storage-test-utils.d.ts.map +1 -1
- package/src/storage-test-utils.js +234 -116
- package/src/tagged.d.ts +152 -0
- package/src/testing-utils.d.ts +2 -0
- package/src/testing-utils.d.ts.map +1 -1
- package/src/testing-utils.js +44 -5
- package/src/tmpDir.d.ts +2 -0
- package/src/tmpDir.d.ts.map +1 -0
- package/src/tmpDir.js +17 -0
- package/src/tokens.d.ts +34 -0
- package/src/tokens.d.ts.map +1 -0
- package/src/tokens.js +35 -0
- package/src/typeCheck.d.ts +9 -0
- package/src/typeCheck.d.ts.map +1 -0
- package/src/typeCheck.js +23 -0
- package/src/typeGuards.d.ts +17 -0
- package/src/typeGuards.d.ts.map +1 -1
- package/src/typeGuards.js +20 -0
- package/src/types-index.d.ts +1 -0
- package/src/types-index.js +2 -0
- package/src/types.d.ts +83 -18
- package/src/types.d.ts.map +1 -0
- package/src/types.ts +129 -0
- package/src/upgrade-api.d.ts +14 -4
- package/src/upgrade-api.d.ts.map +1 -1
- package/src/upgrade-api.js +50 -18
- package/CHANGELOG.md +0 -106
- package/src/utils.d.ts +0 -67
- package/src/utils.d.ts.map +0 -1
- package/src/utils.js +0 -451
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* eslint-env node */
|
|
2
|
+
import { Transform } from 'stream';
|
|
3
|
+
|
|
4
|
+
// Transform objects which convert from hardened Arrays of JSON-serializable
|
|
5
|
+
// data into Buffers suitable for netstring conversion.
|
|
6
|
+
|
|
7
|
+
export function arrayEncoderStream() {
|
|
8
|
+
/**
|
|
9
|
+
* @param {any} object
|
|
10
|
+
* @param {BufferEncoding} encoding
|
|
11
|
+
* @param {any} callback
|
|
12
|
+
* @this {{ push: (b: Buffer) => void }}
|
|
13
|
+
*/
|
|
14
|
+
function transform(object, encoding, callback) {
|
|
15
|
+
if (!Array.isArray(object)) {
|
|
16
|
+
throw Error('stream requires Arrays');
|
|
17
|
+
}
|
|
18
|
+
let err;
|
|
19
|
+
try {
|
|
20
|
+
this.push(Buffer.from(JSON.stringify(object)));
|
|
21
|
+
} catch (e) {
|
|
22
|
+
err = e;
|
|
23
|
+
}
|
|
24
|
+
callback(err);
|
|
25
|
+
}
|
|
26
|
+
// Array in, Buffer out, hence writableObjectMode
|
|
27
|
+
return new Transform({ transform, writableObjectMode: true });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function arrayDecoderStream() {
|
|
31
|
+
/**
|
|
32
|
+
* @param {Buffer} buf
|
|
33
|
+
* @param {BufferEncoding} encoding
|
|
34
|
+
* @param {any} callback
|
|
35
|
+
* @this {{ push: (b: Buffer) => void }}
|
|
36
|
+
*/
|
|
37
|
+
function transform(buf, encoding, callback) {
|
|
38
|
+
let err;
|
|
39
|
+
try {
|
|
40
|
+
if (!Buffer.isBuffer(buf)) {
|
|
41
|
+
throw Error('stream expects Buffers');
|
|
42
|
+
}
|
|
43
|
+
this.push(JSON.parse(buf.toString()));
|
|
44
|
+
} catch (e) {
|
|
45
|
+
err = e;
|
|
46
|
+
}
|
|
47
|
+
// this Transform is a one-to-one conversion of Buffer into Array, so we
|
|
48
|
+
// always consume the input each time we're called
|
|
49
|
+
callback(err);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Buffer in, Array out, hence readableObjectMode
|
|
53
|
+
return new Transform({ transform, readableObjectMode: true });
|
|
54
|
+
}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const cookie = harden({});
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Facilitate static analysis to prevent
|
|
7
|
-
*
|
|
6
|
+
* Facilitate static analysis to prevent demo/test facilities from being bundled
|
|
7
|
+
* in production.
|
|
8
8
|
*/
|
|
9
9
|
export const notForProductionUse = () => {
|
|
10
10
|
return cookie;
|
package/src/marshal.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function makeBoardRemote({ boardId, iface }: {
|
|
2
|
+
boardId: string | null;
|
|
3
|
+
iface?: string;
|
|
4
|
+
}): BoardRemote;
|
|
5
|
+
export function slotToBoardRemote(boardId: string, iface: string): BoardRemote;
|
|
6
|
+
export function boardSlottingMarshaller(slotToVal?: (slot: string, iface: string) => any): Omit<import("@endo/marshal").Marshal<string | null>, "serialize" | "unserialize">;
|
|
7
|
+
/**
|
|
8
|
+
* @type {TypedPattern<CapData<any>>}
|
|
9
|
+
*/
|
|
10
|
+
export const CapDataShape: TypedPattern<CapData<any>>;
|
|
11
|
+
export function assertCapData(data: unknown): asserts data is CapData<unknown>;
|
|
12
|
+
export function unmarshalFromVstorage(data: Map<string, string>, key: string, fromCapData: ReturnType<typeof import("@endo/marshal").makeMarshal>["fromCapData"], index: number): any;
|
|
13
|
+
export function makeHistoryReviver(entries: [string, string][], slotToVal?: (slot: string, iface?: string) => any): {
|
|
14
|
+
getItem: (key: string) => any;
|
|
15
|
+
children: (prefix: string) => string[];
|
|
16
|
+
has: (k: string) => boolean;
|
|
17
|
+
};
|
|
18
|
+
export const pureDataMarshaller: {
|
|
19
|
+
toCapData: import("@endo/marshal").ToCapData<CapData<unknown>>;
|
|
20
|
+
fromCapData: import("@endo/marshal").FromCapData<CapData<unknown>>;
|
|
21
|
+
serialize: import("@endo/marshal").ToCapData<CapData<unknown>>;
|
|
22
|
+
unserialize: import("@endo/marshal").FromCapData<CapData<unknown>>;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Should be a union with Remotable, but that's `any`, making this type
|
|
26
|
+
* meaningless
|
|
27
|
+
*/
|
|
28
|
+
export type BoardRemote = {
|
|
29
|
+
getBoardId: () => string | null;
|
|
30
|
+
};
|
|
31
|
+
import type { CapData } from '@endo/marshal';
|
|
32
|
+
import type { TypedPattern } from './types.js';
|
|
33
|
+
//# sourceMappingURL=marshal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marshal.d.ts","sourceRoot":"","sources":["marshal.js"],"names":[],"mappings":"AAuBO,oDAHI;IAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,WAAW,CAKvB;AAMM,2CAHI,MAAM,SACN,MAAM,eAGoB;AAqB9B,oDANI,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,GAClC,IAAI,CAChB,OAAW,eAAe,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,EAClD,WAAe,GAAG,aAAa,CAC5B,CAMH;AAGD;;GAEG;AACH,2BAFU,aAAa,QAAQ,GAAG,CAAC,CAAC,CAE+B;AAS5D,oCAHI,OAAO,GACL,QAAQ,IAAI,IAAI,QAAQ,OAAO,CAAC,CAO5C;AAeM,4CATI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,OACnB,MAAM,eACN,UAAU,CACpB,cAAkB,eAAe,EAAE,WAAW,CAC3C,CAAC,aAAa,CAAC,SACR,MAAM,GAEJ,GAAG,CAwBf;AASM,4CAHI,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,cAClB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,GAAG;mBAQlC,MAAM;uBAEN,MAAM;aAYN,MAAM;EAInB;AAID;;;;;EAEG;;;;;0BA1IU;IAAE,UAAU,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;CAAE;6BARtB,eAAe;kCACV,YAAY"}
|
package/src/marshal.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
import { Fail } from '@endo/errors';
|
|
3
|
+
import { Far } from '@endo/far';
|
|
4
|
+
import { makeMarshal } from '@endo/marshal';
|
|
5
|
+
import { M } from '@endo/patterns';
|
|
6
|
+
import { isStreamCell } from './lib-chainStorage.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @import {CapData} from '@endo/marshal';
|
|
10
|
+
* @import {TypedPattern} from './types.js';
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Should be a union with Remotable, but that's `any`, making this type
|
|
15
|
+
* meaningless
|
|
16
|
+
*
|
|
17
|
+
* @typedef {{ getBoardId: () => string | null }} BoardRemote
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @param {{ boardId: string | null; iface?: string }} slotInfo
|
|
22
|
+
* @returns {BoardRemote}
|
|
23
|
+
*/
|
|
24
|
+
export const makeBoardRemote = ({ boardId, iface }) => {
|
|
25
|
+
const nonalleged = iface ? iface.replace(/^Alleged: /, '') : '';
|
|
26
|
+
return Far(`BoardRemote${nonalleged}`, { getBoardId: () => boardId });
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} boardId
|
|
31
|
+
* @param {string} iface
|
|
32
|
+
*/
|
|
33
|
+
export const slotToBoardRemote = (boardId, iface) =>
|
|
34
|
+
makeBoardRemote({ boardId, iface });
|
|
35
|
+
|
|
36
|
+
/** @param {BoardRemote | object} val */
|
|
37
|
+
const boardValToSlot = val => {
|
|
38
|
+
if ('getBoardId' in val) {
|
|
39
|
+
return val.getBoardId();
|
|
40
|
+
}
|
|
41
|
+
throw Fail`unknown obj in boardSlottingMarshaller.valToSlot ${val}`;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A marshaller which can serialize getBoardId() -bearing Remotables. This
|
|
46
|
+
* allows the caller to pick their slots. The deserializer is configurable: the
|
|
47
|
+
* default cannot handle Remotable-bearing data.
|
|
48
|
+
*
|
|
49
|
+
* @param {(slot: string, iface: string) => any} [slotToVal]
|
|
50
|
+
* @returns {Omit<
|
|
51
|
+
* import('@endo/marshal').Marshal<string | null>,
|
|
52
|
+
* 'serialize' | 'unserialize'
|
|
53
|
+
* >}
|
|
54
|
+
*/
|
|
55
|
+
export const boardSlottingMarshaller = (slotToVal = undefined) => {
|
|
56
|
+
return makeMarshal(boardValToSlot, slotToVal, {
|
|
57
|
+
serializeBodyFormat: 'smallcaps',
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// TODO move CapDataShape to Endo
|
|
62
|
+
/**
|
|
63
|
+
* @type {TypedPattern<CapData<any>>}
|
|
64
|
+
*/
|
|
65
|
+
export const CapDataShape = { body: M.string(), slots: M.array() };
|
|
66
|
+
harden(CapDataShape);
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Assert that this is CapData
|
|
70
|
+
*
|
|
71
|
+
* @param {unknown} data
|
|
72
|
+
* @returns {asserts data is CapData<unknown>}
|
|
73
|
+
*/
|
|
74
|
+
export const assertCapData = data => {
|
|
75
|
+
assert.typeof(data, 'object');
|
|
76
|
+
assert(data);
|
|
77
|
+
typeof data.body === 'string' || Fail`data has non-string .body ${data.body}`;
|
|
78
|
+
Array.isArray(data.slots) || Fail`data has non-Array slots ${data.slots}`;
|
|
79
|
+
};
|
|
80
|
+
harden(assertCapData);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Read and unmarshal a value from a map representation of vstorage data
|
|
84
|
+
*
|
|
85
|
+
* @param {Map<string, string>} data
|
|
86
|
+
* @param {string} key
|
|
87
|
+
* @param {ReturnType<
|
|
88
|
+
* typeof import('@endo/marshal').makeMarshal
|
|
89
|
+
* >['fromCapData']} fromCapData
|
|
90
|
+
* @param {number} index index of the desired value in a deserialized stream
|
|
91
|
+
* cell
|
|
92
|
+
* @returns {any}
|
|
93
|
+
*/
|
|
94
|
+
export const unmarshalFromVstorage = (data, key, fromCapData, index) => {
|
|
95
|
+
const serialized = data.get(key) || Fail`no data for ${key}`;
|
|
96
|
+
assert.typeof(serialized, 'string');
|
|
97
|
+
assert.typeof(index, 'number');
|
|
98
|
+
|
|
99
|
+
const streamCell = JSON.parse(serialized);
|
|
100
|
+
if (!isStreamCell(streamCell)) {
|
|
101
|
+
throw Fail`not a StreamCell: ${streamCell}`;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const { values } = streamCell;
|
|
105
|
+
values.length > 0 || Fail`no StreamCell values: ${streamCell}`;
|
|
106
|
+
|
|
107
|
+
const marshalled = values.at(index);
|
|
108
|
+
assert.typeof(marshalled, 'string');
|
|
109
|
+
|
|
110
|
+
/** @type {import('@endo/marshal').CapData<string>} */
|
|
111
|
+
const capData = harden(JSON.parse(marshalled));
|
|
112
|
+
assertCapData(capData);
|
|
113
|
+
|
|
114
|
+
const unmarshalled = fromCapData(capData);
|
|
115
|
+
return unmarshalled;
|
|
116
|
+
};
|
|
117
|
+
harden(unmarshalFromVstorage);
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Provide access to object graphs serialized in vstorage.
|
|
121
|
+
*
|
|
122
|
+
* @param {[string, string][]} entries
|
|
123
|
+
* @param {(slot: string, iface?: string) => any} [slotToVal]
|
|
124
|
+
*/
|
|
125
|
+
export const makeHistoryReviver = (entries, slotToVal = undefined) => {
|
|
126
|
+
const board = boardSlottingMarshaller(slotToVal);
|
|
127
|
+
const vsMap = new Map(entries);
|
|
128
|
+
/** @param {...unknown} args } */
|
|
129
|
+
const fromCapData = (...args) =>
|
|
130
|
+
Reflect.apply(board.fromCapData, board, args);
|
|
131
|
+
/** @param {string} key } */
|
|
132
|
+
const getItem = key => unmarshalFromVstorage(vsMap, key, fromCapData, -1);
|
|
133
|
+
/** @param {string} prefix } */
|
|
134
|
+
const children = prefix => {
|
|
135
|
+
prefix.endsWith('.') || Fail`prefix must end with '.'`;
|
|
136
|
+
return harden([
|
|
137
|
+
...new Set(
|
|
138
|
+
entries
|
|
139
|
+
.map(([k, _]) => k)
|
|
140
|
+
.filter(k => k.startsWith(prefix))
|
|
141
|
+
.map(k => k.slice(prefix.length).split('.')[0]),
|
|
142
|
+
),
|
|
143
|
+
]);
|
|
144
|
+
};
|
|
145
|
+
/** @param {string} k } */
|
|
146
|
+
const has = k => vsMap.get(k) !== undefined;
|
|
147
|
+
|
|
148
|
+
return harden({ getItem, children, has });
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/** @param {import('@endo/marshal').CapData<unknown>} cap */
|
|
152
|
+
const rejectOCap = cap => Fail`${cap} is not pure data`;
|
|
153
|
+
export const pureDataMarshaller = makeMarshal(rejectOCap, rejectOCap, {
|
|
154
|
+
serializeBodyFormat: 'smallcaps',
|
|
155
|
+
});
|
|
156
|
+
harden(pureDataMarshaller);
|
package/src/method-tools.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export function getMethodNames<K extends PropertyKey>(val: Record<K, any>): K[];
|
|
2
|
+
export function getStringMethodNames<K extends PropertyKey>(val: Record<K, any>): string[];
|
|
2
3
|
export function bindAllMethods<T extends Record<PropertyKey, any>>(obj: T): T;
|
|
3
4
|
//# sourceMappingURL=method-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-tools.d.ts","sourceRoot":"","sources":["method-tools.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"method-tools.d.ts","sourceRoot":"","sources":["method-tools.js"],"names":[],"mappings":"AAmBO,+BAJoB,CAAC,SAAd,WAAY,OACf,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,CAAC,EAAE,CAG8B;AAUvC,qCAJoB,CAAC,SAAd,WAAY,OACf,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GACZ,MAAM,EAAE,CAKlB;AA+BI,+BAJiC,CAAC,SAA3B,MAAM,CAAC,WAAW,EAAE,GAAG,CAAE,OAC5B,CAAC,GACC,CAAC,CAiBX"}
|
package/src/method-tools.js
CHANGED
|
@@ -1,86 +1,57 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import {
|
|
2
|
+
import { getMethodNames as realGetMethodNames } from '@endo/eventual-send/utils.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @file method-tools use dynamic property lookup, which is not
|
|
5
|
+
* @file method-tools use dynamic property lookup, which is not
|
|
6
|
+
* Jessie-compatible
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
const {
|
|
9
|
-
|
|
10
|
-
const { ownKeys, apply } = Reflect;
|
|
9
|
+
const { create, fromEntries } = Object;
|
|
10
|
+
const { apply } = Reflect;
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* TODO Consolidate with the `getMethodNames` in `@endo/eventual-send`
|
|
14
14
|
*
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
15
|
+
* @deprecated Use `getMethodNames` from `@endo/eventual-send/utils.js` instead.
|
|
16
|
+
* @template {PropertyKey} K
|
|
17
|
+
* @param {Record<K, any>} val
|
|
18
|
+
* @returns {K[]}
|
|
18
19
|
*/
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const right = String(b);
|
|
23
|
-
// eslint-disable-next-line no-nested-ternary
|
|
24
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
25
|
-
}
|
|
26
|
-
if (typeof a === 'symbol') {
|
|
27
|
-
assert(typeof b === 'string');
|
|
28
|
-
return -1;
|
|
29
|
-
}
|
|
30
|
-
assert(typeof a === 'string');
|
|
31
|
-
assert(typeof b === 'symbol');
|
|
32
|
-
return 1;
|
|
33
|
-
};
|
|
20
|
+
export const getMethodNames = val =>
|
|
21
|
+
/** @type {K[]} */ (realGetMethodNames(val));
|
|
22
|
+
harden(getMethodNames);
|
|
34
23
|
|
|
35
24
|
/**
|
|
36
|
-
*
|
|
25
|
+
* The subset of `getMethodNames` containing only string names, without symbols
|
|
37
26
|
*
|
|
38
27
|
* @template {PropertyKey} K
|
|
39
28
|
* @param {Record<K, any>} val
|
|
40
|
-
* @returns {
|
|
29
|
+
* @returns {string[]}
|
|
41
30
|
*/
|
|
42
|
-
export const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
// be tolerant of non-objects
|
|
47
|
-
const descs = getOwnPropertyDescriptors(layer);
|
|
48
|
-
const ownNames = /** @type {K[]} */ (ownKeys(descs));
|
|
49
|
-
for (const name of ownNames) {
|
|
50
|
-
// In case a method is overridden by a non-method,
|
|
51
|
-
// test `val[name]` rather than `layer[name]`
|
|
52
|
-
if (typeof val[name] === 'function') {
|
|
53
|
-
names.add(name);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
if (!isObject(val)) {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
layer = getPrototypeOf(layer);
|
|
60
|
-
}
|
|
61
|
-
return harden([...names].sort(compareStringified));
|
|
62
|
-
};
|
|
63
|
-
harden(getMethodNames);
|
|
31
|
+
export const getStringMethodNames = val =>
|
|
32
|
+
/** @type {string[]} */ (
|
|
33
|
+
realGetMethodNames(val).filter(name => typeof name === 'string')
|
|
34
|
+
);
|
|
64
35
|
|
|
65
36
|
/**
|
|
66
37
|
* TODO This function exists only to ease the
|
|
67
38
|
* https://github.com/Agoric/agoric-sdk/pull/5970 transition, from all methods
|
|
68
|
-
* being own properties to methods being inherited from a common prototype.
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
39
|
+
* being own properties to methods being inherited from a common prototype. This
|
|
40
|
+
* transition breaks two patterns used in prior code: autobinding, and
|
|
41
|
+
* enumerating methods by enumerating own properties. For both, the preferred
|
|
42
|
+
* repairs are
|
|
43
|
+
*
|
|
44
|
+
* - autobinding: Replace, for example, `foo(obj.method)` with `foo(arg =>
|
|
45
|
+
* `obj.method(arg))`. IOW, stop relying on expressions like `obj.method`to
|
|
46
|
+
* extract a method still bound to the state of`obj` because, for virtual and
|
|
47
|
+
* durable objects, they no longer will after #5970.
|
|
48
|
+
* - method enumeration: Replace, for example `Reflect.ownKeys(obj)` with
|
|
49
|
+
* `getMethodNames(obj)`.
|
|
79
50
|
*
|
|
80
51
|
* Once all problematic cases have been converted in this manner, this
|
|
81
52
|
* `bindAllMethods` hack can and TODO should be deleted. However, we currently
|
|
82
|
-
* have no reliable static way to track down and fix all autobinding sites.
|
|
83
|
-
*
|
|
53
|
+
* have no reliable static way to track down and fix all autobinding sites. For
|
|
54
|
+
* those objects that have not yet been fully repaired by the above two
|
|
84
55
|
* techniques, `bindAllMethods` creates an object that acts much like the
|
|
85
56
|
* pre-#5970 objects, with all their methods as instance-bound own properties.
|
|
86
57
|
* It does this by making a new object inheriting from `obj` where the new
|
|
@@ -96,7 +67,7 @@ export const bindAllMethods = obj =>
|
|
|
96
67
|
create(
|
|
97
68
|
obj,
|
|
98
69
|
fromEntries(
|
|
99
|
-
|
|
70
|
+
realGetMethodNames(obj).map(name => [
|
|
100
71
|
name,
|
|
101
72
|
{
|
|
102
73
|
value: (/** @type {unknown[]} */ ...args) =>
|
package/src/metrics.d.ts
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
export namespace HISTOGRAM_METRICS {
|
|
2
|
+
namespace swingset_crank_processing_time {
|
|
3
|
+
let description: "Processing time per crank (ms)";
|
|
4
|
+
let unit: "ms";
|
|
5
|
+
let boundaries: number[];
|
|
6
|
+
}
|
|
7
|
+
namespace swingset_block_processing_seconds {
|
|
8
|
+
let description_1: "Processing time per block";
|
|
9
|
+
export { description_1 as description };
|
|
10
|
+
let unit_1: "s";
|
|
11
|
+
export { unit_1 as unit };
|
|
12
|
+
export { HISTOGRAM_SECONDS_LATENCY_BOUNDARIES as boundaries };
|
|
13
|
+
}
|
|
14
|
+
namespace swingset_vat_startup {
|
|
15
|
+
let description_2: "Vat startup time (ms)";
|
|
16
|
+
export { description_2 as description };
|
|
17
|
+
let unit_2: "ms";
|
|
18
|
+
export { unit_2 as unit };
|
|
19
|
+
export { HISTOGRAM_MS_LATENCY_BOUNDARIES as boundaries };
|
|
20
|
+
}
|
|
21
|
+
namespace swingset_vat_delivery {
|
|
22
|
+
let description_3: "Vat delivery time (ms)";
|
|
23
|
+
export { description_3 as description };
|
|
24
|
+
let unit_3: "ms";
|
|
25
|
+
export { unit_3 as unit };
|
|
26
|
+
export { HISTOGRAM_MS_LATENCY_BOUNDARIES as boundaries };
|
|
27
|
+
}
|
|
28
|
+
namespace swingset_meter_usage {
|
|
29
|
+
let description_4: "Vat meter usage";
|
|
30
|
+
export { description_4 as description };
|
|
31
|
+
let unit_4: "ms";
|
|
32
|
+
export { unit_4 as unit };
|
|
33
|
+
export { HISTOGRAM_MS_LATENCY_BOUNDARIES as boundaries };
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export namespace BLOCK_HISTOGRAM_METRICS {
|
|
37
|
+
namespace swingsetRunSeconds {
|
|
38
|
+
let unit_5: string;
|
|
39
|
+
export { unit_5 as unit };
|
|
40
|
+
export namespace advice {
|
|
41
|
+
let explicitBucketBoundaries: number[];
|
|
42
|
+
}
|
|
43
|
+
let description_5: "Per-block time spent executing SwingSet";
|
|
44
|
+
export { description_5 as description };
|
|
45
|
+
}
|
|
46
|
+
namespace swingsetChainSaveSeconds {
|
|
47
|
+
let unit_6: string;
|
|
48
|
+
export { unit_6 as unit };
|
|
49
|
+
export namespace advice_1 { }
|
|
50
|
+
export { advice_1 as advice };
|
|
51
|
+
let description_6: "Per-block time spent propagating SwingSet state into cosmos";
|
|
52
|
+
export { description_6 as description };
|
|
53
|
+
}
|
|
54
|
+
namespace swingsetCommitSeconds {
|
|
55
|
+
let unit_7: string;
|
|
56
|
+
export { unit_7 as unit };
|
|
57
|
+
export namespace advice_2 { }
|
|
58
|
+
export { advice_2 as advice };
|
|
59
|
+
let description_7: "Per-block time spent committing SwingSet state to host storage";
|
|
60
|
+
export { description_7 as description };
|
|
61
|
+
}
|
|
62
|
+
namespace cosmosCommitSeconds {
|
|
63
|
+
let unit_8: string;
|
|
64
|
+
export { unit_8 as unit };
|
|
65
|
+
export namespace advice_3 { }
|
|
66
|
+
export { advice_3 as advice };
|
|
67
|
+
let description_8: "Per-block time spent committing cosmos state";
|
|
68
|
+
export { description_8 as description };
|
|
69
|
+
}
|
|
70
|
+
namespace fullCommitSeconds {
|
|
71
|
+
let unit_9: string;
|
|
72
|
+
export { unit_9 as unit };
|
|
73
|
+
export namespace advice_4 { }
|
|
74
|
+
export { advice_4 as advice };
|
|
75
|
+
let description_9: "Per-block time spent committing state, inclusive of COMMIT_BLOCK processing plus time spent [outside of cosmic-swingset] before and after it";
|
|
76
|
+
export { description_9 as description };
|
|
77
|
+
}
|
|
78
|
+
namespace interBlockSeconds {
|
|
79
|
+
let unit_10: string;
|
|
80
|
+
export { unit_10 as unit };
|
|
81
|
+
export namespace advice_5 { }
|
|
82
|
+
export { advice_5 as advice };
|
|
83
|
+
let description_10: "Time spent idle between blocks";
|
|
84
|
+
export { description_10 as description };
|
|
85
|
+
}
|
|
86
|
+
namespace afterCommitHangoverSeconds {
|
|
87
|
+
let unit_11: string;
|
|
88
|
+
export { unit_11 as unit };
|
|
89
|
+
export namespace advice_6 { }
|
|
90
|
+
export { advice_6 as advice };
|
|
91
|
+
let description_11: "Per-block time spent waiting for previous-block afterCommit work";
|
|
92
|
+
export { description_11 as description };
|
|
93
|
+
}
|
|
94
|
+
namespace blockLagSeconds {
|
|
95
|
+
export namespace advice_7 {
|
|
96
|
+
let explicitBucketBoundaries_1: number[];
|
|
97
|
+
export { explicitBucketBoundaries_1 as explicitBucketBoundaries };
|
|
98
|
+
}
|
|
99
|
+
export { advice_7 as advice };
|
|
100
|
+
let unit_12: string;
|
|
101
|
+
export { unit_12 as unit };
|
|
102
|
+
let description_12: "The delay of each block from its expected begin time";
|
|
103
|
+
export { description_12 as description };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
export type QueueMetricAspect = (typeof QueueMetricAspect)[keyof typeof QueueMetricAspect];
|
|
107
|
+
export namespace QueueMetricAspect {
|
|
108
|
+
let Length: "length";
|
|
109
|
+
let IncrementCount: "increments";
|
|
110
|
+
let DecrementCount: "decrements";
|
|
111
|
+
}
|
|
112
|
+
export function makeQueueMetricsMeta(namePrefix: string, descPrefix: string): Record<QueueMetricAspect, {
|
|
113
|
+
name: string;
|
|
114
|
+
options: MetricAttributes;
|
|
115
|
+
}>;
|
|
116
|
+
export function makeQueueMetrics<QueueName extends string>({ otelMeter, namePrefix, descPrefix, console, }: {
|
|
117
|
+
otelMeter: OTelMeter;
|
|
118
|
+
namePrefix: string;
|
|
119
|
+
descPrefix: string;
|
|
120
|
+
console?: Pick<Console, "warn"> | undefined;
|
|
121
|
+
}): QueueMetrics<QueueName>;
|
|
122
|
+
/**
|
|
123
|
+
* @typedef KernelMetricMeta
|
|
124
|
+
* @property {string} key
|
|
125
|
+
* @property {string} name
|
|
126
|
+
* @property {{ dimension: string; value: string }} [sub]
|
|
127
|
+
* @property {string} description
|
|
128
|
+
* @property {boolean} [consensus]
|
|
129
|
+
* @property {MetricType} metricType
|
|
130
|
+
*/
|
|
131
|
+
/** @type {Omit<KernelMetricMeta, 'metricType'>[]} */
|
|
132
|
+
export const KERNEL_STATS_SUM_METRICS: Omit<KernelMetricMeta, "metricType">[];
|
|
133
|
+
/** @type {Omit<KernelMetricMeta, 'metricType'>[]} */
|
|
134
|
+
export const KERNEL_STATS_UPDOWN_METRICS: Omit<KernelMetricMeta, "metricType">[];
|
|
135
|
+
/** @type {KernelMetricMeta[]} */
|
|
136
|
+
export const KERNEL_STATS_METRICS: KernelMetricMeta[];
|
|
137
|
+
export type QueueMetrics<QueueName extends string> = {
|
|
138
|
+
/**
|
|
139
|
+
* must be
|
|
140
|
+
* called before any other function
|
|
141
|
+
*/
|
|
142
|
+
initLengths: (lengths: Record<QueueName, number>) => void;
|
|
143
|
+
updateLengths: (lengths: Record<QueueName, number>) => void;
|
|
144
|
+
/**
|
|
145
|
+
* for a
|
|
146
|
+
* non-negative delta
|
|
147
|
+
*/
|
|
148
|
+
incLength: (queue: QueueName, delta?: number) => void;
|
|
149
|
+
/**
|
|
150
|
+
* for a
|
|
151
|
+
* non-negative delta
|
|
152
|
+
*/
|
|
153
|
+
decLength: (queue: QueueName, delta?: number) => void;
|
|
154
|
+
};
|
|
155
|
+
export type KernelMetricMeta = {
|
|
156
|
+
key: string;
|
|
157
|
+
name: string;
|
|
158
|
+
sub?: {
|
|
159
|
+
dimension: string;
|
|
160
|
+
value: string;
|
|
161
|
+
} | undefined;
|
|
162
|
+
description: string;
|
|
163
|
+
consensus?: boolean | undefined;
|
|
164
|
+
metricType: MetricType;
|
|
165
|
+
};
|
|
166
|
+
declare const HISTOGRAM_SECONDS_LATENCY_BOUNDARIES: number[];
|
|
167
|
+
/**
|
|
168
|
+
* @import {Meter as OTelMeter, MetricAttributes} from '@opentelemetry/api';
|
|
169
|
+
* @import {TotalMap} from '@agoric/internal';
|
|
170
|
+
*/
|
|
171
|
+
declare const HISTOGRAM_MS_LATENCY_BOUNDARIES: number[];
|
|
172
|
+
import type { MetricAttributes } from '@opentelemetry/api';
|
|
173
|
+
import type { Meter as OTelMeter } from '@opentelemetry/api';
|
|
174
|
+
/**
|
|
175
|
+
* MetricType
|
|
176
|
+
*/
|
|
177
|
+
type MetricType = (typeof MetricType)[keyof typeof MetricType];
|
|
178
|
+
declare namespace MetricType {
|
|
179
|
+
let Counter: "counter";
|
|
180
|
+
let Gauge: "gauge";
|
|
181
|
+
}
|
|
182
|
+
export {};
|
|
183
|
+
//# sourceMappingURL=metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["metrics.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4CAqH2C,MAAM,EAAE;;;;;;;;;;gCAQxC,CAAC,OAAO,iBAAiB,EAAE,MAAM,OAAO,iBAAiB,CAAC;;;;;;AAiB9D,iDAPI,MAAM,cACN,MAAM,GACJ,MAAM,CACd,iBAAiB,EACrB;IAAM,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,CAC5C,CAoBH;AA0BM,iCARe,SAAS,SAAlB,MAAQ,mDAElB;IAA0B,SAAS,EAA3B,SAAS;IACM,UAAU,EAAzB,MAAM;IACS,UAAU,EAAzB,MAAM;IACyB,OAAO;CAC9C,GAAU,YAAY,CAAC,SAAS,CAAC,CA8GnC;AAQD;;;;;;;;GAQG;AACH,qDAAqD;AACrD,uCADW,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,EAAE,CAkF/C;AAEF,qDAAqD;AACrD,0CADW,IAAI,CAAC,gBAAgB,EAAE,YAAY,CAAC,EAAE,CA4D/C;AAGF,iCAAiC;AACjC,mCADW,gBAAgB,EAAE,CAI1B;yBA3SmB,SAAS,SAAlB,MAAQ;;;;;iBAEP,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,IAAI;mBAE5C,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,IAAI;;;;;eAC5C,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI;;;;;eAE1C,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,IAAI;;;SAsI1C,MAAM;UACN,MAAM;;mBACO,MAAM;eAAS,MAAM;;iBAClC,MAAM;;gBAEN,UAAU;;AAnRxB,6DACuD;AApBvD;;;GAGG;AAEH,wDAaE;sCAjBqD,oBAAoB;wCAApB,oBAAoB;;;;kBAyRhE,CAAC,OAAO,UAAU,EAAE,MAAM,OAAO,UAAU,CAAC"}
|