Add bootstrap nodes at compile time for testnet0 (#998)
- Add bootstrap nodes from a bootstrap_nodes.txt file at compile time - Add --network flag to select network specific bootstrap nodes
This commit is contained in:
parent
b14dfea553
commit
ae4aef6065
|
@ -1,5 +1,5 @@
|
|||
# Nimbus
|
||||
# Copyright (c) 2021 Status Research & Development GmbH
|
||||
# Copyright (c) 2021-2022 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
|
@ -39,6 +39,10 @@ type
|
|||
noCommand
|
||||
populateHistoryDb
|
||||
|
||||
PortalNetwork* = enum
|
||||
none
|
||||
testnet0
|
||||
|
||||
PortalConf* = object
|
||||
logLevel* {.
|
||||
defaultValue: LogLevel.DEBUG
|
||||
|
@ -57,6 +61,14 @@ type
|
|||
desc: "Listening address for the Discovery v5 traffic"
|
||||
name: "listen-address" .}: ValidIpAddress
|
||||
|
||||
portalNetwork* {.
|
||||
desc:
|
||||
"Select which Portal network to join. This will currently only " &
|
||||
"set the network specific bootstrap nodes automatically"
|
||||
defaultValue: PortalNetwork.none
|
||||
defaultValueDesc: "none"
|
||||
name: "network" }: PortalNetwork
|
||||
|
||||
# Note: This will add bootstrap nodes for both Discovery v5 network and each
|
||||
# enabled Portal network. No distinction is made on bootstrap nodes per
|
||||
# specific network.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Nimbus
|
||||
# Copyright (c) 2021 Status Research & Development GmbH
|
||||
# Copyright (c) 2021-2022 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
|
@ -14,7 +14,7 @@ import
|
|||
json_rpc/rpcproxy, stew/[byteutils, io2],
|
||||
eth/keys, eth/net/nat,
|
||||
eth/p2p/discoveryv5/protocol as discv5_protocol,
|
||||
./conf, ./common/common_utils,
|
||||
./conf, ./network_metadata, ./common/common_utils,
|
||||
./rpc/[rpc_eth_api, bridge_client, rpc_discovery_api, rpc_portal_api,
|
||||
rpc_portal_debug_api],
|
||||
./network/state/[state_network, state_content],
|
||||
|
@ -64,6 +64,15 @@ proc run(config: PortalConf) {.raises: [CatchableError, Defect].} =
|
|||
loadBootstrapFile(string config.bootstrapNodesFile, bootstrapRecords)
|
||||
bootstrapRecords.add(config.bootstrapNodes)
|
||||
|
||||
case config.portalNetwork
|
||||
of testnet0:
|
||||
for enrURI in testnet0BootstrapNodes:
|
||||
var record: Record
|
||||
if fromURI(record, enrURI):
|
||||
bootstrapRecords.add(record)
|
||||
else:
|
||||
discard
|
||||
|
||||
let
|
||||
discoveryConfig = DiscoveryConfig.init(
|
||||
config.tableIpLimit, config.bucketIpLimit, config.bitsPerHop)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# nimbus-fluffy-mainnet-master-01@metal-01.he-eu-hel1.nimbus.fluffy
|
||||
enr:-IS4QGeTMHteRmm-MSYniUd48OZ1M7RMUsIjnSP_TRbo-goQZAdYuqY2PyNJfDJQBz33kv16k7WB3bZnBK-O1DagvJIBgmlkgnY0gmlwhEFsKgOJc2VjcDI1NmsxoQIQXNgOCBNyoXz_7XP4Vm7pIB1Lp35d67BbC4iSlrrcJoN1ZHCCI40
|
||||
# nimbus-fluffy-mainnet-master-02@metal-01.he-eu-hel1.nimbus.fluffy
|
||||
enr:-IS4QOA4voX3J7-R_x8pjlaxBTpT1S_CL7ZaNjetjZ-0nnr2VaP0wEZsT2KvjA5UWc8vi9I0XvNSd1bjU0GXUjlt7J0BgmlkgnY0gmlwhEFsKgOJc2VjcDI1NmsxoQI7aL5dFuHhwbxWD-C1yWH7UPlae5wuV_3WbPylCBwPboN1ZHCCI44
|
||||
# nimbus-fluffy-mainnet-master-01@metal-02.he-eu-hel1.nimbus.fluffy
|
||||
enr:-IS4QFzPZ7Cc7BGYSQBlWdkPyep8XASIVlviHbi-ZzcCdvkcE382unsRq8Tb_dYQFNZFWLqhJsJljdgJ7WtWP830Gq0BgmlkgnY0gmlwhEFsKq6Jc2VjcDI1NmsxoQPjz2Y1Hsa0edvzvn6-OADS3re-FOkSiJSmBB7DVrsAXIN1ZHCCI40
|
||||
# nimbus-fluffy-mainnet-master-02@metal-02.he-eu-hel1.nimbus.fluffy
|
||||
enr:-IS4QHA1PJCdmESyKkQsBmMUhSkRDgwKjwTtPZYMcbMiqCb8I1Xt-Xyh9Nj0yWeIN4S3sOpP9nxI6qCCR1Nf4LjY0IABgmlkgnY0gmlwhEFsKq6Jc2VjcDI1NmsxoQLMWRNAgXVdGc0Ij9RZCPsIyrrL67eYfE9PPwqwRvmZooN1ZHCCI44
|
|
@ -0,0 +1,50 @@
|
|||
# Nimbus
|
||||
# Copyright (c) 2022 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
|
||||
import
|
||||
std/[sequtils, strutils, os, macros]
|
||||
|
||||
proc loadBootstrapNodes(
|
||||
path: string): seq[string] {.raises: [IOError, Defect].} =
|
||||
# Read a list of ENR URIs from a file containing a flat list of entries.
|
||||
# If the file can't be read, this will raise. This is intentionally.
|
||||
splitLines(readFile(path)).
|
||||
filterIt(it.startsWith("enr:")).
|
||||
mapIt(it.strip())
|
||||
|
||||
proc loadCompileTimeBootstrapNodes(
|
||||
path: string): seq[string] {.raises: [Defect].} =
|
||||
try:
|
||||
return loadBootstrapNodes(path)
|
||||
# TODO: This error doesn't seem to get printed. It instead dies with an
|
||||
# unhandled exception (IOError)
|
||||
except IOError as err:
|
||||
macros.error "Failed to load bootstrap nodes metadata at '" &
|
||||
path & "': " & err.msg
|
||||
|
||||
const
|
||||
# TODO: Change this from our local repo to an eth-client repo if/when this
|
||||
# gets created for the Portal networks.
|
||||
portalNetworksDir =
|
||||
currentSourcePath.parentDir.replace('\\', '/') / "network_data"
|
||||
# Note:
|
||||
# For now it gets called testnet0 but this Portal network serves Eth1 mainnet
|
||||
# data. Giving the actual Portal (test)networks different names might not be
|
||||
# that useful as there is no way to distinguish the networks currently.
|
||||
# Additionally, sub-networks like history network pass the eth1 network
|
||||
# information in their requests, potentially supporting many eth1 networks
|
||||
# over a single Portal Network.
|
||||
#
|
||||
# When more config data is required per Portal network, a metadata object can
|
||||
# be created, but right now only bootstrap nodes can be different.
|
||||
# TODO: It would be nice to be able to use `loadBootstrapFile` here, but that
|
||||
# doesn't work at compile time. The main issue seems to be the usage of
|
||||
# rlp.rawData() in the enr code.
|
||||
testnet0BootstrapNodes* = loadCompileTimeBootstrapNodes(
|
||||
portalNetworksDir / "testnet0" / "bootstrap_nodes.txt")
|
Loading…
Reference in New Issue