-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(rln-relay): group manager integration #1496
Conversation
Jenkins BuildsClick to see older builds (6)
|
Currently blocked by #1497 |
ab64d4b
to
d237e76
Compare
CI seems to be timing out on experimental/ubuntu |
@@ -154,7 +154,7 @@ proc stopGanache(runGanache: Process) {.used.} = | |||
|
|||
# We wait the daemon to exit | |||
try: | |||
let returnCodeExit = runGanache.waitForExit() | |||
let returnCodeExit = runGanache.waitForExit(15) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is most likely the source of the ci timeouts - https://nim-lang.org/docs/osproc.html#waitForExit%2CProcess%2Cint
The ganache instance is used more heavily in these tests, with more contract deployments and interactions, hence may have filled the output buffers. No reason for this to error out on ubuntu specifically though, so I may be wrong
e114165
to
7a1ac1f
Compare
@@ -0,0 +1,470 @@ | |||
when (NimMajor, NimMinor) < (1, 4): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: renamed utils.nim to rln_relay.nim
There is more refactoring to be done in terms of message validation, will create a tracking issue for it.
e5b8fb6
to
6cc4bba
Compare
Moving back to draft to integrate waku_keystore |
fb05489
to
0040816
Compare
0040816
to
c9f52c3
Compare
proc mount(conf: WakuRlnConfig, | ||
registrationHandler: Option[RegistrationHandler] = none(RegistrationHandler) | ||
): Future[WakuRlnRelay] {.async.} = | ||
var groupManager: GroupManager | ||
var credentials: MembershipCredentials | ||
var persistCredentials = false | ||
# create an RLN instance | ||
let rlnInstanceRes = createRLNInstance() | ||
if rlnInstanceRes.isErr(): | ||
raise newException(CatchableError, "RLN instance creation failed") | ||
let rlnInstance = rlnInstanceRes.get() | ||
if not conf.rlnRelayDynamic: | ||
# static setup | ||
let parsedGroupKeysRes = StaticGroupKeys.toIdentityCredentials() | ||
if parsedGroupKeysRes.isErr(): | ||
raise newException(ValueError, "Static group keys are not valid") | ||
groupManager = StaticGroupManager(groupSize: StaticGroupSize, | ||
groupKeys: parsedGroupKeysRes.get(), | ||
membershipIndex: conf.rlnRelayMembershipIndex, | ||
rlnInstance: rlnInstance) | ||
# we don't persist credentials in static mode since they exist in ./constants.nim | ||
# TODO: registration handler | ||
else: | ||
# dynamic setup | ||
let ethPrivateKey = if conf.rlnRelayEthAccountPrivateKey == "": none(string) else: some(conf.rlnRelayEthAccountPrivateKey) | ||
let rlnRelayCredPath = if conf.rlnRelayCredPath == "": none(string) else: some(conf.rlnRelayCredPath) | ||
let rlnRelayCredentialsPassword = if conf.rlnRelayCredentialsPassword == "": none(string) else: some(conf.rlnRelayCredentialsPassword) | ||
groupManager = OnchainGroupManager(ethClientUrl: conf.rlnRelayEthClientAddress, | ||
ethContractAddress: $conf.rlnRelayEthContractAddress, | ||
ethPrivateKey: ethPrivateKey, | ||
rlnInstance: rlnInstance, | ||
registrationHandler: registrationHandler, | ||
keystorePath: rlnRelayCredPath, | ||
keystorePassword: rlnRelayCredentialsPassword, | ||
saveKeystore: true) | ||
|
||
# Initialize the groupManager | ||
await groupManager.init() | ||
# Start the group sync | ||
await groupManager.startGroupSync() | ||
|
||
return WakuRLNRelay(pubsubTopic: conf.rlnRelayPubsubTopic, | ||
contentTopic: conf.rlnRelayContentTopic, | ||
groupManager: groupManager) | ||
|
||
|
||
proc new*(T: type WakuRlnRelay, | ||
conf: WakuRlnConfig, | ||
registrationHandler: Option[RegistrationHandler] = none(RegistrationHandler) | ||
): Future[RlnRelayResult[WakuRlnRelay]] {.async.} = | ||
## Mounts the rln-relay protocol on the node. | ||
## The rln-relay protocol can be mounted in two modes: on-chain and off-chain. | ||
## Returns an error if the rln-relay protocol could not be mounted. | ||
debug "rln-relay input validation passed" | ||
try: | ||
waku_rln_relay_mounting_duration_seconds.nanosecondTime: | ||
let rlnRelay = await mount(conf, | ||
registrationHandler) | ||
return ok(rlnRelay) | ||
except CatchableError as e: | ||
return err(e.msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are the only lines changed from utils.nim, for any comments re: other code, I'll create a issue for it and address it in a follow up pr.
c9f52c3
to
2f883f8
Compare
@rymnc I have a couple questions/queries:
|
|
Afaik this also closes #1357 ? (The only remaining CI issue related to macos timeouts during RLN tests on experimental runs). |
Yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general LGTM ✅
proc createMembershipList*(n: int): RlnRelayResult[( | ||
seq[(string, string, string, string)], string | ||
)] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you have these types (string, string, string, string)
my recommendation is that you define a Type name/alias. For example:
type MembershipList = (string, string, string, string)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let rlnInstance = createRLNInstance() | ||
if rlnInstance.isErr(): | ||
return err("could not create rln instance: " & rlnInstance.error()) | ||
let rln = rlnInstance.get() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend passing this instance as a parameter (as it is created from the very beginning of the function). And create the instance one level up and check there the initialzation error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
09da0a8
to
375aaf2
Compare
fix(rln-relay): integrate group manager. todo spam and reg handlers fix(rln-relay): decouple waku-relay and waku-rln-relay fix(rln-relay): compiles now fix(chat2): compilation fix(rln-relay): wip segfault fix(rln-relay): segfault fix(chat2|wakunode2): use optional field fix(rln-relay): wakunode test fix(rln-relay): uncomment fields in proto decode fix(rln-relay): used pragma on tests fix(rln-relay): include cred processing fix(rln-relay): add reg callback fix(rln-relay): args to mount fix(rln-relay): add timeout to waitForExit fix(rln-relay): use osproc term instead of posix kill fix(rln-relay): use poParentStream to prevent deadlock fix(rln-relay): remove poParentStream, remove ganache log output
375aaf2
to
60684fd
Compare
60684fd
to
261b1e1
Compare
This PR integrates the group manager for rln introduced in #1465. This involved the following changes
mountRlnRelay
proc on wakuNode