Skip to content

Commit

Permalink
Merge ddd14f0 into 29b0c0b
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status authored Feb 17, 2024
2 parents 29b0c0b + ddd14f0 commit 188e841
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions apps/wakunode2/internal_config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ proc enrConfiguration*(conf: WakuNodeConf, netConfig: NetConfig, key: crypto.Pri
return err($recordRes.error)
else: recordRes.get()

trace "enrConfiguration result", record = $record

return ok(record)

proc validateExtMultiAddrs*(vals: seq[string]):
Expand Down
4 changes: 3 additions & 1 deletion waku/common/enr/typed_record.nim
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ func toTyped*(record: Record): EnrResult[TypedRecord] =
if idOpt.isNone():
return err("missing id scheme field")

discard ? toRecordId(idOpt.get())
let toRecIdRes = toRecordId(idOpt.get())
if toRecIdRes.isErr():
return err("toRecIdRes is not ok")

ok(tr)

Expand Down
24 changes: 20 additions & 4 deletions waku/waku_enr/sharding.nim
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,24 @@ proc containsShard*(r: Record, topic: PubsubTopic|string): bool =

proc isClusterMismatched*(record: Record, clusterId: uint32): bool =
## Check the ENR sharding info for matching cluster id
if (let typedRecord = record.toTyped(); typedRecord.isOk()):
if (let relayShard = typedRecord.get().relaySharding(); relayShard.isSome()):
return relayShard.get().clusterId != clusterId


if clusterId == 0:
trace "isClusterMismatched skipping validation because clusterId == 0 "
return false

let typedRecord = record.toTyped().valueOr:
error "isClusterMismatched typedRecord is not ok: ", error = error
return true

let relayShard = typedRecord.relaySharding()
if relayShard.isNone():
error "isClusterMismatched relayShard is none"
return true

if relayShard.get().clusterId != clusterId:
error "isClusterMismatched mismatch",
relayShardClusterId = relayShard.get().clusterId,
clusterId = clusterId
return true

return false

0 comments on commit 188e841

Please sign in to comment.