* Move Service::new to a macro
* Move function calls to macros
* Extract offchain_workers and start_rpc in separate function
In follow-up commits, we want to be able to directly call maintain_transaction_pool, offchain_workers, and start_rpc, without having to implement the Components trait.
This commit is a preliminary step: we extract the code to freestanding functions.
* Introduce an AbstractService trait
* Introduce NewService as an implementation detail of Service
* Implement traits on NewService instead
Instead of implementing AbstractService, Future, and Executor on Service, we implement them on NewService instead.
The implementations of AbstractService, Future, and Executor on Service still exist, but they just wrap to the respective implementations for NewService.
* Move components creation back to macro invocation
Instead of having multiple $build_ parameters passed to the macro, let's group them all into one.
This change is necessary for the follow-up commits, because we are going to call new_impl! only after all the components have already been built.
* Add a $block parameter to new_impl
This makes it possible to be explicit as what the generic parameter of the NewServiceis, without relying on type inference.
* Introduce the ServiceBuilder struct
Introduces a new builder-like ServiceBuilder struct that creates a NewService.
* Macro-ify import_blocks, export_blocks and revert_chain
Similar to the introduction of new_impl!, we extract the actual code into a macro, letting us get rid of the Components and Factory traits
* Add export_blocks, import_blocks and revert_chain methods on ServiceBuilder
Can be used as a replacement for the chain_ops::* methods
* Add run_with_builder
Instead of just run, adds run_with_builder to ParseAndPrepareExport/Import/Revert. This lets you run these operations with a ServiceBuilder instead of a ServiceFactory.
* Transition node and node-template to ServiceBuilder
* Transition transaction-factory to the new service factory
This is technically a breaking change, but the transaction-factory crate is only ever used from within substrate-node, which this commit updates as well.
* Remove old service factory
* Adjust the AbstractService trait to be more usable
We slightly change the trait bounds in order to make all the methods usable.
* Make substrate-service-test compile
* Fix the node-cli tests
* Remove the old API
* Remove the components module
* Fix indentation on chain_ops
* Line widths
* Fix bad line widths commit
* Line widths again 🤦
* Fix the sync test
* Apply suggestions from code review
Co-Authored-By: Gavin Wood <i@gavwood.com>
* Address some concerns
* Remove TelemetryOnConnect
* Remove informant::start
* Update jsonrpc
* Rename factory to builder
* Line widths 😩
* introduce some type aliases for round and set-id
* overhaul session "changed" flag and document better
* do_initialize in BABE when getting new session
* grandpa module tracks set IDs
* update runtime versions
* doc comment -> comment
* Include docs fixes from Gav
Co-Authored-By: Gavin Wood <gavin@parity.io>
* some more review changes
* fix srml-grandpa compilation
* Add ability to destroy a contract in the overlay.
* Don't allow contracts to be destroyed in recursive execution.
* Tests for contract self-destruction.
* Don't allow constructor to exit with insufficient balance.
* Remove dead code.
* Bump node runtime spec version.
This version fixes an issue with lifetime elision which causes
compilation to fail on recent rustc versions (e.g. 1.39.0-nightly
(bea0372a1 2019-08-20)).
See https://github.com/paritytech/soketto/pull/1 for more information.
In order to have authorities (validators) discover each other, they need
to publish their public addresses by their ip address on the Kademlia
Dht indexed by their public key. This payload needs to be signed by a
key identifying them as a valid authority.
Code inside `/core` does not know the current set of authorities nor
can it assume what kind of cryptography primitives are currently in use.
Instead it can retrieve its public key and the current set of
authorities from the runtime and have it sign and verify Dht payloads.
This commit enables code in `/core` to do so by introducing a srml
module and runtime api to:
1. Retrieve own public key.
2. Retrieve public keys of current authority set.
3. Sign a Dht payload.
4. Verify a Dht payload.
This commit makes the logic from the previous commit
(`core/consensus/common/primitives.ConsensusApi`)
cf80af9255 obsolete and thus removes it.
* value range in blockchain cache
* revert me (testing for spurious failure)
* Revert "revert me (testing for spurious failure)"
This reverts commit 21a4a3cf5ee14e003541b779c41351e4f5e1122a.
* Introduce srml/scored-pool
* Bump impl_version
* Apply suggestions from code review
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Remove unnecessary pub use
* Remove unnecessary import
* Adapt to InitializeMembers
* Bump impl_version
* Implement remarks (shortens code)
* Improve complexity of score()
Search and remove and search again for the
new spot and insert then => O(2LogN).
* Get rid of a clone()
* Reduce complexity of issue_candidacy()
* Add CandidateScored event + Improve comments
* Fix naming
* Use Lookup instead of AccountId as param
* Use set_members_sorted instead of computing diff
* Remove function which is only used during genesis
* Get rid of rev() by changing sort order of Pool
* Rename issue_candidacy to submit_candidacy
* Shorten code
* Remove find_in_pool() and have transactor submit index
* Remove unnecessary dependency
* Improve error messages
* Improve naming
* Improve comments
* Make code clearer wrt which receiver to invoke
* Adapt to new system trait
* Refactor to request CandidateDeposit only once
* Refactor to request Pool only once
* Improve structure and comments
* client: don't import blocks that revert finality
* client: test import of blocks that revert finality
* client: replace tempdir with tempfile in test
* Remove offline slashing logic from staking.
* Initial version of reworked offence module, can report offences
* Clean up staking example.
* Commit SlashingOffence
* Force new era on slash.
* Add offenders in the SlashingOffence trait.
* Introduce the ReportOffence trait.
* Rename `Offence`.
* Add on_before_session_ending handler.
* Move offence related stuff under sr-primitives.
* Fix cargo check.
* Import new im-online implementation.
* Adding validator count to historical session storage as it's needed for slash calculations
* Add a comment about offence.
* Add BabeEquivocationOffence
* GrandpaEquivocationOffence
* slash_fraction and fix
* current_era_start_session_index
* UnresponsivnessOffence
* Finalise OnOffenceHandler traits, and stub impl for staking.
* slash_fraction doesn't really need &self
* Note that offenders count is greater than 0
* Add a test to ensure that I got the math right
* Use FullIdentification in offences.
* Use FullIndentification.
* Hook up the offences module.
* Report unresponsive validators
* Make sure eras have the same length.
* Slashing and rewards.
* Fix compilation.
* Distribute rewards.
* Supply validators_count
* Use identificationTuple in Unresponsivness report
* Fix merge.
* Make sure we don't slash if amount is zero.
* We don't return an error from report_offence anymo
* We actually can use vec!
* Prevent division by zero if the reporters is empty
* offence_forces_new_era/nominators_also_get_slashed
* advance_session
* Fix tests.
* Update srml/staking/src/lib.rs
Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>
* slashing_performed_according_exposure
* Check that reporters receive their slice.
* Small clean-up.
* invulnerables_are_not_slashed
* Minor clean ups.
* Improve docs.
* dont_slash_if_fraction_is_zero
* Remove session dependency from offences.
* Introduce sr-staking-primitives
* Move offence under sr_staking_primitives
* rename session_index
* Resolves todos re using SessionIndex
* Fix staking tests.
* Properly scale denominator.
* Fix UnresponsivnessOffence
* Fix compilation.
* Tests for offences.
* Clean offences tests.
* Fix staking doc test.
* Bump spec version
* Fix aura tests.
* Fix node_executor
* Deposit an event on offence.
* Fix compilation of node-runtime
* Remove aura slashing logic.
* Remove HandleReport
* Update docs for timeslot.
* rename with_on_offence_fractions
* Add should_properly_count_offences
* Replace ValidatorIdByIndex with CurrentElectedSet
ValidatorIdByIndex was querying the current_elected set in each call, doing loading (even though its from cache), deserializing and cloning of element.
Instead of this it is more efficient to use `CurrentElectedSet`. As a small bonus, the invariant became a little bit easier: now we just rely on the fact that `keys` and `current_elected` set are of the same length rather than relying on the fact that `validator_id_by_index` would work similar to `<[T]>::get`.
* Clarify babe equivocation
* Fix offences.
* Rename validators_count to validator_set_count
* Fix squaring.
* Update core/sr-staking-primitives/src/offence.rs
Co-Authored-By: Gavin Wood <gavin@parity.io>
* Docs for CurrentElectedSet.
* Don't punish only invulnerables
* Use `get/insert` instead of `mutate`.
* Fix compilation
* Update core/sr-staking-primitives/src/offence.rs
Co-Authored-By: Gavin Wood <gavin@parity.io>
* Update srml/offences/src/lib.rs
Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>
* Update srml/im-online/src/lib.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Update srml/im-online/src/lib.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Update srml/im-online/src/lib.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Update srml/babe/src/lib.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Update core/sr-staking-primitives/src/offence.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Update core/sr-staking-primitives/src/offence.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Update core/sr-staking-primitives/src/offence.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Update core/sr-staking-primitives/src/offence.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Update core/sr-staking-primitives/src/offence.rs
Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>
* Add aura todo.
* Allow multiple reports for single offence report.
* Fix slash_fraction calculation.
* Fix typos.
* Fix compilation and tests.
* Fix staking tests.
* Update srml/im-online/src/lib.rs
Co-Authored-By: Logan Saether <x@logansaether.com>
* Fix doc on time_slot
* Allow slashing only on current era (#3411)
* only slash in current era
* prune journal for last era
* comment own_slash
* emit an event when old slashing events are discarded
* Pave the way for pruning
* Address issues.
* Try to refactor collect_offence_reports
* Other fixes.
* More fixes.