KomodoPlatform / komodo-wallet

Komodo Wallet
https://app.komodoplatform.com
239 stars 206 forks source link

[BUG]: GUI looses connection to mm2 and needs kill and restart #2330

Closed cipig closed 1 day ago

cipig commented 1 year ago

If there are timeouts interacting with electrums or other external sources, it can happen that GUI can not interact with mm2 any more, Only thing that helps then is to kill the app and restart everything.

This is an example of such a timeout:

13 13:28:13, coins::utxo::utxo_builder::utxo_coin_builder:792] ERROR Electrum 88.99.26.209:5061 server.version error: JsonRpcError { client_info: "coin: NAV", request: JsonRpcRequest { jsonrpc: "2.0", id: "29", method: "server.version", params: [String("Komodo Wallet 0.6.0-beta GUI/MM2 1.0.6-beta_01bc10e"), Array([String("1.2"), String("1.4")])] }, error: Transport("Connection 88.99.26.209:5061 is not established yet") }

When there is a general problem with internet (eg loosing connection completely for couple minutes), it can happen too.

cipig commented 1 year ago

after digging further i think i found the problem if i set the balance loop to 300s instead of 30s here https://github.com/KomodoPlatform/komodo-wallet-desktop/blob/dev/src/core/atomicdex/services/mm2/mm2.service.cpp#L313 the app runs without problems

it is related to balance requests that are passed to PLG20 RPC nodes, so to replicate enable many PLG20 tokens and let the app run

we do too many requests to PLG20 RPC nodes anyway and we can be throttled or denied access completely i have seen this on a mm2 CLI node running on the same IP as the ADEX Desktop app if i restart the app i get 100 errors like this on CLI console

20 21:31:25, coins::eth:4523] ERROR Error request MethodCall(MethodCall { jsonrpc: Some(V2), method: "eth_gasPrice", params: Array([]), id: Num(1339093) }) failed: Transport("Server 'HttpTransportNode { uri: https://polygon-rpc.com/, gui_auth: false }' response !200: 429 Too Many Requests, {\"jsonrpc\":\"2.0\",\"id\":null,\"error\":\"You're using more requests than are allowed in the free RPC service. Create a Premium RPC API to continue at https://www.ankr.com/rpc/pricing/#premiumBlock\"}");  on eth_gasPrice request

429 Too Many Requests those errors don't show up otherwise as can be seen here in the output from my market maker script:

================================================================== Wed 20 Sep 2023 08:22:21 PM UTC
================================================================== Wed 20 Sep 2023 08:39:47 PM UTC
================================================================== Wed 20 Sep 2023 08:53:35 PM UTC
================================================================== Wed 20 Sep 2023 09:07:04 PM UTC
================================================================== Wed 20 Sep 2023 09:18:36 PM UTC
================================================================== Wed 20 Sep 2023 09:27:46 PM UTC
=== my_balance for BAL-PLG20 error
=== my_balance for LDO-PLG20 error
=== my_balance for AAVE-PLG20 error
=== my_balance for TUSD-PLG20 error
=== my_balance for MATIC error
=== my_balance for TEL-PLG20 error
=== my_balance for JJPY-PLG20 error
=== my_balance for XSGD-PLG20 error
=== my_balance for FXS-PLG20 error
=== my_balance for JSGD-PLG20 error
=== my_balance for WBTC-PLG20 error
================================================================== Wed 20 Sep 2023 09:36:59 PM UTC
================================================================== Wed 20 Sep 2023 09:46:32 PM UTC
================================================================== Wed 20 Sep 2023 09:56:44 PM UTC
================================================================== Wed 20 Sep 2023 10:11:52 PM UTC

no errors for hours, then a lot of them during ADEX Desktop restart 09:30 PM no other of my CLI nodes (running on different IPs) are showing this errors during that time

i also have lots of BEP20 tokens in ADEX Desktop, but those don't show errors/make problems because i run the RPC nodes for BEP20 myself, without throttling or timeouts or anything

to solve the problem on enable, we need to use v2 erc activation enable_eth_with_tokens with param \"get_balances\":false

and to solve this problem, we need to reduce balance requests to EVM RPC nodes