-
Notifications
You must be signed in to change notification settings - Fork 17
feat: single entrypoint json-rpc based host-call #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.