mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-02 14:03:06 +00:00
chore: rename Waku API's "Waku Config" to "Protocols" Config (#3603)
* chore: rename Waku API's "Waku Config" to "Protocols" Config Make it clearer that with this config, we are configuring the Waku protocols, in contrast to other parameters which are more executable related. * ensure var name matches type * format
This commit is contained in:
parent
6958eac6f1
commit
5b5ff4cbe7
@ -16,7 +16,9 @@ when isMainModule:
|
||||
if (args.ethRpcEndpoint == ""):
|
||||
# Create a basic configuration for the Waku node
|
||||
# No RLN as we don't have an ETH RPC Endpoint
|
||||
NodeConfig.init(wakuConfig = WakuConfig.init(entryNodes = @[], clusterId = 42))
|
||||
NodeConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(entryNodes = @[], clusterId = 42)
|
||||
)
|
||||
else:
|
||||
# Connect to TWN, use ETH RPC Endpoint for RLN
|
||||
NodeConfig.init(ethRpcEndpoints = @[args.ethRpcEndpoint])
|
||||
|
||||
@ -23,9 +23,9 @@ suite "LibWaku Conf - toWakuConf":
|
||||
|
||||
test "Core mode configuration":
|
||||
## Given
|
||||
let wakuConfig = WakuConfig.init(entryNodes = @[], clusterId = 1)
|
||||
let protocolsConfig = ProtocolsConfig.init(entryNodes = @[], clusterId = 1)
|
||||
|
||||
let nodeConfig = NodeConfig.init(mode = Core, wakuConfig = wakuConfig)
|
||||
let nodeConfig = NodeConfig.init(mode = Core, protocolsConfig = protocolsConfig)
|
||||
|
||||
## When
|
||||
let wakuConfRes = toWakuConf(nodeConfig)
|
||||
@ -44,7 +44,7 @@ suite "LibWaku Conf - toWakuConf":
|
||||
## Given
|
||||
let nodeConfig = NodeConfig.init(
|
||||
mode = Core,
|
||||
wakuConfig = WakuConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes = @[],
|
||||
staticStoreNodes = @[],
|
||||
clusterId = 42,
|
||||
@ -72,8 +72,9 @@ suite "LibWaku Conf - toWakuConf":
|
||||
]
|
||||
let libConf = NodeConfig.init(
|
||||
mode = Core,
|
||||
wakuConfig =
|
||||
WakuConfig.init(entryNodes = entryNodes, staticStoreNodes = @[], clusterId = 1),
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes = entryNodes, staticStoreNodes = @[], clusterId = 1
|
||||
),
|
||||
)
|
||||
|
||||
## When
|
||||
@ -95,7 +96,7 @@ suite "LibWaku Conf - toWakuConf":
|
||||
"/ip4/192.168.1.1/tcp/60001/p2p/16Uuu2HBmAcHvhLqQKwSSbX6BG5JLWUDRcaLVrehUVqpw7fz1hbYd",
|
||||
]
|
||||
let nodeConf = NodeConfig.init(
|
||||
wakuConfig = WakuConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes = @[], staticStoreNodes = staticStoreNodes, clusterId = 1
|
||||
)
|
||||
)
|
||||
@ -113,7 +114,7 @@ suite "LibWaku Conf - toWakuConf":
|
||||
test "Message validation with max message size":
|
||||
## Given
|
||||
let nodeConfig = NodeConfig.init(
|
||||
wakuConfig = WakuConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes = @[],
|
||||
staticStoreNodes = @[],
|
||||
clusterId = 1,
|
||||
@ -135,7 +136,7 @@ suite "LibWaku Conf - toWakuConf":
|
||||
test "Message validation with RLN config":
|
||||
## Given
|
||||
let nodeConfig = NodeConfig.init(
|
||||
wakuConfig = WakuConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes = @[],
|
||||
clusterId = 1,
|
||||
messageValidation = MessageValidation(
|
||||
@ -174,7 +175,7 @@ suite "LibWaku Conf - toWakuConf":
|
||||
## Given
|
||||
let nodeConfig = NodeConfig.init(
|
||||
mode = Core,
|
||||
wakuConfig = WakuConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes =
|
||||
@[
|
||||
"enr:-QESuEC1p_s3xJzAC_XlOuuNrhVUETmfhbm1wxRGis0f7DlqGSw2FM-p2Vn7gmfkTTnAe8Ys2cgGBN8ufJnvzKQFZqFMBgmlkgnY0iXNlY3AyNTZrMaEDS8-D878DrdbNwcuY-3p1qdDp5MOoCurhdsNPJTXZ3c5g3RjcIJ2X4N1ZHCCd2g"
|
||||
@ -254,8 +255,9 @@ suite "LibWaku Conf - toWakuConf":
|
||||
|
||||
let nodeConfig = NodeConfig.init(
|
||||
mode = Core,
|
||||
wakuConfig =
|
||||
WakuConfig.init(entryNodes = entryNodes, staticStoreNodes = @[], clusterId = 1),
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes = entryNodes, staticStoreNodes = @[], clusterId = 1
|
||||
),
|
||||
)
|
||||
|
||||
## When
|
||||
|
||||
@ -7,8 +7,9 @@ import waku
|
||||
suite "Waku API - Create node":
|
||||
asyncTest "Create node with minimal configuration":
|
||||
## Given
|
||||
let nodeConfig =
|
||||
NodeConfig.init(wakuConfig = WakuConfig.init(entryNodes = @[], clusterId = 1))
|
||||
let nodeConfig = NodeConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(entryNodes = @[], clusterId = 1)
|
||||
)
|
||||
|
||||
# This is the actual minimal config but as the node auto-start, it is not suitable for tests
|
||||
# NodeConfig.init(ethRpcEndpoints = @["http://someaddress"])
|
||||
@ -27,7 +28,7 @@ suite "Waku API - Create node":
|
||||
## Given
|
||||
let nodeConfig = NodeConfig.init(
|
||||
mode = Core,
|
||||
wakuConfig = WakuConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes =
|
||||
@[
|
||||
"enr:-QESuEC1p_s3xJzAC_XlOuuNrhVUETmfhbm1wxRGis0f7DlqGSw2FM-p2Vn7gmfkTTnAe8Ys2cgGBN8ufJnvzKQFZqFMBgmlkgnY0iXNlY3AyNTZrMaEDS8-D878DrdbNwcuY-3p1qdDp5MOoCurhdsNPJTXZ3c5g3RjcIJ2X4N1ZHCCd2g"
|
||||
@ -63,7 +64,7 @@ suite "Waku API - Create node":
|
||||
## Given
|
||||
let nodeConfig = NodeConfig.init(
|
||||
mode = Core,
|
||||
wakuConfig = WakuConfig.init(
|
||||
protocolsConfig = ProtocolsConfig.init(
|
||||
entryNodes =
|
||||
@[
|
||||
"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im",
|
||||
|
||||
@ -26,7 +26,7 @@ type MessageValidation* {.requiresInit.} = object
|
||||
maxMessageSize*: string # Accepts formats like "150 KiB", "1500 B"
|
||||
rlnConfig*: Option[RlnConfig]
|
||||
|
||||
type WakuConfig* {.requiresInit.} = object
|
||||
type ProtocolsConfig* {.requiresInit.} = object
|
||||
entryNodes: seq[string]
|
||||
staticStoreNodes: seq[string]
|
||||
clusterId: uint16
|
||||
@ -42,7 +42,7 @@ const DefaultMessageValidation* =
|
||||
MessageValidation(maxMessageSize: "150 KiB", rlnConfig: none(RlnConfig))
|
||||
|
||||
proc init*(
|
||||
T: typedesc[WakuConfig],
|
||||
T: typedesc[ProtocolsConfig],
|
||||
entryNodes: seq[string],
|
||||
staticStoreNodes: seq[string] = @[],
|
||||
clusterId: uint16,
|
||||
@ -57,7 +57,7 @@ proc init*(
|
||||
messageValidation: messageValidation,
|
||||
)
|
||||
|
||||
const TheWakuNetworkPreset* = WakuConfig(
|
||||
const TheWakuNetworkPreset* = ProtocolsConfig(
|
||||
entryNodes:
|
||||
@[
|
||||
"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im"
|
||||
@ -83,20 +83,20 @@ type WakuMode* {.pure.} = enum
|
||||
|
||||
type NodeConfig* {.requiresInit.} = object
|
||||
mode: WakuMode
|
||||
wakuConfig: WakuConfig
|
||||
protocolsConfig: ProtocolsConfig
|
||||
networkingConfig: NetworkingConfig
|
||||
ethRpcEndpoints: seq[string]
|
||||
|
||||
proc init*(
|
||||
T: typedesc[NodeConfig],
|
||||
mode: WakuMode = WakuMode.Core,
|
||||
wakuConfig: WakuConfig = TheWakuNetworkPreset,
|
||||
protocolsConfig: ProtocolsConfig = TheWakuNetworkPreset,
|
||||
networkingConfig: NetworkingConfig = DefaultNetworkingConfig,
|
||||
ethRpcEndpoints: seq[string] = @[],
|
||||
): T =
|
||||
return T(
|
||||
mode: mode,
|
||||
wakuConfig: wakuConfig,
|
||||
protocolsConfig: protocolsConfig,
|
||||
networkingConfig: networkingConfig,
|
||||
ethRpcEndpoints: ethRpcEndpoints,
|
||||
)
|
||||
@ -134,20 +134,20 @@ proc toWakuConf*(nodeConfig: NodeConfig): Result[WakuConf, string] =
|
||||
return err("Edge mode is not implemented")
|
||||
|
||||
## Network Conf
|
||||
let wakuConfig = nodeConfig.wakuConfig
|
||||
let protocolsConfig = nodeConfig.protocolsConfig
|
||||
|
||||
# Set cluster ID
|
||||
b.withClusterId(wakuConfig.clusterId)
|
||||
b.withClusterId(protocolsConfig.clusterId)
|
||||
|
||||
# Set sharding configuration
|
||||
b.withShardingConf(ShardingConfKind.AutoSharding)
|
||||
let autoShardingConfig = wakuConfig.autoShardingConfig
|
||||
let autoShardingConfig = protocolsConfig.autoShardingConfig
|
||||
b.withNumShardsInCluster(autoShardingConfig.numShardsInCluster)
|
||||
|
||||
# Process entry nodes - supports enrtree:, enr:, and multiaddress formats
|
||||
if wakuConfig.entryNodes.len > 0:
|
||||
if protocolsConfig.entryNodes.len > 0:
|
||||
let (enrTreeUrls, bootstrapEnrs, staticNodesFromEntry) = processEntryNodes(
|
||||
wakuConfig.entryNodes
|
||||
protocolsConfig.entryNodes
|
||||
).valueOr:
|
||||
return err("Failed to process entry nodes: " & error)
|
||||
|
||||
@ -169,11 +169,11 @@ proc toWakuConf*(nodeConfig: NodeConfig): Result[WakuConf, string] =
|
||||
|
||||
# TODO: verify behaviour
|
||||
# Set static store nodes
|
||||
if wakuConfig.staticStoreNodes.len > 0:
|
||||
b.withStaticNodes(wakuConfig.staticStoreNodes)
|
||||
if protocolsConfig.staticStoreNodes.len > 0:
|
||||
b.withStaticNodes(protocolsConfig.staticStoreNodes)
|
||||
|
||||
# Set message validation
|
||||
let msgValidation = wakuConfig.messageValidation
|
||||
let msgValidation = protocolsConfig.messageValidation
|
||||
let maxSizeBytes = parseMsgSize(msgValidation.maxMessageSize).valueOr:
|
||||
return err("Failed to parse max message size: " & error)
|
||||
b.withMaxMessageSize(maxSizeBytes)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user