Fluffy: Make number of nodes to gossip content to configurable (#2653)
This commit is contained in:
parent
b1dc1578f0
commit
cb69723ff3
|
@ -45,6 +45,7 @@ const
|
||||||
defaultTableIpLimitDesc* = $defaultPortalProtocolConfig.tableIpLimits.tableIpLimit
|
defaultTableIpLimitDesc* = $defaultPortalProtocolConfig.tableIpLimits.tableIpLimit
|
||||||
defaultBucketIpLimitDesc* = $defaultPortalProtocolConfig.tableIpLimits.bucketIpLimit
|
defaultBucketIpLimitDesc* = $defaultPortalProtocolConfig.tableIpLimits.bucketIpLimit
|
||||||
defaultBitsPerHopDesc* = $defaultPortalProtocolConfig.bitsPerHop
|
defaultBitsPerHopDesc* = $defaultPortalProtocolConfig.bitsPerHop
|
||||||
|
defaultMaxGossipNodesDesc* = $defaultPortalProtocolConfig.maxGossipNodes
|
||||||
|
|
||||||
type
|
type
|
||||||
TrustedDigest* = MDigest[32 * 8]
|
TrustedDigest* = MDigest[32 * 8]
|
||||||
|
@ -235,6 +236,14 @@ type
|
||||||
name: "bits-per-hop"
|
name: "bits-per-hop"
|
||||||
.}: int
|
.}: int
|
||||||
|
|
||||||
|
maxGossipNodes* {.
|
||||||
|
hidden,
|
||||||
|
desc: "The maximum number of nodes to send content to during gossip",
|
||||||
|
defaultValue: defaultPortalProtocolConfig.maxGossipNodes,
|
||||||
|
defaultValueDesc: $defaultMaxGossipNodesDesc,
|
||||||
|
name: "max-gossip-nodes"
|
||||||
|
.}: int
|
||||||
|
|
||||||
radiusConfig* {.
|
radiusConfig* {.
|
||||||
desc:
|
desc:
|
||||||
"Radius configuration for a fluffy node. Radius can be either `dynamic` " &
|
"Radius configuration for a fluffy node. Radius can be either `dynamic` " &
|
||||||
|
|
|
@ -159,7 +159,7 @@ proc run(
|
||||||
let
|
let
|
||||||
portalProtocolConfig = PortalProtocolConfig.init(
|
portalProtocolConfig = PortalProtocolConfig.init(
|
||||||
config.tableIpLimit, config.bucketIpLimit, config.bitsPerHop, config.radiusConfig,
|
config.tableIpLimit, config.bucketIpLimit, config.bitsPerHop, config.radiusConfig,
|
||||||
config.disablePoke,
|
config.disablePoke, config.maxGossipNodes,
|
||||||
)
|
)
|
||||||
|
|
||||||
portalNodeConfig = PortalNodeConfig(
|
portalNodeConfig = PortalNodeConfig(
|
||||||
|
|
|
@ -182,6 +182,7 @@ type
|
||||||
offerWorkers: seq[Future[void]]
|
offerWorkers: seq[Future[void]]
|
||||||
disablePoke: bool
|
disablePoke: bool
|
||||||
pingTimings: Table[NodeId, chronos.Moment]
|
pingTimings: Table[NodeId, chronos.Moment]
|
||||||
|
maxGossipNodes: int
|
||||||
|
|
||||||
PortalResult*[T] = Result[T, string]
|
PortalResult*[T] = Result[T, string]
|
||||||
|
|
||||||
|
@ -573,6 +574,7 @@ proc new*(
|
||||||
offerQueue: newAsyncQueue[OfferRequest](concurrentOffers),
|
offerQueue: newAsyncQueue[OfferRequest](concurrentOffers),
|
||||||
disablePoke: config.disablePoke,
|
disablePoke: config.disablePoke,
|
||||||
pingTimings: Table[NodeId, chronos.Moment](),
|
pingTimings: Table[NodeId, chronos.Moment](),
|
||||||
|
maxGossipNodes: config.maxGossipNodes,
|
||||||
)
|
)
|
||||||
|
|
||||||
proto.baseProtocol.registerTalkProtocol(@(proto.protocolId), proto).expect(
|
proto.baseProtocol.registerTalkProtocol(@(proto.protocolId), proto).expect(
|
||||||
|
@ -1503,7 +1505,6 @@ proc neighborhoodGossip*(
|
||||||
# in its propagation than when looking only for nodes in the own routing
|
# in its propagation than when looking only for nodes in the own routing
|
||||||
# table, but at the same time avoid unnecessary node lookups.
|
# table, but at the same time avoid unnecessary node lookups.
|
||||||
# It might still cause issues in data getting propagated in a wider id range.
|
# It might still cause issues in data getting propagated in a wider id range.
|
||||||
const maxGossipNodes = 8
|
|
||||||
|
|
||||||
let closestLocalNodes =
|
let closestLocalNodes =
|
||||||
p.routingTable.neighbours(NodeId(contentId), k = 16, seenOnly = true)
|
p.routingTable.neighbours(NodeId(contentId), k = 16, seenOnly = true)
|
||||||
|
@ -1518,9 +1519,9 @@ proc neighborhoodGossip*(
|
||||||
elif node.id != srcNodeId.get():
|
elif node.id != srcNodeId.get():
|
||||||
gossipNodes.add(node)
|
gossipNodes.add(node)
|
||||||
|
|
||||||
if gossipNodes.len >= 8: # use local nodes for gossip
|
if gossipNodes.len >= p.maxGossipNodes: # use local nodes for gossip
|
||||||
portal_gossip_without_lookup.inc(labelValues = [$p.protocolId])
|
portal_gossip_without_lookup.inc(labelValues = [$p.protocolId])
|
||||||
let numberOfGossipedNodes = min(gossipNodes.len, maxGossipNodes)
|
let numberOfGossipedNodes = min(gossipNodes.len, p.maxGossipNodes)
|
||||||
for node in gossipNodes[0 ..< numberOfGossipedNodes]:
|
for node in gossipNodes[0 ..< numberOfGossipedNodes]:
|
||||||
let req = OfferRequest(dst: node, kind: Direct, contentList: contentList)
|
let req = OfferRequest(dst: node, kind: Direct, contentList: contentList)
|
||||||
await p.offerQueue.addLast(req)
|
await p.offerQueue.addLast(req)
|
||||||
|
@ -1528,7 +1529,7 @@ proc neighborhoodGossip*(
|
||||||
else: # use looked up nodes for gossip
|
else: # use looked up nodes for gossip
|
||||||
portal_gossip_with_lookup.inc(labelValues = [$p.protocolId])
|
portal_gossip_with_lookup.inc(labelValues = [$p.protocolId])
|
||||||
let closestNodes = await p.lookup(NodeId(contentId))
|
let closestNodes = await p.lookup(NodeId(contentId))
|
||||||
let numberOfGossipedNodes = min(closestNodes.len, maxGossipNodes)
|
let numberOfGossipedNodes = min(closestNodes.len, p.maxGossipNodes)
|
||||||
for node in closestNodes[0 ..< numberOfGossipedNodes]:
|
for node in closestNodes[0 ..< numberOfGossipedNodes]:
|
||||||
# Note: opportunistically not checking if the radius of the node is known
|
# Note: opportunistically not checking if the radius of the node is known
|
||||||
# and thus if the node is in radius with the content. Reason is, these
|
# and thus if the node is in radius with the content. Reason is, these
|
||||||
|
|
|
@ -40,17 +40,21 @@ type
|
||||||
bitsPerHop*: int
|
bitsPerHop*: int
|
||||||
radiusConfig*: RadiusConfig
|
radiusConfig*: RadiusConfig
|
||||||
disablePoke*: bool
|
disablePoke*: bool
|
||||||
|
maxGossipNodes*: int
|
||||||
|
|
||||||
const
|
const
|
||||||
defaultRadiusConfig* = RadiusConfig(kind: Dynamic)
|
defaultRadiusConfig* = RadiusConfig(kind: Dynamic)
|
||||||
defaultRadiusConfigDesc* = $defaultRadiusConfig.kind
|
defaultRadiusConfigDesc* = $defaultRadiusConfig.kind
|
||||||
defaultDisablePoke* = false
|
defaultDisablePoke* = false
|
||||||
|
defaultMaxGossipNodes = 8
|
||||||
revalidationTimeout* = chronos.seconds(30)
|
revalidationTimeout* = chronos.seconds(30)
|
||||||
|
|
||||||
defaultPortalProtocolConfig* = PortalProtocolConfig(
|
defaultPortalProtocolConfig* = PortalProtocolConfig(
|
||||||
tableIpLimits: DefaultTableIpLimits,
|
tableIpLimits: DefaultTableIpLimits,
|
||||||
bitsPerHop: DefaultBitsPerHop,
|
bitsPerHop: DefaultBitsPerHop,
|
||||||
radiusConfig: defaultRadiusConfig,
|
radiusConfig: defaultRadiusConfig,
|
||||||
|
disablePoke: defaultDisablePoke,
|
||||||
|
maxGossipNodes: defaultMaxGossipNodes,
|
||||||
)
|
)
|
||||||
|
|
||||||
proc init*(
|
proc init*(
|
||||||
|
@ -60,6 +64,7 @@ proc init*(
|
||||||
bitsPerHop: int,
|
bitsPerHop: int,
|
||||||
radiusConfig: RadiusConfig,
|
radiusConfig: RadiusConfig,
|
||||||
disablePoke: bool,
|
disablePoke: bool,
|
||||||
|
maxGossipNodes: int,
|
||||||
): T =
|
): T =
|
||||||
PortalProtocolConfig(
|
PortalProtocolConfig(
|
||||||
tableIpLimits:
|
tableIpLimits:
|
||||||
|
@ -67,6 +72,7 @@ proc init*(
|
||||||
bitsPerHop: bitsPerHop,
|
bitsPerHop: bitsPerHop,
|
||||||
radiusConfig: radiusConfig,
|
radiusConfig: radiusConfig,
|
||||||
disablePoke: disablePoke,
|
disablePoke: disablePoke,
|
||||||
|
maxGossipNodes: maxGossipNodes,
|
||||||
)
|
)
|
||||||
|
|
||||||
func fromLogRadius*(T: type UInt256, logRadius: uint16): T =
|
func fromLogRadius*(T: type UInt256, logRadius: uint16): T =
|
||||||
|
|
Loading…
Reference in New Issue