4 Commits

Author SHA1 Message Date
Prem Chaitanya Prathi
ba39ee4a37
fix(tests): libp2p v2.0.0 API migrations across test suite
Three small classes of fix across 12 test files (uncovered by a local
`nim c` sweep of tests/all_tests_common.nim + tests/all_tests_waku.nim):

1. `rng` no longer auto-calls when used as an argument: libp2p v2.0.0
   exports its own `rng` symbol (SwitchBuilder field), so Nim's resolver
   sees the testlib `common.rng` template ambiguously and stops auto-
   calling it. Add explicit `()`:
   - tests/test_helpers.nim
   - tests/waku_filter_v2/waku_filter_utils.nim
   - tests/waku_lightpush/lightpush_utils.nim
   - tests/waku_lightpush_legacy/lightpush_utils.nim
   - tests/node/test_wakunode_filter.nim
   - tests/waku_store/store_utils.nim

2. `PeerId.random()` zero-arg form removed in v2.0.0; new signature
   takes `rng: Rng`. Add `newRng()` + `libp2p/crypto/crypto` import:
   - tests/common/test_requestratelimiter.nim
   - tests/common/test_ratelimit_setting.nim

3. `some()` ambiguity vs `Opt.some` — files that don't directly
   `import std/options` get `Opt.some` template only, breaking calls
   intended for `Option[T]`. Add `std/options` to imports:
   - tests/waku_store/test_wakunode_store.nim
   - tests/waku_relay/test_wakunode_relay.nim

4. Two more API removals:
   - tests/testlib/wakunode.nim — `builders.MaxConnections` was removed;
     use `DefaultMaxConnections` from `libp2p/connmanager`.
   - tests/waku_rln_relay/utils_onchain.nim — `keys.PrivateKey.random
     (rng[])` `rng` ambiguous between testlib/common and eth/keys
     exports; qualify as `common.rng()[]`.

There are still more test-compile errors past this point — this is
incremental progress, not a complete v2.0.0 test-suite migration.
2026-06-04 18:55:26 +05:30
Miran
ed0474ade3 chore: fix unused and deprecated imports (#3368) 2025-04-11 18:20:23 +03:00
NagyZoltanPeter
e7ae1a0382 chore: rate limit peer exchange protocol, enhanced response status in RPC (#3035)
* Enhanced peer-ex protocol - added rate limiting, added response status and desc to the rpc

* Better error result handling for PeerEx request, adjusted tests

* Refactored RateLimit configuration option for better CLI UX - now possible to set separate limits per protocol. Adjusted mountings. Added and adjusted tests

* Fix libwaku due to changes of error return type of fetchPeerExchangePeers

* Fix rate limit setting tests due to changed defaults

* Introduce new gauge to help dasboard effectively show current rate limit applied for protocol

* Adjust timeing in filter rate limit test to let macos CI test run ok.

* Address review findings, namings, error logs, removed left-overs

* Changes to reflect latest spec agreement and changes. PeerExchange RPC is changed the now respond structure will contain status_code and status_desc.
2024-09-18 15:58:07 +02:00
NagyZoltanPeter
ca634ef3ba feat: DOS protection of non relay protocols - rate limit phase3 (#2897)
* DOS protection of non relay protocols - rate limit phase3:
- Enhanced TokenBucket to be able to add compensation tokens based on previous usage percentage,
- per peer rate limiter 'PeerRateLimier' applied on waku_filter_v2 with opinionated default of acceptable request rate
- Add traffic metrics to filter message push
- RequestRateLimiter added to combine simple token bucket limiting of request numbers but consider per peer usage over time and prevent some peers to over use the service
  (although currently rule violating peers will not be disconnected by this time only their requests will get not served)
- TimedMap utility created (inspired and taken from libp2p TimedCache) which serves as forgiving feature for peers had been overusing the service.
- Added more tests
- Fix rebase issues
- Applied new RequestRateLimiter for store and legacy_store and lightpush
* Incorporate review comments, typos, file/class naming and placement changes.
* Add issue link reference of the original issue with nim-chronos TokenBucket
* Make TimedEntry of TimedMap private and not mixable with similar named in libp2p
* Fix review comments, renamings, const instead of values and more comments.
2024-07-16 15:46:21 +02:00