@agoric/cosmic-swingset 0.41.4-dev-aa5ce6f.0.aa5ce6f → 0.41.4-dev-70fb93a.0.70fb93a
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 +11 -11
- package/src/chain-main.js +1 -1
- package/src/helpers/bufferedStorage.js +11 -106
- package/src/launch-chain.js +2 -1
- package/src/sim-chain.js +1 -1
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-70fb93a.0.70fb93a",
|
|
4
4
|
"description": "Agoric's Cosmos blockchain integration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,15 +22,15 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/builders": "0.1.1-dev-
|
|
25
|
+
"@agoric/builders": "0.1.1-dev-70fb93a.0.70fb93a",
|
|
26
26
|
"@agoric/cosmos": "",
|
|
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-
|
|
27
|
+
"@agoric/deploy-script-support": "0.10.4-dev-70fb93a.0.70fb93a",
|
|
28
|
+
"@agoric/internal": "0.3.3-dev-70fb93a.0.70fb93a",
|
|
29
|
+
"@agoric/store": "0.9.3-dev-70fb93a.0.70fb93a",
|
|
30
|
+
"@agoric/swing-store": "0.9.2-dev-70fb93a.0.70fb93a",
|
|
31
|
+
"@agoric/swingset-vat": "0.32.3-dev-70fb93a.0.70fb93a",
|
|
32
|
+
"@agoric/telemetry": "0.6.3-dev-70fb93a.0.70fb93a",
|
|
33
|
+
"@agoric/vm-config": "0.1.1-dev-70fb93a.0.70fb93a",
|
|
34
34
|
"@endo/bundle-source": "^4.1.2",
|
|
35
35
|
"@endo/env-options": "^1.1.11",
|
|
36
36
|
"@endo/errors": "^1.2.13",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"tmp": "^0.2.1"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@agoric/kmarshal": "0.1.1-dev-
|
|
55
|
+
"@agoric/kmarshal": "0.1.1-dev-70fb93a.0.70fb93a",
|
|
56
56
|
"ava": "^5.3.0",
|
|
57
57
|
"better-sqlite3": "^10.1.0",
|
|
58
58
|
"c8": "^10.1.3",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"typeCoverage": {
|
|
85
85
|
"atLeast": 86.47
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "70fb93afcb746d40510dcbe3a20370786fb627db"
|
|
88
88
|
}
|
package/src/chain-main.js
CHANGED
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* @import {EReturn} from '@endo/far';
|
|
64
|
-
* @import {KVStore} from '
|
|
64
|
+
* @import {KVStore} from '@agoric/internal/src/kv-store.js';
|
|
65
65
|
* @import {SwingStore} from '@agoric/swing-store';
|
|
66
66
|
* @import {StateSyncExporter} from './export-kernel-db.js';
|
|
67
67
|
*/
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
import { assert, Fail } from '@endo/errors';
|
|
2
|
+
import {
|
|
3
|
+
makeKVStoreFromMap,
|
|
4
|
+
compareByCodePoints,
|
|
5
|
+
} from '@agoric/internal/src/kv-store.js';
|
|
2
6
|
|
|
3
7
|
// XXX Do these "StorageAPI" functions belong in their own package?
|
|
4
|
-
|
|
5
8
|
/**
|
|
6
|
-
* @
|
|
7
|
-
* @typedef {{
|
|
8
|
-
* has: (key: string) => boolean,
|
|
9
|
-
* get: (key: string) => T | undefined,
|
|
10
|
-
* getNextKey: (previousKey: string) => string | undefined,
|
|
11
|
-
* set: (key: string, value: T ) => void,
|
|
12
|
-
* delete: (key: string) => void,
|
|
13
|
-
* }} KVStore
|
|
9
|
+
* @import {KVStore} from '@agoric/internal/src/kv-store.js'
|
|
14
10
|
*/
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* @template [T=unknown]
|
|
18
13
|
* @typedef {KVStore<T> & {commit: () => void, abort: () => void}} BufferedKVStore
|
|
@@ -36,100 +31,6 @@ export function insistStorageAPI(kvStore) {
|
|
|
36
31
|
}
|
|
37
32
|
}
|
|
38
33
|
|
|
39
|
-
// TODO: Replace compareByCodePoints and makeKVStoreFromMap and
|
|
40
|
-
// provideEnhancedKVStore with imports when
|
|
41
|
-
// available.
|
|
42
|
-
// https://github.com/Agoric/agoric-sdk/pull/10299
|
|
43
|
-
|
|
44
|
-
const compareByCodePoints = (left, right) => {
|
|
45
|
-
const leftIter = left[Symbol.iterator]();
|
|
46
|
-
const rightIter = right[Symbol.iterator]();
|
|
47
|
-
for (;;) {
|
|
48
|
-
const { value: leftChar } = leftIter.next();
|
|
49
|
-
const { value: rightChar } = rightIter.next();
|
|
50
|
-
if (leftChar === undefined && rightChar === undefined) {
|
|
51
|
-
return 0;
|
|
52
|
-
} else if (leftChar === undefined) {
|
|
53
|
-
// left is a prefix of right.
|
|
54
|
-
return -1;
|
|
55
|
-
} else if (rightChar === undefined) {
|
|
56
|
-
// right is a prefix of left.
|
|
57
|
-
return 1;
|
|
58
|
-
}
|
|
59
|
-
const leftCodepoint = /** @type {number} */ (leftChar.codePointAt(0));
|
|
60
|
-
const rightCodepoint = /** @type {number} */ (rightChar.codePointAt(0));
|
|
61
|
-
if (leftCodepoint < rightCodepoint) return -1;
|
|
62
|
-
if (leftCodepoint > rightCodepoint) return 1;
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @template [T=unknown]
|
|
68
|
-
* @param {Map<string, T>} map
|
|
69
|
-
* @returns {KVStore<T>}
|
|
70
|
-
*/
|
|
71
|
-
export const makeKVStoreFromMap = map => {
|
|
72
|
-
let sortedKeys;
|
|
73
|
-
let priorKeyReturned;
|
|
74
|
-
let priorKeyIndex;
|
|
75
|
-
|
|
76
|
-
const ensureSorted = () => {
|
|
77
|
-
if (sortedKeys) return;
|
|
78
|
-
sortedKeys = [...map.keys()].sort(compareByCodePoints);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
const clearGetNextKeyCache = () => {
|
|
82
|
-
priorKeyReturned = undefined;
|
|
83
|
-
priorKeyIndex = -1;
|
|
84
|
-
};
|
|
85
|
-
clearGetNextKeyCache();
|
|
86
|
-
|
|
87
|
-
const clearSorted = () => {
|
|
88
|
-
sortedKeys = undefined;
|
|
89
|
-
clearGetNextKeyCache();
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
/** @type {KVStore<T>} */
|
|
93
|
-
const fakeStore = harden({
|
|
94
|
-
has: key => map.has(key),
|
|
95
|
-
get: key => map.get(key),
|
|
96
|
-
getNextKey: priorKey => {
|
|
97
|
-
assert.typeof(priorKey, 'string');
|
|
98
|
-
ensureSorted();
|
|
99
|
-
const start =
|
|
100
|
-
priorKeyReturned === undefined
|
|
101
|
-
? 0
|
|
102
|
-
: // If priorKeyReturned <= priorKey, start just after it.
|
|
103
|
-
(compareByCodePoints(priorKeyReturned, priorKey) <= 0 &&
|
|
104
|
-
priorKeyIndex + 1) ||
|
|
105
|
-
// Else if priorKeyReturned immediately follows priorKey, start at
|
|
106
|
-
// its index (and expect to return it again).
|
|
107
|
-
(sortedKeys.at(priorKeyIndex - 1) === priorKey && priorKeyIndex) ||
|
|
108
|
-
// Otherwise, start at the beginning.
|
|
109
|
-
0;
|
|
110
|
-
for (let i = start; i < sortedKeys.length; i += 1) {
|
|
111
|
-
const key = sortedKeys[i];
|
|
112
|
-
if (compareByCodePoints(key, priorKey) <= 0) continue;
|
|
113
|
-
priorKeyReturned = key;
|
|
114
|
-
priorKeyIndex = i;
|
|
115
|
-
return key;
|
|
116
|
-
}
|
|
117
|
-
// reached end without finding the key, so clear our cache
|
|
118
|
-
clearGetNextKeyCache();
|
|
119
|
-
return undefined;
|
|
120
|
-
},
|
|
121
|
-
set: (key, value) => {
|
|
122
|
-
if (!map.has(key)) clearSorted();
|
|
123
|
-
map.set(key, value);
|
|
124
|
-
},
|
|
125
|
-
delete: key => {
|
|
126
|
-
if (map.has(key)) clearSorted();
|
|
127
|
-
map.delete(key);
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
return fakeStore;
|
|
131
|
-
};
|
|
132
|
-
|
|
133
34
|
/**
|
|
134
35
|
* Return an object representing KVStore contents as both a KVStore and a Map.
|
|
135
36
|
*
|
|
@@ -334,7 +235,11 @@ export const makeReadCachingStorage = kvStore => {
|
|
|
334
235
|
|
|
335
236
|
// Fetch the value and cache it until the next commit or abort.
|
|
336
237
|
value = kvStore.get(key);
|
|
337
|
-
cache.set(
|
|
238
|
+
cache.set(
|
|
239
|
+
key,
|
|
240
|
+
// eslint-disable-next-line no-nested-ternary
|
|
241
|
+
value === undefined ? (kvStore.has(key) ? undef : deleted) : value,
|
|
242
|
+
);
|
|
338
243
|
return value;
|
|
339
244
|
},
|
|
340
245
|
set(key, value) {
|
|
@@ -364,7 +269,7 @@ export const makeReadCachingStorage = kvStore => {
|
|
|
364
269
|
// Enqueue a write of any retrieved value, to handle callers like mailbox.js
|
|
365
270
|
// that expect local mutations to be automatically written back.
|
|
366
271
|
onGet(key, value) {
|
|
367
|
-
buffered.set(key, value);
|
|
272
|
+
if (value !== undefined) buffered.set(key, value);
|
|
368
273
|
},
|
|
369
274
|
|
|
370
275
|
// Reset the read cache upon commit or abort.
|
package/src/launch-chain.js
CHANGED
|
@@ -55,7 +55,8 @@ import { computronCounter } from './computron-counter.js';
|
|
|
55
55
|
* @import {BlockInfo} from '@agoric/internal/src/chain-utils.js';
|
|
56
56
|
* @import {SwingStoreKernelStorage} from '@agoric/swing-store';
|
|
57
57
|
* @import {Mailbox, RunPolicy, SwingSetConfig} from '@agoric/swingset-vat';
|
|
58
|
-
* @import {
|
|
58
|
+
* @import {BufferedKVStore} from './helpers/bufferedStorage.js';
|
|
59
|
+
* @import {KVStore} from '@agoric/internal/src/kv-store.js';
|
|
59
60
|
* @import {ConfigProposal} from '@agoric/deploy-script-support/src/extract-proposal.js';
|
|
60
61
|
* @import {ERef} from '@endo/far';
|
|
61
62
|
* @import {QueueStorage} from './helpers/make-queue.js';
|
package/src/sim-chain.js
CHANGED
|
@@ -14,11 +14,11 @@ import { getTelemetryProviders, makeSlogSender } from '@agoric/telemetry';
|
|
|
14
14
|
import { resolve as importMetaResolve } from 'import-meta-resolve';
|
|
15
15
|
import { makeWithQueue } from '@agoric/internal/src/queue.js';
|
|
16
16
|
import { makeBatchedDeliver } from '@agoric/internal/src/batched-deliver.js';
|
|
17
|
+
import { makeKVStoreFromMap } from '@agoric/internal/src/kv-store.js';
|
|
17
18
|
import stringify from './helpers/json-stable-stringify.js';
|
|
18
19
|
import { launch } from './launch-chain.js';
|
|
19
20
|
import { DEFAULT_SIM_SWINGSET_PARAMS, QueueInbound } from './sim-params.js';
|
|
20
21
|
import { parseQueueSizes } from './params.js';
|
|
21
|
-
import { makeKVStoreFromMap } from './helpers/bufferedStorage.js';
|
|
22
22
|
import { makeQueue, makeQueueStorageMock } from './helpers/make-queue.js';
|
|
23
23
|
|
|
24
24
|
/** @import { Mailbox } from '@agoric/swingset-vat' */
|