* fix node-template
Use MultiSignature to maintain compatibility with substrate-node
Reset version to 1
Remove unused const
* fix chain_spec
* line width
* Now construct_runtime must include treasury config so account is created at genesis.
* if it doesn't though it is ok, account will be created when the amount put is more than existential deposit.
* Add SECP256k1/ECDSA support for transaction signing.
* Refactoring and fixes
* Fix for contracts
* Avoid breaking runtime host function
* Build fixes, make subkey work more generaically.
* Fix tests
* Dedpulicate a bit of code, remove unneeded code, docs
* Bump runtime version
* Fix a test and clean up some code.
* Derivation can derive seed.
* Whitespace
* Bump runtime again.
* Update core/primitives/src/crypto.rs
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
* Update core/primitives/src/ecdsa.rs
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
* Fix AppVerify
* Initial draft that compiles
* Extract payment stuff from balances
* Extract multiplier update stuff from system
* Some fixes.
* Update len-fee as well
* some review comments.
* Remove todo
* bump
* async txpool API
* Update core/rpc/src/author/mod.rs
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* Update core/transaction-pool/graph/src/pool.rs
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* Pool -> Pool + ValidatedPool
* removed lost block_on when importing xt from network
* fix grumbles
* alias for future::Executor in rpc
* removed executor from Author RPCs
* Pool + SharedValidatedPool -> Pool
* fix compilation after merge
* another fix
* another fix
* Add some chainspec tests and make sure we validate it.
* Manual implementation of Extension + Forks definitions.
* Move chain spec to separate crate.
* Allow using ChainSpec with extensions.
* Renames.
* Implement Extension derive.
* Implement Extension for Forks.
* Support specifying fork blocks.
* make for_blocks work
* Support forks correctly.
* Add a bunch of docs.
* Make fork blocks optional.
* Add missing docs.
* Fix build.
* Use struct for check_block params.
* Fix tests?
* Clean up.
* always fetch epoch from runtime
* node integration tests don't test light nodes
* give stand-in full node a FULL role
* rejig babe APIs
* introduce next-epoch-descriptor type
* overhaul srml-BABE epoch logic
* ensure VRF outputs end up in the right epoch-randomness
* rewrite `do_initialize` to remove unnecessary loop
* begin accounting for next epoch in epoch function
* slots passes header to epoch_data
* pass slot_number to SlotWorker::epoch_data
* begin extracting epoch-change logic into its own module
* aux methods for block weight
* aux methods for genesis configuration
* comment-out most, refactor header-check pipeline
* mostly flesh out verifier again
* reinstantiate babe BlockImport implementation
* reinstate import-queue instantiation
* reintroduce slot-worker implementation
* reinstate pretty much all the rest
* move fork-choice logic to BlockImport
* fix some, but not all errors
* patch test-runtime
* make is_descendent of slightly more generic
* get skeleton compiling when passing is_descendent_of
* make descendent-of-builder more succinct
* restore ordering of authority_index / slot_number
* start fiddling with tests
* fix warnings
* improve initialization architecture and handle genesis
* tests use correct block-import
* fix BABE tests
* fix some compiler errors
* fix node-cli compilation
* all crates compile
* bump runtime versions and fix some warnings
* tweak fork-tree search implementation
* do backtracking search in fork-tree
* node-cli integration tests now work
* fix broken assumption in test_connectivity
* babe tests fail for the right reasons.
* test genesis epoch logic for epoch_changes
* test that epochs can change between blocks
* First BABE SRML test
* Testing infrastructure for BABE
Also includes a trivial additional test.
* Apply suggestions from code review
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* A little more test progress
* More work on BABE testing
* Try to get the tests working
* Implement `UintAuthorityId`-based test mocks
* Fix compilation errors
* Adjust to upstream changes
* Block numbers are ignored in BABE epoch calculation
* authority_index() should ignore invalid authorities
* Fix compile error
* Add tests that session transitions happen
* Check if BABE produces logs
It currently does not.
* Fix test suite
This was really nasty, due to a type confusion that showed up as an
off-by-1 buffer error.
* Add additional tests
Most of these were derived from the current output, so they are only
useful to guard against regressions.
* Make the tests more readable
Also bump impl_version.
* Fix excessive line width
* Remove unused imports
* Update srml/babe/src/lib.rs
Co-Authored-By: André Silva <andre.beat@gmail.com>
* try to fix imports
* Fix build errors in test suite
* tests did not pass
* Try to get at least one digest to be output
Currently, the code emits either no digests (if I don’t call
`Session::rotate_session()` or two digests (if I do), which is wrong.
* More tests
They still don’t work, but this should help debugging.
* fix silly error
* Don’t even try to compile a broken test
* remove broken check_epoch test and add one for genesis epoch
* Check that the length of the pre-digests is correct
* Bump `impl_version`
* use epoch_for_descendent_of even for genesis
* account for competing block 1s
* finish srml-babe docs
Co-Authored-By: André Silva <andre.beat@gmail.com>
* address grumbles
* Clear up import/export misunderstandings
* Fetch minimum period from runtime
* Remove unnecessary comment
This variable is already fetched from the runtime
in the line below.
* Fix bug in factory
The `best_block_id` stayed the same, it was always the
genesis hash. This resulted in the factory failing after
4096 blocks, since `client/db` discards hashes (in this
case the genesis hash) after 4096 blocks from the database.
* Fix tense in error message
* Improve allocator documentation
* Fix bug in allocator
Under certain circumstances an invalid pointer was
returned: when the `ptr` was calculated as equal
to the `max_heap_size`. This is an invalid pointer
since there is no access allowed after the heap limit.
The way to provoke this was to repeatedly allocate
with sizes which were previously not allocated and
immediately deallocate right afterwards. What this
did was to increment the `bumper` with each allocation,
whilst keeping the `total_size` of the heap `0`.
If this repeated allocation/deallocation scheme resulted
in `max_heap_size == ptr` the `ptr` was still returned.
The allocator only checked if the `total_size` was
still within the `max_heap_size` limits, and not
if the resulting `ptr` was still within the valid
heap region.
This commit introduces a check to validate if the
calculated `ptr` is within the heap.
* Add test for zero byte allocation and document behavior
* Improve code readability by introducing a const
* Fix error message in test
* Apply suggestions from code review
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Fix code review suggestions
* Replace early return with assertion
* Remove test for zero size allocations
* Shorten test code
* Shorten comment
* Make bump() return Result
* Add comment for bump()
* Remove ambiguous comment
* Replace value with const
* Use proof for panic message
* Fix merge
* Add comment regarding minimum allocation size
* Sketch
* Some work on docs.
* Doc improvements.
* More docs.
* Some more docs.
* Yet another comment.
* Bump impl_version.
* Accept the block hash
* Use NumberOrHex
* Update node/rpc/src/contracts.rs
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* Move rpc/primitives
With the *authority-discovery* module an authoritative node makes itself
discoverable and is able to discover other authorities. Once discovered, a node
can directly connect to other authorities instead of multi-hop gossiping
information.
1. **Making itself discoverable**
1. Retrieve its external addresses
2. Adds its network peer id to the addresses
3. Sign the above
4. Put the signature and the addresses on the libp2p Kademlia DHT
2. **Discovering other authorities**
1. Retrieve the current set of authorities
2. Start DHT queries for the ids of the authorities
3. Validate the signatures of the retrieved key value pairs
4. Add the retrieved external addresses as ~reserved~ priority nodes to the
peerset
* node/runtime: Add authority-discovery as session handler
The srml/authority-discovery module implements the OneSessionHandler in
order to keep its authority set in sync. This commit adds the module to
the set of session handlers.
* core/network: Make network worker return Dht events on poll
Instead of network worker implement the Future trait, have it implement
the Stream interface returning Dht events.
For now these events are ignored in build_network_future but will be
used by the core/authority-discovery module in subsequent commits.
* *: Add scaffolding and integration for core/authority-discovery module
* core/authority-discovery: Implement module logic itself
* srml-system checks
* wip
* more modules compiles
* node-runtime checks
* build.sh passes
* include dispatch error in failed event
* revert some unnecessary changes
* refactor based on comments
* more compile error fixes
* avoid unnecessary into
* reorder code
* fixes some tests
* manually implement encode & decode to avoid i8 workaround
* more test fixes
* more fixes
* more error fixes
* Apply suggestions from code review
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* address comments
* test for DispatchError encoding
* tyep alias for democracy
* make error printable
* line width
* fix balances tests
* fix executive test
* fix system tests
* bump version
* ensure consistent method signature
* Apply suggestions from code review
Co-Authored-By: Gavin Wood <github@gavwood.com>
* changes based on review
* Add issue number for TODOs
* fix
* line width
* fix test
* Update core/sr-primitives/src/lib.rs
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Update core/sr-primitives/src/traits.rs
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Update srml/council/src/motions.rs
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Update srml/council/src/motions.rs
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* update based on review
* More concrete macro matching
* fix test build issue
* Update hex-literal dependency version. (#3141)
* Update hex-literal dep version.
* Update lock file.
* Start to rework the new error handling
* More work to get it back compiling
* Start to fix after master merge
* The great transaction error handling refactoring
* Make `decl_error` errors convertible to `&'static str`
* Make srml-executive build again
* Fix `sr-primitives` tests
* More fixes
* Last round of fix ups
* Fix build
* Fix build
* Apply suggestions from code review
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* Rename some stuff
* Fixes after master merge
* Adds `CheckBlockGasLimit` signed extension
* Remove debug stuff
* Fix srml-balances test
* Rename `InvalidIndex` to `CannotLookup`
* Remove weird generic parameters
* Rename function again
* Fix import
* Document the signed extension
* Change from `Into` to `From`
* Update srml/contracts/src/lib.rs
Co-Authored-By: Sergei Pepyakin <sergei@parity.io>
* Fix compilation
* Update srml/contracts/src/lib.rs
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* Update core/sr-primitives/src/transaction_validity.rs
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* Remove unused code
* Fix compilation
* Some cleanups
* Fix compile errors
* Make `TransactionValidity` a `Result`
* Apply suggestions from code review
Co-Authored-By: Gavin Wood <gavin@parity.io>
* Beautify the code a little bit and fix test
* Make `CannotLookup` an inherent error declared by `decl_error!`
* Adds some documentation
* Make `ApplyOutcome` a result
* Up the spec_version
* Apply suggestions from code review
Co-Authored-By: Gavin Wood <gavin@parity.io>
Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com>
* generalize tree_root to remove client.backend dependency
* replace client.backend.blockchain.header with client.header
* move used_state_cache_size into client info
* Create intermediate Setup State. Fixes#1134
* remove client.backend from finality proof
* update node-template
* move memory backend into test helper mode
* move test helper into client
* starting the big refactor, remove unused functions
* apply_finality
* apply_finality
* replacing more .backend from environment with client directly
* remove .backend from grandpa by using traits
* remove .backend from babe
* remove .backend from tests where it is not needed
* remove .backend from tests
* fixing tests
* fixing tests
* fixing more tests
* fixing tests
* fix all forks test
* fix style
* fixing unnecessary allocation
* remove old test.
* fix service docs
* apply suggestion
* minor clean ups
* turns out the test-helper features actually is being used!
* fixing line length.
* fix line length
* minor cleaning
* Apply suggestions from code review
thanks, @Basti
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* address grumbles
* simplify finalize block on client
* move block back into inner function
* Apply suggestions from code review
Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com>
* use as.ref instead of match
* Update core/client/src/backend.rs
Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com>
* 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 😩
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.
* 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.
* Add transaction pool to babe import queue
* Add transaction pool to Babe check header
* Fix tests
* Add tx pool to Aura import_queue
* Fix tests, node-template
* Add comments regarding unused _transaction_pool
* Make tx pool optional in check_header
* node: exit on GRANDPA voter or BABE authoring error
* node: exit process with non-zero return code when service fails
* service: rename infallible task to essential task
* service: revert field name changes
* core: fix service testnet
* Refactor `parse_and_execute`
Adds a new function named `parse_and_prepare`, which prepares the environment and parses the command.
Contrary to `parse_and_execute`, `parse_and_prepare` returns a struct that permis the user to execute the command, as opposed to execute it itself.
`parse_and_execute` has been modified to use `parse_and_prepare` internally.
* Embed dispatch functions directly into run()
After the previous commit, we now have a lot of functions whose only one is to call other functions. And these other functions are called only from one location.
Let's merge these two for clarity.
* Deprecate parse_and_execute and replace it in node and node-template
* Apply suggestions from code review
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Scale trait and move to u32 blocknumbers.
* Fixes
* Cleanups
* Update node/runtime/src/lib.rs
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Fix up some of the factory stuff.
* Update core/sr-primitives/src/traits.rs
Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>
* Move Nonce/Index to u32 (#3361)
* Force a non-borked version of upstream crate
* Line lengths and runtime version bump
* Implement `is_validator` for offchain-workers
* Introduce `--no-validator` flag
* Don't run babe/grandpa/im-online when `--no-validator` is given
* Fixes compilation
* Bump spec version
* Improve error handling in executor
* Add missing extern function
* Revert making error public
* Remove `--no-validator` CLI
* Remove generic from sign()
* Remove mandatory RuntimeGenesis trait req
* Remove requirement from Configuration
* Relax trait bounds of core/cli
* Move method
* The config field is no longer public
* Remove Components from bounds of functions
* Implement DerefMut for LightComponents
* Implement Executor for Full/LightComponents
* Fix bad merge
* Fix forgotten config()
* Fix build