Commit Graph

44 Commits

Author SHA1 Message Date
Andrea Maria Piana 7387049d4b Upgrade linter and address issues 2020-12-28 16:55:14 +01:00
Andrea Maria Piana 1237cc9ac6 Add logs when rate limited peer 2020-12-04 08:31:06 +01:00
Andrea Maria Piana 86e0ec8e10 Log disconnect/connect event
Marketing was relying on mailserver entries for checking the time a
give peer spent on the app.

This was not accurate as the assumption was that a peer would "ping" a
mailserver every 15s, which is not the case, it only hit the mailserver
as it comes from an "offline" state.

This commit changes the log level of two entries so that we have
connect/disconnect time for a given peer, which should be enough to
calculate roughly the time a peer has been online if connected to our
fleet.
2020-11-03 15:58:26 +01:00
Jakub Sokołowski 3d5e21e276 unify format of logs with peerID
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2020-09-24 14:58:49 +02:00
Andrea Maria Piana e836ffb47f Soft blacklist peer ids
Why make this change?

This change is useful so we can blacklist peer ids, without actually
disconnecting them, so that it's harder for them to tell that they are
being blacklisted. Envelopes will just be dropped.

What has changed?

In waku we pass a config with a list of hex-encoded peer ids, and we
check that against newly received envelopes.
If so we just drop the envelope and return
2020-09-09 22:57:15 +02:00
Andrea Maria Piana 56c0142f16 Honor FullNode config in waku
previously FullNode would only result in setting a bloom filter to full.

This behavior caused issues as you effectively cannot install a filter
on a FullNode, as it would advertise the new topic/bloom filter and stop
receiving all the messages.

This caused an issue when running push notifications servers together
with mailservers, also the behavior is a bit counter-intuitive as I
would expect the FullNode config to be honored no matter of what filters
are installed.
2020-08-26 14:11:13 +02:00
Andrea Maria Piana 82deccef60 Use a single throttler per type 2020-06-15 19:46:23 +02:00
Andrea Maria Piana 35e95d1568 Move bytes rate limits to a different rlp key 2020-06-15 19:46:23 +02:00
Andrea Maria Piana c5577418b7 Implement rate limiting by bytes
Why make this change?

Currently we only rate limit by number of messages.
This works well if we want to limit a large amount of small messages but
breaks down if sending a smaller amount of large messages.

This commit extends the current code to limit by size as well, setting
the default to 1MB per second, which should be enough.

What has changed?

