Skip to content

ariadne_wasm_transform_test: the runtime registers the engine on its app (master builds again) - #1229

Merged
transfix merged 2 commits into
masterfrom
fix/wasm-browser-test-app-engine
Nov 14, 2026
Merged

transfix merged 2 commits into
masterfrom
fix/wasm-browser-test-app-engine

Conversation

@transfix

Copy link
Copy Markdown
Owner

Master at accadc35 doesn't compile ariadne_wasm_transform_test. #1197's src/cvc/tests/ariadne_wasm_browser_test.cpp still calls register_script_engine(engine) and unregister_script_engine("wasm"). #1203 replaced both with the (app, ...) forms, and #1197's CI ran before #1203 landed. The file builds natively wherever wasmtime is found, and in the wasm-guests node job.

The fix follows what #1203 did for ariadne_wasm_test.cpp:

  • SetUp no longer registers the engine;
  • the TearDown that unregistered it is gone.

All 14 tests' 18 AppRuntimes already call use_script_engine(engine), which registers the engine on that runtime's app.

#1206 carries the same change, so whichever lands second takes master's copy.

…app (master builds again)

#1197's ariadne_wasm_browser_test.cpp (built natively as ariadne_wasm_transform_test wherever
wasmtime is found, and in the wasm-guests node job) still called register_script_engine(engine)
and unregister_script_engine("wasm"), which #1203 replaced with the (app, ...) forms. #1197's CI ran
before #1203 landed, so master at accadc3 doesn't compile it.

As #1203 did for ariadne_wasm_test.cpp: SetUp no longer registers the engine, and the TearDown
that unregistered it goes. Each of the file's 18 AppRuntimes already calls
use_script_engine(engine), which registers it on that runtime's app.
@transfix
transfix enabled auto-merge (squash) November 14, 2026 08:57
… app

