Enable IPv6 for discovery5 using dualstack support. (#6242)
* Make listen-address default to use dualstack. * Use correct newProtocol(). * Bump nim-eth. * Bump nim-eth one more time. * Use `*` instead of IPv6 address for dualstack sockets. * Bump chronos and nim-eth. * Use new constructor. * Fix listenAddress should be Opt[T] not Option[T]. * Fix options.md.
This commit is contained in:
parent
bd33828681
commit
c9b54bf1aa
|
@ -21,6 +21,7 @@ import
|
||||||
eth/common/eth_types as commonEthTypes, eth/net/nat,
|
eth/common/eth_types as commonEthTypes, eth/net/nat,
|
||||||
eth/p2p/discoveryv5/enr,
|
eth/p2p/discoveryv5/enr,
|
||||||
json_serialization, web3/[primitives, confutils_defs],
|
json_serialization, web3/[primitives, confutils_defs],
|
||||||
|
chronos/transports/common,
|
||||||
kzg4844/kzg_ex,
|
kzg4844/kzg_ex,
|
||||||
./spec/[engine_authentication, keystore, network, crypto],
|
./spec/[engine_authentication, keystore, network, crypto],
|
||||||
./spec/datatypes/base,
|
./spec/datatypes/base,
|
||||||
|
@ -49,14 +50,11 @@ declareGauge network_name, "network name", ["name"]
|
||||||
const
|
const
|
||||||
# TODO: How should we select between IPv4 and IPv6
|
# TODO: How should we select between IPv4 and IPv6
|
||||||
# Maybe there should be a config option for this.
|
# Maybe there should be a config option for this.
|
||||||
defaultListenAddress* = (static parseIpAddress("0.0.0.0"))
|
|
||||||
defaultAdminListenAddress* = (static parseIpAddress("127.0.0.1"))
|
defaultAdminListenAddress* = (static parseIpAddress("127.0.0.1"))
|
||||||
defaultSigningNodeRequestTimeout* = 60
|
defaultSigningNodeRequestTimeout* = 60
|
||||||
defaultBeaconNode* = "http://127.0.0.1:" & $defaultEth2RestPort
|
defaultBeaconNode* = "http://127.0.0.1:" & $defaultEth2RestPort
|
||||||
defaultBeaconNodeUri* = parseUri(defaultBeaconNode)
|
defaultBeaconNodeUri* = parseUri(defaultBeaconNode)
|
||||||
defaultGasLimit* = 30_000_000
|
defaultGasLimit* = 30_000_000
|
||||||
|
|
||||||
defaultListenAddressDesc* = $defaultListenAddress
|
|
||||||
defaultAdminListenAddressDesc* = $defaultAdminListenAddress
|
defaultAdminListenAddressDesc* = $defaultAdminListenAddress
|
||||||
defaultBeaconNodeDesc = $defaultBeaconNode
|
defaultBeaconNodeDesc = $defaultBeaconNode
|
||||||
|
|
||||||
|
@ -292,9 +290,8 @@ type
|
||||||
|
|
||||||
listenAddress* {.
|
listenAddress* {.
|
||||||
desc: "Listening address for the Ethereum LibP2P and Discovery v5 traffic"
|
desc: "Listening address for the Ethereum LibP2P and Discovery v5 traffic"
|
||||||
defaultValue: defaultListenAddress
|
defaultValueDesc: "*"
|
||||||
defaultValueDesc: $defaultListenAddressDesc
|
name: "listen-address" .}: Option[IpAddress]
|
||||||
name: "listen-address" .}: IpAddress
|
|
||||||
|
|
||||||
tcpPort* {.
|
tcpPort* {.
|
||||||
desc: "Listening TCP port for Ethereum LibP2P traffic"
|
desc: "Listening TCP port for Ethereum LibP2P traffic"
|
||||||
|
@ -1497,3 +1494,9 @@ proc loadKzgTrustedSetup*(trustedSetupPath: string): Result[void, string] =
|
||||||
Kzg.loadTrustedSetupFromString(readFile(trustedSetupPath))
|
Kzg.loadTrustedSetupFromString(readFile(trustedSetupPath))
|
||||||
except IOError as err:
|
except IOError as err:
|
||||||
err(err.msg)
|
err(err.msg)
|
||||||
|
|
||||||
|
proc formatIt*(v: Option[IpAddress]): string =
|
||||||
|
if v.isSome():
|
||||||
|
$v.get()
|
||||||
|
else:
|
||||||
|
"*"
|
||||||
|
|
|
@ -63,9 +63,7 @@ type LightClientConf* = object
|
||||||
|
|
||||||
listenAddress* {.
|
listenAddress* {.
|
||||||
desc: "Listening address for the Ethereum LibP2P and Discovery v5 traffic"
|
desc: "Listening address for the Ethereum LibP2P and Discovery v5 traffic"
|
||||||
defaultValue: defaultListenAddress
|
name: "listen-address" .}: Option[IpAddress]
|
||||||
defaultValueDesc: $defaultListenAddressDesc
|
|
||||||
name: "listen-address" .}: IpAddress
|
|
||||||
|
|
||||||
tcpPort* {.
|
tcpPort* {.
|
||||||
desc: "Listening TCP port for Ethereum LibP2P traffic"
|
desc: "Listening TCP port for Ethereum LibP2P traffic"
|
||||||
|
|
|
@ -96,8 +96,14 @@ proc new*(T: type Eth2DiscoveryProtocol,
|
||||||
if fileExists(persistentBootstrapFile):
|
if fileExists(persistentBootstrapFile):
|
||||||
loadBootstrapFile(persistentBootstrapFile, bootstrapEnrs)
|
loadBootstrapFile(persistentBootstrapFile, bootstrapEnrs)
|
||||||
|
|
||||||
|
let listenAddress =
|
||||||
|
if config.listenAddress.isSome():
|
||||||
|
Opt.some(config.listenAddress.get())
|
||||||
|
else:
|
||||||
|
Opt.none(IpAddress)
|
||||||
|
|
||||||
newProtocol(pk, enrIp, enrTcpPort, enrUdpPort, enrFields, bootstrapEnrs,
|
newProtocol(pk, enrIp, enrTcpPort, enrUdpPort, enrFields, bootstrapEnrs,
|
||||||
bindPort = config.udpPort, bindIp = config.listenAddress,
|
bindPort = config.udpPort, bindIp = listenAddress,
|
||||||
enrAutoUpdate = config.enrAutoUpdate, rng = rng)
|
enrAutoUpdate = config.enrAutoUpdate, rng = rng)
|
||||||
|
|
||||||
func isCompatibleForkId*(discoveryForkId: ENRForkID, peerForkId: ENRForkID): bool =
|
func isCompatibleForkId*(discoveryForkId: ENRForkID, peerForkId: ENRForkID): bool =
|
||||||
|
|
|
@ -2255,10 +2255,15 @@ proc createEth2Node*(rng: ref HmacDrbgContext,
|
||||||
discoveryForkId = getDiscoveryForkID(
|
discoveryForkId = getDiscoveryForkID(
|
||||||
cfg, getBeaconTime().slotOrZero.epoch, genesis_validators_root)
|
cfg, getBeaconTime().slotOrZero.epoch, genesis_validators_root)
|
||||||
|
|
||||||
(extIp, extTcpPort, extUdpPort) = try: setupAddress(
|
listenAddress =
|
||||||
config.nat, config.listenAddress, config.tcpPort, config.udpPort,
|
if config.listenAddress.isSome():
|
||||||
clientId)
|
config.listenAddress.get()
|
||||||
except CatchableError as exc: raise exc
|
else:
|
||||||
|
getAutoAddress(Port(0)).toIpAddress()
|
||||||
|
|
||||||
|
(extIp, extTcpPort, extUdpPort) =
|
||||||
|
setupAddress(config.nat, listenAddress, config.tcpPort,
|
||||||
|
config.udpPort, clientId)
|
||||||
|
|
||||||
directPeers = block:
|
directPeers = block:
|
||||||
var res: DirectPeers
|
var res: DirectPeers
|
||||||
|
@ -2278,7 +2283,7 @@ proc createEth2Node*(rng: ref HmacDrbgContext,
|
||||||
info "Adding privileged direct peer", peerId, address
|
info "Adding privileged direct peer", peerId, address
|
||||||
res
|
res
|
||||||
|
|
||||||
hostAddress = tcpEndPoint(config.listenAddress, config.tcpPort)
|
hostAddress = tcpEndPoint(listenAddress, config.tcpPort)
|
||||||
announcedAddresses =
|
announcedAddresses =
|
||||||
if extIp.isNone() or extTcpPort.isNone(): @[]
|
if extIp.isNone() or extTcpPort.isNone(): @[]
|
||||||
else: @[tcpEndPoint(extIp.get(), extTcpPort.get())]
|
else: @[tcpEndPoint(extIp.get(), extTcpPort.get())]
|
||||||
|
|
|
@ -55,7 +55,7 @@ The following options are available:
|
||||||
verifying/generating JWT tokens.
|
verifying/generating JWT tokens.
|
||||||
-b, --bootstrap-node Specifies one or more bootstrap nodes to use when connecting to the network.
|
-b, --bootstrap-node Specifies one or more bootstrap nodes to use when connecting to the network.
|
||||||
--bootstrap-file Specifies a line-delimited file of bootstrap Ethereum network addresses.
|
--bootstrap-file Specifies a line-delimited file of bootstrap Ethereum network addresses.
|
||||||
--listen-address Listening address for the Ethereum LibP2P and Discovery v5 traffic [=0.0.0.0].
|
--listen-address Listening address for the Ethereum LibP2P and Discovery v5 traffic [=*].
|
||||||
--tcp-port Listening TCP port for Ethereum LibP2P traffic [=9000].
|
--tcp-port Listening TCP port for Ethereum LibP2P traffic [=9000].
|
||||||
--udp-port Listening UDP port for node discovery [=9000].
|
--udp-port Listening UDP port for node discovery [=9000].
|
||||||
--max-peers The target number of peers to connect to [=160].
|
--max-peers The target number of peers to connect to [=160].
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 0d050d582306e8c521c3a4a6f6dcb3c83c93a90f
|
Subproject commit bb96f02ae877e04230dac85c040e66656b7d2ef0
|
|
@ -1 +1 @@
|
||||||
Subproject commit d66a29db7ca4372dba116928f979e92cb7f7661f
|
Subproject commit 4cd9e27c09117b284b91978fe6cdd76a181925f7
|
Loading…
Reference in New Issue