- Rate limiter for waku only
2020-06-15 19:46:23 +02:00
Andrea Maria Piana 2d12ac4fbb Rename rate limiting to packet rate limiting 2020-06-15 19:46:23 +02:00
Samuel Hawksby-Robinson 77d9d0f4c9
Waku package README.md documentation (#1949)
* Added waku README.md, starting text and structure

Resolves GH-1944

* Added api, config and doc details

* Created Docs for waku.const, envelope and events

* Added notes on Filter

* Rewrote the filter section

* Restructured docs to match new versioning structure

* Moved package files out of the main ToC

* Added waku/common/README.md

* Added details to mailserver.go and notes to api.go

* Update to bloomfilter and const common

* Added common/ helpers.go, errors.go and message.go details

* Added common/metrics.go and protocol details

* Added rate_limiter and topic.go details

* fix rate limiter table

* Added Waku Versioning details

* Added Versioned sub-package file details

* Added better detail for Waku Filters

Addressing https://github.com/status-im/status-go/pull/1949#discussion_r419232235

* Added notes about light nodes not being actually new

* Added more detail for Waku node configs and defaults

* Added details to the version message.go section

* Added details to waku/common/rate_limiter

* Minor typo fix in docs
2020-05-14 08:49:06 +01:00
Andrea Maria Piana a605442de5 Re-introduce deprecated method of requesting messages
During the move to waku/1 we removed handing of a deprecated format.
aa7f591587 (diff-ea5e44cf3db4a12b3a2a246c7fa39602R290)
Turns out that no client is using the new format and the only live
client is using the deprecated format.
This commit re-introduces the functionality.
2020-05-13 14:10:43 +02:00
Samuel Hawksby-Robinson a21f8a39bc
Minor Waku version subpackage message.go tidy (#1964)
Moved sendBundle() from v*/message_response.go to v*/peer.go
Moved TestSendBundle() from v*/message_response_test.go to v*/peer_test.go
Renamed message.go to v*/message_response.go
Renamed message_test.go to v*/message_response_test.go
2020-05-07 15:45:25 +01:00
Samuel Hawksby-Robinson 4d00656c41
Refactor/waku tidy 1 (#1958)
* Refactor tidy of waku package

* Added deprecation warning on whisper README.md

* Appeasing the lint gods and testing is good

* Place Whisper deprecation warning in the correct package README

:facepalm

* Implementing changes after team feedback

* More offerings to the lint gods

* Remove apparently redundant context params

* Correctly handle concurrent HandlePeer err

* Revert "Remove apparently redundant context params"

This reverts commit 557dbd0d64.

* Added note to waku/api.go about context

* renamed statusoptions and removed unused global

* Removed OnNewP2PEnvelopes() from WakuHost interface

* Matched v1 Peer with new interface sig

Also changed common/helper.go to common/helpers.go

* Formatting of waku tests and some additional error handling

* Changed version to 0.53.0

* Removed redundant type declaration

* Moved TopicToBloom function into a Topic{} method

* Moved GenerateSecureRandomData() into helpers.go
2020-05-01 19:14:01 +01:00
Andrea Maria Piana 0e27e464d3 Add tests for sendBundle and fix flaky tests 2020-05-01 10:14:04 +02:00
Andrea Maria Piana 299b3fc093 Implement waku/1
Why make the change?

This implements waku/1 which is a breaking change as waku/0 diverged
from the specs.

What has changed?

- Added v1 namespace
- Changed the testing code to test from the outside rather than stubbing
p2p specific messages, so that any version specific code is under `vx`
namespaces
- Split waku vs waku/x test code
- Added a test suite that can be used for different versions

Things still to do

I kept the tests we have for the versioned aspect of waku, probably we
want to add some or change other to provide the optimal test coverage.
2020-05-01 10:14:04 +02:00
Andrea Maria Piana 8aa42e4148 Create waku/1 namespace
This commit creates a waku/1 namespace and adds the code to it.
No changes in the protocol have been made (i.e waku/1 is the same as
waku/1 in this commit).
2020-05-01 10:14:04 +02:00
Samuel Hawksby-Robinson b025db235f
Refactor/waku tidy (#1957)
* Refactor tidy of waku package

* Added deprecation warning on whisper README.md

* Appeasing the lint gods and testing is good

* Place Whisper deprecation warning in the correct package README

:facepalm

* Implementing changes after team feedback

* More offerings to the lint gods

* Remove apparently redundant context params

* Correctly handle concurrent HandlePeer err

* Revert "Remove apparently redundant context params"

This reverts commit 557dbd0d64.

* Added note to waku/api.go about context
2020-04-30 13:52:48 +01:00
Andrea Maria Piana aa7f591587 Move networking code for waku under `v0` namespace
Why make the change?

As discussed previously, the way we will move across versions is to maintain completely separate
codebases and eventually remove those that are not supported anymore.

This has the drawback of some code duplication, but the advantage is that is more
explicit what each version requires, and changes in one version will not
impact the other, so we won't pile up backward compatible code.
This is the same strategy used by `whisper` in go ethereum and is influenced by
https://www.youtube.com/watch?v=oyLBGkS5ICk .

All the code that is used for the networking protocol is now under `v0/`.
Some of the common parts might still be refactored out.
The main namespace `waku` deals with `host`->`waku` interactions (through RPC),
while `v0` deals with `waku`->`remote-waku` interactions.

In order to support `v1`, the namespace `v0` will be copied over, and changed to
support `v1`. Once `v0` will be not used anymore, the whole namespace will be removed.

This PR does not actually implement `v1`, I'd rather get things looked over to
make sure the structure is what we would like before implementing the changes.

What has changed?

- Moved all code for the common parts under `waku/common/` namespace
- Moved code used for bloomfilters in `waku/common/bloomfilter.go`
- Removed all version specific code from `waku/common/const` (`ProtocolVersion`, status-codes etc)
- Added interfaces for `WakuHost` and `Peer` under `waku/common/protocol.go`

Things still to do

Some tests in `waku/` are still testing by stubbing components of a particular version (`v0`).
I started moving those tests to instead of stubbing using the actual component, which increases
the testing surface. Some other tests that can't be easily ported should be likely moved under
`v0` instead. Ideally no version specif code should be exported from a version namespace (for
example the various codes, as those might change across versions). But this will be a work-in-progress.

Some code that will be common in `v0`/`v1` could still be extract to avoid duplication, and duplicated only
when implementations diverge across versions.
2020-04-27 14:58:02 +02:00
Samuel Hawksby-Robinson a98e31c20f
Refactor moved message functionality from filter to message (#1951)
When documenting the `filter.go` file I found that there was a lot of functionality that belongs in the `message.go` file, so I've moved it.
2020-04-24 15:34:45 +01:00
Samuel Hawksby-Robinson cc8d57752f
Refactor/waku.doc (#1950)
* Refactor of waku.doc.go

Moved out all code from docs.go, placed much of the seemingly misc code into much more closely related files, created a dedicated const file for housing all the package consts.

* Moved doc_test to message_test

* Refactored type collision and check on nil err

* message_test.go fmt

* Implemented whisper/doc.go refactor

* import order change to attempt to please the linter.

* Bug fix on whisper_test.go

I also spotted a load of redundant type casting and fixed some of them
2020-04-23 20:54:24 +01:00
Samuel Hawksby-Robinson 7d3655976c Reverting most tests related to handshake change 2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson 59530b9d1e Reverting most of the handshake functionality
See GH-1938
2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson 900bad769a Added better prediction of waku RLP key type and value 2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson a50e35b72d Added error handling for waku handshake DecodeRLP 2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson 042ae30f9f Refactor to waku handshake keyType identification
Presuming that all RLP keys will be of the same type. Still failing on forward and backward compatibility, so I will fidn a solution for this next
2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson c16eba55f6 Implemented RLP key field initialisation
This replaces the statically declared values, which previously replaced function varialbes see https://github.com/status-im/status-go/pull/1931#discussion_r406123786
2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson 91e1bdc8ce Apply suggestions from code review
Co-Authored-By: Adam Babik <a.babik@designfortress.com>
2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson 960284056b Added handling for mixed RLP key data types
This the initial implementation, a number of known test fails have been introduced with this commit and will be resolved as a matter of priority.
2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson 7d95118b35 Added new test and used static var declarations for keyFieldIdx 2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson a44fb3c372 Added handling of parseStatuOptionKeys() error 2020-04-21 10:40:39 +02:00
Samuel Hawksby-Robinson 1858ad3ae2 Preliminary fix for GH-1929 2020-04-21 10:40:39 +02:00
Andrea Maria Piana 9ee0e52ea3 Ignore full node flag when in topic mode 2020-03-23 15:10:07 +01:00
Andrea Maria Piana 7a64fbf5f7
make apis private (#1866)
* make apis private

* Bump whisper
2020-02-25 08:03:01 +01:00
Andrea Maria Piana 849492fda9
Add statusUpdate code (#1861)
* Add status-option code

This commits changes the behavior of waku introducing a new status-code,
`2`, that replaces the current single options codes.

* linting
2020-02-21 15:48:53 +01:00
Adam Babik e4b0a97cc5
add bridge metrics to Whisper and Waku (#1864) 2020-02-19 15:36:16 +01:00
Adam Babik 46b05c7478
Handle rateLimitingCode packet (#1852) 2020-02-18 10:33:39 +01:00
Adam Babik 7ba20cb5a2
Prepare Whisper and Waku for bridge implementation (#1850) 2020-02-13 15:30:20 +01:00
Adam Babik 1b515a5a5e
Implement new waku/0 handshake (#1848) 2020-02-11 17:59:21 +01:00
Adam Babik bc2d018483
Add support for request messages by topics (#1805) 2020-01-21 08:11:24 +01:00
Adam Babik 37a508a97b
Integrate Waku service (#1759) 2020-01-08 12:12:23 +01:00
Pedro Pombeiro c8a911ebd1 Use goimports instead of gofmt 2020-01-06 10:17:23 +01:00
Pedro Pombeiro 287e5cdf79 Abstract `accounts.Key` and geth `keystore` 2020-01-06 10:17:23 +01:00
Adam Babik ea0f12b920
Waku/0 service (#1715) 2019-12-20 10:40:50 +01:00