space-data-module-sdk 0.8.25 → 0.8.26

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 CHANGED
@@ -145,6 +145,31 @@ Source-built modules can set this on an emitted output frame with
145
145
  `plugin_set_output_stream_frame(outputIndex, sequence, endOfStream)` or set the
146
146
  raw frame id with `plugin_set_output_frame_id(outputIndex, frameId)`.
147
147
 
148
+ ### Size-prefixed records
149
+
150
+ A size-prefixed FlatBuffer is not an unprefixed buffer with a length written in
151
+ front of it. FlatBuffers aligns each field relative to the start of the buffer.
152
+ A size-prefixed finish lays the record out so that the 4-byte prefix comes
153
+ before an aligned root:
154
+
155
+ - C++: `FinishSizePrefixed`;
156
+ - JS: `finishSizePrefixed`;
157
+ - `flatc --binary --size-prefixed`.
158
+
159
+ Writing a length in front of an unprefixed buffer moves every field by 4
160
+ bytes. Eight-byte scalars and vectors, such as `double` and `long`, are then
161
+ misaligned. `VerifySizePrefixedBuffer` with alignment checks, which a module's
162
+ generated readers run, refuses the record.
163
+
164
+ - Build size-prefixed frames with the generated builder's size-prefixed finish,
165
+ or with `flatc --binary --size-prefixed` from JSON.
166
+ - flatc-wasm's `generateBinary(schema, json, { sizePrefix: true })`, the
167
+ default, writes the length in front in JS and does not produce such a record.
168
+ For a size-prefixed record, run flatc with `--size-prefixed` through
169
+ `runCommand`. Otherwise pass `sizePrefix: false` for an unprefixed record.
170
+ - Forward a module's size-prefixed output frames unchanged. Do not strip the
171
+ prefix or add one.
172
+
148
173
  For simple single-input / single-output methods, command mode also supports a
149
174
  raw shortcut:
150
175
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "space-data-module-sdk",
3
- "version": "0.8.25",
3
+ "version": "0.8.26",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Module SDK for building, validating, signing, and deploying WebAssembly modules on the Space Data Network.",
6
6
  "type": "module",
@@ -276,15 +276,47 @@ export async function buildWasmEdgeEmscriptenPthreadRunner(options = {}) {
276
276
  const WASMEDGE_THREADS_REVISION = "be85c2fbba68318f103b4a766728f6946e65abf8";
277
277
  const runtimeBuilds = new Map();
278
278
 
279
- // Upstream 0.16.4 can lose atomic notifications between comparison and sleep.
280
- // Keep its established SDN fix isolated from the owner's installed SDK/CLI.
281
- // An explicit include/lib pair remains supported for operator-built runtimes.
279
+ // The SDN patch series for WasmEdge 0.16.4 (sdn-server/internal/wasmrt/SUBSTRATE.md),
280
+ // applied here byte-identical from SDN's testdata/ (kept local so this build
281
+ // has no cross-repo file dependency). Order matters (02 and 04 both touch
282
+ // lib/llvm/compiler.cpp) and matches SDN's own build-static-wasmedge.sh.
283
+ // 01-atomic-wait compare/register/sleep under one mutex; a notify
284
+ // wakes a waiter without a store. Fixes upstream's
285
+ // lost wakeups — this build's interpreter is the
286
+ // only execution mode, so this is the one patch
287
+ // with an observable effect here.
288
+ // 02-stop-token a stop is sticky, read (never consumed) by the
289
+ // interpreter and by Interruptible AOT code.
290
+ // 03-fault-jmp darwin _setjmp/_longjmp signal-stack-flag fix
291
+ // for the native-fault path AOT execution uses.
292
+ // 04-atomic-memarg-offset AOT memory.atomic.notify/wait honour the
293
+ // instruction's memarg offset (lib/llvm/compiler.cpp).
294
+ //
295
+ // This runner is built with -DWASMEDGE_USE_LLVM=OFF: in 0.16.4 that flag also
296
+ // gates WASMEDGE_BUILD_AOT_RUNTIME (WasmEdge's CMakeLists.txt), so the linked
297
+ // library can neither compile nor LOAD AOT code. Patches 02-04 therefore
298
+ // patch code this runner never executes; only 01 is load-bearing today. They
299
+ // stay applied anyway so this isolated dependency's WasmEdge checkout tracks
300
+ // SDN's full patched baseline (never drifts if AOT is enabled here later),
301
+ // and 04 specifically is why no memarg-offset regression test is added
302
+ // alongside it: there is no AOT lane in this SDK to run SDN's substrate probe
303
+ // against (module-sdk-oracle: tri-runtime parity is browser / native
304
+ // interpreter WasmEdge / Docker interpreter WasmEdge — none compile AOT).
305
+ const WASMEDGE_PATCH_NAMES = Object.freeze([
306
+ "wasmedge-0.16.4-atomic-wait.patch",
307
+ "wasmedge-0.16.4-stop-token.patch",
308
+ "wasmedge-0.16.4-fault-jmp.patch",
309
+ "wasmedge-0.16.4-atomic-memarg-offset.patch",
310
+ ]);
311
+
282
312
  async function prepareWasmEdgeThreadsRuntime(options) {
283
313
  if ((options.wasmedgeIncludeDir ?? process.env.WASMEDGE_INCLUDE_DIR) &&
284
314
  (options.wasmedgeLibDir ?? process.env.WASMEDGE_LIB_DIR)) return {};
285
- const patchPath = path.join(__dirname, "native/wasmedge-0.16.4-atomic-wait.patch");
286
- const digest = createHash("sha256").update(WASMEDGE_THREADS_REVISION)
287
- .update(await readFile(patchPath)).update(`${process.platform}-${process.arch}`).digest("hex");
315
+ const patchPaths = WASMEDGE_PATCH_NAMES.map((name) => path.join(__dirname, "native", name));
316
+ const patchBytes = await Promise.all(patchPaths.map((p) => readFile(p)));
317
+ const digestHash = createHash("sha256").update(WASMEDGE_THREADS_REVISION);
318
+ for (const bytes of patchBytes) digestHash.update(bytes);
319
+ const digest = digestHash.update(`${process.platform}-${process.arch}`).digest("hex");
288
320
  if (!runtimeBuilds.has(digest)) {
289
321
  const build = (async () => {
290
322
  const root = path.join(os.tmpdir(), "sdm-wasmedge-runtimes", digest);
@@ -324,8 +356,10 @@ async function prepareWasmEdgeThreadsRuntime(options) {
324
356
  }
325
357
  const revision = (await run("git", ["-C", source, "rev-parse", "HEAD"])).stdout.trim();
326
358
  if (revision !== WASMEDGE_THREADS_REVISION) throw new Error(`Unexpected WasmEdge source revision: ${revision}`);
327
- try { await run("git", ["-C", source, "apply", "--reverse", "--check", patchPath]); }
328
- catch { await run("git", ["-C", source, "apply", patchPath]); }
359
+ for (const patchPath of patchPaths) {
360
+ try { await run("git", ["-C", source, "apply", "--reverse", "--check", patchPath]); }
361
+ catch { await run("git", ["-C", source, "apply", patchPath]); }
362
+ }
329
363
  await run("cmake", ["-S", source, "-B", buildDir, "-G", "Ninja",
330
364
  "-DCMAKE_BUILD_TYPE=Release", `-DCMAKE_INSTALL_PREFIX=${prefix}`,
331
365
  process.platform === "darwin" ? "-DCMAKE_CXX_FLAGS=-Wno-invalid-specialization" : "-DCMAKE_CXX_FLAGS=-Wno-error=maybe-uninitialized -Wno-error=array-bounds",
@@ -333,7 +367,10 @@ async function prepareWasmEdgeThreadsRuntime(options) {
333
367
  "-DWASMEDGE_BUILD_PLUGINS=OFF", "-DWASMEDGE_BUILD_TOOLS=OFF", "-DWASMEDGE_FORCE_DISABLE_LTO=ON"]);
334
368
  await run("cmake", ["--build", buildDir, "-j", "4"]);
335
369
  await run("cmake", ["--install", buildDir]);
336
- await writeFile(marker, JSON.stringify({ revision, patchSha256: createHash("sha256").update(await readFile(patchPath)).digest("hex") }));
370
+ const patchesSha256 = Object.fromEntries(
371
+ WASMEDGE_PATCH_NAMES.map((name, i) => [name, createHash("sha256").update(patchBytes[i]).digest("hex")]),
372
+ );
373
+ await writeFile(marker, JSON.stringify({ revision, patchesSha256 }));
337
374
  }
338
375
  } finally {
339
376
  if (held) await rm(lock, { recursive: true, force: true });
@@ -35,12 +35,31 @@ ENV PATH="/opt/wasmedge/bin:${PATH}" \
35
35
  LD_LIBRARY_PATH="/opt/wasmedge/lib64:/opt/wasmedge/lib"
36
36
 
37
37
  COPY native/wasmedge_wasi_threads_runner.c /tmp/sdm-wasi-threads-runner.c
38
- COPY native/wasmedge-0.16.4-atomic-wait.patch /tmp/atomic-wait.patch
39
- # The ordinary CLI keeps its release library. Only the SDK thread runner uses
40
- # the isolated 0.16.4 atomic-wait correction, matching the native build.
38
+ # The SDN WasmEdge 0.16.4 patch series, byte-identical to SDN's testdata/
39
+ # (sdn-server/internal/wasmrt/SUBSTRATE.md): 01-atomic-wait, 02-stop-token,
40
+ # 03-fault-jmp, 04-atomic-memarg-offset. Order matters (02 and 04 both touch
41
+ # lib/llvm/compiler.cpp) and matches SDN's build-static-wasmedge.sh.
42
+ # The ordinary CLI (above) keeps its release library. Only the SDK thread
43
+ # runner links this patched build, matching the native (non-Docker) build in
44
+ # buildWasmEdgeRunner.js. Configured -DWASMEDGE_USE_LLVM=OFF, which in 0.16.4
45
+ # also gates WASMEDGE_BUILD_AOT_RUNTIME: this library can neither compile nor
46
+ # load AOT code. Patches 02-04 therefore patch code this runner never
47
+ # executes (Interruptible-AOT stop-token traffic, the AOT fault path, and the
48
+ # LLVM AOT compiler); only 01 changes this image's observable behaviour
49
+ # today. They stay applied so this image's WasmEdge checkout never drifts
50
+ # from SDN's patched baseline. This is also why no memarg-offset (04)
51
+ # regression test runs against this image: there is no AOT lane here to run
52
+ # SDN's substrate probe against.
53
+ COPY native/wasmedge-0.16.4-atomic-wait.patch /tmp/01-atomic-wait.patch
54
+ COPY native/wasmedge-0.16.4-stop-token.patch /tmp/02-stop-token.patch
55
+ COPY native/wasmedge-0.16.4-fault-jmp.patch /tmp/03-fault-jmp.patch
56
+ COPY native/wasmedge-0.16.4-atomic-memarg-offset.patch /tmp/04-atomic-memarg-offset.patch
41
57
  RUN git clone --depth 1 --branch 0.16.4 https://github.com/WasmEdge/WasmEdge.git /tmp/wasmedge-source \
42
58
  && test "$(git -C /tmp/wasmedge-source rev-parse HEAD)" = be85c2fbba68318f103b4a766728f6946e65abf8 \
43
- && git -C /tmp/wasmedge-source apply /tmp/atomic-wait.patch \
59
+ && git -C /tmp/wasmedge-source apply /tmp/01-atomic-wait.patch \
60
+ && git -C /tmp/wasmedge-source apply /tmp/02-stop-token.patch \
61
+ && git -C /tmp/wasmedge-source apply /tmp/03-fault-jmp.patch \
62
+ && git -C /tmp/wasmedge-source apply /tmp/04-atomic-memarg-offset.patch \
44
63
  && cmake -S /tmp/wasmedge-source -B /tmp/wasmedge-build -G Ninja \
45
64
  -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/sdm-wasmedge \
46
65
  "-DCMAKE_CXX_FLAGS=-Wno-error=maybe-uninitialized -Wno-error=array-bounds" \
@@ -48,7 +67,8 @@ RUN git clone --depth 1 --branch 0.16.4 https://github.com/WasmEdge/WasmEdge.git
48
67
  -DWASMEDGE_BUILD_TOOLS=OFF -DWASMEDGE_FORCE_DISABLE_LTO=ON \
49
68
  && cmake --build /tmp/wasmedge-build -j 4 \
50
69
  && cmake --install /tmp/wasmedge-build \
51
- && rm -rf /tmp/wasmedge-source /tmp/wasmedge-build /tmp/atomic-wait.patch
70
+ && rm -rf /tmp/wasmedge-source /tmp/wasmedge-build \
71
+ /tmp/01-atomic-wait.patch /tmp/02-stop-token.patch /tmp/03-fault-jmp.patch /tmp/04-atomic-memarg-offset.patch
52
72
  RUN cc /tmp/sdm-wasi-threads-runner.c -std=c11 -O2 -pthread -Wall -Wextra -Werror \
53
73
  -I/opt/sdm-wasmedge/include -L/opt/sdm-wasmedge/lib64 -L/opt/sdm-wasmedge/lib -lwasmedge \
54
74
  -Wl,--disable-new-dtags,-rpath,/opt/sdm-wasmedge/lib64,-rpath,/opt/sdm-wasmedge/lib \
@@ -0,0 +1,46 @@
1
+ diff --git a/lib/llvm/compiler.cpp b/lib/llvm/compiler.cpp
2
+ index f765db6..5b1bfc3 100644
3
+ --- a/lib/llvm/compiler.cpp
4
+ +++ b/lib/llvm/compiler.cpp
5
+ @@ -3952,6 +3952,21 @@ public:
6
+ Builder.positionAtEnd(OkBB);
7
+ }
8
+
9
+ + // memory.atomic.notify / wait32 / wait64 call the runtime with the
10
+ + // effective address: the operand plus the memarg offset (as the interpreter
11
+ + // does, threadInstr.cpp). Passing the bare operand notified and waited on
12
+ + // the wrong word whenever the offset was not 0 (a global such as wasi-libc's
13
+ + // __thread_list_lock at `i32.const 0; memory.atomic.notify offset=N`): lost
14
+ + // wakeups. An address past 4 GiB is out of bounds.
15
+ + LLVM::Value compileAtomicEffectiveAddress(LLVM::Value Addr) noexcept {
16
+ + auto OkBB = LLVM::BasicBlock::create(LLContext, F.Fn, "address_in_bounds");
17
+ + auto InBounds = Builder.createLikely(
18
+ + Builder.createICmpULE(Addr, LLContext.getInt64(UINT32_MAX)));
19
+ + Builder.createCondBr(InBounds, OkBB,
20
+ + getTrapBB(ErrCode::Value::MemoryOutOfBounds));
21
+ + Builder.positionAtEnd(OkBB);
22
+ + return Builder.createTrunc(Addr, Context.Int32Ty);
23
+ + }
24
+ void compileMemoryFence() noexcept {
25
+ Builder.createFence(LLVMAtomicOrderingSequentiallyConsistent);
26
+ }
27
+ @@ -3963,7 +3978,8 @@ public:
28
+ Addr = Builder.createAdd(Addr, LLContext.getInt64(MemoryOffset));
29
+ }
30
+ compileAtomicCheckOffsetAlignment(Addr, Context.Int32Ty);
31
+ - auto Offset = stackPop();
32
+ + stackPop();
33
+ + auto Offset = compileAtomicEffectiveAddress(Addr);
34
+
35
+ stackPush(Builder.createCall(
36
+ Context.getIntrinsic(
37
+ @@ -3982,7 +3998,8 @@ public:
38
+ Addr = Builder.createAdd(Addr, LLContext.getInt64(MemoryOffset));
39
+ }
40
+ compileAtomicCheckOffsetAlignment(Addr, TargetType);
41
+ - auto Offset = stackPop();
42
+ + stackPop();
43
+ + auto Offset = compileAtomicEffectiveAddress(Addr);
44
+
45
+ stackPush(Builder.createCall(
46
+ Context.getIntrinsic(
@@ -0,0 +1,35 @@
1
+ diff --git a/include/system/fault.h b/include/system/fault.h
2
+ index 1f57d78..71dd6ea 100644
3
+ --- a/include/system/fault.h
4
+ +++ b/include/system/fault.h
5
+ @@ -43,4 +43,14 @@ private:
6
+
7
+ } // namespace WasmEdge
8
+
9
+ +// _setjmp/_longjmp carry no signal state. darwin's longjmp resets or sets the
10
+ +// thread's alternate-signal-stack flag from a jmp_buf word setjmp never
11
+ +// writes, so a trap could leave a thread marked as running on its signal stack
12
+ +// and the embedder's next signal (Go's preemption) lands on the wrong stack.
13
+ +// The fault handler unblocks its own signal before it jumps, so nothing needs
14
+ +// restoring.
15
+ +#if defined(_WIN32)
16
+ #define PREPARE_FAULT(f) (static_cast<uint32_t>(setjmp((f).buffer())))
17
+ +#else
18
+ +#define PREPARE_FAULT(f) (static_cast<uint32_t>(_setjmp((f).buffer())))
19
+ +#endif
20
+ diff --git a/lib/system/fault.cpp b/lib/system/fault.cpp
21
+ index e435d4e..c49f5ae 100644
22
+ --- a/lib/system/fault.cpp
23
+ +++ b/lib/system/fault.cpp
24
+ @@ -118,7 +118,11 @@ Fault::~Fault() noexcept {
25
+ assuming(localHandler != nullptr);
26
+ auto Buffer = stackTrace(localHandler->StackTraceBuffer);
27
+ localHandler->StackTraceSize = Buffer.size();
28
+ +#if defined(_WIN32)
29
+ longjmp(localHandler->Buffer, static_cast<int>(Error.operator uint32_t()));
30
+ +#else
31
+ + _longjmp(localHandler->Buffer, static_cast<int>(Error.operator uint32_t()));
32
+ +#endif
33
+ }
34
+
35
+ } // namespace WasmEdge
@@ -0,0 +1,111 @@
1
+ diff --git a/include/executor/executor.h b/include/executor/executor.h
2
+ index 6683ee9..6bdccea 100644
3
+ --- a/include/executor/executor.h
4
+ +++ b/include/executor/executor.h
5
+ @@ -201,9 +201,15 @@ public:
6
+ asyncInvoke(const Runtime::Instance::FunctionInstance *FuncInst,
7
+ Span<const ValVariant> Params, Span<const ValType> ParamTypes);
8
+
9
+ - /// Stop execution
10
+ + /// Stop execution.
11
+ + ///
12
+ + /// SDN patch (stop-token): a stop is STICKY for every invocation running on
13
+ + /// this executor. Upstream consumed the token with exchange(0), so one stop
14
+ + /// interrupted exactly one thread and every other wasi-thread on the same
15
+ + /// executor kept running. The token is cleared only when the next
16
+ + /// invocation starts on an idle executor (see invoke()).
17
+ void stop() noexcept {
18
+ - StopToken.store(1, std::memory_order_relaxed);
19
+ + StopToken.store(1, std::memory_order_seq_cst);
20
+ atomicNotifyAll();
21
+ }
22
+
23
+ @@ -1120,6 +1126,8 @@ private:
24
+ Statistics::Statistics *Stat;
25
+ /// Stop Execution
26
+ std::atomic_uint32_t StopToken = 0;
27
+ + /// Invocations currently running on this executor (SDN stop-token patch).
28
+ + std::atomic_uint32_t ActiveInvocations = 0;
29
+ /// Executor Host Function Handler
30
+ HostFuncHandler HostFuncHelper = {};
31
+ };
32
+ diff --git a/lib/executor/engine/controlInstr.cpp b/lib/executor/engine/controlInstr.cpp
33
+ index 935992a..55e08d7 100644
34
+ --- a/lib/executor/engine/controlInstr.cpp
35
+ +++ b/lib/executor/engine/controlInstr.cpp
36
+ @@ -134,7 +134,7 @@ Expect<void> Executor::runBrOnCastOp(Runtime::StackManager &StackMgr,
37
+ Expect<void> Executor::runReturnOp(Runtime::StackManager &StackMgr,
38
+ AST::InstrView::iterator &PC) noexcept {
39
+ // Check stop token
40
+ - if (unlikely(StopToken.exchange(0, std::memory_order_relaxed))) {
41
+ + if (unlikely(StopToken.load(std::memory_order_relaxed))) {
42
+ spdlog::error(ErrCode::Value::Interrupted);
43
+ return Unexpect(ErrCode::Value::Interrupted);
44
+ }
45
+ diff --git a/lib/executor/executor.cpp b/lib/executor/executor.cpp
46
+ index 137131b..68ef4fe 100644
47
+ --- a/lib/executor/executor.cpp
48
+ +++ b/lib/executor/executor.cpp
49
+ @@ -140,6 +140,16 @@ Executor::invoke(const Runtime::Instance::FunctionInstance *FuncInst,
50
+ }
51
+ }
52
+
53
+ + // SDN patch (stop-token): a stop issued while invocations run stays set
54
+ + // until all of them have returned; the first invocation on an idle executor
55
+ + // clears a token left over from an earlier stop.
56
+ + if (ActiveInvocations.fetch_add(1, std::memory_order_acq_rel) == 0) {
57
+ + StopToken.store(0, std::memory_order_seq_cst);
58
+ + }
59
+ + cxx20::scope_exit ActiveInvocationGuard([this]() noexcept {
60
+ + ActiveInvocations.fetch_sub(1, std::memory_order_acq_rel);
61
+ + });
62
+ +
63
+ Runtime::StackManager StackMgr;
64
+
65
+ // Call runFunction.
66
+ diff --git a/lib/executor/helper.cpp b/lib/executor/helper.cpp
67
+ index 96205cc..2ace419 100644
68
+ --- a/lib/executor/helper.cpp
69
+ +++ b/lib/executor/helper.cpp
70
+ @@ -51,7 +51,7 @@ Executor::enterFunction(Runtime::StackManager &StackMgr,
71
+ // RetIt: the return position when the entered function returns.
72
+
73
+ // Check if the interruption occurs.
74
+ - if (unlikely(StopToken.exchange(0, std::memory_order_relaxed))) {
75
+ + if (unlikely(StopToken.load(std::memory_order_relaxed))) {
76
+ spdlog::error(ErrCode::Value::Interrupted);
77
+ return Unexpect(ErrCode::Value::Interrupted);
78
+ }
79
+ @@ -251,7 +251,7 @@ Executor::branchToLabel(Runtime::StackManager &StackMgr,
80
+ const AST::Instruction::JumpDescriptor &JumpDesc,
81
+ AST::InstrView::iterator &PC) noexcept {
82
+ // Check the stop token.
83
+ - if (unlikely(StopToken.exchange(0, std::memory_order_relaxed))) {
84
+ + if (unlikely(StopToken.load(std::memory_order_relaxed))) {
85
+ spdlog::error(ErrCode::Value::Interrupted);
86
+ return Unexpect(ErrCode::Value::Interrupted);
87
+ }
88
+ diff --git a/lib/llvm/compiler.cpp b/lib/llvm/compiler.cpp
89
+ index 8db12e3..f765db6 100644
90
+ --- a/lib/llvm/compiler.cpp
91
+ +++ b/lib/llvm/compiler.cpp
92
+ @@ -5670,12 +5670,13 @@ private:
93
+ return;
94
+ }
95
+ auto NotStopBB = LLVM::BasicBlock::create(LLContext, F.Fn, "NotStop");
96
+ - auto StopToken = Builder.createAtomicRMW(
97
+ - LLVMAtomicRMWBinOpXchg, Context.getStopToken(Builder, ExecCtx),
98
+ - LLContext.getInt32(0), LLVMAtomicOrderingMonotonic);
99
+ -#if LLVM_VERSION_MAJOR >= 13
100
+ - StopToken.setAlignment(32);
101
+ -#endif
102
+ + // SDN patch (stop-token): read the token, never consume it. An exchange
103
+ + // let one thread swallow a stop meant for all of them, and it made every
104
+ + // block of every thread an RMW on one shared cache line.
105
+ + auto StopToken = Builder.createLoad(
106
+ + LLContext.getInt32Ty(), Context.getStopToken(Builder, ExecCtx), true);
107
+ + StopToken.setOrdering(LLVMAtomicOrderingMonotonic);
108
+ + StopToken.setAlignment(4);
109
+ auto NotStop = Builder.createLikely(
110
+ Builder.createICmpEQ(StopToken, LLContext.getInt32(0)));
111
+ Builder.createCondBr(NotStop, NotStopBB,
@@ -71,9 +71,16 @@ export function loadWasmEdgePin() {
71
71
  if (!repository) {
72
72
  throw new Error("wasmedgePin.json dockerImageRepository is required.");
73
73
  }
74
+ // The SDN WasmEdge 0.16.4 patch series (01-atomic-wait, 02-stop-token,
75
+ // 03-fault-jmp, 04-atomic-memarg-offset; sdn-server/internal/wasmrt/SUBSTRATE.md).
76
+ // Any change to the runner source, any patch, or the Dockerfile itself must
77
+ // bump this identity so a stale-patched image is never reused.
74
78
  const runnerIdentity = createHash("sha256")
75
79
  .update(readFileSync(path.join(__dirname, "native/wasmedge_wasi_threads_runner.c")))
76
80
  .update(readFileSync(path.join(__dirname, "native/wasmedge-0.16.4-atomic-wait.patch")))
81
+ .update(readFileSync(path.join(__dirname, "native/wasmedge-0.16.4-stop-token.patch")))
82
+ .update(readFileSync(path.join(__dirname, "native/wasmedge-0.16.4-fault-jmp.patch")))
83
+ .update(readFileSync(path.join(__dirname, "native/wasmedge-0.16.4-atomic-memarg-offset.patch")))
77
84
  .update(readFileSync(path.join(__dirname, String(pin.dockerfile))))
78
85
  .digest("hex").slice(0, 16);
79
86
  return Object.freeze({