* More doc fixes.
* Minor refactorings in the process of #2177
By having everything peer set related depend directly on the enum the
code becomes more clear and it is also straight forward to add more
peersets/protocols as the compiler will complain if you forget to
implement parts of it.
* Add peer set infos on startup properly
For feature real_overseer.
+ Fixes from review. Thanks @coriolinus and @ordian!
* More structure in network-bridge
Some changes, which would have helped me in groking the code faster.
Entry points/public types more to the top. Factored out implementation
in their own files, to clear up the top-level view.
* Get rid of local ProtocolName type definition.
Does not add much at this level.
* Fix tests + import cleanup.
* Make spaces tabs.
* Clarify what correct parameters to send_message are
* Be more less vague in docs of send_message.
* Apply suggestions from code review
Extend copyright on new files to 2021 as well.
Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: Andronik Ordian <write@reusable.software>
* scheduler: handle re-scheduling around finalization correctly
* also make sure parathreads get cleaned
* run scheduling in finalization
* Remove stray println!
* Update the schedule call site in inclusion inherent
* Clarify subtlety around SessionStartBlock
* Remove double semi-colon
* reschedule prior to `availability_cores` and in on-initialize
* improve docs
* fix line
* more doc reformat
* remove unneeded call
* avoid unnecessary scheduling on initialize
* split `clear` and `schedule
* Update runtime/parachains/src/scheduler.rs
Co-authored-by: Sergei Shulepov <sergei@parity.io>
Co-authored-by: Sergei Shulepov <sergei@parity.io>
* Drive by fixes
The visibility modifiers are remnants of the previous structure where
HRMP wasn't a standalone module, by rather a submodule of the router
module.
* Add Currency assoc type to Config
This would allow us to reserve balance for deposits. This commit also
integrates the HRMP module in rococo, test-runtime and mocks to use the
balances pallet.
* Fix a bug that doesn't increment the age
In case the request is not confirmed, the age would be incremented but
not persisted.
* Fix cleaning the indexes
Before that change, the cleaning of the channel indexes was wrong, because it
naively removed entire rows that was pertaining to the para we delete.
This approach is flawed because it doesn't account for the rows that are
pertaining to other paras that contain the outgoing one.
This clearly violates the invariant imposed on the indexes, that all
the index rows must contain alive paras, but apart from that it also
lead to the situation where ingress index would contain the a different
set of channels that an egress have.
* Reserve currency for opening the channels
Note the ugly `unique_saturated_into` calls. The reason for them is the
currency trait accepts and defines the `Balance` associated type and the
deposit values are coming from the `HostConfiguration` where they are
defined using the `Balance`.
I figured that parameterising `HostConfiguration` would be annoying. On
the other hand, I don't expect these `unique_saturated_into` calls to
give us problems since it seems to be a reasonable assumption that this
module will be instantiated within a runtime where the Currency provided
will have a Balance that matches the one used in the configuration.
* Tests: Adapt `run_to_block` so that it submits a proper config
* Tests: exercise the deposit logic
* CI: add rococo build and conteinerization
* CI: overhaul rules
* CI: two new conditional jobs to build rococo, CI overhaul, npm security fix
* CI: remove web-wasm publishing
* Rename crowdfund -> crowdloan
* allow contribution on behalf of another user
* starting some benchmarks
* optimization: use append api
* Use on_initialize instead of on_finalize
* More benchmarks
* try to implement partial child storage removal
* partial dissolve test
* onboard benchmark
* begin retirement
* on_initialize
* remove _ { }
* Revert "allow contribution on behalf of another user"
This reverts commit b7dd7d1ec751495cee3ddb57133a13c390b020e5.
* finish undo of "allow contribution on behalf of another user"
* Allow any user to trigger withdraw on closed crowdloan
* use transfer instead of withdraw/create pattern
* unused warning
* Update runtime/common/src/crowdloan.rs
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
* dont need to assign to empty variable
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
* subsystems have an unbounded channel to the overseer
* Update node/overseer/src/lib.rs
Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
* bump Cargo.lock
Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
* Do not send empty view updates to peers
It happened that we send empty view updates to our peers, because we
only updated our finalized block. This could lead to situations where we
overwhelmed sub systems with too many messages. On Rococo this lead to
constant restarts of our nodes, because some node apparently was
finalizing a lot of blocks.
To prevent this, the pr is doing the following:
1. If a peer sends us an empty view, we report this peer and decrease it
reputation.
2. We ensure that we only send a view update when the `heads` changed
and not only the `finalized_number`.
3. We do not send empty `ActiveLeavesUpdates` from the overseer, as this
makes no sense to send these empty updates. If some subsystem is relying
on the finalized block, it needs to listen for the overseer signal.
* Update node/network/bridge/src/lib.rs
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* Don't work if they're are no added heads
* Fix test
* Ahhh
* More fixes
Co-authored-by: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
* Fuse receive stream in Context
* Revert "Fuse receive stream in Context"
This reverts commit ddd26fa98f0ca1afbc22064e93010e4193a058b2.
* Exit on node shutdown from av-store loop
* Filter only context error
* Store all chunks and in a single transaction
* Adds chunks LRU to store
* Add pruning records metrics
* Use honest cache instead of LRU
* Remove unnecessary optional cache
* Fix review nits that are fixable
* Companion PR for refactoring priority groups
* Fix non reserved node
* Try fix tests
* Missing import
* Fix warning
* Change protocols order
* Fix test
* Renames
* Update syn dependency to make it compile again after merging master
* "Update Substrate"
Co-authored-by: parity-processbot <>
* add timing setup to OverseerSubsystemContext
* figure out how to initialize the rng
* attach a timer to a portion of the messages traveling to the Overseer
This timer only exists / logs a fraction of the time (configurable
by `MESSAGE_TIMER_METRIC_CAPTURE_RATE`). When it exists, it tracks
the span between the `OverSubsystemContext` receiving the message
and its receipt in `Overseer::run`.
* propagate message timing to the start of route_message
This should be more accurate; it ensures that the timer runs
at least as long as that function. As `route_message` is async,
it may not actually run for some time after it is called (or ever).
* fix failing test
* rand_chacha apparently implicitly has getrandom feature
* change rng initialization
The previous impl using `from_entropy` depends on the `getrandom`
crate, which uses the system entropy source, and which does not
work on `wasm32-unknown-unknown` because it wants to fall back to
a JS implementation which we can't assume exists.
This impl depends only on `rand::thread_rng`, which has no documentation
stating that it's similarly limited.
* remove randomness in favor of a simpler 1 of N procedure
This deserves a bit of explanation, as the motivating issue explicitly
requested randomness. In short, it's hard to get randomness to compile
for `wasm32-unknown-unknown` because that is explicitly intended to be
as deterministic as practical. Additionally, even though it would never
be used for consensus purposes, it still felt offputting to intentionally
introduce randomness into a node's operations. Except, it wasn't really
random, either: it was a deterministic PRNG varying only in its state,
and getting the state to work right for that target would have required
initializing from a constant.
Given that it was a deterministic sequence anyway, it seemed much simpler
and more explicit to simply select one of each N messages instead of
attempting any kind of realistic randomness.
* reinstate randomness for better statistical properties
This partially reverts commit 0ab8594c328b3f9ce1f696fe405556d4000630e9.
`oorandom` is much lighter than the previous `rand`-based implementation,
which makes this easier to work with.
This implementation gives each subsystem and each child RNG a distinct
increment, which should ensure they produce distinct streams of values.
* don't modify inherent data on heavy block
* write up current thinking on block weight detection
* extract inherent inclusion check into its own function
* put heavy block check into runtime
* the `inclusion` inherent call is Operational, not Mandatory
This resolves a lot of the trickiness about this issue, because
we no longer need to override or supplant any existing proposer
logic; the existing logic should exhibit these behaviors:
- the `inclusion` inherent is prioritized over standard transactions
- but if it's too heavy, i.e. in case of runtime upgrade, it'll be
dropped in favor of that.
It is my belief that allowing the proposer to just not include
this data won't have any adverse effects: it's equivalent to replacing
them with empty versions of themselves, which the `ProvideInherent`
impl already does.
* Revert "the `inclusion` inherent call is Operational, not Mandatory"
This reverts commit e58858d109b18b84e7af3ac47981c6900b2d9a3e.
* Revert "write up current thinking on block weight detection"
This reverts commit fd587b80c46761b2a2b62448193348237863f99f.
* Revert "don't modify inherent data on heavy block"
This reverts commit 38299d3c23e9efb5a354d8cfa658e62a5c8c7ddf.
* add backed candidate block weight assumption to configuration
* Limit backed candidates according to a candidate weight heuristic.
This approach replaces making the inclusion inherent non-mandatory.
It's still not ideal in that we have to configure a heuristic for
how much each backed candidate 'weighs', instead of directly
measuring it somehow.
This approach also never truncates the signed bitfields. The
rationale for that depends on some assumptions:
- processing the signed bitfields is cheap compared to the
backed candidates
- it is beneficial to the progress of the relay chain
to update the signed bitfields even if not all backed candidates
are updated
* simplify limit_backed_candidates and weight assumption
* don't trust the provisioner to fairly distribute candidates
* use saturating subtraction
* empty commit to restart ci
* use new mechanism for getting max block weight
* apply weight refunds to the inclusion inherent
This makes some assumptions about fundamental weights, which are
encapsulated as constants. From there, it lets Substrate know
what the actual computed weight of the inherent is.
* use a correct fixed weight for the inclusion inherent
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* use dynamic inclusion weight so we reduce calculated weight when excluding candidates
* don't double-count this intrinsic's weight in the block weight
* add unit tests of fn limit_backed_candidates
* add tests that the inclusion inherent's weight correctly updates
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
* Add one Jaeger span per relay parent
This adds one Jaeger span per relay parent, instead of always creating
new spans per relay parent. This should improve the UI view, because
subsystems are now grouped below one common span.
* Fix doc tests
* Replace `PerLeaveSpan` to `PerLeafSpan`
* More renaming
* Moare
* Update node/subsystem/src/lib.rs
Co-authored-by: Andronik Ordian <write@reusable.software>
* Skip the spans
* Increase `spec_version`
Co-authored-by: Andronik Ordian <write@reusable.software>
* Add well_known_keys
* Reorder HrmpChannel and HostConfiguration members
* abridged versions and well known keys tests
* Add some comments
* Add a note on generation of the prefixes
and other magic values
* Recommend accessing the well known values through abridged structs
* Cont.: Implement the state root obtaining during inclusion
During inclusion now we obtain the storage root by passing it through
the inclusion_inherent.
* Fix tests
* Bump rococo spec version
* Reorder the parent header into the end
of the inclusion inherent.
When the parent header is in the beginning, it shifts the other two
fields, so that a previous version won't be able to decode that. If
we put the parent header in the end, the other two fields will stay
at their positions, thus make it possible to decode with the previous
version.
That allows us to perform upgrade of rococo runtime without needing of
simultanuous upgrade of nodes and runtime, or restart of the network.
* Squash a stray tab