desktop-wallet
desktop-wallet copied to clipboard
Harvesting: fallback option in case when statistics service fail to find a node
What Happened
During harvesting page improvements: https://github.com/symbol/desktop-wallet/pull/1781 there was a change to query (by nodePublicKey) for node using statistics service. Chosen by user node is no longer stored in local storage because we are able to identify URL based on statistics service.
Unfortunately, statistics service may not always know about all nodes for example:
- it could be a bug in discovery: https://github.com/symbol/statistics-service/issues/120
- or service may not yet discover all nodes (it may take a while especially when network will grow)
- other centralized service issue
In such situation (when statistics service don't have information about selected by user node) there are two problems:
- Wallet is not able to query nodePublicKey based on node URL (at this moment for that is used statistics service) forcing user to provide nodePublicKey manually even if node exposes API
- When user provide manually nodePublicKey and will start harvesting then wallet is not able "find" correct URL (statistics service returns 404 error) to check status.
How to Reproduce
As a precondition we need a valid node that is not listed in statistics service. At the moment of rising this issue it was 154.53.43.170
- Go to an account that can start harvesting (balance >= 10000 and importance > 0)
- Go to harvesting view
- Put "Node URL" using a node that is not known by statistics service (154.53.43.170)
First problem: wallet asks for nodePublicKey but it could query it using
/node/info
endpoint since it's the dual node.
- Put nodePublicKey manually, link keys and after tx confirmation start harvesting
Second problem: After second transaction confirmation status is still "Activation in progress" and after some time "Failed". It's because wallet is not able "find" node URL based on statistics service.
In debug console we can see that statistics service returns 404 for publicKey and nodePublicKey calls:
https://symbol.services/nodes/F854E875BD2A158909B1E8BC287DC6F1FE051B55AC4E37648B29ECEEC3563991 -> 404 'not found' https://symbol.services/nodes/nodePublicKey/C5D1FB3FD8E356AC34B31067A02CF930E520480C9C2BAD3CE336CA13BD8316C4 -> 404 'not found'
Harvesting is indeed activated which can be checked using /node/unlockedaccount
endpoint. So problem is only node URL by nodePublicKey resolution.
Why This Happens
It happens because the wallet don't store anymore information about chosen by user node URL. When statistics service did not discover yet selected by user node, a wallet is not able query correct node URL to check harvesting status.
Proposed Improvement
-
As a fallback option save (in local storage) URL of node on which user requested harvesting. Use this URL to check harvesting status (if nodePublicKey on blockchain matches with nodePublicKey returned by
/node/info
endpoint) in case when statistics service returns 404. -
When user provide node URL then to query
nodePublicKey
use information from/node/info
endpoint (because this is more reliable) instead statistics service.