Using wrong part of the result to check compatible version
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 493
- PR merge metrics
- No merged PRs in 30d
Description
Dear,
When analyzing the code and writing my own hub, I struggled with the server.version method. In LBRY a request of server.version looks like {"method":"server.version","id":58,"jsonrpc":"2.0","params":["0.113.0","0.113.0"]} and a response looks like {"jsonrpc":"2.0","result":["0.107.0","0.113.0"],"id":47}. At first glance, it doesn't look compatible with the server.version of Electrum, but it is.
First the request. Electrum defines server.version(client_name, protocol_version), where client_name is the name of the client and protocol_version is the supported version or range of supported versions of the client. When looking at the code at https://github.com/lbryio/hub/blob/ebcc6e508660f72fe11d308ae4031971b5fbf782/hub/herald/session.py#L1688, this is indeed the case. The LBRY request is fully compatible with the Electrum request, so it is also possible to send a request like {"method":"server.version","id":58,"jsonrpc":"2.0","params":["LBRY Desktop 1.0.0","0.113.0"]} or {"method":"server.version","id":58,"jsonrpc":"2.0","params":["LBRY Desktop 1.0.0",["0.113.0","0.113.0"]]}.
Then the response. Electrum defines it as returning [server_software_version, protocol_version], where server_software_version is the name of server and protocol_version is the chosen protocol version by the server to communicate with. Looking at https://github.com/lbryio/hub/blob/ebcc6e508660f72fe11d308ae4031971b5fbf782/hub/herald/session.py#L1695 and https://github.com/lbryio/hub/blob/ebcc6e508660f72fe11d308ae4031971b5fbf782/hub/herald/session.py#L1723, it indeed returns 2 variables.
Now we take a look at the following code:
https://github.com/lbryio/lbry-sdk/blob/eb5da9511e162ef1080cb34af2ee087383cfa94a/lbry/wallet/network.py#L106
Note the response[0]. Why does this client code check for the first variable? The protocol information is in the second variable. I assume that response[1] is the right solution.
Also, some logging (note line 106):
2024-05-21 21:34:42,756 ERROR lbry.wallet.network:219: wallet server connection loop crashed
Traceback (most recent call last):
File "lbry\wallet\network.py", line 216, in loop_task_done_callback
File "lbry\wallet\network.py", line 321, in network_loop
File "lbry\wallet\network.py", line 304, in connect_to_fastest
File "lbry\wallet\network.py", line 106, in ensure_server_version
File "lbry\wallet\network.py", line 106, in <genexpr>
ValueError: invalid literal for int() with base 10: 'LBRYum Hub 1'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at lbry/wallet/network.py, especially ensure_server_version around line 106, and compare the server.version response fields with the logged failure. Confirm which response element contains the protocol version and trace the connection path that parses it. Done means compatible-version checking handles the server response without interpreting the server software name as a version.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100