#1203 gives every cvc command its app as an argument, removes cvc_app() and
makes cvc::ariadne::load_string take the app. It merged after #1168 and #1180,
whose new code still used the old forms, so master does not build:
- src/cvc-cli/main.cpp: cmd_trace (#1168) takes cvc::app & like the other
  commands and replays on it, not cvc_app().
- src/cvc/tests/ariadne_runtime_test.cpp: #1180's three AriadneRichText
  tests pass their app to load_string; each already makes one.
@transfix

Copy link
Copy Markdown
Owner Author

Now also carries #1225's commit unchanged (cmd_trace and the three AriadneRichText load_string calls take their app), so this PR's CI can build on current master without waiting for #1225. The edits are identical, so whichever of the two lands second merges cleanly.

transfix added a commit that referenced this pull request Nov 14, 2026
transfix added a commit that referenced this pull request Nov 14, 2026
…e browser test's fixture) into feat/wasm-weighted-gas
@transfix
transfix merged commit 5896f78 into master Nov 14, 2026
28 checks passed
@transfix
transfix deleted the fix/wasm-browser-test-app-engine branch November 14, 2026 13:01
transfix added a commit that referenced this pull request Nov 14, 2026
…wser (G2, second part) (#1206)

A guest's work now counts the same on wasmtime and in the browser, and
however a call is sliced.

- meter.h/.cpp: the gas pass, in C++. It reads a core module, charges each
  metered block's cost against a new exported i64 global, ari_gas, inline,
  and calls a new import, ari.gas(cost), only when the slice can't pay for
  the block. A block starts at a function's entry and after loop, if, else,
  end and the conditional branches. An instruction costs what wasmtime's
  fuel charges. The new import shifts every defined function's index, in
  calls, ref.func, element segments, exports, the start function and the
  name section. ari_gas starts at the start function's allowance.
  - It refuses GC types and instructions, the legacy exception handling,
    components, and code that names a global index the pass's own would
    take. A module that imports ari.gas already is left as it is.
  - It's C++ rather than paritytech/wasm-instrument, which the roadmap
    named: that crate and its parser, parity-wasm, haven't changed since
    2022, and parity-wasm doesn't read reference types, which LLVM 19 turns
    on by default for wasm32.
- meter_main.cpp: ari_wasm_meter, the pass as a command. Under Emscripten
  it runs in node.
- cvc_ariadne_wasm_transform: binaryen reads the guest, ari_wasm_meter
  meters it, then wasm-opt --asyncify --pass-arg=asyncify-imports@ari.* -O1.
  This replaces --log-execution.
- wasmtime validates and meters each module it compiles. A poll sets
  ari_gas to its slice; ari.gas is an async import that ends the poll.
  When a charge ends a slice, the next slice is at least that block's cost.
  Fuel stays on as a backstop (16 units per unit of gas). A start function
  past its allowance traps instead of hanging.
- browser_runtime.cpp pauses at ari.gas instead of counting log_execution
  checks. The page sets ari_gas before each call, and the gas the guest
  took is the call's. kFuelPerCheck is gone.
- Call::poll(gas), gas_used() and Instance::run(..., gas, ...) replace the
  fuel names.
- Tests: WasmGasTest (ariadne_wasm_test). A module naming functions
  everywhere runs as it did. count(1000) costs 8001 in slices of
  1, 7, 8, 100, 4096 and in one. A module is metered once. What the pass
  can't read is refused, and every prefix of a module is read or refused.
  A start function that never ends is refused.
  WasmTransformed.ASpinCountsTheSameOnBothBackends: the transformed guest's
  spin costs 24,000,001 in one slice and in 376 of 64,000, on wasmtime and
  in the browser.
- The WASI guest (#1199) is metered and Asyncified in the transform too, and
  the transform passes binaryen CVC_WASM_GUEST_FEATURES on both runs.
- The branch also carries the compile fixes for #1203's API change that
  #1225 and #1229 bring to master (cmd_trace, the rich-text tests'
  load_string, the browser test's fixture), which master may have first.
transfix added a commit that referenced this pull request Nov 14, 2026
CI at 9d002d1 built it on master as of 09:28, after #1197 added
ariadne_wasm_browser_test.cpp with register_script_engine calls that
predate #1203 (all three package-linux lanes and wasm-guests failed to
compile it). Master fixed that in #1229, and the load_string calls
#1169 left in the loader and chart tests in #1190. This merge takes
master as it is now, so CI builds on those fixes. No conflicts.

Master's new natives (#1190's file-pick and http-upload, #1195's
py_console, #1169's chart) build against this branch's call_args
context as they are.

Checked on Windows (MSVC Release): full build; the Ariadne, net, HTTP,
state_exec, groups, slices, async-call, cycle-registry and multi-app
ctests, 1336/1336. ariadne_wasm_browser_test is not built here (it needs
wasmtime or Emscripten); master's CI builds it.
transfix added a commit that referenced this pull request Nov 14, 2026
…#1222-#1225, #1229)

Master's #1190 (file-pick and http-upload) was written for a single async host; this branch runs
an isolated document's programs on its own group's host, on a pool worker in an `any` group.

- net_intrinsics.cpp: StartedRequest takes master's deliver()/on_outcome, settling through the
  host's finisher. http-upload is its own provider, `any` as the requests are: it parks on the
  calling program's host (ictx.host), takes its progress path from ictx.root_path (no tree walk
  on a worker), and a started upload (a browser page) keeps the host's finisher, not the host.
- ariadne.cpp: file-pick, file-info and file-forget bind into the program's env as they are, in
  every group (install_backend_verbs), not through the backend verbs' host_proxied wrapper, which
  cannot park an async verb. file-pick parks on the program's own host, claims the Runtime's
  picker hub under its lock where it is called, and opens the picker on the host thread
  (exec_pool::run_on_host; inline when called there). Its answer goes through the host's
  finisher, as the host may be gone by then.
- ci.yml: the sanitizer list keeps this branch's tests and master's point_classes_test.
- STATE_EXEC_THREADED.md: rows for http-upload, the file verbs, and the contours and
  point-classes providers. The last two are registered without a kind, so they are host_only, and
  an isolated document in an app that installs them goes to a host-affinity group.
- New test: AriadneIsolatedDocs.FilePickOpensItsPickerOnTheFramesThread.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant