Add radius cli option to Fluffy and use it in local testnet script (#968)
This commit is contained in:
parent
b46d60f65d
commit
f29e307fd0
|
@ -141,6 +141,13 @@ type
|
||||||
desc: "URI of eth client where to proxy unimplemented rpc methods to"
|
desc: "URI of eth client where to proxy unimplemented rpc methods to"
|
||||||
name: "proxy-uri" .}: ClientConfig
|
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* {.
|
tableIpLimit* {.
|
||||||
hidden
|
hidden
|
||||||
desc: "Maximum amount of nodes with the same IP in the routing tables"
|
desc: "Maximum amount of nodes with the same IP in the routing tables"
|
||||||
|
|
|
@ -22,6 +22,11 @@ import
|
||||||
./network/wire/[portal_stream, portal_protocol_config],
|
./network/wire/[portal_stream, portal_protocol_config],
|
||||||
"."/[content_db, populate_db]
|
"."/[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] =
|
proc initializeBridgeClient(maybeUri: Option[string]): Option[BridgeClient] =
|
||||||
try:
|
try:
|
||||||
if (maybeUri.isSome()):
|
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
|
# This is done because the content in the db is dependant on the `NodeId` and
|
||||||
# the selected `Radius`.
|
# the selected `Radius`.
|
||||||
let
|
let
|
||||||
|
radius = UInt256.fromLogRadius(config.logRadius)
|
||||||
db = ContentDB.new(config.dataDir / "db" / "contentdb_" &
|
db = ContentDB.new(config.dataDir / "db" / "contentdb_" &
|
||||||
d.localNode.id.toByteArrayBE().toOpenArray(0, 8).toHex())
|
d.localNode.id.toByteArrayBE().toOpenArray(0, 8).toHex())
|
||||||
|
|
||||||
portalConfig = PortalProtocolConfig.init(
|
portalConfig = PortalProtocolConfig.init(
|
||||||
config.tableIpLimit, config.bucketIpLimit, config.bitsPerHop)
|
config.tableIpLimit, config.bucketIpLimit, config.bitsPerHop)
|
||||||
stateNetwork = StateNetwork.new(d, db,
|
stateNetwork = StateNetwork.new(d, db, radius,
|
||||||
bootstrapRecords = bootstrapRecords, portalConfig = portalConfig)
|
bootstrapRecords = bootstrapRecords, portalConfig = portalConfig)
|
||||||
historyNetwork = HistoryNetwork.new(d, db,
|
historyNetwork = HistoryNetwork.new(d, db, radius,
|
||||||
bootstrapRecords = bootstrapRecords, portalConfig = portalConfig)
|
bootstrapRecords = bootstrapRecords, portalConfig = portalConfig)
|
||||||
|
|
||||||
# One instance of UtpDiscv5Protocol is shared over all the PortalStreams.
|
# One instance of UtpDiscv5Protocol is shared over all the PortalStreams.
|
||||||
|
|
|
@ -246,6 +246,9 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
|
||||||
|
|
||||||
if [[ ${NUM_NODE} != ${BOOTSTRAP_NODE} ]]; then
|
if [[ ${NUM_NODE} != ${BOOTSTRAP_NODE} ]]; then
|
||||||
BOOTSTRAP_ARG="--bootstrap-file=${BOOTSTRAP_ENR_FILE}"
|
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
|
# Wait for the bootstrap node to write out its enr file
|
||||||
START_TIMESTAMP=$(date +%s)
|
START_TIMESTAMP=$(date +%s)
|
||||||
|
@ -279,6 +282,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
|
||||||
--table-ip-limit=1024 \
|
--table-ip-limit=1024 \
|
||||||
--bucket-ip-limit=24 \
|
--bucket-ip-limit=24 \
|
||||||
--bits-per-hop=1 \
|
--bits-per-hop=1 \
|
||||||
|
${RADIUS_ARG} \
|
||||||
${EXTRA_ARGS} \
|
${EXTRA_ARGS} \
|
||||||
> "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 &
|
> "${DATA_DIR}/log${NUM_NODE}.txt" 2>&1 &
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue