fix(challenge-sdk-wasm): align host function signatures and extend SDK types - #17
Conversation
…interface - Fix http_get, http_post, dns_resolve extern signatures to use 4 params (req_ptr, req_len, resp_ptr, resp_len) matching the host linker registrations - Add http_request extern for the generic HTTP host function - Fix storage externs: rename storage_set to storage_propose_write, add storage_delete, update return types to match host pack_result convention - Update all wrapper functions to pass correct arguments - Change host_http_post to accept single serialized request (body is part of the HttpPostRequest struct deserialized by the host)
…t functions Extend the guest SDK to support richer evaluation types and new host function modules needed by term-challenge. Types (types.rs): Add optional fields to EvaluationInput (submission_id, participant_id, epoch, metadata) and EvaluationOutput (score_f64, results, execution_time_ms) with #[serde(default)] for backward compatibility. Update the success() and error() constructors to initialize new fields as None. Host functions (host_functions.rs): Add platform_exec module with exec_command(cmd_ptr, cmd_len, resp_ptr, resp_len) -> i32 for sandboxed command execution, and platform_time module with get_timestamp() -> i64. Include safe Rust wrappers host_exec_command() and host_get_timestamp(). Trait (lib.rs): Add challenge_id() method to the Challenge trait with a default implementation that delegates to name().
|
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 |
…m-host-signatures-and-types # Conflicts: # crates/challenge-sdk-wasm/src/host_functions.rs # crates/challenge-sdk-wasm/src/lib.rs # crates/challenge-sdk-wasm/src/types.rs
…m-host-signatures-and-types
…m-host-signatures-and-types
…m-host-signatures-and-types
Summary
Fixes mismatches between guest SDK extern declarations and host-registered function signatures, and extends evaluation types and host function modules to support richer challenge evaluation workflows (e.g., terminal benchmarks).
Changes
Host function signature fixes (
host_functions.rs)http_get,dns_resolveextern declarations to 4-param signatures (req_ptr, req_len, resp_ptr, resp_len) matching the runtime interfacehttp_postto use 4 params (remove extraneousextra/body.len()param)storage_getandstorage_set→storage_propose_writeto usei64-packed return values matching the host ABIstorage_deleteextern and wrapperhttp_requestgeneric extern andhost_http_requestwrapperhost_http_get,host_dns_resolve, etc.)New host function modules (
host_functions.rs)platform_execmodule withexec_command(cmd_ptr, cmd_len, resp_ptr, resp_len) -> i32for sandboxed command executionplatform_timemodule withget_timestamp() -> i64for retrieving timestampsExtended evaluation types (
types.rs)EvaluationInput:submission_id,participant_id,epoch,metadataEvaluationOutput:score_f64,results,execution_time_ms#[serde(default)]for backward compatibilityChallenge trait (
lib.rs)challenge_id()method with default implementation delegating toname()