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

chore(rln-relay): Verify proofs based on bandwidth usage #1844

Merged
merged 4 commits into from
Jul 7, 2023

Conversation

rymnc
Copy link
Contributor

@rymnc rymnc commented Jul 6, 2023

Description

Runs rln verification only if bandwidth exceeds 1mbps. @jm-clius, what is the bandwidth cutoff you'd like to be the default?

Changes

  • Uses TokenBucket from chronos/ratelimit to check if bandwidth has been exceeded

Issue

closes #1837

@rymnc rymnc self-assigned this Jul 6, 2023
@rymnc rymnc marked this pull request as draft July 6, 2023 07:32
@rymnc rymnc force-pushed the bandwidth-verification branch 9 times, most recently from 2bf7b48 to 36c80b0 Compare July 6, 2023 11:36
@rymnc rymnc marked this pull request as ready for review July 6, 2023 12:04
@rymnc rymnc requested a review from SionoiS July 6, 2023 12:07
Copy link
Contributor

@SionoiS SionoiS left a comment

Choose a reason for hiding this comment

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

nitpick:
At first, I got confused by the word cutoff. I thought it was stopping the rate limiting then I read the code.

Call it threshold maybe?

Otherwise 👍

Copy link
Contributor

@jm-clius jm-clius left a comment

Choose a reason for hiding this comment

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

Nice feature!

@jm-clius, what is the bandwidth cutoff you'd like to be the default?

Mmm. Wondering if this shouldn't be 0 for now - someone enabling RLN probably expects it to work immediately and not just after a threshold. This is also backwards compatible with previous iterations and current docs. We can reconsider once we have a default design for the public network finished. Does it make sense to use/initialise the token bucket at all if threshold is 0? Perhaps make it an Option?

@rymnc
Copy link
Contributor Author

rymnc commented Jul 6, 2023

Thanks @SionoiS and @jm-clius, addressed both concerns in 9974535

Copy link
Contributor

@alrevuelta alrevuelta left a comment

Choose a reason for hiding this comment

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

great! lgtm.

perhaps we are missing a simple unit test? since a missconfoguration of this feature can totally "short circuit" rln, totally disabling it. Even if it works now, its always nice to protect the code from future changes.

on the other hand (no action required) i usually prefer when things always works or never works. this introduces a sometimes works.

@rymnc
Copy link
Contributor Author

rymnc commented Jul 7, 2023

Thanks @alrevuelta, addressed in a633f30 and 63fa8dd

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

LGTM! 👏

@@ -211,6 +211,11 @@ type
defaultValue: ""
name: "rln-relay-tree-path" }: string

rlnRelayBandwidthThreshold* {.
Copy link
Collaborator

Choose a reason for hiding this comment

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

From a user perspective, how could I set the proper value of this setting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, it's mentioned bytes/sec, so it should be according to their personal bandwidth constraints.

Copy link
Contributor

Choose a reason for hiding this comment

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

im fine with having it as a cli flag, but imho this parameter should be fixed for the network and not "according to their personal bandwidth constraints". wouldn't this be dangerous?

if different nodes in the same network set different thresholds, then message validity (valid/invalid) wont be an objective truth, but something that will depend on each node (each node will have its own view on wether the message is valid or invalid). and for waku as a network, i thinnk this can cause troubles.

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 think this problem can be solved if we broadcast capabilities like waku_relay, however if you'd like to set it to a global value, it'll be a matter of prioritising resource restrained nodes vs an overall global stable network. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

just to ensure we are on the same page:

  • do we agree that these value has to be fixed for the whole network because of the above reasons?
  • mind elaborating on "it'll be a matter of prioritising resource restrained nodes vs an overall global stable network"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. yes, agree that the value has to be fixed for the whole network
  2. follow up comment

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 network will be stable if we set a fixed bandwidth threshold for all nodes, however, some nodes which have a bandwidth lesser than that will blindly forward messages to other nodes. and if we implement peer scoring for rln, this opens another issue where we need to adjust peer score based on the other's bandwidth threshold

Copy link
Contributor

@Menduist Menduist Jul 10, 2023

Choose a reason for hiding this comment

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

then message validity (valid/invalid) wont be an objective truth

That will be the case not matter what with this PR, since the order in which the messages are received will impact if they are valid or invalid.
As long as the messages are not counted as Invalid, this shouldn't cause issue at the GS level, but it will of course means that the global view of the messages won't be.. global

(just to clarify: for GS, the valid/ignore distinction doesn't need to be network-wide, but Invalid does need to be global)

@rymnc rymnc merged commit 3fe4522 into master Jul 7, 2023
13 checks passed
@rymnc rymnc deleted the bandwidth-verification branch July 7, 2023 11:58
return pubsub.ValidationResult.Accept
else:
info "message bandwidth limit exceeded, running rate limit proof validation"
except OverflowDefect: # not a problem
Copy link
Contributor

Choose a reason for hiding this comment

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

Ehh that shouldn't be necessary, and catching defects is not great, what happened? Probably a bug to fix in the rate limiter

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, if you pass in 0 to the TokenBucket, it underflows. sorry for not creating an issue!

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.

chore(rln-relay): Verify proofs based on bandwidth usage
6 participants