Consensys / teku

Open-source Ethereum consensus client written in Java
https://consensys.io/teku
Apache License 2.0
673 stars 283 forks source link

/network/enr #1169

Closed rolfyone closed 4 years ago

rolfyone commented 4 years ago

document the /network/enr endpoint? the implementation is incomplete so maybe we park this one...

rolfyone commented 4 years ago

there's references to ENR in the eth2 spec https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/validator.md

Teku has no implementation currently, the API says "Discovery service not yet implemented"

We may need to un-advertise this endpoint until it's actually functional?

rolfyone commented 4 years ago

https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/p2p-interface.md#enr-structure

Teku doesnt currently have discovery, ENR sounds for 'Ethereum Node Record'. Discovery may be coming in the next week or so.

rolfyone commented 4 years ago

lighthouse: https://lighthouse-book.sigmaprime.io/http_network.html#networkenr P2PNetwork now has getEnr, which is hopefully the exact string we need to return. We need to clean up the old start functionality of adding a default get for every element in an array, and remove the array. getEnr is an optional String response, so if it's empty we can probably return ok_no_content

rolfyone commented 4 years ago

to demo, need to update the config.toml

diff --git a/config/config.toml b/config/config.toml
index 6299aeb0..bda7d576 100644
--- a/config/config.toml
+++ b/config/config.toml
@@ -5 +5 @@
-networkMode = "mock"
+networkMode = "jvmlibp2p"
@@ -11 +11 @@ port = 9000
-discovery = "static"
+discovery = "discv5"
@@ -53 +53 @@ portNumber = 5051
-enableSwagger = false
+enableSwagger = true

then when the server starts, the ENR will be returned:

curl http://localhost:19501/network/enr
"enr:-Iu4QOYyODBRXANBP6gqYIUOfkfaXAg5h8ZUHMgz4LH4JyaqdU9JaNKBmv0CHfsNhgqhntsPlc9MrCXuQs6URQXsE7YBgmlkgnY0gmlwhAAAAACJc2VjcDI1NmsxoQO3RHbHi9Fg7lwj_NUZ3dBVGk9NFn-rF8-XNt8g3FgFKYN0Y3CCIy2DdWRwgiMt"%