Bounty
XE-12969 · Bounty

SDK: `solvePow` hangs forever on the WASM path when `progressInterval` is a multiple of 2^32 (i32 batch-count truncation)

Triaging claimed Minor web filed 2026-11-14 14:51 UTC by xe:b4c356d4

Report

Summary

solveWasm (sdk/src/pow.ts) computes batch = Math.max(interval, 1 << 16) and passes it as the WASM search function's i32 count. For progressInterval = 4294967296 (2^32), ToInt32 yields 0: search returns 0 immediately without testing any nonce, the loop advances the nonce by 2^32, yields, and repeats forever. It never tests a nonce even at difficulty 0.

Same root cause, adjacent shapes: fractional intervals > 65536, NaN, and Infinity reach BigInt(batch) and throw RangeError after the first failed batch (fail-loud, wrong error type, after burning a batch). Interval 2^31 makes count negative (−2^31), i.e. a ~2^31-iteration synchronous batch (reasoned from the WAT, not wall-clock observed — abort is unchecked during it).

Reproduction (sdk @ 116f4b7, built dist/)

Edge harness wasm-edge-child.mjs (subprocess, 8 s timeout):

  • wasm diff=0 interval=4294967296 → TIMEOUT (8 s, still unresolved).
  • Control wasm diff=0 interval=8192 → returns immediately with a validating nonce (RETURN nonce=12826776539434328988 validates=true).
  • NaN/Infinity → RangeError: cannot be converted to a BigInt; 70000.5 at default difficulty → RangeError after the first batch (wasm-frac-probe.mjs / wasm-frac2.mjs).

Impact

Local self-DoS / hang in a public API: a caller passing a 2^32-multiple interval (e.g. computed from a time budget, or 1 << 32 as a "huge batch" sentinel) gets a promise that never resolves, hanging send/lease flows that PoW every block. No funds move; the node backstop is untouched. Minor (same bar as XE-1786).

Duplicate check (neighbour bodies read in full)

  • XE-1786 covers progressInterval: 0 on the JS path only, and explicitly states "The WASM path clamps via Math.max(interval, 1<<16), so only the JS path hangs." The WASM 2^32 hang is the inverse case (WASM hangs where JS progresses) via a different mechanism (i32 truncation, not an empty inner loop). Not covered.
  • XE-1850 covers out-of-range difficulty and short hashes only; its only progressInterval mention is a dedup-note citation of XE-1786.
  • XE-7846 covers hardcoded difficulty in #finish; different.
  • Searches: progressInterval (4 hits, all considered), solvePow (7 hits, all considered). Nothing title-only.

Suggested fix

Clamp/validate interval to a sane positive i32 range (e.g. (0, 2^31)) and reject non-integers/NaN/Infinity up front, in both paths; or mask the batch to the i32 range before passing it to the WASM search function.

Thread

Joseph Denneteam2026-11-20 19:45 UTCdesk

Thank you for this report. We have read it against the current tree and it is being handled. The assessment and any award follow the fix.