feat(validator-node): integrate WASM runtime for challenge evaluation - #13
Conversation
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).
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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)
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. Comment |
…e-into-validator-node
…e-into-validator-node
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.rsWasmChallengeExecutorstruct wrappingwasm_runtime_interface::WasmRuntimewith compile-once module caching viaRwLock<HashMap<String, Arc<WasmModule>>>execute_evaluation()— loads/compiles a WASM module, allocates guest memory, writes input data, calls theevaluate(ptr, len)export, and returns ani64score with execution metricsexecute_validation()— similar flow calling thevalidate(ptr, len)export, returning aboolresultExecutionMetricscapturing execution time, memory usage, network requests, and fuel consumedIntegration in
main.rsWasmChallengeExecutorinitialized at startup with configurableWasmExecutorConfigadd_validator_evaluation()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 executionDependencies
wasm-runtime-interface(workspace crate) andbincodetobins/validator-node/Cargo.toml