feat(wasm): integrate evaluation pipeline with structured I/O and registry support - #35
Conversation
…lenge registry Update the validator node WASM executor, challenge registry, build infrastructure, and documentation to support loading and executing term-challenge WASM modules through the evaluation pipeline. WASM Executor (wasm_executor.rs, main.rs): - Add EvaluationInput/EvaluationOutput structs for structured data exchange across the WASM boundary using bincode serialization - Refactor execute_evaluation() to accept challenge_id and params, construct EvaluationInput, and deserialize packed ptr+len return values into EvaluationOutput with score, valid flag, and message - Add StorageHostConfig/StorageHostState integration for persistent storage - Rename allocator call from "allocate" to "alloc" matching WASM SDK ABI - Handle WASM traps, OOM, fuel exhaustion with descriptive error types - Update main.rs call sites to pass challenge_id and params, and read structured output fields (score, valid, message) from EvaluationOutput Challenge Registry (registry.rs): - Deprecate docker_image field with compile warning in favor of wasm_module - Add register_wasm_challenge() method that validates the WASM file exists, computes its SHA256 hash, and stores the entry with WasmModuleMetadata - Add #[allow(deprecated)] annotations to suppress warnings in existing tests and constructors that still reference docker_image Build Script (build-wasm.sh): - Extract build logic into reusable build_challenge() function - Add wasm-strip support for reducing binary size before wasm-opt - Copy compiled artifacts to challenges/compiled/ standard location - Compute and print SHA256 hash of each compiled module - When no argument given, discover and build all challenge crates under challenges/*/ plus term-challenge-wasm if present as workspace member - Preserve chain-runtime fallback build when no challenges are found Documentation (challenges/README.md): - Document WASM Challenge trait as recommended approach alongside legacy ServerChallenge - Add WASM ABI export requirements (evaluate, validate, alloc) - Add term-challenge-wasm build instructions and link to term-challenge repo - Update external challenge guidance to reference Challenge trait and register_challenge! macro
|
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 |
…aluation-pipeline # Conflicts: # bins/validator-node/src/wasm_executor.rs # challenges/README.md
…ature, fix clippy warnings
Summary
Reworks the WASM challenge executor to use structured
EvaluationInput/EvaluationOutputtypes serialized via bincode across the WASM boundary, and updates the challenge registry to support WASM-primary challenge registration with module hash verification.Changes
WASM Executor (
bins/validator-node/src/wasm_executor.rs)EvaluationInputandEvaluationOutputstructs for typed data exchange with WASM modulesexecute_evaluationto acceptchallenge_idandparams, constructingEvaluationInputinternallyEvaluationOutputfrom packed ptr+len return value (high 32 bits = length, low 32 bits = pointer)StorageHostStateandStorageHostConfigfor persistent storage supportallocatetoallocto match SDK conventionvalidate_submissionwith the same structured input patternValidator Node (
bins/validator-node/src/main.rs)StorageHostConfigtoWasmExecutorConfigprocess_wasm_evaluationsto passchallenge_idand params to executorEvaluationOutputfields (score, valid, message) in loggingChallenge Registry (
crates/challenge-registry/src/registry.rs)register_wasm_challenge()method that validates WASM file existence, computes SHA256 hash, and stores the entrydocker_imagefield onChallengeEntrywith compile warning#[allow(deprecated)]annotations to existing tests and constructorsBuild Script (
scripts/build-wasm.sh)build_challenge()function for reusable per-crate buildswasm-stripsupport for reducing binary size before optimizationchallenges/compiled/directorychallenges/*/when no argument giventerm-challenge-wasmworkspace member detectionDocumentation (
challenges/README.md)Challengetrait,register_challenge!macro, expected exports)ServerChallengeas legacy approach