Waku v2 usage of ENR #
- Status: raw
- Editor: Franck Royer [email protected]
This RFC is an extension of EIP-778, ENR used in Waku v2 MUST adhere to both EIP-778 and 31/WAKU2-ENR.
EIP-778 specifies a number of pre-defined keys. However, the usage of these keys alone does not allow for certain transport capabilities to be encoded, such as Websocket. Currently, Waku v2 nodes running in a Browser only support websocket transport protocol. Hence, new ENR keys need to be defined to allow for the encoding of transport protocol other than raw TCP.
Usage of Multiaddr Format Rationale #
One solution would be to define new keys such as
ws to encode the websocket port of a node.
However, we expect new transport protocols to be added overtime such as quic.
Hence, this would only provide a short term solution until another RFC would need to be added.
Moreover, secure websocket involves SSL certificates. SSL certificates are only valid for a given domain and ip, so an ENR containing the following information:
- secure websocket port
- ipv4 fqdn
- ipv4 address
- ipv6 address
Would carry some ambiguity: Is the certificate securing the websocket port valid for the ipv4 fqdn? the ipv4 address? the ipv6 address?
Directly storing one or several multiaddresses in the ENR would fix the issues listed above:
- multiaddr is self-describing and support addresses for any network protocol: No new RFC would be needed to support encoding other transport protocols in an ENR.
- multiaddr contains both the host and port information, allowing the ambiguity previously described to be resolved.
multiaddrs ENR key
We define a
- The value MUST be a list of binary encoded multiaddr prefixed by their size.
- The size of the multiaddr MUST be encoded in a Big Endian unsigned 16-bit integer.
- The size of the multiaddr MUST be encoded in 2 bytes.
secp256k1value MUST be present on the record;
secp256k1is defined in EIP-778 and contains the compressed secp256k1 public key.
- The node’s peer id SHOULD be deduced from the
- The multiaddresses SHOULD NOT contain a peer id.
- For raw TCP & UDP connections details, EIP-778 pre-defined keys SHOULD be used;
ip6for IPv6) are enough to convey all necessary information;
- To save space,
multiaddrskey SHOULD only be used for connection details that cannot be represented using the EIP-778 pre-defined keys.
- The 300 bytes size limit as defined by EIP-778 still applies; In practice, it is possible to encode 3 multiaddresses in ENR, more or less could be encoded depending on the size of each multiaddress.
Many connection types #
Alice is a node operator, she runs a node that supports inbound connection for the following protocols:
- TCP 10101 on
- UDP 20202 on
- TCP 30303 on
- UDP 40404 on
- Secure Websocket on
- QUIC on
Alice SHOULD structure the ENR for her node as follows:
||Alice’s compressed secp256k1 public key, 33 bytes|
||len1 | /dns4/example.com/tcp/443/wss | len2 | /dns4/quic.examle.com/tcp/443/quic|
|is the concatenation operator,
len1is the length of
len2is the length of
Raw TCP only #
Bob is a node operator, he runs a node that supports inbound connection for the following protocols:
- TCP 10101 on
Bob SHOULD structure the ENR for her node as follows:
||Bob’s compressed secp256k1 public key, 33 bytes|
Indeed, as Bob’s node’s connection details can be represented with EIP-778’s pre-defined keys only
then it is not needed to use the
Supported key type is
In the future, an extension of this RFC could be made to support other elliptic curve cryptography such as
waku2 ENR key
We define a
waku2 field key:
- The value MUST be an 8-bit flag field,
where bits set to
trueand bits set to
falsefor the relevant flags.
- The flag values already defined are set out below,
bit 7the most significant bit and
bit 0the least significant bit.
|bit 7||bit 6||bit 5||bit 4||bit 3||bit 2||bit 1||bit 0|
- In the scheme above, the flags
relaycorrelates with support for protocols with the same name. If a protocol is not supported, the corresponding field MUST be set to
false. Indicating positive support for any specific protocol is OPTIONAL, though it MAY be required by the relevant application or discovery process.
- Flags marked as
undefis not yet defined. These SHOULD be set to
- A Waku v2 node MAY choose to populate the
waku2field for enhanced discovery capabilities, such as indicating supported protocols. Such a node MAY indicate support for any specific protocol by setting the corresponding flag to
- Waku v2 nodes that want to participate in Node Discovery Protocol v5 , however,
MUST implement the
waku2key with at least one flag set to
- Waku v2 nodes that discovered other participants using Discovery v5,
MUST filter out participant records that do not implement this field or do not have at least one flag set to
- In addition, such nodes MAY choose to filter participants on specific flags (such as supported protocols),
or further interpret the
waku2field as required by the application.
Copyright and related rights waived via CC0.