Commit Graph

64 Commits

Author SHA1 Message Date
Andrea Maria Piana e65760ca85 Add basic peersyncing
This commit adds basic syncing capabilities with peers if they are both
online.

It updates the work done on MVDS, but I decided to create the code in
status-go instead, since it's very tight to the application (similarly
the code that was the inspiration for mvds, bramble, is all tight
together at the database level).

I reused parts of the protobufs.

The flow is:

1) An OFFER message is sent periodically with a bunch of message-ids and
   group-ids.
2) Anyone can REQUEST some of those messages if not present in their
   database.

3) The peer will then send over those messages.

It's disabled by default, but I am planning to add a way to set up the
flags.
2024-01-23 12:46:17 +00:00
Andrea Maria Piana ed9ca8392c Upgrade linter to 1.50.0 2023-01-13 17:52:03 +00:00
frank 9137257638
synchronize display name (#2989) 2022-12-29 14:16:19 +08:00
Richard Ramos 0f7c9f52d8 feat: mark automatic status updates as ephemeral 2022-11-09 15:49:26 +03:00
Jakub Sokołowski 530f3c7a3a
rename status-react to status-mobile
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2022-07-17 15:37:14 +02:00
Anthony Laibe 8e9c5d31d1
fix: joining communities sync correct filters (#2740) 2022-07-07 10:33:50 +02:00
Andrea Maria Piana 8a5f77dc37 Address linter issues 2022-03-28 13:14:12 +01:00
Andrea Maria Piana f60cf5cd47 Wait for p2p messages to be processed 2021-12-01 12:58:46 +00:00
Andrea Maria Piana 6724cf4c75 Block contact endpoint 2021-11-15 18:53:35 +00:00
Andrea Maria Piana 2d13fa1e25 Add logging of message-id 2021-11-01 11:53:08 +00:00
Andrea Maria Piana 62b9d8062e Discard installations with no metadata in tests
We need to discard installations with no metadata, as some might be sent
before, so we need to check in the loop that the one we care about is
received.
2021-10-06 20:43:36 +01:00
Andrea Maria Piana 93497f4644 Remove flaky tests 2021-09-15 09:28:51 +01:00
RichΛrd 842ba229df
feat: add function to obtain bloomfilter (#2334) 2021-08-26 16:25:43 -04:00
Jakub Sokołowski b22a261bc2 using zap.NewNop() ignores configured log level
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2021-08-19 11:35:40 +02:00
RichΛrd facad9f07e
feat: upload/download rate for waku v1 messages (#2286)
* feat: upload/download rate for waku v1 messages

* reorganize code

* fix failing test
2021-08-03 15:27:15 -04:00
Andrea Maria Piana d84da4f515 Fix some tests and restore private/public RPC client 2021-07-20 10:57:38 +02:00
Andrea Maria Piana 4b0daeb47b Move services to status-node
Move all the services to status-node, as some of them were there, some
of them were in the geth backend and scattered around.
2021-07-20 10:57:38 +02:00
Andrea Maria Piana e433e7d470 Fix potential race condition 2021-01-26 17:58:25 +01:00
Andrea Maria Piana cec7c52505 Don't leak goroutines on decorator
When an error occours (or the peer disconnect), we return from decorator
as an error is published to the chan.
There are though still 5 or 6 goroutines that want to write on that
channel and at least 3/4 of them will be hanging, leaving them stuck
publishing on the chan.
This though is probably not the cause of
https://github.com/status-im/infra-eth-cluster/issues/39
fills up the stack trace with hung go routines.
2021-01-26 17:58:25 +01:00
Andrea Maria Piana a1b3e3a772
Clean topics that we don't listen to
There was a bug on status-react where it would save filters that were
not listened to.
This commit adds a task to clean up those filters as they might result
in long syncing times.

This commit also returns topics/ranges/mailserves from messenger in
order to make the initialization of the app simpler and start moving
logic to status-go.

It also removes whisper from vendor.
2021-01-26 09:39:57 +01:00
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