Developer Resources
Block ExplorerGitHubRun a NodeMigration GuideETN Testnet Faucet
  • Overview
  • Foundational topics
    • Intro to the Electroneum Smart Chain
    • Intro to ETN
    • Intro to dapps
    • Web2 vs Web3
    • Accounts
    • Transactions
    • Blocks
    • Electroneum Virtual Machine (EVM)
      • Opcodes
    • Gas and Fees
    • Nodes and clients
    • Networks
    • Consensus mechanisms
      • IBFT
  • Electroneum Stack
    • Intro to the stack
    • Smart contracts
    • Development networks
    • Development frameworks
    • Electroneum client APIs
      • JavaScript APIs
      • JSON-RPC
    • Storage
    • Integrated Development Environments (IDEs)
    • Metamask
    • Rabby Wallet
    • Trust Wallet
  • Advanced
    • Bridges
    • Standards
      • Token standards
        • ERC-20 Fungible Tokens
        • ERC-721 NFTs
    • Oracles
    • Networking layer
      • Network addresses
    • Data structures and encoding
      • Patricia Merkle Trie
      • Recursive-length prefix (RLP)
      • Web3 secret storage definition
  • Design fundamentals
    • Intro to design and UX
  • ETN-SC Client
    • Getting started
      • Introduction
      • Hardware requirements
      • Instaling ETN-SC
    • Fundamentals
      • Command-line options
      • Security
      • Sync-modes
      • Account management
      • Databases
      • Backup & restore
      • Logs
      • Connecting to peers
      • Pruning
      • Private networks
      • Config files
      • Light client
    • Interacting with ETN-SC
      • JSON-RPC Server
        • Batch requests
        • Real-time events
      • JSON-RPC Namespaces
        • admin
        • clique
        • debug
        • eth
        • istanbul
        • les
        • miner
        • net
        • personal
        • txpool
      • JS Console
      • JS Console 2: Contracts
      • GraphQL Server
    • Developers
      • Introduction
      • Dapp developers
        • Dev mode
        • Go API
        • Go Account Management
        • Go Contract Bindings
      • EVM tracing
        • Introduction
        • Basic traces
        • Built-in tracers
        • Custom EVM tracer
        • Tutorial for JavaScript tracing
      • ETN-SC developer
        • Developer guide
        • Disclosures
        • DNS discovery setup guide
        • Code review guidelines
      • Contributing
    • Monitoring
      • Creating Dashboards
      • Understanding Dashboards
      • Ethstats
      • Metrics
    • Tools
      • Clef
        • Introduction
        • APIs
        • Rules
        • Setup
        • Datatypes
        • Tutorial
        • Clique-signing
      • abigen
      • devp2p
    • FAQs
  • Migration to Smart Chain
    • Overview
    • How to Migrate
      • ETN Online Wallets
      • Paper Wallets
      • CLI Wallet Users
      • Exchange Holders
      • Exchanges
    • Bridge Smart Contract
  • Misc. Guides
    • Set up Ledger + Metamask
  • MY.ELECTRONEUM.COM
    • Vendor API
Powered by GitBook
On this page
  • Installing the devp2p command
  • Crawling the v4 DHT
  • Creating sub-lists through filtering
  • Creating DNS trees
  • Publishing DNS trees
  • Using DNS trees with ETN-SC

Was this helpful?

  1. ETN-SC Client
  2. Developers
  3. ETN-SC developer

DNS discovery setup guide

PreviousDisclosuresNextCode review guidelines

Last updated 1 year ago

Was this helpful?

This document explains how to set up an node list using the devp2p developer tool. The focus of this guide is creating a public list for the Electroneum mainnet and public testnets, but it may also be helpful for setting up DNS-based discovery for a private network.

DNS-based node lists can serve as a fallback option when connectivity to the discovery DHT is unavailable. In this guide, node lists will be created by crawling the discovery DHT, then publishing the resulting node sets under chosen DNS names.

Installing the devp2p command

cmd/devp2p is a developer utility and is not included in the Etn-sc distribution. You can install this command using go get:

go get github.com/electroneum/electroneum-sc/cmd/devp2p

To create a signing key, the etnkey utility is needed.

go get github.com/electroneum/electroneum-sc/cmd/etnkey

Crawling the v4 DHT

Our first step is to compile a list of all reachable nodes. The DHT crawler in cmd/devp2p is a batch process which runs for a set amount of time. You should schedule this command to run at a regular interval. To create a node list, run

devp2p discv4 crawl -timeout 30m all-nodes.json

This walks the DHT and stores the set of all found nodes in the all-nodes.json file. Subsequent runs of the same command will revalidate previously discovered node records, add newly-found nodes to the set, and remove nodes which are no longer alive. The quality of the node set improves with each run because the number of revalidations is tracked alongside each node in the set.

Creating sub-lists through filtering

Once all-nodes.json has been created and the set contains a sizeable number of nodes, useful sub-sets of nodes can be extracted using the devp2p nodeset filter command. This command takes a node set file as argument and applies filters given as command-line flags.

To create a filtered node set, first create a new directory to hold the output set. You can use any directory name, though it's good practice to use the DNS domain name as the name of this directory.

mkdir mainnet.nodes.example.org

Then, to create the output set containing Electroneum mainnet nodes only, run

devp2p nodeset filter all-nodes.json -eth-network mainnet > mainnet.nodes.example.org/nodes.json

The following filter flags are available:

  • -eth-network ( mainnet | testnet ) selects an Electroneum Smart Chain network.

  • -les-server selects LES server nodes.

  • -ip <mask> restricts nodes to the given IP range.

  • -min-age <duration> restricts the result to nodes which have been live for the given duration.

Creating DNS trees

To turn a node list into a DNS node tree, the list needs to be signed. To do this, a key pair is required. To create the key file in the correct format, the cmd/etnkey utility should be used. Choose a strong password to encrypt the key on disk!

etnkey generate dnskey.json

Now use devp2p dns sign to update the signature of the node list. If the list's directory name differs from the name it will be published at, specify the DNS name using the -domain flag. This command will prompt for the key file password and update the tree signature.

devp2p dns sign mainnet.nodes.example.org dnskey.json

The resulting DNS tree metadata is stored in the mainnet.nodes.example.org/enrtree-info.json file.

Publishing DNS trees

Now that the tree is signed, it can be published to a DNS provider. cmd/devp2p currently supports publishing to CloudFlare DNS and Amazon Route53.TXT records can also be exported as a JSON file and published independently.

To publish to CloudFlare, first create an API token in the management console. cmd/devp2p expects the API token in the CLOUDFLARE_API_TOKEN environment variable. Now use the following command to upload DNS TXT records via the CloudFlare API:

devp2p dns to-cloudflare mainnet.nodes.example.org

Note that this command uses the domain name specified during signing. Any existing records below this name will be erased by cmd/devp2p.

Using DNS trees with ETN-SC

Once a tree is available through a DNS name, Etn-sc can use it with the --discovery.dns command line flag. Node trees are referenced using the enrtree:// URL scheme. The URL of the tree can be found in the enrtree-info.json file created by devp2p dns sign. Pass the URL as an argument to the flag in order to make use of the published tree.

etn-sc --discovery.dns "enrtree://AMBMWDM3J6UY3M32TMMROUNLX6Y3YTLVC3DC6HN2AVG5NHNSAXDW6@mainnet.nodes.example.org"
EIP 1459