Skip to content

feat(validator-node): integrate WASM runtime for challenge evaluation - #13

Merged
echobt merged 3 commits into
mainfrom
feat/wire-wasm-runtime-into-validator-node
Feb 17, 2026
Merged

feat(validator-node): integrate WASM runtime for challenge evaluation#13
echobt merged 3 commits into
mainfrom
feat/wire-wasm-runtime-into-validator-node

Conversation

@echobt

@echobt echobt commented Feb 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds WASM challenge execution support to the validator node, enabling validators to load, compile, and execute WASM challenge modules as an alternative evaluation path alongside the existing Docker/HTTP evaluator.

Changes

New module: wasm_executor.rs

  • WasmChallengeExecutor struct wrapping wasm_runtime_interface::WasmRuntime with compile-once module caching via RwLock<HashMap<String, Arc<WasmModule>>>
  • execute_evaluation() — loads/compiles a WASM module, allocates guest memory, writes input data, calls the evaluate(ptr, len) export, and returns an i64 score with execution metrics
  • execute_validation() — similar flow calling the validate(ptr, len) export, returning a bool result
  • ExecutionMetrics capturing execution time, memory usage, network requests, and fuel consumed
  • Graceful error handling for fuel exhaustion, timeouts, and OOM traps

Integration in main.rs

  • WasmChallengeExecutor initialized at startup with configurable WasmExecutorConfig
  • Periodic WASM evaluation tick (every 5s) checks pending evaluations for matching WASM modules
  • Evaluation results are signed and recorded in the consensus state via add_validator_evaluation()
  • Failed WASM executions report a score of 0 with appropriate warning/error logging

CLI configuration flags

  • --wasm-module-dir <path> — directory for WASM challenge modules (default: ./wasm_modules)
  • --wasm-max-memory <bytes> — max WASM memory limit (default: 512MB)
  • --wasm-enable-fuel — enable fuel metering
  • --wasm-fuel-limit <u64> — optional fuel limit per execution

Dependencies

  • Added wasm-runtime-interface (workspace crate) and bincode to bins/validator-node/Cargo.toml

Add WASM challenge evaluation support to the validator node, enabling
validators to load, compile, and execute WASM challenge modules during
the evaluation flow as an alternative to the Docker/HTTP evaluator path.

New WasmChallengeExecutor (wasm_executor.rs) wraps wasm-runtime-interface
to provide execute_evaluation() and execute_validation() methods. Modules
are compiled once and cached using an in-memory HashMap protected by
RwLock. Each execution allocates guest memory, writes input data, and
calls the exported evaluate/validate function. Execution metrics (time,
memory, network requests, fuel consumed) are tracked and logged.

The executor is initialized in main.rs and integrated into the event loop
via a 5-second polling interval that checks pending evaluations for WASM
modules. When a matching module exists, evaluation runs on a blocking
task, and results are signed and recorded in consensus state. Errors
(traps, timeouts, OOM) are handled gracefully with a score of 0.

CLI flags added: --wasm-module-dir, --wasm-max-memory, --wasm-enable-fuel,
and --wasm-fuel-limit, all with env var overrides. Dependencies added:
wasm-runtime-interface (workspace crate) and bincode (for signing data
serialization).
@coderabbitai

coderabbitai Bot commented Feb 17, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@echobt has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 25 minutes and 16 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/wire-wasm-runtime-into-validator-node

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@echobt
echobt merged commit c427534 into main Feb 17, 2026
11 checks passed
@echobt
echobt deleted the feat/wire-wasm-runtime-into-validator-node branch February 17, 2026 07:41
This was referenced Feb 17, 2026
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