Repository navigation
jsonrpc@1: read any JSON spelling of a method name, write valid JSON, refuse non-UTF-8 frames - #28
Merged
Merged
Conversation
added 2 commits
October 26, 2026 03:26
… refuse non-UTF-8 frames Bump comline-runtime to 78320db (runtime main), which brings runtime#45, and port its fixes to the simulator's vendored JSON-RPC framing: - A request's `method` is read as raw JSON and becomes a `contract::MethodName`, so a name with escapes (`"app.Chat\/count"`) is accepted instead of refused (runtime#41). - A method name is written escaped as serde_json escapes it, so a name with `"`, `\` or a control character makes valid JSON (runtime#41). - Requests and responses are UTF-8-checked whole before parsing, so invalid UTF-8 in an ignored member (`jsonrpc`, `error.message`, an unknown member) refuses the frame (runtime#42). The `corrupt` fault flips a byte with `^ 0xff`, so it could produce such a frame. The new tests carry runtime#45's `framing-jsonrpc/found-*` conformance cases byte for byte; they fail against the old code.
Enable serde_json's `float_roundtrip`, as comline-runtime's JSON format does. The default parser is best-effort and reads some f64s one ulp off; the test carries runtime's `format-json/found-f64-exact-digits` value, 4.520618856987477e-279, which it read as bits 0x062483bf55de65f1 instead of 0x062483bf55de65f2.
Kinflou
force-pushed
the
fix/jsonrpc-strings
branch
from
October 25, 2026 19:32
76daf2f to
3acd78c
Compare
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.
Bumps
comline-runtimeto78320db(runtimemain), which brings ComlineProject/runtime#45, and ports that PR's two fixes to the simulator's vendored JSON-RPC framing (src/framing.rs). The runtime keepsJsonRpcFramingbehindstd, andstddoesn't build forwasm32, so the simulator still can't delegate to it. The vendored helpers (method_of,put_method,parse) now match the runtime's text, apart fromcore::strvsstd::str.Both bugs were present
The new tests carry runtime#45's
framing-jsonrpc/found-*conformance cases byte for byte. Against the old code:a_method_name_reads_in_any_json_spellingfails because"app.Chat\/count"was refused (method: &strcan't borrow an escaped string).a_method_name_is_written_as_serde_json_writes_itfails because a name containing",\or control characters was copied into the frame unescaped, which gave invalid JSON.invalid_utf8_anywhere_refuses_the_framefails because a request with0xffinside"jsonrpc"was accepted. Requests and responses usedserde_json::from_slice, which doesn't check skipped members. In the simulator this could actually happen: thecorruptfault flips a byte in the frame's back half with^ 0xff, which can land inerror.messageand leave a frame that the simulator accepted and a real runtime refuses.Changes
RequestCall::Namenow holds aMethodName. Request decode readsmethodas aRawValueand passes it toMethodName::from_json. Amethodthat isn't a string, or isn't valid JSON string text, is refused.put_methodescaper.serde_json::from_str.generic.rs: tests updated for the new type, plus a case that resolves an escaped name (s\u0065nd).Also: exact f64 reads (
float_roundtrip)The simulator's own
serde_jsonnow enablesfloat_roundtrip, matching runtime's JSON format. The default parser is best-effort and reads somef64values one ulp off.format::tests::an_f64_reads_back_exactlyuses runtime'sformat-json/found-f64-exact-digitsvalue,4.520618856987477e-279. Before this change, the test failed: the value was read as bits0x062483bf55de65f1instead of...f2.WASM size
JSON-RPC fix only,
wasm-bindgenoutput beforewasm-opt, measured locally:--no-default-features)Post-
wasm-optsizes, from CI logs:4e8e5e3)f3fbb6f)float_roundtrip(3acd78c)float_roundtripadds about 22 KB because it compiles in serde_json's exact (arbitrary-precision) float parser.Follow-up
Once this merges, the playground (
app/package.json, which pins4e8e5e3) needs a bump.