* Allow fallback names for protocols
* Apply suggestions from code review
Co-authored-by: Roman Proskuryakov <humbug@deeptown.org>
* Fix some issues
* Fix compilation after merging master
Co-authored-by: Roman Proskuryakov <humbug@deeptown.org>
* 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>
* 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>
* 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
* 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
* Rework priority groups
* Broken tests fix
* Fix warning causing CI to fail
* [Hack] Try restore backwards-compatibility
* Fix peerset bug
* Doc fixes and clean up
* Error on state mismatch
* Try debug CI
* CI debugging
* [CI debug] Can I please see this line
* Revert "[CI debug] Can I please see this line"
This reverts commit 4b7cf7c1511f579cd818b21d46bd11642dfac5cb.
* Revert "CI debugging"
This reverts commit 9011f1f564b860386dc7dd6ffa9fc34ea7107623.
* Fix error! which isn't actually an error
* Fix Ok() returned when actually Err()
* Tweaks and fixes
* Fix build
* Peerset bugfix
* [Debug] Try outbound GrandPa slots
* Another bugfix
* Revert "[Debug] Try outbound GrandPa slots"
This reverts commit d175b9208c088faad77d9f0ce36ff6f48bd92dd3.
* [Debug] Try outbound GrandPa slots
* Apply suggestions from code review
Co-authored-by: Max Inden <mail@max-inden.de>
* Use consts for hardcoded peersets
* Revert "Try debug CI"
This reverts commit 62c4ad5e79c03d561c714a008022ecac463a597e.
* Renames
* Line widths
* Add doc
Co-authored-by: Max Inden <mail@max-inden.de>
* *: Update to libp2p v0.33.0
* client/network: Consistently track request arrival time
With https://github.com/libp2p/rust-libp2p/pull/1886/ one is guaranteed
to receive either a `ResponseSent` or a `InboundFailure` event for each
received inbound request via `RequestResponseEvent::Message`. Given this
guarantee there is no need to track arrival times in a best-effort
manner and thus there is no need to use a LRU cache for arrival times.
* client/offchain: Adjust to PeerId API changes
* *: Update to libp2p v0.32.0
* Cargo.lock: Update async-tls to 0.10.2
* client/network/request_response: Adjust to new request response events
* client/network/request_response.rs: Clean up silently failing responses
* client/network/discovery: Lazily instantiate mdns
* client/network/discovery: Exclude MdnsWrapper for target_os unknown
* client/network/discovery: Fix indentation
* client/network/request-response: Use LruCache to track pending resp time
* client/network/request_responses: Fix early connection closed error
* client/network/request-response: Replace debug_assert with debug
* client/network/request-response: Fix typo
* client/network/request-response: Don't emit event on send_response fail
* client/network/request-response: Revert waker.wake_by_ref()
* client/network/request-resp: Make duration in InboundRequest optional
* client/network/req-resp: Don't emit two events for busy builder
When a response builder is busy incoming requests are dropped.
Previously this was reported both via a `ResponseFailure::Busy` and a
`ReponseFailure::Network(InboundFailure::Omisssion)` event.
With this commit the former is removed, leaving only the latter in
place.
* Remove necessity to pass ConsensusEngineId when registering notifications protocol
* Line width
* Fix tests protocol name
* Other renames
* Doc update
* Change issue in TODO
Extend `sub_libp2p_kbuckets_num_nodes` Prometheus metric to expose the
number of nodes per bucket per Kademlia instance instead of only per
Kademlia instance.
* client/*: Treat protocol name as str and not [u8]
Notification protocol names are in practice always valid utf8 strings.
Instead of treating them as such in the type system, thus far they were
casted to a [u8] at creation time.
With this commit protocol names are instead treated as valid utf8
strings throughout the codebase and passed as `Cow<'static, str>`
instead of `Cow<'static, [u8]>`. Among other things this eliminates the
need for string casting when logging.
* client/network: Don't allocate when protocol name is borrowed
* Implement request-responses protocols
* Add tests
* Fix sc-cli
* Apply suggestions from code review
Co-authored-by: Max Inden <mail@max-inden.de>
* Fix naming
* Fix other issues
* Other naming fix
* Fix error logging
* Max sizes to u64
* Don't kill connections on refusal to process
* Adjust comment
Co-authored-by: Max Inden <mail@max-inden.de>
* client/network/src/discovery: Adjust to Kademlia API changes
* client/network: Add peers to DHT only if protocols match
With https://github.com/libp2p/rust-libp2p/pull/1628 rust-libp2p allows
manually controlling which peers are inserted into the routing table.
Instead of adding each peer to the routing table automatically, insert
them only if they support the local nodes protocol id (e.g. `dot`)
retrieved via the `identify` behaviour.
For now this works around
https://github.com/libp2p/rust-libp2p/issues/1611. In the future one
might add more requirements. For example one might try to exclude
light-clients.
* Cargo.toml: Remove crates.io patch for libp2p
* client/network/src/behaviour: Adjust to PeerInfo name change
* client/network/src/discovery: Rework Kademlia event matching
* client/network/discovery: Add trace on adding peer to DHT
* client/network/discovery: Retrieve protocol name from kad behaviour
* client/network/discovery: Fix formatting
* client/network: Change DiscoveryBehaviour::add_self_reported signature
* client/network: Document manual insertion strategy
* client/network/discovery: Remove TODO for ignoring DHT address
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
* Add NetworkService::send_notifications
* Doc
* Doc
* API adjustment
* Address concerns
* Make it compile
* Start implementation
* Progress in the implementation
* Change implementation strategy again
* More work before weekend
* Finish changes
* Minor doc fix
* Revert some minor changes
* Apply suggestions from code review
* GroupError -> NotifsHandlerError
* Apply suggestions from code review
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
* state_transition_waker -> close_waker
* Apply suggestions from code review
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
* Finish renames in service.rs
* More renames
* More review suggestsions applied
* More review addressing
* Final change
* 512 -> 2048
Co-authored-by: Roman Borschel <romanb@users.noreply.github.com>
Information retrieved via `DebugInfoBehaviour` is not only used for
debugging purposes, e.g. disconnecting from nodes not responding to
pings, using external addresses retrieved via indentify, ...
In order for the name to reflect the usage of the module this commit
renames it.
* Add metrics about block requests
* Apply suggestions from code review
Co-Authored-By: Max Inden <mail@max-inden.de>
Co-authored-by: Gavin Wood <i@gavwood.com>
Co-authored-by: Max Inden <mail@max-inden.de>
* Turn kbuckets_num_nodes into a GaugeVec
* random_kademlia_queries -> kademlia_random_queries
* kademalia_random_queries_total now a CounterVec
* Add metrics about records store
* Split the Roles bitfield in three
* Forgot to include some changes
* Fix cli test
* More test fixes
* Oh God, merging master broke other tests
* Didn't run the doctests
* Address review
* I'm trying to fix the build blindly because it's taking a good hour to compile on my machine
* Address some review
* Also update the peerset's API to make sense
* Fix peerset tests
* Fix browser node
* client: distinguish between local and network authority
Co-authored-by: André Silva <andre.beat@gmail.com>
* network: Use "one shot" protocol handler.
Add two new `NetworkBehaviour`s, one handling remote block requests
and another one to handle light client requests (both local and from
remote). The change is motivated by the desire to use multiple
substreams of a single connection for different protocols. To achieve
this, libp2p's `OneShotHandler` is used as a protocol handler in each
behaviour. It will open a fresh substream for the duration of the
request and close it afterwards. For block requests, we currently only
handle incoming requests from remote and tests are missing. For light
client handling we support incoming requests from remote and also
ported a substantial amount of functionality over from
`light_dispatch.rs` (including several tests). However the result lacks
in at least two aspects:
(1) We require external updates w.r.t. the best block per peer and
currently nothing updates this information.
(2) We carry a lot of peer-related state around.
Both aspects could be simplified by externalising peer selection and
just requiring a specific peer ID where the request should be sent to.
We still have to maintain some peer related state due to the way
libp2p's swarm and network behaviour work (e.g. we must make sure to
always issue `NetworkBehaviourAction::SendEvent`s to peers we are
connected to, otherwise the actions die a silent death.
Another change implemented here is the use of protocol buffers as the
encoding for network messages. Certain individual fields of messages
are still SCALE encoded. There has been some discussion about this
in another PR (https://github.com/paritytech/substrate/pull/3452), so
far without resolution.
* Uncomment `Behaviour::light_client_request`.
* Add license headers.
* Pause Kademlia if too many connections
* Fix test
* Update client/network/src/discovery.rs
Co-Authored-By: Toralf Wittner <tw@dtex.org>
* Change the limit
Co-authored-by: Toralf Wittner <tw@dtex.org>