diff --git a/fluffy/conf.nim b/fluffy/conf.nim index 608c25722..9ad0b620b 100644 --- a/fluffy/conf.nim +++ b/fluffy/conf.nim @@ -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" diff --git a/fluffy/fluffy.nim b/fluffy/fluffy.nim index c985d2700..163cb461f 100644 --- a/fluffy/fluffy.nim +++ b/fluffy/fluffy.nim @@ -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. diff --git a/fluffy/scripts/launch_local_testnet.sh b/fluffy/scripts/launch_local_testnet.sh index f2b4cd06c..edbb6230e 100755 --- a/fluffy/scripts/launch_local_testnet.sh +++ b/fluffy/scripts/launch_local_testnet.sh @@ -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 &