Add radius cli option to Fluffy and use it in local testnet script (#968)

This commit is contained in:
Kim De Mey 2022-02-15 13:11:27 +01:00 committed by GitHub
parent b46d60f65d
commit f29e307fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View File

@ -141,6 +141,13 @@ type
desc: "URI of eth client where to proxy unimplemented rpc methods to"
name: "proxy-uri" .}: ClientConfig
logRadius* {.
desc: "Hardcoded (logarithmic) radius for each Portal network. This is " &
"a temporary development option which will be replaced in the " &
"future by e.g. a storage size limit"
defaultValue: 256
name: "radius" .}: uint16
tableIpLimit* {.
hidden
desc: "Maximum amount of nodes with the same IP in the routing tables"

View File

@ -22,6 +22,11 @@ import
./network/wire/[portal_stream, portal_protocol_config],
"."/[content_db, populate_db]
proc fromLogRadius(T: type UInt256, logRadius: uint16): T =
# Get the max value of the logRadius range
pow((2).stuint(256), logRadius) - 1
# For the min value do `pow((2).stuint(256), logRadius - 1)`
proc initializeBridgeClient(maybeUri: Option[string]): Option[BridgeClient] =
try:
if (maybeUri.isSome()):
@ -72,14 +77,15 @@ proc run(config: PortalConf) {.raises: [CatchableError, Defect].} =
# This is done because the content in the db is dependant on the `NodeId` and
# the selected `Radius`.
let
radius = UInt256.fromLogRadius(config.logRadius)
db = ContentDB.new(config.dataDir / "db" / "contentdb_" &
d.localNode.id.toByteArrayBE().toOpenArray(0, 8).toHex())
portalConfig = PortalProtocolConfig.init(
config.tableIpLimit, config.bucketIpLimit, config.bitsPerHop)
stateNetwork = StateNetwork.new(d, db,
stateNetwork = StateNetwork.new(d, db, radius,
bootstrapRecords = bootstrapRecords, portalConfig = portalConfig)
historyNetwork = HistoryNetwork.new(d, db,
historyNetwork = HistoryNetwork.new(d, db, radius,
bootstrapRecords = bootstrapRecords, portalConfig = portalConfig)
# One instance of UtpDiscv5Protocol is shared over all the PortalStreams.

View File

@ -246,6 +246,9 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
if [[ ${NUM_NODE} != ${BOOTSTRAP_NODE} ]]; then
BOOTSTRAP_ARG="--bootstrap-file=${BOOTSTRAP_ENR_FILE}"
# All nodes but bootstrap node run with log. radius of 254 which should
# result in ~1/4th of the data set stored.
RADIUS_ARG="--radius=254"
# Wait for the bootstrap node to write out its enr file
START_TIMESTAMP=$(date +%s)
@ -279,6 +282,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
--table-ip-limit=1024 \
--bucket-ip-limit=24 \
--bits-per-hop=1 \
${RADIUS_ARG} \
${EXTRA_ARGS} \
> "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 &