Commit Graph

397 Commits

Author SHA1 Message Date
Pierre Krieger 5d2640240c Fix &mut self -> &self in add_known_address (#8468) 2021-03-26 22:28:55 +01:00
Pierre Krieger e8aeadf202 Add NetworkService::add_known_address (#8467) 2021-03-26 17:02:41 +00:00
Pierre Krieger 1063fc7e35 Use Debug for genesis mismatch message (#8449) 2021-03-24 20:51:58 +01:00
Roman Borschel e1570b9ab4 Update to libp2p-0.36 (#8420)
* Update to libp2p-0.36

* Some more Cargo.lock updates.
2021-03-24 18:29:35 +00:00
André Silva ee8e7f1bcd grandpa: speed up tests (#8439)
* grandpa: tests: add peers with authority role

* grandpa: tests: manually wake-up poll_fn future
2021-03-24 09:56:25 +01:00
Pierre Krieger fb922e2794 Refactor NotifsHandler::poll (#8422)
* Refactor a bit NotifsHandler::poll

* Avoid some spurious wake-ups
2021-03-23 10:02:07 +00:00
Pierre Krieger 5087634ccd Rename GenericProto to Notifications (#8415)
* Rename GenericProto to Notifications

* Small comment fix
2021-03-22 10:32:47 +00:00
Arkadiy Paronyan 4a0d6d9490 Storage chains: indexing, renewals and reference counting (#8265)
* Transaction indexing

* Tests and fixes

* Fixed a comment

* Style

* Build

* Style

* Apply suggestions from code review

Co-authored-by: cheme <emericchevalier.pro@gmail.com>

* Code review suggestions

* Add missing impl

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* impl JoinInput

* Don't store empty slices

* JoinInput operates on slices

Co-authored-by: cheme <emericchevalier.pro@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2021-03-18 11:46:27 +00:00
Jon Häggblad 0d6884b919 Storing multiple Justifications per block (#7640)
* primitives/runtime: initial changes on supporting multiple Justifications

* primitives/runtime: make Justifications strongly typed

* Encode/decode Justifications

* primitives/runtime: add Justification type

* backend: apply_finality and finalize_block takes a single Justification

* manual-seal: create engine id and let rpc take encoded justification

* backend: skeleton functions for appending justifications

* backend: initial implementation append_justification

Initial implementation of append_justification on the Backend trait, and also remove unused skeleton
functions for append_justificaton on Finaziler trait.
k

* backend: guard against duplicate consensus engine id

* client/db: add check for block finality

* client/api: add append_justification to in_mem db

* client/light: add no-op append_justification

* network: fix decode call for Justification

* network: only send a single Justification in BlockData

* network: minor comment update

* protocol: update field names to distinguish single justification

* client: further field renames to plural

* client: update function names to plural justifications

* client/db: upgrade existing database for new format

* network: remove dependency on grandpa crate

* db: fix check for finalized block

* grandpa: check for multiple grandpa justifications hwne importing

* backend: update Finalizer trait to take multiple Justifications

* db: remove debugging statements in migration code

* manual-seal: update note about engine id

* db: fix check for finalized block

* client: update variable name to reflect it is now plural

* grandpa: fix incorrect empty Justications in test

* primitives: make Justifications opaque to avoid being empty

* network: fix detecting empty Justification

* runtime: doc strings for Justifications functions

* runtime: add into_justifications

* primitives: check for duplicates in when adding to Justifications

* network/test: use real grandpa engine id in test

* client: fix reviewer comments

* primitives: rename Justifications::push to append

* backend: revert changes to Finalizer trait

* backend: revert mark_finalized

* backend: revert changes to finalize_block

* backend: revert finalized_blocks

* db: add a quick early return for performance

* client: minor reviewer comments

* service/test: use local ConsensusEngineId

* network: add link to issue for sending multiple Justifications

* Apply suggestions from code review

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

* Apply suggestions from code review

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

* network: tweaks to review suggestions

* network: revert change to BlockData for backwards compatibility

* Apply suggestion from code review

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

* Apply suggestions from code review

Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>

* primitives: update doc comment for Justifications

* client/db/upgrade: avoid grandpa crate dependency

* consensus: revert to single Justification for import_justification

* primitives: improve justifications docs

* style cleanups

* use and_then

* client: rename JUSTIFICATIONS db column

* network: revert to using FRNK in network-test

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: André Silva <andrerfosilva@gmail.com>
2021-03-17 21:18:16 +00:00
Robert Klotzner def7b4dca2 Derive common classes for IfDisconnected. (#8346) 2021-03-12 20:54:44 +01:00
Bastian Köcher 3743cec9bd Do not ban peers for sending multiple valid requests (#8325)
We introduced banning of peers who spam us with the same request (more
than 2 times). However, we missed that it is completely legal to send
the same request multiple times as long as we did not provide any
answer. An example for that is the justification request. This request
is send multiple times until we could fetch the justification from one
of our peers. So, the solution to this problem is to tag requests as
fulfilled and to start counting these fulfilled requests. If the number
is higher than what we allow, the peer should be banned.
2021-03-12 11:13:44 +00:00
Pierre Krieger 39f3b77f4b Fix #8306 (#8330) 2021-03-11 19:07:52 +00:00
Pierre Krieger 5f004b4428 Remove legacy network protocol (#8296) 2021-03-11 13:57:06 +00:00
Bastian Köcher 85f32e8813 Decrease the peer reputation on invalid block requests (#8260)
* Decrease the peer reputation on invalid block requests

This pr changes the block request handler to decrease the reputation of
peers when they send the same request multiple times or they send us an
invalid block request.

* Review feedback

* Change log target

* Remove unused code
2021-03-09 14:43:19 +01:00
Guillaume Thiolliere 9c4e4d453c Fix doc build with --all-features (#8277)
* implement

* make default pre/post_upgrade

* simplify Cargo.toml

* revert removal of outdated/private links

* link in pallet-mmr
2021-03-05 16:08:44 +01:00
Pierre Krieger add5cbebb6 Fix state mismatch in case of bad handshake (#8230) 2021-03-01 18:57:00 +01:00
Pierre Krieger 2bd41a0251 Fix transactions not being propagated to authorities (#8212) 2021-02-26 15:09:42 +00:00
Pierre Krieger d5b308f13c Fix networking debug_asserts (#8200)
* Fix networking debug_asserts

* Fix comment
2021-02-25 13:51:29 +01:00
Pierre Krieger a3d749f3c5 Add some debug_asserts for #8171 (#8181) 2021-02-24 17:13:34 +01:00
Pierre Krieger ba659f9440 Bump lru dependency (#8182) 2021-02-23 12:52:59 +01:00
Roman Borschel fbd3148bba Update to libp2p-0.35.1 (#8141) 2021-02-22 09:52:22 +01:00
Pierre Krieger aa95196be3 Extract transactions handling from protocol.rs (#8110)
* Extract transactions handling from protocol.rs

* Oops, boolean

* Do this better

* Update client/network/src/transactions.rs

Co-authored-by: Nikolay Volf <nikvolf@gmail.com>

* [WIP] Fix handshake

* Finish handshake change

* Bugfix

Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
2021-02-18 17:04:23 +01:00
Pierre Krieger f6273f7914 Remove all code related to sentry nodes (#8079)
* Remove all code related to sentry nodes

* More fixing
2021-02-15 08:45:03 +00:00
Benjamin Kampmann 6a964c5df0 Releasing 3.0 (#8098)
* bumping version for next release
* add changelog
* add guide
2021-02-10 19:23:18 +01:00
Benjamin Kampmann 2d31af3eb6 sc-network: switch on default features for libp2p on non-wasm-builds (#8088) 2021-02-10 08:42:37 +00:00
Pierre Krieger 1eeafdd2b3 Remove backwards-compatibility networking hack (#8068)
* Remove backwards-compatibility networking hack

* Fix compilation

* Try fix
2021-02-08 13:44:34 +00:00
Benjamin Kampmann 8e36d87ca8 Update dependencies ahead of next release (#8015)
Updates dependencies:
parity-db 0.2.2
paste
prometheus 0.11
cfg-if 1.0
strum 0.20
env_logger 0.8
pin-project
prost
nix
platforms
quickcheck 1.0
2021-02-04 19:17:42 +01:00
Robert Klotzner 0ec82c3484 Export IfDisconnected in public module. (#8034) 2021-02-03 09:39:39 +01:00
Pierre Krieger 11b00681d2 Improve log line (#8032)
Co-authored-by: parity-processbot <>
2021-02-03 08:24:23 +00:00
Arkadiy Paronyan e905c9a92d Storage chains: serve transactions over IPFS/bitswap (#7963)
* IPFS server for transactions

* Style

* Indent

* Log message

* CLI option

* Apply suggestions from code review

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

* Style

* Style

* Minor fixes

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2021-02-03 07:14:23 +00:00
Robert Klotzner 3628998d3c Add a send_request function to NetworkService (#8008)
* Add a `send_request` to `NetworkService`.

This function delivers responses via a provided sender and also allows
for sending requests to currently not connected peers.

* Document caveats of send_request better.

* Fix compilation in certain cases.

* Update docs + introduce IfDisconnected enum

for more readable function calls.

* Doc fix.

* Rename send_request to detached_request.

* Whitespace fix - arrrgh

* Update client/network/src/service.rs

spaces/tabs

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>

* Update client/network/src/request_responses.rs

Documentation fix

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

* Update client/network/src/service.rs

Typo.

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

* Update client/network/src/service.rs

Better docs.

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

* Update client/network/src/service.rs

Typo.

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

* Update client/network/src/service.rs

Doc improvements.

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

* Remove error in logs on dialing a peer.

This is now valid behaviour.

* Rename detached_request to start_request.

As suggested by @romanb.

* Fix merged master.

* Fix too long lines.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2021-02-02 20:52:12 +01:00
Pierre Krieger eeff8f3204 Disable Kademlia random walk when --reserved-nodes is passed (#7999)
* Disable Kademlia random walk when --reserved-nodes is passed

* Update client/network/src/discovery.rs

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>

Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
2021-02-02 13:52:09 +00:00
Max Inden 3006100977 client/network: Use request response for light client requests (#7895)
* client/network: Re-enable light_client_handler.rs unit tests

* client/network: Add scaffolding for light client using req-resp

* client/network: Make it compile

* client/network: Rename OutEvent SendRequest

* client/network: Restructure light client request client and handler

* client/network: Rename light client request client to sender

* client/network: Remove light client prepare_request

* client/network/src/light: Rework configuration

* client/network: Formatting

* client/network/light: Remove RequestId

* client/network/light: Make request functions methods

* client/network/light: Refactor request wrapping

* client/network/light: Fix warnings

* client/network/light: Serialize request in method

* client/network/light: Make returning response a method

* client/network/light: Depend on request response to timeout requests

* client/network: Fix test compilation

* client/network/light: Re-enable connection test

* client/network/light: Re-enable timeout test

* client/network/light: Re-enable incorrect_response test

* client/network/light: Re-enable wrong_response_type test

* client/network/light: Re-enable retry_count_failures test

* client/network/light: Re-enable issue_request tests

* client/network/light: Re-enable send_receive tests

* client/network/light: Deduplicate test logic

* client/network/light: Remove unused imports

* client/network/light: Handle request failure

* client/network/light: Move generate_protocol_config

* client/network: Fix test compilation

* client/network: Rename light client request client to sender

* client/network: Handle too-many-requests error

* client/network: Update outdated comments

* client/network/light: Choose any peer if none has best block defined

* .maintain: Replace sentry-node with local-docker-test-network

Sentry nodes are deprecated. Thus there is no need for
`.maintain/sentry-node` to spin up a sentry node test environment.
Instead this commit rewrites the setup to contain two full-connected
validators and one light client.

With the steps below one can now spin up a local test network with
two validators, one light-client, Prometheus and Grafana.

- cargo build --release
- sudo docker-compose -f .maintain/local-docker-test-network/docker-compose.yml up

* client/network/light: Handle oneshot cancellation

* client/network/light: Do not reduce retry count on missing peer

* client/network/request-response: Assert in debug request id to be unique

* client/network/light: Choose same limit as block request protocol

* client/network: Report reputation changes via response

Allow request response protocol handlers to issue reputation changes, by
sending them back along with the response payload.

* client/network: Remove resolved TODOs
2021-02-01 15:59:47 +00:00
Bastian Köcher d40f9c166f Sync: Fix issue of not freeing a block announcement slot (#8006)
* Sync: Fix issue of not freeing a block announcement slot

There was a bug that when the block announcement validation returned an
error, the slot reserved for this validation wasn't freed. This could
lead to a situation where we rejected any block announcement from such a
peer for that the block announcement returned an error multiple times.

* Better logging

* Fuck I'm dumb

* 🤦
2021-01-29 16:29:25 +00:00
Guillaume Thiolliere f48296e9ad Update parity-scale-codec to 2.0 (#7994)
* update cargo.toml

* use 2.0 in mmmr
2021-01-29 12:22:45 +00:00
Pierre Krieger dc70c889ce Introduce sc_peerset::DropReason (#7996)
* Introduce sc_peerset::DropReason

* Fix peerset tests
2021-01-29 09:33:27 +00:00
Pierre Krieger 12fe61a965 Increase maximum size of transaction notifications (#7993) 2021-01-27 10:41:48 +00:00
Max Inden b692954c6e client/network: Report reputation changes via response (#7958)
* client/network: Report reputation changes via response

When handling a request by a remote peer in a request response handler,
one might want to in- or de-crease the reputation of the peer. E.g. one
might want to decrease the reputation slightly for each request, given
that it forces the local node to do work, or one might want to issue a
larger reputation change due to a malformed request by the remote peer.

Instead of having to pass a peerset handle to each request response
handler, this commit suggests to allow handlers to isssue reputation
changes via the provided `pending_response` `oneshot` channel.

A reputation change issued by a request response handler via the
`pending_response` channel is received by the
`RequestResponsesBehaviour` which passes the reputation change up as an
event to eventually be send to a peerset via a peerset handle.

* client/network/req-resp: Use Vec::new instead of None::<Vec<_>>

* client/network: Rename Response to OutgoingResponse

Given that a request-response request is not called `Request` but
`InomingRequest`, rename a request-response response to
`OutgoingResponse`.

* client/finality-grandpa-warp: Send empty rep change via response
2021-01-26 10:45:41 +00:00
Max Inden 62d551a063 client/network/req-resp: Prevent request id collision (#7957)
* client/network/req-resp: Add unit test for request id collision

* client/network/req-resp: Prevent request id collision

`RequestId` is a monotonically increasing integer, starting at
`1`. A `RequestId` is unique for a single `RequestResponse`
behaviour, but not across multiple `RequestResponse` behaviours. Thus
when handling `RequestId` in the context of multiple
`RequestResponse` behaviours, one needs to couple the protocol name
with the `RequestId` to get a unique request identifier.

This commit ensures that pending requests (`pending_requests`) and
pending responses (`pending_response_arrival_time`) are tracked both by
their protocol name and `RequestId`.

* client/network/req-resp: Remove unused import

* client/network/req-resp: Introduce ProtocolRequestId struct

* client/network/req-resp: Update test doc comment

Treat `RequestId` as an opaque type.

* client/network/req-resp: Improve expect proof
2021-01-25 13:09:45 +00:00
Cecile Tonglet 970cc25cef Telemetry per node (#7463) 2021-01-20 12:28:56 +01:00
Pierre Krieger 9d6b9684d9 Disable Nagle algorithm (#7932)
* Disable Nagle algorithm

* Oops, didn't compile
2021-01-20 10:14:24 +00:00
Bastian Köcher 450b96c50d Sync: Propagate block announcement data (#7903)
* Sync: Propagate block announcement data

This pr adds a feature to the sync protocol to propagate the data that
we received alongside a block announcement. This is done by adding a
cache that caches the last X block announcement data where X is set to
the number of `in_peers` (giving every peer the chance to send us a
different block). This will be required by parachains to ensure that
even peers who are not connected to a collator receive the data
alongside the block announcement to properly validate it and request the
block.

* Review comment

* Bring back the code and add new variant to ensure we don't insert block
announce data when something wasn't checked

* Also use out_peers
2021-01-19 17:01:11 +01:00
Pierre Krieger 8e04515912 Add explicit limits to notifications sizes and adjust yamux buffer size (#7925)
* Add explicit limits to notifications sizes and adjust yamux buffer size

* Docfix

* Tests

* Document these 10 bytes
2021-01-19 11:00:37 +00:00
Pierre Krieger e39ffb5a3c Address review comments of #7916 (#7917) 2021-01-18 16:52:25 +01:00
Pierre Krieger c58a2d9a74 Allow configuring Yamux window size (#7916) 2021-01-18 11:10:47 +01:00
Pierre Krieger 7db15cfb75 Fix not restoring non-poisoned state (#7906) 2021-01-15 12:47:32 +00:00
Pierre Krieger 782fe4a3fb Fix bad debug_assert (#7904) 2021-01-15 11:55:21 +01:00
Max Inden 3927b649cb *: Update to libp2p v0.34.0 (#7888)
* *: Update to libp2p v0.34.0

* client/network: Update bytes, unsigned-varint and asynchronous-codec

* client: Update to prost v0.7
2021-01-15 09:55:42 +00:00
Pierre Krieger 4678da3efb Clean-up pass in network/src/protocol.rs (#7889)
* Remove statistics system

* Remove ContextData struct

* Remove next_request_id

* Some TryFrom nit-picking

* Use constants for peer sets
2021-01-13 10:27:49 +00:00
Guillaume Thiolliere 014e6f03c6 bumpd minor version (#7873) 2021-01-12 09:25:47 +01:00