Part 5 - jsonrpc: replace jsonrpcserver/jsonrpcclient with custom implementation#971
Open
ping-ke wants to merge 13 commits intoupgrade/py313-baselinefrom
Open
Part 5 - jsonrpc: replace jsonrpcserver/jsonrpcclient with custom implementation#971ping-ke wants to merge 13 commits intoupgrade/py313-baselinefrom
ping-ke wants to merge 13 commits intoupgrade/py313-baselinefrom
Conversation
The jsonrpcserver (3.x) and jsonrpcclient (2.x) packages are incompatible with Python 3.13 and are no longer maintained. Changes: - Add quarkchain/cluster/jsonrpcserver.py: lightweight custom JSON-RPC 2.0 server built on aiohttp (RpcMethods, JsonRpcError hierarchy, request dispatch with positional/named params) - Add quarkchain/jsonrpc_client.py: synchronous JsonRpcClient (uses httpx) and asynchronous AsyncJsonRpcClient (uses aiohttp) replacing jsonrpcclient.HTTPClient / aiohttpClient - Update quarkchain/cluster/jsonrpc.py to use the new RpcMethods class; make start_*_server() classmethod async; use get_running_loop() - Replace jsonrpcclient calls in all tools with JsonRpcClient.call() - Rename quarkchain/tools/stats → quarkchain/tools/stats.py - Remove jsonrpcserver config log suppression (no longer needed) - Update test_jsonrpc.py to use AsyncJsonRpcClient Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- adjust_difficulty.py: replace bare `import monitoring` with `from quarkchain.tools import monitoring` (breaks when run from outside the tools directory) - adjust_difficulty.py: replace jsonrpc_async.Server with AsyncJsonRpcClient and use .call() method - monitoring.py: replace jsonrpc_async.Server with AsyncJsonRpcClient and use .call() method; close session via .close() - jsonrpc_client.py: fix AsyncJsonRpcClient.call signature to use *params (variadic) to match JsonRpcClient.call, fixing callers that pass positional arguments Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fix send_request in test_jsonrpc.py to unpack list params correctly instead of double-wrapping them (e.g. [["0x..."]] → ["0x..."]) - Add call_with_dict_params to AsyncJsonRpcClient for named params - Implement JSONRPCWebsocketServer.shutdown() to actually close the server, fixing test isolation hangs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…r shutdown" This reverts commit 9f603e6.
2 tasks
Contributor
Code reviewFound 2 issues:
pyquarkchain/quarkchain/tools/stats.py Lines 20 to 22 in f867cb3
pyquarkchain/quarkchain/cluster/jsonrpc.py Lines 505 to 510 in f867cb3 pyquarkchain/quarkchain/cluster/jsonrpc.py Lines 1458 to 1463 in f867cb3 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
qzhodl
reviewed
Mar 31, 2026
qzhodl
reviewed
Mar 31, 2026
qzhodl
reviewed
Mar 31, 2026
qzhodl
reviewed
Mar 31, 2026
…sues - Rename jsonrpcserver.py to jsonrpc_server.py for consistent naming - Replace armor with asyncio.shield for cancellation protection - Fix get_running_loop to get_event_loop for compatibility - Fix subscription.py import from old jsonrpcserver package - Fix indentation in test_jsonrpc.py and method name in stats.py
qzhodl
reviewed
Mar 31, 2026
- Fix snake_case field names to camelCase for JSON-RPC responses (network_id->networkId, shard_size->chainSize, block_height->blockHeight, contract_address->contractAddress) - Fix resp.data.result access pattern to direct dict access - Add exception handling and cli.close() to prevent connection leaks - Add 0x prefix for address in balance_watcher query_balance
qzhodl
approved these changes
Apr 1, 2026
syntrust
reviewed
Apr 3, 2026
…internal RPC errors
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.
Summary
jsonrpcserver3.x andjsonrpcclient2.x are no longer maintainedand are incompatible with Python 3.13.
quarkchain/cluster/jsonrpcserver.py: a lightweight JSON-RPC 2.0server dispatcher built on aiohttp (
RpcMethods,JsonRpcErrorhierarchy,positional and named parameter dispatch)
quarkchain/jsonrpc_client.py:JsonRpcClient(synchronous, httpx-based)and
AsyncJsonRpcClient(async, aiohttp-based) replacing the old clientsjsonrpc.pyto use the newRpcMethodsclass and makestart_*_server()classmethods asyncjsonrpcclientcalls in all tools andprom.pywithJsonRpcClient.call()quarkchain/tools/stats→quarkchain/tools/stats.py(was missing extension)test_jsonrpc.pyto useAsyncJsonRpcClientTest plan
pytest quarkchain/cluster/tests/test_jsonrpc.pypassesexternal_miner.pycan fetch work and submit results