Skip to content

Commit

Permalink
add hidden --disable-poke option into fluffy [#1640]
Browse files Browse the repository at this point in the history
  • Loading branch information
mynameisdaniil committed Aug 29, 2023
1 parent 820525d commit 3918a94
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
7 changes: 7 additions & 0 deletions fluffy/conf.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion fluffy/fluffy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 8 additions & 1 deletion fluffy/network/wire/portal_protocol.nim
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ type
radiusCache: RadiusCache
offerQueue: AsyncQueue[OfferRequest]
offerWorkers: seq[Future[void]]
disablePoke: bool

PortalResult*[T] = Result[T, string]

Expand Down Expand Up @@ -467,7 +468,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")
Expand Down Expand Up @@ -933,6 +935,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:
Expand Down
8 changes: 6 additions & 2 deletions fluffy/network/wire/portal_protocol_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 3918a94

Please sign in to comment.