* babe: backoff authoring blocks when finality lags
* babe: move backoff authoring params to default constructor
* babe: deduplicate the test a bit
* babe: set backoff constants in service
* babe: use better names for backoff authoring block parameters
* babe: remove last unwrap
* babe: slight style tweak
* babe: fix comment
* slots: move backoff block authorship logic to SimpleSlotWorker
* aura: append SlotInfo in on_slot
* slots: use the correct types for parameters
* slots: fix review comments
* aura: add missing backoff authoring blocks parameters
* slots: add comments for default values
* slots: add additional checks in test
* slots: update implementation for new master
* slots: revert the change to SlotInfo
* Fix review comments
* slots: rework unit tests for backing off claiming slots
* slots: add test for asymptotic behaviour for slot claims
* slots: address review comments
* slots: add test for max_interval
* slots: add assertion for intervals between between claimed slots
* slots: remove rustfmt directive
* slots: another attempt at explaining authoring_rate
* slots: up unfinalized_slack to 50 by default
* slots: add tests for time to reach max_interval
* slots: fix typo in comments
* Apply suggestions from code review
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* slots: additional tweaks to comments and info calls
* slots: rename to BackoffAuthoringOnFinalizedHeadLagging
* slots: make the backing off strategy generic
* Apply suggestions from code review
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
* slots: implement backoff trait for () for simplicity
* slots: move logging inside backing off function to make it more specific
* aura: add missing function parameter
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
The genesis header doesn't have the BABE pre-digest and we insert `0` as
slot number. The slot lenience calculation will return the maximum in
this situation. Besides returning the maximum which is not bad at all,
it also prints some a debug message that can be confusing in the first
moment. To prevent printing this debug message, we now just return early
when we see that the parent block is the genesis block.
* Make consensus `SlotWorker` don't assume a slot is time / duration
This removes the last bit of assumption that a slot is always `time /
duration`. This will be required by parachains where a slot will be the
relay chain block number. Besides this there are also some other drive
by changes. One more notable is that `on_slot` now returns a
`SlotResult` that holds the block and a potential storage proof.
To simplify the implementation and usage of the `SimpleSlotWorker` the
`SlotWorker` trait is now implemented for each type that implements
`SimpleSlotWorker`.
* Update client/consensus/slots/src/lib.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Update client/consensus/slots/src/lib.rs
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
* Initial draft
* Add an iterator that helps us get most items
* Revert changes to grandpa
* Change fields to just be the grandpa authority set and babe epoch changes
* Only use the fields we need from the shared authority set
* Switch to RPC call
* Revert "Only use the fields we need from the shared authority set"
This reverts commit 6ede87b0c5fe53f251d7cb45951006a7dc8f9b83.
* Add babe_finalized_block_weight from `ashley-improve-sync-state-WIP-loading`
* Fix rpc test
* Move sync state rpc stuff into sc-sync-state-rpc
* Remove as_json_value and remove unwraps from sc-sync-state-rpc
* Add clone_inner to SharedAuthoritySet
* Asyncify sign_with
* Asyncify generate/get keys
* Complete BareCryptoStore asyncification
* Cleanup
* Rebase
* Add Proxy
* Inject keystore proxy into extensions
* Implement some methods
* Await on send
* Cleanup
* Send result over the oneshot channel sender
* Process one future at a time
* Fix cargo stuff
* Asyncify sr25519_vrf_sign
* Cherry-pick and fix changes
* Introduce SyncCryptoStore
* SQUASH ME WITH THE first commit
* Implement into SyncCryptoStore
* Implement BareCryptoStore for KeystoreProxyAdapter
* authority-discovery
* AURA
* BABE
* finality-grandpa
* offchain-workers
* benchmarking-cli
* sp_io
* test-utils
* application-crypto
* Extensions and RPC
* Client Service
* bin
* Update cargo.lock
* Implement BareCryptoStore on proxy directly
* Simplify proxy setup
* Fix authority-discover
* Pass async keystore to authority-discovery
* Fix tests
* Use async keystore in authority-discovery
* Rename BareCryptoStore to CryptoStore
* WIP
* Remote mutable borrow in CryptoStore trait
* Implement Keystore with backends
* Remove Proxy implementation
* Fix service builder and keystore user-crates
* Fix tests
* Rework authority-discovery after refactoring
* futures::select!
* Fix multiple mut borrows in authority-discovery
* Merge fixes
* Require sync
* Restore Cargo.lock
* PR feedback - round 1
* Remove Keystore and use LocalKeystore directly
Also renamed KeystoreParams to KeystoreContainer
* Join
* Remove sync requirement
* Fix keystore tests
* Fix tests
* client/authority-discovery: Remove event stream dynamic dispatching
With authority-discovery moving from a poll based future to an `async`
future Rust has difficulties propagating the `Sync` trade through the
generated state machine.
Instead of using dynamic dispatching, use a trait parameter to specify
the DHT event stream.
* Make it compile
* Fix submit_transaction
* Fix block_on issue
* Use await in async context
* Fix manual seal keystore
* Fix authoring_blocks test
* fix aura authoring_blocks
* Try to fix tests for auth-discovery
* client/authority-discovery: Fix lookup_throttling test
* client/authority-discovery: Fix triggers_dht_get_query test
* Fix epoch_authorship_works
* client/authority-discovery: Remove timing assumption in unit test
* client/authority-discovery: Revert changes to termination test
* PR feedback
* Remove deadcode and mark test code
* Fix test_sync
* Use the correct keyring type
* Return when from_service stream is closed
* Convert SyncCryptoStore to a trait
* Fix line width
* Fix line width - take 2
* Remove unused import
* Fix keystore instantiation
* PR feedback
* Remove KeystoreContainer
* Revert "Remove KeystoreContainer"
This reverts commit ea4a37c7d74f9772b93d974e05e4498af6192730.
* Take a ref of keystore
* Move keystore to dev-dependencies
* Address some PR feedback
* Missed one
* Pass keystore reference - take 2
* client/finality-grandpa: Use `Arc<dyn CryptoStore>` instead of SyncXXX
Instead of using `SyncCryptoStorePtr` within `client/finality-grandpa`,
which is a type alias for `Arc<dyn SyncCryptoStore>`, use `Arc<dyn
CryptoStore>`. Benefits are:
1. No additional mental overhead of a `SyncCryptoStorePtr`.
2. Ability for new code to use the asynchronous methods of `CryptoStore`
instead of the synchronous `SyncCryptoStore` methods within
`client/finality-granpa` without the need for larger refactorings.
Note: This commit uses `Arc<dyn CryptoStore>` instead of
`CryptoStorePtr`, as I find the type signature more descriptive. This is
subjective and in no way required.
* Remove SyncCryptoStorePtr
* Remove KeystoreContainer & SyncCryptoStorePtr
* PR feedback
* *: Use CryptoStorePtr whereever possible
* *: Define SyncCryptoStore as a pure extension trait of CryptoStore
* Follow up to SyncCryptoStore extension trait
* Adjust docs for SyncCryptoStore as Ben suggested
* Cleanup unnecessary requirements
* sp-keystore
* Use async_std::task::block_on in keystore
* Fix block_on std requirement
* Update primitives/keystore/src/lib.rs
Co-authored-by: Max Inden <mail@max-inden.de>
* Fix wasm build
* Remove unused var
* Fix wasm compilation - take 2
* Revert async-std in keystore
* Fix indent
* Fix version and copyright
* Cleanup feature = "std"
* Auth Discovery: Ignore if from_service is cloed
* Max's suggestion
* Revert async-std usage for block_on
* Address PR feedback
* Fix example offchain worker build
* Address PR feedback
* Update Cargo.lock
* Move unused methods to test helper functions
* Restore accidentally deleted cargo.lock files
* Fix unused imports
Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Revamp npos-elections and implement phragmms
* Update primitives/npos-elections/src/phragmms.rs
* Fix build
* Some review grumbles
* Add some stuff for remote testing
* fix some of the grumbles.
* Add remote testing stuff.
* Cleanup
* fix docs
* Update primitives/arithmetic/src/rational.rs
Co-authored-by: Dan Forbes <dan@danforbes.dev>
* Small config change
* Better handling of approval_stake == 0
* Final touhces.
* Clean fuzzer a bit
* Clean fuzzer a bit
* Update primitives/npos-elections/src/balancing.rs
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Fix fuzzer.
* Better api for normalize
* Add noramlize_up
* A large number of small fixes.
* make it merge ready
* Fix warns
* bump
* Fix fuzzers a bit.
* Fix warns as well.
* Fix more tests.
Co-authored-by: Dan Forbes <dan@danforbes.dev>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
* Re-generate READMEs to fix doc links; set readme field in package manifests
* Re-generate READMEs to fix doc links; set readme field in package manifests
* Re-generate READMEs to fix doc links; set readme field in package manifests
* Re-generate READMEs to fix doc links; set readme field in package manifests
* Revert stuff that shouldn't have been committed
* Revert stuff that shouldn't have been committed
* Fix parent relative link generation
* Manually remove this incorrect link for now.
* init_logger: switch from log-based to tracing-based and add compatibility layer
* Move tracing profiling subscriber related config realization
* sp-tracing: change profiling to be a layer instead of a subscriber
* Enable profiling layer in cli
* Change all test env_logger init to sp_tracing::try_init_simple
* Remove all local env_logger dependency
* Add missing tracing-subscriber dependency
* frame-sudo: fix tests
* frame-support: fix tests
* Fix frame/pallet and executor tests
* Fix the remaining tests
* Use subscriber's try_init as recommended by @davidbarsky
* Be explict that the tracing-log feature is needed
* Set subscriber writer to stderr
* Shorter line width
* Update cargo lock tracing version
* Fix sc_tracing crate compile
* Fix sc_authority_discovery crate test
* unremove default-features
* Leave enabled to default true
* Warn if global default cannot be set
* Fix unused import
* Remove unused PROXY_TARGET
* Change all reference from rc5 to rc6
* Change all reference of rc2 to rc6
* Fix styling
* Fix typo
* make logger init error'ing
* re-fixing the test issue
Co-authored-by: Benjamin Kampmann <ben@parity.io>
* Bump version
* update test-utils crates to be ready for publishing
* adding changelog
* Adding automaticly generated READMEs
* fixing versions
* another version mishap
* pow: check can_author_with before calling check_inherents
* babe: check can_author_with before calling check_inherents
* aura: check can_author_with before calling check_inherents
* Fix node and node template compile
* Add missing comma
* Put each parameter on its own line
* Add debug print
* Fix line width too long
* Fix pow line width issue
* BabeWorker -> BabeSlotWorker
* SlotWorker::notify_slot: similar to claim_slot, but called no matter authoring
* Wrap the future with a new struct BabeWorker
* Add type definition slot_notification_sinks
* Function slot_notification_streams for the receiver side
* Get a handle of slot_notification_sinks in BabeSlotWorker
* Implement notify_slot
* Switch to use bounded mpsc
* Do not drop the sink when channel is full
Only skip sending the message and emit a warning, because it is recoverable.
* Fix future type bounds
* Add must_use and sink type alias
* slots: create primitives crate for consensus slots
* offences: add method to check if an offence is unknown
* babe: initial equivocation reporting implementation
* babe: organize imports
* babe: working equivocation reporting
* babe: add slot number to equivocation proof
* session: move duplicate traits to session primitives
* babe: move equivocation stuff to its own file
* offences: fix test
* session: don't have primitives depend on frame_support
* babe: use opaque type for key owner proof
* babe: cleanup client equivocation reporting
* babe: cleanup equivocation code in pallet
* babe: allow sending signed equivocation reports
* node: fix compilation
* fix test compilation
* babe: return bool on check_equivocation_proof
* babe: add test for equivocation reporting
* babe: add more tests
* babe: add test for validate unsigned
* babe: take slot number in generate_key_ownership_proof API
* babe: add benchmark for equivocation proof checking
* session: add benchmark for membership proof checking
* offences: fix babe benchmark
* babe: add weights based on benchmark results
* babe: adjust weights after benchmarking on reference hardware
* babe: reorder checks in check_and_report_equivocation
* Introduce trait
* Implement VRFSigner in keystore
* Use vrf_sign from keystore
* Convert output to VRFInOut
* Simplify conversion
* vrf_sign secondary slot using keystore
* Fix RPC call to claim_slot
* Use Public instead of Pair
* Check primary threshold in signer
* Fix interface to return error
* Move vrf_sign to BareCryptoStore
* Fix authorship_works test
* Fix BABE logic leaks
* Acquire a read lock once
* Also fix RPC acquiring the read lock once
* Implement a generic way to construct VRF Transcript
* Use make_transcript_data to call sr25519_vrf_sign
* Make sure VRFTranscriptData is serializable
* Cleanup
* Move VRF to it's own module
* Implement & test VRF signing in testing module
* Remove leftover
* Fix feature requirements
* Revert removing vec macro
* Drop keystore pointer to prevent deadlock
* Nitpicks
* Add test to make sure make_transcript works
* Fix mismatch in VRF transcript
* Add a test to verify transcripts match in babe
* Return VRFOutput and VRFProof from keystore
* Seperate out the complexity in ServiceBuilder::build_common into seperate functions
* Fix line widths
* Move some functions to their respective crates
* Bump jsonrpc pubsub, core, http, and ws
Right now these are the packages which _need_ to be updated
so I can just the latest `jsonrpc-pubsub` code. Once a release
it cut upstream the rest of the dependencies should be updated
as well.
* Use jsonrpc-pubsub's SubscriptionManager
This places sc-rpc-api::Subscriptions
* Bump jsonrpc-core outside of sc-rpc-*
* Update client/rpc tests
Right now one of the `author` tests is failing, I
need to think a bit about how best to fix it.
* Remove Subscriptions manager
There's no need for this implementation since we're
using the one from `jsonrpc-pubsub` now
* Fix author RPC test
This test used to check for a numerial subscription ID,
whereas now it uses a string based ID which is the default
provided by `jsonrpc-pubsub`'s subscription manager.
* Remove unused NumericIdProvider
* Add missing bracket
Removed one too many with that last one, lol
* Bump `jsonrpc` to v14.2
There's an exception though. `jsonrpc-derive` cannot be bumped
past v14.0.5 just yet since it has a dependency on `quote` pinned
to v1.0.1. This means that at the moment it won't build on Substrate
since it's using v1.0.3.
* Track `jsonrpc-derive` master branch
* Bump `quote` version to v1.0.6
* Bump `jsonrpc-derive` to v14.2.1
This includes support for `quote` v1.0.6
* Use exact version for jsonrpc crates
Doing this to make sure any updates in jsonrpc don't
accidently trickle down to Polkadot.
Co-authored-by: André Silva <andre.beat@gmail.com>
* Bump jsonrpc pubsub, core, http, and ws
Right now these are the packages which _need_ to be updated
so I can just the latest `jsonrpc-pubsub` code. Once a release
it cut upstream the rest of the dependencies should be updated
as well.
* Use jsonrpc-pubsub's SubscriptionManager
This places sc-rpc-api::Subscriptions
* Bump jsonrpc-core outside of sc-rpc-*
* Update client/rpc tests
Right now one of the `author` tests is failing, I
need to think a bit about how best to fix it.
* Remove Subscriptions manager
There's no need for this implementation since we're
using the one from `jsonrpc-pubsub` now
* Fix author RPC test
This test used to check for a numerial subscription ID,
whereas now it uses a string based ID which is the default
provided by `jsonrpc-pubsub`'s subscription manager.
* Remove unused NumericIdProvider
* Add missing bracket
Removed one too many with that last one, lol
* Bump `jsonrpc` to v14.2
There's an exception though. `jsonrpc-derive` cannot be bumped
past v14.0.5 just yet since it has a dependency on `quote` pinned
to v1.0.1. This means that at the moment it won't build on Substrate
since it's using v1.0.3.
* Track `jsonrpc-derive` master branch
* Bump `quote` version to v1.0.6
* Bump `jsonrpc-derive` to v14.2.1
This includes support for `quote` v1.0.6
* Make `Proposer` consume its reference on `propose`
A proposer must be created per new round, so it makes sense to have the
proposer consume its own reference.
* Remove `ProposerInner`
* Add derive_more to sp_core
* Convert Vec to Signature
* Use sign_with in AURA and BABE
* Signing errors
* Update slots to return consensus result
* Fix use
* Clone public key
* Match block_params
* WIP
* Use to_public_crypto_pair
* Pass public key only to block import params
* Address PR review
* Fix consensus RPC
* Fix babe tests
* adjust uses
* Fix line widths
* babe: don't repeatedly lookup keys in authorship rpc function
Expose a new function `claim_slot_using_keypars` in Babe so that the `babe_epochAuthorship` can
lookup authorship for all slots in the epoch without repeatedly looking up keys in the keystore.
Time to run the `babe_epochAuthorship` RPC call goes from 7s to 25ms on a local dev chain on my
machine.
* babe: pass reference to slice instead of ref to Vec
* babe: fix bunch of clippy warnings
* Expose that `BasicQueue` expects blocking spawn
Up to now `BasicQueue` expected a closure that to spawn a `Future`.
This was expected to be a closure that spawns a blocking future.
However, this wasn't documented anywhere. This pr introduces a new trait
`SpawnBlocking` that exposes this requirement to the outside.
* Feedback