Skip to content

rpc: simplify the encoding of interface-typed arguments in JSON#7600

Merged
creachadair merged 7 commits intomasterfrom
mjf/rpc-cleanup-14
Jan 15, 2022
Merged

rpc: simplify the encoding of interface-typed arguments in JSON#7600
creachadair merged 7 commits intomasterfrom
mjf/rpc-cleanup-14

Conversation

@creachadair
Copy link

Add a new package internal/jsontypes that implements a subset of the behaviour defined in the custom libs/json (a.k.a. tmjson) package. Specifically, this new package implements the tag type registry used to map concrete types to interfaces, but omits all the recursive reflection. The new package handles only the packaging and decoding of "type wrapper" objects, using the same format as the original code.

Apply this package to encode the parameters to the broadcast_evidence call in the JSON-RPC client. This case was explicitly skipped in #7552.

For now, this change only affects the "encoding" side. The server decoding code is still using tmjson, but I will update that in future PRs by applying similar treatment to the handful of other types (e.g., GenesisDoc) that traffic in interface fields.

@creachadair creachadair force-pushed the mjf/rpc-cleanup-14 branch 2 times, most recently from 2175ab2 to dd9fd5e Compare January 14, 2022 19:00
@creachadair creachadair marked this pull request as ready for review January 14, 2022 19:06
@creachadair
Copy link
Author

I apparently missed a case in the e2e test, working on that.

M. J. Fromberger added 4 commits January 14, 2022 13:39
This implements a subset of the custom libs/json package, specifically it
handles encoding and decoding of interface types wrapped in "tagged" JSON
objects. It omits the deep reflection on arbitrary types, preserving only the
handling of type tags wrapper encoding.
- Extend the Evidence interface to require support for tagged encoding.
- Update the existing implementations to satisfy the type.
- Register those types with the jsontypes registry.
- Add string tags to 64-bit integer fields where needed.
@creachadair creachadair force-pushed the mjf/rpc-cleanup-14 branch 3 times, most recently from b2ae00d to 08f44bf Compare January 14, 2022 23:53
@creachadair creachadair force-pushed the mjf/rpc-cleanup-14 branch 2 times, most recently from bcd26e7 to 955945c Compare January 15, 2022 01:40
@creachadair creachadair merged commit dbe2146 into master Jan 15, 2022
@creachadair creachadair deleted the mjf/rpc-cleanup-14 branch January 15, 2022 02:14
@mmsqe mmsqe mentioned this pull request Sep 22, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants