add hidden --disable-poke option into fluffy [#1640] (#1711)

This commit is contained in:
Daniel Sobol 2023-08-30 11:01:00 +03:00 committed by GitHub
parent 7a1fe5707c
commit 85134eb24b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 4 deletions

View File

@ -226,6 +226,13 @@ type
defaultValue: none(TrustedDigest)
name: "trusted-block-root" .}: Option[TrustedDigest]
disablePoke* {.
hidden
desc: "Disable POKE functionality for gossip mechanisms testing"
defaultValue: defaultDisablePoke
defaultValueDesc: $defaultDisablePoke
name: "disable-poke" .}: bool
case cmd* {.
command
defaultValue: noCommand .}: PortalCmd

View File

@ -166,7 +166,8 @@ proc run(config: PortalConf) {.raises: [CatchableError].} =
config.tableIpLimit,
config.bucketIpLimit,
config.bitsPerHop,
config.radiusConfig
config.radiusConfig,
config.disablePoke
)
streamManager = StreamManager.new(d)

View File

@ -170,6 +170,7 @@ type
radiusCache: RadiusCache
offerQueue: AsyncQueue[OfferRequest]
offerWorkers: seq[Future[void]]
disablePoke: bool
PortalResult*[T] = Result[T, string]
@ -470,7 +471,8 @@ proc new*(T: type PortalProtocol,
bootstrapRecords: @bootstrapRecords,
stream: stream,
radiusCache: RadiusCache.init(256),
offerQueue: newAsyncQueue[OfferRequest](concurrentOffers))
offerQueue: newAsyncQueue[OfferRequest](concurrentOffers),
disablePoke: config.disablePoke)
proto.baseProtocol.registerTalkProtocol(@(proto.protocolId), proto).expect(
"Only one protocol should have this id")
@ -936,6 +938,11 @@ proc triggerPoke*(
nodes: seq[Node],
contentKey: ByteList,
content: seq[byte]) =
## In order to properly test gossip mechanisms (e.g. in Portal Hive),
## we need the option to turn off the POKE functionality as it influences
## how data moves around the network.
if p.disablePoke:
return
## Triggers asynchronous offer-accept interaction to provided nodes.
## Provided content should be in range of provided nodes.
for node in nodes:

View File

@ -27,10 +27,12 @@ type
tableIpLimits*: TableIpLimits
bitsPerHop*: int
radiusConfig*: RadiusConfig
disablePoke*: bool
const
defaultRadiusConfig* = RadiusConfig(kind: Dynamic)
defaultRadiusConfigDesc* = $defaultRadiusConfig.kind
defaultDisablePoke* = false
defaultPortalProtocolConfig* = PortalProtocolConfig(
tableIpLimits: DefaultTableIpLimits,
@ -43,14 +45,16 @@ proc init*(
tableIpLimit: uint,
bucketIpLimit: uint,
bitsPerHop: int,
radiusConfig: RadiusConfig): T =
radiusConfig: RadiusConfig,
disablePoke: bool): T =
PortalProtocolConfig(
tableIpLimits: TableIpLimits(
tableIpLimit: tableIpLimit,
bucketIpLimit: bucketIpLimit),
bitsPerHop: bitsPerHop,
radiusConfig: radiusConfig
radiusConfig: radiusConfig,
disablePoke: disablePoke
)
proc parseCmdArg*(T: type RadiusConfig, p: string): T