Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make mm2 connect only to a subset of passed electrums #2110

Open
10 tasks
cipig opened this issue May 6, 2024 · 0 comments
Open
10 tasks

make mm2 connect only to a subset of passed electrums #2110

cipig opened this issue May 6, 2024 · 0 comments

Comments

@cipig
Copy link
Member

cipig commented May 6, 2024

The situation atm is as follows:

This approach has some drawbacks:

  • if one or more of the servers are lagging behind the chain and mm2 uses them, it will show a wrong balance and swaps will fail too
  • if the 3 servers selected by the script in coins repo are later failing, the coin will not work any more, even though the initial config has eg 6 servers and the others are still working
  • if the SSL certificates of the 3 selected servers expire, the coin can't be enabled any more, even though TCP would still work (assuming TCP ports are also configured in the initial config, like it is with all servers run by us, see eg KMD)

I propose to make mm2 do all the filtering to which servers it connects and to which it doesn't, so if i pass 6 electrum servers to the electrum call, it should choose eg 2 or 3 good working ones and connect to them. The filtering should include the following:

  • don't connect to servers that are lagging behind the chain... eg choose 2 with the highest height... if there are only 2 and they differ, then connect only to one... there should be a tolerance though (optimal would be if the tolerance is not a fixed number of blocks, but dependent on the block time of the chain, so for BTC 3 blocks is a lot while for DGB 3 blocks is still acceptable... coins file contains avg_blocktime in seconds, which can be used for this)
  • don't connect to the same server twice, even if it is passed twice to the electrum call.. this is done often, since config in coins repo contains both TCP and SSL ports for many servers, even though it is the same server... maybe we can also go down to the IP level, so if 2 hosts in DNS point to the same IP, mm2 connects only once to one of them... this will also reduce the number of file descriptors used and help Mobile since it only support 128 open files afaik
  • optionally we can also filter based on connection time, even though i guess that it is not that important since most time is spent with processing the request not with the sending/receiving the data itself... maybe define "connection time" as the time needed to process a certain call, since that also includes the speed of the actual server and not only the time needed to connect to it... i propose to use blockchain.headers.subscribe for this test... it also returns the latest height, so the data can be used for the filtering based on height

Left overs from #1966:

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

No branches or pull requests

1 participant