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

ws: allow filtering notification by parameters #3689

Merged
merged 2 commits into from
Nov 26, 2024

Conversation

carpawell
Copy link
Member

Closes #3624.

@carpawell carpawell self-assigned this Nov 18, 2024
@carpawell
Copy link
Member Author

Some questions:

  1. Is there any full test for client-to-server communication to check that filtering works? Not just unmarshalling but also creating notifications and receiving only the important ones. Have not found it.
  2. Are type limitations correct?
  3. What limit should be used for parameter filters? Why should we have it (the issue says)? Just not to have some OOMs on a server side or it is possible to abuse a node somehow?

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 60.37736% with 21 lines in your changes missing coverage. Please review.

Project coverage is 83.01%. Comparing base (ff15e39) to head (97bd73b).
Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
pkg/neorpc/filters.go 50.00% 13 Missing and 5 partials ⚠️
pkg/neorpc/rpcevent/filter.go 82.35% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3689      +/-   ##
==========================================
- Coverage   83.04%   83.01%   -0.04%     
==========================================
  Files         335      335              
  Lines       46719    46782      +63     
==========================================
+ Hits        38800    38834      +34     
- Misses       6327     6350      +23     
- Partials     1592     1598       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@carpawell carpawell force-pushed the feat/filter-events-by-parameters branch from d4643f2 to fd5ad7b Compare November 18, 2024 08:57
@AnnaShaleva
Copy link
Member

  1. Is there any full test for client-to-server communication to check that filtering works?

Use and extend the following tests:

func TestSubscriptions(t *testing.T) {

func TestWSClient_SubscriptionsCompat(t *testing.T) {

That's the way how we test subscriptions. If it's not enough, then create your own test based on
func TestSubClientWait(t *testing.T) {

  1. Are type limitations correct?

Will be answered in review.

  1. What limit should be used for parameter filters?

Let's limit the number of parameters to 16 for now, it's pretty enough for notifications used by NeoFS and at the same time it won't allow to DoS the node with useless filtering process for large notifications/filters. Also, parameter types should be limited by non-compound types (simple Integer, String, Hash160 and etc.; excluding Arrays, Structs and Maps), we don't need compounds for now and NeoFS contracts don't use them in notifications; in future the set of supported types may be extended.

Why should we have it (the issue says)?

Avoid filters misuse and unwanted load for RPC server. This extension will be available on public RPC nodes.

it is possible to abuse a node somehow?

Deploy contract that emits thousands of notifications (it's possible, hi, #3490), then subscribe to RPC server with matching filters.

pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/rpcevent/filter.go Show resolved Hide resolved
pkg/neorpc/rpcevent/filter.go Outdated Show resolved Hide resolved
pkg/neorpc/rpcevent/filter.go Outdated Show resolved Hide resolved
pkg/neorpc/rpcevent/filter.go Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
@carpawell carpawell force-pushed the feat/filter-events-by-parameters branch 2 times, most recently from 9191c15 to b4fc362 Compare November 20, 2024 17:31
@carpawell
Copy link
Member Author

@AnnaShaleva thanks for the review! It was kinda draft with the main questions but tried to answer and fix all the threads you left, check one more time, please.

@carpawell carpawell marked this pull request as ready for review November 20, 2024 17:37
Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Tests are not yet checked, will review them after PR finalisation.

docs/notifications.md Outdated Show resolved Hide resolved
docs/notifications.md Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/subscription_test.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/subscription_test.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/subscription_test.go Outdated Show resolved Hide resolved
pkg/services/rpcsrv/subscription_test.go Outdated Show resolved Hide resolved
@AnnaShaleva
Copy link
Member

@carpawell tests are failing.

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

Some of previous conversations are unresolved.

pkg/neorpc/filters.go Outdated Show resolved Hide resolved
docs/notifications.md Outdated Show resolved Hide resolved
pkg/neorpc/filters.go Outdated Show resolved Hide resolved
@carpawell carpawell force-pushed the feat/filter-events-by-parameters branch from 29d2a57 to 0919d65 Compare November 25, 2024 21:25
`Any` type with nil/null value is treated as a parameter filter that allows
any notification value. Not more than 16 filter parameters are allowed.
Closes #3624.

Signed-off-by: Pavel Karpy <[email protected]>
@carpawell carpawell force-pushed the feat/filter-events-by-parameters branch from 0919d65 to 97bd73b Compare November 25, 2024 21:26
@carpawell
Copy link
Member Author

Some of previous conversations are unresolved.

Can you point me, please? As I see it: it is either fixed or I asked some questions that have not been answered or something is not relevant already.

@AnnaShaleva AnnaShaleva merged commit f98169a into master Nov 26, 2024
32 of 34 checks passed
@AnnaShaleva AnnaShaleva deleted the feat/filter-events-by-parameters branch November 26, 2024 07:12
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.

Notification filtering based on parameters
3 participants