Skip to content

Instantly share code, notes, and snippets.

@carver
Last active September 20, 2021 04:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carver/f3c26d9adb28ea2b4e5d5bbe42b4f4b7 to your computer and use it in GitHub Desktop.
Save carver/f3c26d9adb28ea2b4e5d5bbe42b4f4b7 to your computer and use it in GitHub Desktop.
Testing Portal Network with trin & ddht
git clone git@github.com:ethereum/ddht.git
cd ddht
# Install ddht in virtualenv
python3 -m venv venv
. venv/bin/activate
pip install -U pip wheel setuptools
pip install -e .[dev]
# Get a local IP address
MYIP=$(hostname -I | awk '{print $1}')
# Launch the python implementation for the portal network
# The choice for port and private key are arbitrary. The point is to get a stable ENR
ddht --listen-address $MYIP --disable-upnp --port 12345 --log-level-stderr 10 --private-key 7261696e626f7773756e69636f726e737261696e626f7773756e69636f726e73 alexandria
# Grab the encoded ENR out of the logs, like "enr:-IS4Q...MDk", from a log like:
INFO 2021-05-19 18:00:19,663 ddht.DDHT Local ENR : encoded=enr:-IS4QLMQSaI_ankLFcwxD3k0qCrLPlZGLnCNFL4DlCHaE7BPN-t5nld3tRwSNvJ80mOelqN-Bf2rIOE23CL-cdSXWzYFgmlkgnY0gmlwhMCoKgeJc2VjcDI1NmsxoQIFdXcJmfhLBgMkGMmrAxYpnZCROu2gIxzN2z7z5Ci5Y4N1ZHCCMDk, decoded=ENR: seq=5 node_id=a26ebac137d3d210cc7570e25229b984bf7898ccbdcf04f4057b2590fb0d5dce sig=b31049a23f6a790b15cc310f7934a82acb3e56462e708d14be039421da13b04f37eb799e5777b51c1236f27cd2639e96a37e05fdab20e136dc22fe71d4975b36 KV: id=v4 ip=192.168.42.7 secp256k1=0x020575770999f84b06032418c9ab0316299d90913aeda0231ccddb3ef3e428b963 udp=12345
# Launch trin (see below)
# Confirm that the base layer session is initialized, via logs like:
DEBUG 2021-05-19 18:01:10,425 ddht.Session Session[a26e..5dce<-|-UNKNOWN@127.0.0.1:4242]: received handshake initiation
DEBUG 2021-05-19 18:01:10,425 ddht.Session Session[a26e..5dce<-~-UNKNOWN@127.0.0.1:4242]: sending handshake response
DEBUG 2021-05-19 18:01:10,432 ddht.Session Session[a26e..5dce<-~-UNKNOWN@127.0.0.1:4242]: received handshake completion
DEBUG 2021-05-19 18:01:10,443 ddht.Dispatcher Session established: 37fd..69f2@127.0.0.1:4242 (inbound) id=f1a6f308-99ef-44f4-9eeb-ae0960246e5f
DEBUG 2021-05-19 18:01:10,460 ddht.Network Bonded with 37fdc2005b04e78960f570abd6a7b8260f163b7fbd5794982a9b822575f569f2 successfully
git clone git@github.com:ethereum/trin.git
cd trin
# Pass in the ENR from the ddht logs
RUST_LOG=debug cargo run -- --bootnodes enr:-IS4...MDk
# Confirm that base layer is connected with a log like:
[2021-05-20T01:01:10Z DEBUG discv5::service] Session established with Node: 0xa26e..5dce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment