Skip to content
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

Merged
merged 3 commits into from
Jul 22, 2024
Merged

fix: handle rln-relay-message-limit #2867

merged 3 commits into from
Jul 22, 2024

Conversation

darshankabariya
Copy link
Contributor

close #2822

@@ -435,19 +434,20 @@ proc mount(
(await groupManager.startGroupSync()).isOkOr:
return err("could not start the group sync: " & $error)

if (conf.rlnRelayUserMessageLimit > 20):
Copy link
Contributor

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 :)

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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?

Copy link
Contributor

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()

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

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.

Copy link

github-actions bot commented Jul 2, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2867

Built from 45de3af

Copy link
Contributor

@gabrielmer gabrielmer left a 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

@@ -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 ")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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"
Copy link
Contributor

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

Copy link
Contributor

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,
Copy link
Contributor

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

Comment on lines 227 to 254

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"
Copy link
Contributor

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)

Comment on lines 448 to 451
if (conf.rlnRelayUserMessageLimit > groupManager.rlnRelayMaxMessageLimit):
return err(
"rln-relay-message-limit can't be exceed then MAX_MESSAGE_LIMIT set by contract"
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be removed

@darshankabariya darshankabariya force-pushed the bug_2822 branch 2 times, most recently from 81e2949 to 2acba9d Compare July 22, 2024 12:43
@@ -775,7 +779,27 @@ suite "Onchain group manager":
isReady == true

await manager.stop()

asyncTest "rln-relay-max-message-limit testing":
Copy link
Contributor

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?

Copy link
Contributor

@rymnc rymnc left a 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

@darshankabariya darshankabariya merged commit 8d107b0 into master Jul 22, 2024
8 of 10 checks passed
@darshankabariya darshankabariya deleted the bug_2822 branch July 22, 2024 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: RLN_RELAY_MSG_LIMIT handling
4 participants