feat: single entrypoint json-rpc based host-call#176
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds a unified JSON-RPC entrypoint for host calls and integrates HTTP request handling into the Blockless runtime.
- Introduces a new
BlocklessRpcErrorKindenum and WITX interface forrpc_call - Implements JSON-RPC request/response types and the
rpc_callhandler in WASI - Adds async HTTP request execution via
reqwestand links the RPC interface into the runtime
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/blockless-env/src/lib.rs | Registers the new add_bless_to_linker integration |
| crates/blockless-drivers/witx/blockless_rpc.witx | Defines the $bless WITX module and rpc_call function |
| crates/blockless-drivers/src/wasi/rpc.rs | Implements JSON-RPC types and the async rpc_call logic |
| crates/blockless-drivers/src/wasi/mod.rs | Exposes the rpc submodule |
| crates/blockless-drivers/src/lib.rs | Adds the handlers module to the driver crate |
| crates/blockless-drivers/src/handlers/http.rs | Implements handle_http_request and HTTP execution logic |
| crates/blockless-drivers/src/error.rs | Defines the BlocklessRpcErrorKind enum and Display |
| crates/blockless-drivers/Cargo.toml | Enables the multipart feature for reqwest |
| blockless/src/lib.rs | Links the new RPC entrypoint into the Blockless runtime |
Comments suppressed due to low confidence (2)
crates/blockless-drivers/src/handlers/http.rs:1
- Public structs and functions in this file lack documentation comments. Adding docstrings for
HttpRpcRequest,handle_http_request, andexecute_http_requestwill improve clarity for consumers of the API.
use reqwest::{Client, Method};
crates/blockless-drivers/src/wasi/rpc.rs:110
- The new
handle_rpc_requestasync handler lacks unit tests to verify each RPC method (e.g.,ping,echo,version,http.request). Consider adding tests to cover these code paths.
async fn handle_rpc_request(request: JsonRpcRequest) -> JsonRpcResponse {
Pull Request Test Coverage Report for Build 16256800493Details
💛 - Coveralls |
Joinhack
reviewed
Jul 14, 2025
Joinhack
reviewed
Jul 14, 2025
uditdc
approved these changes
Jul 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request introduces significant updates to the Blockless runtime to support JSON-RPC functionality and HTTP request handling.
Key changes include the addition of a new
BlocklessRpcErrorKindenum, integration of a JSON-RPC interface, and a comprehensive HTTP request handler.These updates enhance the runtime's ability to process RPC calls and execute HTTP requests directly within the WASM environment.
JSON-RPC Integration:
BlocklessRpcErrorKindenum to define error types for RPC operations, along with implementations forstd::error::Errorandstd::fmt::Display. (crates/blockless-drivers/src/error.rs, crates/blockless-drivers/src/error.rsR220-R242)JsonRpcRequest,JsonRpcResponse,JsonRpcError) and implemented therpc_callmethod to handle RPC calls in WASM memory. (crates/blockless-drivers/src/wasi/rpc.rs, crates/blockless-drivers/src/wasi/rpc.rsR1-R153)$blesswith anrpc_callinterface for JSON-RPC operations. (crates/blockless-drivers/witx/blockless_rpc.witx, crates/blockless-drivers/witx/blockless_rpc.witxR1-R30)HTTP Request Handling:
HttpRpcRequest,HttpOptions,HttpBody, and related structures to support HTTP requests, including multipart handling. (crates/blockless-drivers/src/handlers/http.rs, crates/blockless-drivers/src/handlers/http.rsR1-R239)handle_http_requestandexecute_http_requestmethods to process HTTP requests asynchronously usingreqwest. (crates/blockless-drivers/src/handlers/http.rs, crates/blockless-drivers/src/handlers/http.rsR1-R239)Runtime Enhancements:
add_bless_to_linker. (blockless/src/lib.rs, [1];crates/blockless-env/src/lib.rs, [2]Cargo.tomlto include themultipartfeature forreqwest. (crates/blockless-drivers/Cargo.toml, crates/blockless-drivers/Cargo.tomlL29-R29)These changes collectively enhance the runtime's extensibility and enable advanced communication and request handling capabilities.