space-data-module-sdk 0.9.2 → 0.9.4
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/docs/tri-runtime-parity.html +1 -0
- package/docs/tri-runtime-parity.md +10 -0
- package/package.json +1 -1
- package/src/host/adapterOperations.js +10 -0
- package/src/host/browserHost.js +10 -0
- package/src/host/cpp/typedHostcall.hpp +18 -2
- package/src/host/hostWorkerBundleSources.js +3 -3
- package/src/host/nodeHost.js +11 -0
- package/src/host/typedDispatch.js +113 -1
- package/src/standards/runtimeContracts.js +2 -1
- package/src/testing/docker/wasmedge-parity.Dockerfile +3 -1
- package/src/testing/native/wasmedge_wasi_threads_runner.c +144 -2
- package/src/testing/parityBrowserRunner.js +5 -1
- package/src/testing/parityHarness.js +17 -2
- package/src/testing/parityHostcalls.js +40 -0
- package/src/testing/parityLanes.js +33 -9
|
@@ -159,6 +159,7 @@
|
|
|
159
159
|
<li><code>expect</code> (<code>"ok" | "guest-error" | "trap"</code>) is optional; without it the case only requires the class to be IDENTICAL across lanes (malformed-input fixtures compare error/trap classes this way).</li>
|
|
160
160
|
<li>Payloads: <code>payloadFile</code> (relative to the fixture), <code>payloadBase64</code>, <code>payloadHex</code>, <code>payloadUtf8</code>.</li>
|
|
161
161
|
<li>Committed payload binaries are regenerated deterministically by <code>node fixtures/parity/generate-fixtures.mjs</code>.</li>
|
|
162
|
+
<li><code>config</code> (an object, on the fixture or a case; the case's replaces the fixture's, <code>{}</code> by default) is what a module's <code>plugin.getConfig</code> hostcall answers. Every lane serves the typed hostcall bridge (<code>space_data_module_host.call</code> / <code>response_len</code> / <code>read_response</code>): <code>plugin.getConfig</code> answers the case's config as one <code>ModuleConfig</code> on raw <code>config</code> (the answer the SDK JS hosts give), and every other operation a STATUS FAILED <code>unsupported</code> $PIV answer. The WasmEdge CLI provides no host imports, so the wasmedge lanes run an artifact that imports the bridge on the SDK runner (single-thread or not), which replays answers the orchestrator encodes with the SDK's own encoder.</li>
|
|
162
163
|
</ul>
|
|
163
164
|
<h2 id="scope-and-current-limits-v1"><a class="anchor" href="#scope-and-current-limits-v1" aria-hidden="true">#</a>Scope and current limits (v1)</h2>
|
|
164
165
|
<ul>
|
|
@@ -113,6 +113,16 @@ Every lane receives EXACTLY the same guest-observable inputs:
|
|
|
113
113
|
`payloadHex`, `payloadUtf8`.
|
|
114
114
|
- Committed payload binaries are regenerated deterministically by
|
|
115
115
|
`node fixtures/parity/generate-fixtures.mjs`.
|
|
116
|
+
- `config` (an object, on the fixture or a case; the case's replaces the
|
|
117
|
+
fixture's, `{}` by default) is what a module's `plugin.getConfig` hostcall
|
|
118
|
+
answers. Every lane serves the typed hostcall bridge
|
|
119
|
+
(`space_data_module_host.call` / `response_len` / `read_response`):
|
|
120
|
+
`plugin.getConfig` answers the case's config as one `ModuleConfig` on raw
|
|
121
|
+
`config` (the answer the SDK JS hosts give), and every other operation a
|
|
122
|
+
STATUS FAILED `unsupported` $PIV answer. The WasmEdge CLI provides no host
|
|
123
|
+
imports, so the wasmedge lanes run an artifact that imports the bridge on the
|
|
124
|
+
SDK runner (single-thread or not), which replays answers the orchestrator
|
|
125
|
+
encodes with the SDK's own encoder.
|
|
116
126
|
|
|
117
127
|
## Scope and current limits (v1)
|
|
118
128
|
|
package/package.json
CHANGED
|
@@ -40,6 +40,16 @@ export const ADAPTER_OPERATIONS = Object.freeze({
|
|
|
40
40
|
"node_activity_read.activity": { capability: "node_activity_read", adapter: "node", method: "activity" },
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
/**
|
|
44
|
+
* The Go node's other ipfs operations, served by the host's ipfs adapter (options.ipfs / capabilityAdapters.ipfs) as
|
|
45
|
+
* adapter.<method>(params) or adapter.invoke(method, params): the IpfsParams record's set fields as lower-case keys
|
|
46
|
+
* ({cid, name, type, lifetime, ttl}), answered the way Kubo answers ({Objects: [{Links}]}, {Pins}, {Keys}, {ID, ...}).
|
|
47
|
+
*/
|
|
48
|
+
export const IPFS_ADAPTER_OPERATIONS = Object.freeze([
|
|
49
|
+
"ipfs.ls", "ipfs.pin_add", "ipfs.pin_rm", "ipfs.pin_ls", "ipfs.dag_get", "ipfs.id", "ipfs.swarm_peers",
|
|
50
|
+
"ipfs.name_resolve", "ipfs.name_publish", "ipfs.pubsub_publish",
|
|
51
|
+
]);
|
|
52
|
+
|
|
43
53
|
/** The capabilities those operations need. */
|
|
44
54
|
export const ADAPTER_CAPABILITIES = Object.freeze(
|
|
45
55
|
[...new Set(Object.values(ADAPTER_OPERATIONS).map((o) => o.capability).filter(Boolean))],
|
package/src/host/browserHost.js
CHANGED
|
@@ -22,6 +22,7 @@ import { createBrowserEdgeShims } from "./browserEdgeShims.js";
|
|
|
22
22
|
import {
|
|
23
23
|
ADAPTER_CAPABILITIES,
|
|
24
24
|
ADAPTER_OPERATIONS,
|
|
25
|
+
IPFS_ADAPTER_OPERATIONS,
|
|
25
26
|
callServiceAdapter,
|
|
26
27
|
normalizePluginConfig,
|
|
27
28
|
resolveServiceAdapters,
|
|
@@ -87,6 +88,7 @@ export const BrowserHostSupportedOperations = Object.freeze([
|
|
|
87
88
|
"ipfs.invoke",
|
|
88
89
|
"ipfs.add",
|
|
89
90
|
"ipfs.cat",
|
|
91
|
+
...IPFS_ADAPTER_OPERATIONS,
|
|
90
92
|
"protocol_handle.register",
|
|
91
93
|
"protocol_handle.unregister",
|
|
92
94
|
"protocol_dial.dial",
|
|
@@ -640,6 +642,11 @@ export class BrowserHost {
|
|
|
640
642
|
this.#assertCapability("ipfs", "ipfs.cat");
|
|
641
643
|
return invokeAdapterMethod(ipfsAdapter, "cat", params, "ipfs");
|
|
642
644
|
},
|
|
645
|
+
// ls, pin_add, pin_rm, pin_ls, dag_get, id, swarm_peers, name_resolve, name_publish, pubsub_publish
|
|
646
|
+
...Object.fromEntries(IPFS_ADAPTER_OPERATIONS.map((operation) => [operation.slice(5), async (params = {}) => {
|
|
647
|
+
this.#assertCapability("ipfs", operation);
|
|
648
|
+
return invokeAdapterMethod(ipfsAdapter, operation.slice(5), params, "ipfs");
|
|
649
|
+
}])),
|
|
643
650
|
});
|
|
644
651
|
|
|
645
652
|
this.protocolHandle = Object.freeze({
|
|
@@ -1226,6 +1233,9 @@ export class BrowserHost {
|
|
|
1226
1233
|
if (ADAPTER_OPERATIONS[normalized]) {
|
|
1227
1234
|
return this.serveAdapterOperation(normalized, params);
|
|
1228
1235
|
}
|
|
1236
|
+
if (IPFS_ADAPTER_OPERATIONS.includes(normalized)) {
|
|
1237
|
+
return this.ipfs[normalized.slice(5)](params);
|
|
1238
|
+
}
|
|
1229
1239
|
throw new Error(`Unknown browser host operation "${normalized}".`);
|
|
1230
1240
|
}
|
|
1231
1241
|
}
|
|
@@ -293,6 +293,18 @@ class ConfigTable {
|
|
|
293
293
|
for (const auto* s : *f.entry->STRINGS()) out.push_back(view(s));
|
|
294
294
|
return out;
|
|
295
295
|
}
|
|
296
|
+
/// How many items a list holds: a NumberList's numbers, a StringList's strings or a TableList's tables (0 when
|
|
297
|
+
/// the key is missing or not a list). Iterate 0..count-1 instead of probing "key.N" until a lookup fails.
|
|
298
|
+
size_t count(std::string_view key) const {
|
|
299
|
+
const Found f = find(key);
|
|
300
|
+
if (!f.entry || f.index >= 0) return 0;
|
|
301
|
+
switch (f.entry->KIND()) {
|
|
302
|
+
case sdn::runtime::configValueKind_NumberList: return f.entry->NUMBERS() ? f.entry->NUMBERS()->size() : 0;
|
|
303
|
+
case sdn::runtime::configValueKind_StringList: return f.entry->STRINGS() ? f.entry->STRINGS()->size() : 0;
|
|
304
|
+
case sdn::runtime::configValueKind_TableList: return f.entry->TABLES() ? f.entry->TABLES()->size() : 0;
|
|
305
|
+
default: return 0;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
296
308
|
/// How many tables a TableList holds (0 when missing or another kind).
|
|
297
309
|
size_t tables(std::string_view key) const {
|
|
298
310
|
const Found f = find(key);
|
|
@@ -354,9 +366,13 @@ class ConfigTable {
|
|
|
354
366
|
const bool indexed = index_of(head, index);
|
|
355
367
|
switch (e->KIND()) {
|
|
356
368
|
case sdn::runtime::configValueKind_NumberList:
|
|
357
|
-
case sdn::runtime::configValueKind_StringList:
|
|
358
|
-
|
|
369
|
+
case sdn::runtime::configValueKind_StringList: {
|
|
370
|
+
// an item past the end is missing, like any other missing key (modules find a list's end by probing)
|
|
371
|
+
const size_t n = e->KIND() == sdn::runtime::configValueKind_NumberList ? (e->NUMBERS() ? e->NUMBERS()->size() : 0)
|
|
372
|
+
: (e->STRINGS() ? e->STRINGS()->size() : 0);
|
|
373
|
+
if (indexed && next == std::string_view::npos && static_cast<uint64_t>(index) < n) return {e, index};
|
|
359
374
|
return {};
|
|
375
|
+
}
|
|
360
376
|
case sdn::runtime::configValueKind_TableList: {
|
|
361
377
|
const auto* tables = e->TABLES();
|
|
362
378
|
if (!tables) return {};
|