lambdaclass / ethereum_war_game_tooling

We are slow while using the UI/UX of crypto wallets so we created our CLI version
MIT License
5 stars 2 forks source link

Retrieve list of nodes via DNS #63

Open gabrielbosio opened 2 years ago

gabrielbosio commented 2 years ago

Related to this issue: https://github.com/lambdaclass/ethereum_war_game_tooling/issues/11

Based on https://eips.ethereum.org/EIPS/eip-1459#client-protocol It returns the node records for a specific network, without verifying them.

Known issue: Sometimes, when calling EthClient.NodesList.update_using_dns <testnet> it throws

** (exit) exited in: GenServer.call(EthClient.NodesList, {:update_using_dns, :rinkeby}, 20000)
    ** (EXIT) an exception was raised:
        ** (UndefinedFunctionError) function Socket.Error.exception/1 is undefined or private
            (socket 0.3.13) Socket.Error.exception([reason: :emfile])
            (socket 0.3.13) lib/socket/udp.ex:72: Socket.UDP.open!/1
            (dns 2.3.0) lib/dns.ex:72: DNS.query/4
            (dns 2.3.0) lib/dns.ex:23: DNS.resolve/4
            (eth_client 0.1.0) lib/eth_client/nodes_list/dns.ex:70: EthClient.NodesList.DNS.wait_to_resolve/2
            (eth_client 0.1.0) lib/eth_client/nodes_list/dns.ex:37: EthClient.NodesList.DNS.get_children/3
            (elixir 1.13.2) lib/task/supervised.ex:89: Task.Supervised.invoke_mfa/2
            (elixir 1.13.2) lib/task/supervised.ex:34: Task.Supervised.reply/4
    (elixir 1.13.2) lib/gen_server.ex:1030: GenServer.call/3

To check if all the connections are used, the DNS library should throw an exception and NodesList.DNS should catch it. But, in this case, it seems that an external library Socket is breaking.

Usage

# Get Goerli nodes using DNS
EthClient.NodesList.update_using_dns(:goerli)