-
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
fix: handle rln-relay-message-limit #2867
Conversation
waku/waku_rln_relay/rln_relay.nim
Outdated
@@ -435,19 +434,20 @@ proc mount( | |||
(await groupManager.startGroupSync()).isOkOr: | |||
return err("could not start the group sync: " & $error) | |||
|
|||
if (conf.rlnRelayUserMessageLimit > 20): |
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.
it should be 100 now, as per parameters decided by the waku research team :)
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.
Thanks for the review, @rymnc. I will updates in the next commit.
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.
mm, why enforcing this limit? the user is free to choose whatever rlnRelayUserMessageLimit
they want. TheWakuNetwork sets this to a max of 100, but it shouldn't be enforced in the code.
for example, someone may want to deploy their own cluster, with their own contract with rlnRelayUserMessageLimit=9999.
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.
Hi @AlejandroCabeza, Alvaro makes a good point about why we are enforcing a limit for messages.
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.
mm, why enforcing this limit? the user is free to choose whatever
rlnRelayUserMessageLimit
they want. TheWakuNetwork sets this to a max of 100, but it shouldn't be enforced in the code.for example, someone may want to deploy their own cluster, with their own contract with rlnRelayUserMessageLimit=9999.
agree - this limit should probably be enforced in another place -
OnchainGroupManager
: fetch the MAX_MESSAGE_LIMIT
from the contract and compare with the user provided rlnRelayUserMessageLimit
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.
Hi @rymnc, I tried fetching MAX_MESSAGE_LIMIT from the contract based on your suggestion, but it failed in many cases. Upon debugging, I discovered that it returns 0 because it hasn't been initialized yet. Now, I've found another approach: there's an attribute called userMessageLimit in base_groupmanager, which I believe is a better option. What do you think ?
Earlier, as you mentioned that the message limit is set 20 for static. Can we fetch the on-chain limit from the contract?
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.
Can we fetch the on-chain limit from the contract?
that is possible by calling MAX_MESSAGE_LIMIT()
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 discovered that it returns 0
please share a code snippet?
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've just updated the PR. plz take a look at.
cc @rymnc
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.
The associated test case failed with this implementation because the MAX_MESSAGE_LIMIT() API is returning 0. This is likely due to it not being initialized, which is why it returns zero.
You can find the image built from this PR at
Built from 45de3af |
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.
Thanks so much! Added just a nitpick change
waku/waku_rln_relay/rln_relay.nim
Outdated
@@ -435,19 +434,20 @@ proc mount( | |||
(await groupManager.startGroupSync()).isOkOr: | |||
return err("could not start the group sync: " & $error) | |||
|
|||
if (conf.rlnRelayUserMessageLimit > 100): | |||
return err("relay message limit (rln) cannot be exceed 100 ") |
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.
return err("relay message limit (rln) cannot be exceed 100 ") | |
return err("relay message limit (rln) cannot exceed 100") |
await node.mountRlnRelay(wakuRlnConfig) | ||
|
||
check: | ||
$error == "relay message limit (rln) cannot be exceed 100 " |
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.
$error == "relay message limit (rln) cannot be exceed 100 " | |
$error == "relay message limit (rln) cannot exceed 100" |
@@ -595,4 +595,4 @@ procSuite "WakuNode - RLN relay": | |||
await node.mountRlnRelay(wakuRlnConfig) | |||
except CatchableError as e: | |||
check e.msg == | |||
"failed to mount WakuRlnRelay: relay message limit (rln) cannot be exceed 100" | |||
"failed to mount WakuRlnRelay: relay-message-limit can't be exceed then user-message-limit set by contract" |
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 file uses the static mode of operation, so there is no point checking the user message limit from the contract
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 test should actually go in the tests/waku_rln_relay/test_rln_group_manager_onchain.nim
file
|
||
# mount rlnrelay in off-chain mode | ||
let wakuRlnConfig = WakuRlnConfig( | ||
rlnRelayDynamic: false, |
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.
notice that it is not dynamic, aka not onchain, hence we cannot get the user message limit from the contract. I would suggest to use a different mechanism for the static group manager
|
||
asyncTest "test rln-relay-message-limit": | ||
let | ||
nodeKey = generateSecp256k1Key() | ||
node = newTestWakuNode(nodeKey, parseIpAddress("0.0.0.0"), Port(0)) | ||
|
||
await node.mountRelay(@[DefaultPubsubTopic]) | ||
|
||
# mount rlnrelay in off-chain mode | ||
let wakuRlnConfig = WakuRlnConfig( | ||
rlnRelayDynamic: false, | ||
rlnRelayCredIndex: some(0.uint), | ||
rlnRelayUserMessageLimit: 111, | ||
rlnEpochSizeSec: 0, | ||
rlnRelayTreePath: genTempPath("rln_tree", "wakunode_9"), | ||
) | ||
|
||
try: | ||
await node.mountRlnRelay(wakuRlnConfig) | ||
except CatchableError as e: | ||
check e.msg == | ||
"failed to mount WakuRlnRelay: rln-relay-message-limit can't be exceed then MAX_MESSAGE_LIMIT set by contract" |
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 wont work, because you're testing the static group manager here (there is no contract, and therefore, no enforceable max msg limit)
waku/waku_rln_relay/rln_relay.nim
Outdated
if (conf.rlnRelayUserMessageLimit > groupManager.rlnRelayMaxMessageLimit): | ||
return err( | ||
"rln-relay-message-limit can't be exceed then MAX_MESSAGE_LIMIT set by contract" | ||
) |
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 can be removed
9c59059
to
ad25f43
Compare
81e2949
to
2acba9d
Compare
@@ -775,7 +779,27 @@ suite "Onchain group manager": | |||
isReady == true | |||
|
|||
await manager.stop() | |||
|
|||
asyncTest "rln-relay-max-message-limit testing": |
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 am not sure if this test belongs here since we are just testing the behaviour of the onchain group manager in this module
can you add a todo comment mentioning it should be moved later?
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.
LGTM after addressing my comment
close #2822