Commit Graph

1152 Commits

Author SHA1 Message Date
Wei Tang 18fa1d15ce Cumulative fixes to make working with consensus-pow easier (#3617)
* consensus-pow: add difficulty data to auxiliary

* Timestamp api

* Implement FinalityProofProvider for ()

* Add DifficultyApi

* Remove assumption that Difficulty is u128

* Use a separate trait for add instead of hard-code it as Saturating

* Some convenience functions to work with PowVerifier

* Try to fix mining unstability

* Fix generic resolution

* Unused best_header variable

* Fix hash calculation

* Remove artificial sleep

* Tweak proposer waiting time

* Revert sleep removal

The reason why it was there is because when mine_loop returns, it means an error
happened. In that case, we'd better sleep for a moment before trying again,
because immediately trying would most likely just fail.

* Pass sync oracle to mining

So that it does not mine when major syncing

* Expose build time as a parameter

Instead of hardcode it as previously 100ms.

* Update lock file

* Fix compile

* Support skipping check_inherents for ancient blocks

For PoW, older blocks are secured by the work, and can mostly be considered to
be finalized. Thus we can save both code complexity and validation time by
skipping checking inherents for them.

* Move difficulty fetch function out of loop

To make things faster

* Remove seed from mining

Each engine can use its own Rng source.

* Better comments

* Add TotalDifficulty definition for U256 and u128

* Update core/consensus/pow/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Rename TotalDifficulty::add -> increment

* Use SelectChain to fetch the best header/hash

* Update lock file
2019-10-03 11:02:20 +08:00
DemiMarie-parity 62b97a090d Upgrade dependencies whenever “easy” (#3556)
* Update all dependencies

* Upgrade dependencies whenever “easy”

“easy” means that there are no major changes required.

* Fix build and bump paste dependency to 0.1.6

* Remove dead code

* Re-add = dependency for futures-preview

* Add missing std features for runtime-io

* Remove git dependencies

as updated versions have been published to crates.io

* try to debug bug

* For sr-io, "std" should imply "no_oom" and "no_panic_handler".

Otherwise, rustc complains (correctly) about duplicate lang items.

* Add missing "runtime-io/std" features

* Fix compilation errors

* Prevent duplicate lang items

Rust does not allow duplicate lang items.  When compiled without the
`std` feature, `sr-io` defines two lang items.  Therefore, `sr-io`
compiled without `feature = "std"` must not be linked with `std`.

However, `pwasm-utils` and `wasmi-validation` both bring in `std` unless
compiled with `default-features = "false"`.  This caused a duplicate
lang item error.  Building both with `default-features = "false"`
prevents this error.  When building with `feature = "std"`, they should
both be built with the `std` feature, so this feature needs to be
explicitly depended on.

* Bump `impl_version`

* Make tests pass

Three tests used 1 less gas than they had previously.

* Try to un-break build

* Add a Cargo.lock file

* Revert offchain code

* Revert "Revert offchain code"

This reverts commit d216d08cc6ca0344614669c1d24cde3aa5c0d4e2.

* Don’t try to send a body with a GET request

without adding a Transfer-Encoding or Content-Length header.

This has always been wrong, but hyperium/hyper#1925 hid the bug until
hyper was upgraded to 0.12.35.

* Change some more GET requests to POST requests

* Fix excess line width and remove an `extern crate`

* Delete commented-out extern crate

Co-Authored-By: Sergei Pepyakin <sergei@parity.io>

* Fix regression in Cargo.toml files

dev-dependencies need `default-features = false`, too.

* Bump parity-wasm dependency

* Bump `futures-preview`

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update Cargo.lock files

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update core/service/src/chain_ops.rs

Co-Authored-By: Sergei Pepyakin <sergei@parity.io>
2019-10-02 15:23:59 -04:00
Marcio Diaz f6bd58ac1f Optimize tree route to sync faster (#3665)
* Introduce HeaderMetadata and use it for tree_route. Add lowest_common_ancestor.
* Add tests.
2019-10-02 20:30:43 +02:00
DemiMarie-parity 8646cd158e BABE refactoring: split out verification (#3658)
* Refactor parts of BABE verification into separate module

* Fix silly compiler error

* Move more of the verification code to verification.rs

* Remove some unused imports

* Fix line width

* fix testsuite compile error

* Fix compile errors in tests

* Move authorship-related code to its own files

* fix compile errors in tests

* Respond to review comments by @rphmeier

* improve docs

* fix compile error

* Add missing doc comment
2019-10-02 15:51:49 +02:00
Tomasz Drwięga 90df6b3c6c Move offchain worker http helpers to sr-primitives. (#3733)
* Move offchain helpers to sr-primitives.

* Add some docs and fix tests.

* Refresh cargo.lock

* Bump runtime.

* Don't run offchain http example.
2019-10-02 10:03:18 +02:00
Alexandre R. Baldé 3907582457 Remove unused imports (#3737) 2019-10-02 00:10:37 +02:00
thiolliere 53e0ddee4e Use EncodeLike for storages traits (#3676)
* impl

* patch

* lock

* some refactor

* some avoided copy

* new api without ref for doublemap

* fix

* version bump

* fix

* point to incoming release

* use codec latest

* bumpd impl version

* fix unused

* fix

* Update srml/support/src/storage/mod.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
2019-10-01 19:45:24 +02:00
André Silva 83d4764d46 grandpa: add identifier to UntilImported logging message (#3735)
* grandpa: add identifier to UntilImported logging

* grandpa: fix tests
2019-10-01 11:42:11 -04:00
Svyatoslav Nikolsky 387c31598d Prepare for asynchronous transaction validation in tx pool (#3650)
* 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
2019-10-01 12:14:25 +03:00
Ashley c545344c60 Add an Error type to Aura (#3688)
* Add an Error type to Aura

* Add Cargo.lock

* AuRa -> Aura

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2019-10-01 12:42:11 +08:00
Bastian Köcher f6c4c47b50 Give more information why conversion between native and runtime failed (#3720)
* Give more information why conversion between native and runtime failed

This adds the SCALE error description to the error when the conversion
between native and runtime failed.

* Fixes tests
2019-09-30 18:03:13 +02:00
Pierre Krieger 98879a2bdb Revert "core/sr-api-macros/Cargo.toml: Pin protobuf version (#3723)" (#3726)
This reverts commit 2b85a48c71.
2019-09-30 18:02:54 +02:00
Max Inden 2b85a48c71 core/sr-api-macros/Cargo.toml: Pin protobuf version (#3723)
* Cargo.toml: Pin protobuf version

The protobuf crate introduced a breaking change within its semver minor
update from 2.8.1 to 2.9.0. This commit ensures Substrate uses anything
within the 2.8 minor releases.

* Cargo.lock: Update

* core/sr-api-macros/Cargo.toml: Pin protobuf version

The protobuf crate introduced a breaking change within its semver minor
update from 2.8.1 to 2.9.0. This commit ensures Substrate uses anything
within the 2.8 minor releases.

* Revert "Cargo.toml: Pin protobuf version"

This reverts commit 4e293c741c5c4510cb1a347c444d1876d65ddb1e.

* core/sr-api-macros/Cargo.toml: Pin protobuf within dev-dependencies

* core/sr-api-macros/Cargo.toml: Add comment and link to Githu issue
2019-09-30 16:51:28 +02:00
Tomasz Drwięga 667ee95f5d ChainSpec extensions (#3692)
* 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.
2019-09-29 01:05:36 +08:00
André Silva c555b9bf88 peerset: fix reserved nodes (#3706)
* peerset: fix handling of reserved only peering mode

* core: add cli parameter to enable reserved nodes only

* peerset: fix tests

* peerset: add test for priority only mode

* core: fix reserved only cli flag description

* peerset: extend docs on set_priority_only
2019-09-29 01:04:46 +08:00
Arkadiy Paronyan 3242d7f2b6 Explicit sync API for downloading important, possibly orphaned, forks (#3633)
* Explicit sync API

* Keep sync requests

* Don't request the finalized block we already have

* Dropping requests & docs

* Renamed a function
2019-09-28 14:02:36 +02:00
Sergei Pepyakin 85431e9adf Add a comment on the features. (#3714) 2019-09-28 19:14:28 +08:00
André Silva 26889679f3 cli: clean up flag descriptions (#3715) 2019-09-28 19:14:08 +08:00
Coenen Benjamin 53a43e92aa create some vectors with initial capacities (#3701)
Signed-off-by: Benjamin Coenen <benjamin.coenen@hotmail.com>
2019-09-27 11:46:53 +02:00
Alexey 62be947877 Enable runtime_api for Substrate service (#3709)
* added new_full_concrete for service

* line width fix

* Update node/cli/src/service.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update node/cli/src/service.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update node/cli/src/service.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* replaced new_full

* empty

* added backticks to pass ci
2019-09-27 11:43:25 +02:00
Wei Tang 3864d0e4da Update libsecp256k1 dep to 0.3.0 (#3711)
* Update libsecp256k1 dep to 0.3.0

* Bump impl_version
2019-09-27 09:48:29 +02:00
Bastian Köcher ba98168b71 Make TestOffchainExt panic on unknown requests (#3710)
* Make `TestOffchainExt` panic on unknown requests

* Fix test
2019-09-26 23:02:30 +02:00
Caio 0da34de380 Pointer does not implement Display (#3707)
Instead, use `Debug` for `debug_trace!`
2019-09-26 22:21:12 +02:00
André Silva 0330f3bac6 grandpa: send authority id to telemetry when starting new voter (#3705) 2019-09-26 19:23:01 +02:00
Ashley a2c553a0d9 Random seed API for offchain workers (#3694)
* Add random_seed impl for offchain api

* switch to rand::random
2019-09-26 09:36:58 +02:00
Kian Paimani f277c4884a Fix Phragmen equalize loop. (#3693)
* Fix phragmen loop

* Bump.
2019-09-25 16:43:11 +02:00
Kian Paimani 1c15ca6ad1 Refactor: fixed point arithmetic for SRML. (#3456)
* Macro-ify perthings.

* Refactor fixed64

* Half-workign phragmen refactor.

* Finalize phragmen refactor.

* Fix creation of perquintill

* Fix build errors

* Line-width

* Fix more build errors.

* Line-width

* Fix offence test

* Resolve all TODOs.

* Apply suggestions from code review

Co-Authored-By: Gavin Wood <gavin@parity.io>
Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>

* Fix most of the review comments.

* Updates to multiply by rational

* Fxi build

* Fix abs issue with Fixed64

* Fix tests and improvements.

* Fix build

* Remove more tests from staking.

* Review comments.

* Add fuzzing stuff.

* Better fuzzing

* Better doc.

* Bump.

* Master.into()

* A bit more hardening.

* Final nits.

* Update lock

* Fix indent.

* Revert lock file.

* Bump.
2019-09-25 11:21:05 +02:00
Toralf Wittner 3dd5a508b4 Remove debug_assert!ion. (#3678) 2019-09-25 09:35:45 +02:00
Toralf Wittner 7611c08679 Fix invalid debug assertion. (#3663)
The current `debug_assert_eq` is clearly wrong as the code handles zero
response blocks. What should have been expressed is that we expect 0 or
1 response blocks.
2019-09-24 13:53:16 +02:00
Toralf Wittner af0d71d389 Add block announce validator. (#3346)
* Add `BlockAnnounceValidator` trait.

* Add associated data to block announcement.

* Make tests compile.

* Move validator into `sync.rs`.

* Smaller changes.

* Update core/network/src/protocol.rs

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* Update core/network/src/protocol.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Update core/network/src/test/sync.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Formatting.

* Remove assoc. data from `BlockImportNotification`.

* Use `Option<Vec<u8>>` for associated data.

* Update core/network/src/protocol/sync.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Fix type error.
2019-09-24 10:48:21 +02:00
Robert Habermeier 4888c253a3 fix #2177: port GRANDPA node-side code to use Consensus digests (#3669)
* fix #2177: port GRANDPA node-side code to use Consensus digests

* bump runtime version

* fix service compilation

* document change precedence rules
2019-09-24 10:45:44 +02:00
Ashley a7cd458544 Move best_containing from Client to blockchain::Backend (#3655)
* Move best_containing from Client to Backend

* Add comma for clearer diffs

Co-Authored-By: André Silva <andre.beat@gmail.com>
2019-09-24 07:31:06 +02:00
Ashley 1baee72d75 use pdqselect for median_algorithm selection (#3636)
* use pdqselect for median_algorithm selection instead of sorting the whole vec

* Make use of pqdselect clearer

Co-Authored-By: André Silva <andre.beat@gmail.com>

* Make use of pqdselect clearer

Co-Authored-By: André Silva <andre.beat@gmail.com>
2019-09-23 22:37:53 +02:00
Michael Müller 2d6e617309 Send local GRANDPA authority id to telemetry (#3646)
* Fix indentation

There is a space between the tabs.

* Send local GRANDPA authority id to telemetry

* Update core/finality-grandpa/src/lib.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>

* Generalize authority_id()

* Shorten code

* Do not send unfinalized authority sets to telemetry

`update_authority_set()` is called from, among others,
import side. These updates only track a pending change
and may or may not happen, hence it's wrong to send
this set to telemetry (which would assume that this is
the current, finalized authority set).

* Send current authority set and local authority id on set change
2019-09-23 17:48:09 +02:00
Jim Posen 82e7f9e423 Decouple node-executor structures from wasmi (#3610)
* executor: Support non-Wasmi sandbox supervisor environments.

* node-executor: Tests don't reference WasmExecutor directly.

* executor: Simplify encoding of heap metadata.

* executor: Decouple allocator from wasmi::MemoryRef.
2019-09-23 17:38:51 +02:00
Robert Habermeier c200ce757b Fixing BABE epochs to change between blocks (#3583)
* 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
2019-09-23 16:03:05 +02:00
Robert Habermeier e0b3564f2d improve justification docs 2019-09-23 10:28:24 +02:00
Wei Tang 642e76b738 Only submit signed extrinsics back to pool when retracting block (#3660)
* Only submit signed extrinsics back to pool when retracting block

* Fix import
2019-09-21 19:50:37 +08:00
Joshy Orndorff 210290f8ca Remove unused key types sr25 and ed25 (#3659)
* Remove unused key types sr25 and ed25.

* Restore in specific files to fix build.

* Fix runtime tests

* Fix keystore test

* Revert typo

* Move keytypes to primitives/src/testing.rs

* More missed items.

* Getting close now.

* Fix example in documentation.

* Update core/application-crypto/src/ed25519.rs

* Update core/application-crypto/src/sr25519.rs

* Bump impl version.
2019-09-21 12:48:03 +08:00
thiolliere c25d7386cf Make staking inflation curve configurable. (#3644)
* Draft for new design of NPoS rewards

* finish code

* fix test

* add tests

* improve log test

* version bump

* Update srml/staking/reward-curve/Cargo.toml

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

* u128 -> u64

* make conversion to smaller type safe

* Update core/sr-primitives/src/curve.rs

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2019-09-21 12:47:10 +08:00
Robert Habermeier 68cda2fe79 find best_containing even if best chain is shorter (#3657) 2019-09-20 17:44:19 +01:00
Hernando Castano e434dbdfc5 Use ThreadPool::spawn_ok() instead of ThreadPool::spawn() (#3656)
* Bump futures-timer to v0.3

* Bump futures-preview to v0.3.0-alpha.18

* Replace ThreadPoll::spawn() with ThreadPoll::spawn_ok()
2019-09-20 15:26:14 +02:00
Svyatoslav Nikolsky eba6dd73c6 Blockchain cache pruning strategy (#3395)
* blockchain cache pruning strategy

* added some internal docs to cache_pruning_strategy

* Update core/client/db/src/cache/mod.rs

Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com>
2019-09-20 09:49:15 +03:00
Weiliang Li d105d3f3a1 fn import_block -> fn block_import_params in SimpleSlotWorker (#3647) 2019-09-19 15:49:24 +01:00
Kian Paimani bfe240d1b0 srml-module: Phragmen election (#3364)
* phragmen election module.

* Add new files.

* Some doc update

* Update weights.

* bump and a few nits.

* Performance improvement.

* Master.into()

* Update srml/elections-phragmen/src/lib.rs

Co-Authored-By: Gavin Wood <gavin@parity.io>

* Fix build

* Some fixes.

* Fix build.

* Proper outgoing and runner-up managment.

* Bit more sensical weight values.

* Update srml/elections-phragmen/src/lib.rs

* Update srml/elections-phragmen/src/lib.rs

Co-Authored-By: Gavin Wood <gavin@parity.io>

* Update srml/elections-phragmen/src/lib.rs

Co-Authored-By: Gavin Wood <gavin@parity.io>

* Update srml/elections-phragmen/src/lib.rs

Co-Authored-By: Gavin Wood <gavin@parity.io>

* fix lock file

* Fix build.

* Remove runner-ups

* Some refactors.

* Add support for reporting voters.

* Fix member check.

* Remove equlize.rs

* Update srml/elections-phragmen/src/lib.rs

* Update srml/elections-phragmen/src/lib.rs

* Update srml/elections-phragmen/src/lib.rs

Co-Authored-By: Gavin Wood <gavin@parity.io>

* Update srml/elections-phragmen/src/lib.rs

Co-Authored-By: Gavin Wood <gavin@parity.io>

* Bring back runner ups.

* use decode_len

* Better weight values.

* Update bogus doc

* Bump.

* Update srml/elections-phragmen/src/lib.rs

Co-Authored-By: Gavin Wood <gavin@parity.io>

* Review comments.

* One more test

* Fix tests

* Fix build

* .. and fix benchmarks.

* Update srml/elections-phragmen/src/lib.rs

* Version bump
2019-09-19 18:04:02 +08:00
Talha Cross 5585770a12 core, subkey: allow to read Polkadot, Kusama, and Dothereum address types (#3643)
* core/primitives: set dothereum address type to 4

* subkey: add dothereum to network prefix

* core/primitives: set dothereum address type to 20

* core/primitives: update comment

* core/primitives: set default address to Dothereum

* Revert "core/primitives: set default address to Dothereum"

This reverts commit 2fc95490c89390eb26f200cb314435b1e9ff83e8.

* core/primitives: allow to parse different default address types
2019-09-19 08:34:41 +02:00
Pierre Krieger 9ea3d8fc52 Remove the no_std feature from the WASM builder (#3640)
* Remove the no_std feature from the WASM builder

* Address review

* More fixing

* Address review again

* Fix missing Cargo.lock
2019-09-18 22:00:44 +02:00
Bastian Köcher 49ad0dbdff Make wasm-builder check for rust-lld (#3635)
* Make `wasm-builder` check for `rust-lld`

* Update README.adoc

Co-Authored-By: Ricardo Rius <9488369+riusricardo@users.noreply.github.com>
2019-09-18 13:52:18 +02:00
Kian Paimani b46340cf8e From<UintAuthority> for u64 (#3638)
* Add from impl for uint authority

* Undo change to cargo.
2019-09-18 13:24:08 +02:00
Ashley e9c756dced Update parity-wasm to 0.40 (#3631)
* updated direct dependencies to parity-wasm

* fixed tests and incremented impl_version of the runtime

* update wasmi to 0.5.1 in sr-sandbox, bringing all parity-wasm deps up to 0.40
2019-09-18 12:27:59 +02:00