Phase 1 (memory fixes) - applied, builds clean. Phase 2a (relay-proxy CheckSig) - applied, builds clean. ev.CheckSig() in wireConn onEvent drops invalid events at the network boundary. Phase 2b (spawn-based verifier) - BLOCKED. Both app and relay-proxy are callback-driven (main() sets callbacks and returns, no running goroutine). channelrecv blocks via Atomics.wait, which freezes the JS event loop if called from a callback. Needs channeltry_recv OR Atomics.waitAsync watcher support upstream in moxie jsruntime before this can be wired up.
In dispatchEvent() in web/wasm/app/main.mx. Events from relay-proxy go to verifier channel, render only after verification returns.
type VerifyReq struct {
ReqID moxie.Uint32
EvJSON moxie.Bytes
}
type VerifyRes struct {
ReqID moxie.Uint32
Valid moxie.Bool
}
reqCh := chan VerifyReq{} // app -> verifier (unbuffered)
resCh := chan VerifyRes{} // verifier -> app (unbuffered)
spawn(verifierMain, reqCh, resCh)
SAB slot size: 64KB minimum (events can be ~32KB with content + tags).
map[uint32]*nostr.Event keyed by ReqIDcase res := <-resCh: alongside existing selectsfunc verifierMain(reqCh chan VerifyReq, resCh chan VerifyRes) {
for {
select {
case req := <-reqCh:
// deserialize event from EvJSON, extract pubkey + sig + serialized content
// schnorr.Verify uses wNAF precomputed tables (~64KB, stays in this worker's linear memory)
valid := verifyEvent(req.EvJSON)
resCh <- VerifyRes{ReqID: req.ReqID, Valid: moxie.Bool(valid)}
}
}
}
No jsbridge dependencies beyond what's already in the WASM binary. Pure compute.
If verifier worker dies (channel_recv returns -1 / channel closes), fall back to inline verification in the app worker. Log the fallback.
SAB channels are unbuffered at spawn boundary. App blocks on send if verifier is behind. Correct behavior - prevents unverified event accumulation.
wasm-app-worker-host.mjs pattern) would need the idb_* bridge subset wired up for the spawned worker.type DBReq struct {
ReqID moxie.Uint32
Op moxie.Uint8 // 1=save, 2=get, 3=query, 4=delete, 5=putProfile
Data moxie.Bytes
}
type DBRes struct {
ReqID moxie.Uint32
Ok moxie.Bool
Data moxie.Bytes
}
The relay-proxy could accept a PREFETCH message type that triggers speculative REQs for referenced profiles/events. Results flow back through the existing relay-proxy -> app channel. No new worker, no new jsbridge, no IDB contention. The relay-proxy already has the connection pool.
type PrefetchReq struct {
Op moxie.Uint8 // 1=scan event for refs, 2=explicit profile fetch, 3=cancel
Data moxie.Bytes
}
type PrefetchRes struct {
Kind moxie.Uint8 // 1=profile_ready, 2=event_ready, 3=relay_meta_ready
Data moxie.Bytes
}
For any spawned worker that needs jsbridge access (DB, prefetch):