Commit Graph

882 Commits

Author SHA1 Message Date
André Silva 8f81bd90e7 network: don't announce genesis block (#3081) 2019-07-10 13:36:27 +02:00
Max Inden c2491ed20b core/network: Log when ignoring genesis block announcement (#3078)
Instead of logging the fact that a generic invalid block announcement is
ignored, log that the given block is the genesis block.
2019-07-10 10:12:36 +01:00
Pierre Krieger 01060df459 Some documentation for discovery.rs (#3024)
* Some documentation for discovery.rs

* Typos

* Address concerns

* Fix doc after imports
2019-07-10 10:01:56 +02:00
thiolliere d00a2b28ac Make use of child storage for testExternalities and basicExternalities (#3009)
* impl test using both storage and child_storage

* few fixes

* remove unused code

* impl PartialEq with children keys

* fmt

* implementation of basic with children + rename new

* assert and test

* no panic in runtime

* address comments

* fix
2019-07-09 21:07:58 +02:00
Max Inden 6639ab339a Introduce flag to enable sentry nodes to participate in grandpa gossip (#3018)
Given the following situation: A validator 'A' is not supposed to be
connected to the public internet to protect it from e.g. a DoS attack.
Instead it connects to a sentry node 'sentry-A' which connects to the
public internet. Validator 'B' can reach validator 'A' via sentry node
'sentry-A' and vice versa.

A sentry node needs to participate in the grandpa gossip without
becoming a validator itself in order to forward these message to its
validator. This commit adds a new command line flag (`--grandpa-voter`)
forcing a node to participate in the grandpa voting process even though
no `--key` was specified. Due to the fact that it does not have a key,
it does not become a validator in the network.

In order to simulate the above situation this commit also adds a Docker
Compose file (`scripts/sentry-node/docker-compose.yml`) with further
documentation.
2019-07-09 18:35:37 +02:00
Gavin Wood 2c5a3b84db Allow sub accounts to be derived from an TypeId. (#3039)
* Allow sub accounts to be derived from an TypeId.

* Deduplicate

* Fix

* Rephrase.
2019-07-09 18:01:08 +02:00
Pierre Krieger d7b6720663 Change the import queue traits to take &mut self instead of &self (#3058)
* SharedFinalityProofRequestBuilder -> BoxFinalityProofRequestBuilder

* SharedThings -> BoxThings

* Fix tests

* build_request_data now takes &mut self

* The other traits now also take &mut self

* More or less fix tests

* Fix tests

* Fix more tests

* Moar tests

* Don't call make_block_import multiple time

* Fix doctest
2019-07-09 17:11:25 +02:00
Tomasz Drwięga e729dbabbe [offchain] Support for sign & verify for crypto keys (#3023)
* Implement sign & verify.

* Use phrases and password.

* Sign & verify with authority keys.

* Fix tests.

* WiP

* WiP

* Allow the caller to decide on 'CryptoKind'.

* Remove TODO.

* Make seed private back.

* Fix non-std build and bump version.

* Use Into<u32> instead of asses.

* Add missing typedef.
2019-07-09 17:09:14 +02:00
Pierre Krieger 459eb94c38 Hide the Kademlia warnings when offline (#3065) 2019-07-08 20:52:42 +01:00
Robert Habermeier 13b9e49688 Dispatch on-disabled digests from consensus modules (#3055)
* on-disable primitives for engines

* dispatch on-disabled digests from SRML consensus

* bump runtime versions

* use find_map
2019-07-08 16:22:15 +02:00
Bastian Köcher 29311e98b4 Make RUSTFLAGS configurable in wasm-builder (#3057)
* Make `RUSTFLAGS` configurable in `wasm-builder`

* Version ups

* Update `Cargo.lock`
2019-07-08 15:37:42 +02:00
Pierre Krieger 3a002a9100 Specialization::on_message now takes Vec<u8> (#3054) 2019-07-08 15:34:05 +02:00
Pierre Krieger 1e126eab2f Network crate cleanups (#3049)
* Remove useless internal messages

* Remove NetworkService::disconnect_peer

* Remove NetworkMsg altogether

* Rename ProtocolMsg ServerToWorkerMsg

* Remove useless code

* Add example for parse_str_addr

* Move parse_str_addr and ProtocolId to config

* Don't reexport the content of config

* Rework the imports

* More reexports rework

* Add documentation

* Move finalization report to network future

* Move on_block_imported to worker

* get_value/put_value no longer locking

* local_peer_id() no longer locks

* Remove FetchFuture

* Service imports cleanup

* Produce the network state in the network task

* Merge network task and RPC network task

* Move network methods to NetworkWorker

* Remove Arc peers system from network

* add_reserved_peer now goes through the channel

* Remove Mutex around network swarm

* Remove the FnOnce alias traits

* Replace is_offline with num_connected

* Improve style of poll()

* Fix network tests

* Some doc in service module

* Remove macro export

* Minor doc changes

* Remove the synchronized() method of the import queue

* Line width

* Line widths

* Fix import queue tests

* Fix CLI tests
2019-07-08 15:33:29 +02:00
Robert Habermeier 7df8e52cfe Slash and prove membership of prior sessions (#2970)
* skeleton for tracking historical sessions

* refactor OpaqueKeys

* some more skeleton work

* adjust session to new OpaqueKeys API

* further refactoring of key-type-ids

* session gets validator ID parameter

* run up against compiler

* tweak staking to support new session changes

* first run at child storage for deduplication

* Make session use `AccountId` as `ValidatorId`

* run up against child trie issues

* switch to using normal trie but with a fixed prefix

* clear out some println

* add dedup test

* flesh out historical module more

* introduce ExposureOf for staking

* test the historical module

* WASM compiles

* tests all compile

* do some mock change

* fix bulk of tests

* fix staking tests

* test obsolecence mechanic

* Apply suggestions from code review

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

* some more style nits

* a couple more nits

* tweak tries

* fix typo thie -> this
2019-07-08 14:36:46 +02:00
Arkadiy Paronyan bb7ff32e77 Fixed block import command error handling (#3056) 2019-07-08 14:00:09 +02:00
Stanislav Tkach 1fdf315348 Fix ui tests (E0308 error) (#3040) 2019-07-07 22:37:27 +02:00
Pierre Krieger d0a48212a6 Split the import queue in three files (#3031)
* Split the import queue in three files

* Move import_single_block to root
2019-07-06 15:58:20 +01:00
Bastian Köcher c03d3531d2 Make wasm-builder work with cargo install (#3043)
* Make `wasm-builder` work with `cargo install`

* Update `Cargo.lock`
2019-07-06 00:29:16 +02:00
Pierre Krieger 489a5ce9d7 Merge Protocol and ProtocolBehaviour (#2962)
* Pass the peerset config to ProtocolBehaviour

* Don't pass the protocol versions

* Move fields from protocol_behaviour.rs to protocol.rs

* Remove LocalNetworkOut

* Move CustomProtos from protocol_behaviour.rs to protocol.rs

* Remove ProtocolBehaviour

* Inline poll()

* Force Behaviour to use Protocol

* Don't even attempt to have working tests

* Remove NetworkOut trait

* Line widths
2019-07-05 16:06:07 +02:00
Max Inden 6761ef1655 core/finality: Ref run_grandpa_voter instead of deprecated func in doc (#3035) 2019-07-05 15:43:16 +02:00
Bastian Köcher 0ed2b26c96 End build when wasm-builder does not find a prerequisite (#3030)
* End build when `wasm-builder` does not find a prerequisite

Using `compile_error!` was a stupid idea by me, as rust would not
re-execute the build.rs.

* Increment the `wasm-builder` version

* Update core/utils/wasm-builder/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>
2019-07-05 15:02:14 +02:00
Pierre Krieger 22ec13cf65 Rewrite the network TestNet (#3016)
* Add a memory-only option for the network

* Tests cleanup

* Make grandpa/aura/babe compile

* Aura and Babe tests now passing

* More work on tests rewrite

* Attempt to fix grandpa

* Make more grandpa tests pass

* More grandpa tests work

* Work on sync tests

* More work

* light_peer_imports_header_from_announce passes

* can_sync_small_non_best_forks passes

* syncing_node_not_major_syncing_when_disconnected passes

* blocks_are_not_announced_by_light_nodes passing

* All sync tests passing 🎉

* Some TestNet cleanup

* Work on grandpa tests

* More grandpa work

* GrandPa work

* Add check about block_import

* Remove the temporarily added Sync

* Fix network tests warnings

* voter_persists_its_votes passes

* Fix imports in network tests

* Fix service tests

* Call on_block_imported 🤷

* Add shortcut

* Finish using shortcut
2019-07-05 11:19:03 +01:00
Pierre Krieger abf33fe479 Use bip39 from crates.io (#3029) 2019-07-05 10:11:58 +02:00
Pierre Krieger 8bca52128f Adjust the RPC service for the WASM-browser use case (#3013)
* Use SpawnTaskHandle to pass to the RPC

* Create the RPC server in lib.rs

* Create the RPC servers in a separate function

* Keep a local version of the RPC handlers

* Make rpc-servers compile for WASM

* Add RpcSesssion

* Clean up

* Address review

* Address pull request review
2019-07-05 09:55:50 +02:00
André Silva 13164304b3 grandpa: make observer relay round messages (#3021)
* grandpa: make observer relay round messages

* grandpa: observer also notes next round

* grandpa: no need to note commit round
2019-07-05 09:55:10 +02:00
Pierre Krieger a199a989b8 on_start now returns the precise elements to request (#3003)
* on_start now returns the precise elements to request

* Fix test
2019-07-05 09:40:26 +02:00
André Silva d5bc7325b9 grandpa: round catchup messages (#2801)
* grandpa: initial structure for catch up messages

* grandpa: answer catch up requests

* grandpa: inject catch up messages into global stream

* grandpa: keep track of pending catch up request

* grandpa: block catchup until all referenced blocks are imported

* grandpa: unify catch up and commit streams

* grandpa: simplify communication stream/sink types

* grandpa: note gossip validator on catch up message import

* grandpa: fix cost on catch up message validation

* grandpa: check signatures on catch up messages

* grandpa: clean up catch up request handling state

* grandpa: adjust costs on invalid catch up requests

* grandpa: release lock before pushing catch up message

* grandpa: validate catch up request against peer view

* grandpa: catch up docs

* grandpa: fix tests

* grandpa: until_imported: add tests for catch up messages

* grandpa: add tests for catch up message gossip validation

* grandpa: integrate HistoricalVotes changes

* grandpa: add test for neighbor packet triggering catch up

* grandpa: add test for full voter catch up

* grandpa: depend on finality-grandpa 0.8 from crates

* granda: use finality-grandpa test helpers

* grandpa: add PSM cost for answering catch up requests

* grandpa: code style fixes

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>

* grandpa: more trailing commas

* grandpa: lower cost of invalid catch up requests near set change

* grandpa: process catch up sending on import of neighbor message

* grandpa: add comments on HistoricalVotes

* grandpa: use finality-grandpa v0.8.1 from crates.io

* grandpa: fix test compilation
2019-07-04 20:40:16 +01:00
Bastian Köcher 7a2165cff2 Make wasm-builder less spammy (#3020)
* Don't clutter the output that much

* Support building from `crates` or from `path`

* Upgrade the versions

* Update `Cargo.lock`
2019-07-04 17:57:21 +02:00
cheme fb8bb00158 Update trie dependencies. (#3017)
* Update trie dependencies.

* bump rutime impl version.
2019-07-04 15:56:13 +02:00
David Craven 51e345c901 Generic keystore (#3008)
* Add KeyTypeId.

* Implement clone for sr25519::Pair.

* Extend Pair with to_raw_vec.

* Implement TypedKey for Signature and Pair.

* Add trait Public.

* Make keystore generic.

* Fixup clone.

* Fix tests.

* Update service.

* Fix imports.

* Fix build.

* Fix babe build.

* Fix subkey build.

* Make authority setup generic.

* Update node-template.

* Fix build.

* Remove unsafe code.

* Fix tests.
2019-07-04 13:14:55 +02:00
Bastian Köcher fe08221479 Build WASM binaries as part of cargo build (#2868)
* Introduce `wasm-builder` and `wasm-builder-runner` to retire `build.sh`

Make use of `wasm-builder` in `test-runtime`.

* Add build script and remove the wasm project

* Port `node-runtime` to new wasm-builder

* Make `substrate-executor` tests work with `wasm-builder`

* Move `node-template` to `wasm-builder`

* Remove `build.sh` :)

* Remove the last include_bytes

* Adds the missing build.rs files

* Remove `build.sh` from CI

* Debug CI

* Make it work in CI

* CI attempt 3

* Make `substrate-runtime-test` compile on stable

* Ahhh, some missed `include_bytes!`

* AHH

* Add suggestions

* Improve search for `Cargo.lock` and don't panic if it is not found

* Searching from manifest path was no good idea

* Make the `wasm-builder` source better configurable

* Expose the bloaty wasm binary as well

* Make sure to rerun WASM recompilation on changes in dependencies

* Introduce new `WASM_BUILD_TYPE` env and make sure to call `build.rs` on
changes to env variables

* Remove `build.sh` from READMEs

* Rename the projects

* Fixes CI

* Update lock file

* Fixes merge-conflict

* Apply suggestions from code review

Co-Authored-By: TriplEight <denis.pisarev@parity.io>

* Try to make windows happy

* Replace all back slashes in paths with slashes

* Apply suggestions from code review

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>

* Use cargo from `CARGO` env variable

* Fix compilation

* Use `rustup` for running the nightly build

* Make individual projects skipable

* Fix compilation

* Fixes compilation

* Build all WASM projects in one workspace

* Replace more back slashes!

* Remove `inlcude_bytes!`

* Adds some documentation

* Apply suggestions from code review

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Apply suggestions from code review

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* More review comments

* Update `Cargo.lock`

* Set license

* Apply suggestions from code review

Co-Authored-By: joe petrowski <25483142+joepetrowski@users.noreply.github.com>

* More review comments + adds `TRIGGER_WASM_BUILD` env

* Fix doc tests

* Increase version + update README

* Switch crates.io version of `wasm-builder`

* Update README

* Switch to released version of `wasm-builder-runner`
2019-07-04 11:34:06 +02:00
Pierre Krieger eca9c36b75 Can now disable the keystore (#3004)
* Can now disable the keystore

* Fix service test

* Apply suggestions from code review

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

* Fix cli
2019-07-04 10:33:43 +02:00
Bastian Köcher 4fe9e8732f Downgrade memory-db in test-runtime to fix WASM compilation (#3010)
* Downgrade `memory-db` in `test-runtime` to fix WASM compilation

* Remove unneeded `memory-db` dependency

* Update `Cargo.lock`
2019-07-03 21:26:36 +02:00
Pierre Krieger fa535da069 Implement Executor for Service and SpawnHandle (#3007)
* Implement Executor for Service and SpawnHandle

* Update lib.rs

* Fix the race condition
2019-07-03 15:36:49 +02:00
DemiMarie-parity 81d8a5d01d BABE Randomness using PreRuntime digests (#2929)
* Initial work on exposing pre-runtime digests

This provides the primitive API, as well as exposing it from BABE.

* Initial work on using pre-digests in runtimes

This includes both code to expose them from `srml_system`, as well as
using it in (currently dead) code in `srml_babe`.

* Bump `{spec,impl}_version`

* Add `u64_backend` feature to curve25519-dalek

Otherwise, it errors out at compile-time.

* Bump `Cargo.lock`

* Do not depend on the schnorrkel crate in the runtime

The schnorrkel crate does not work on `#![no_std]`, but the runtime only
needs constants from it.  This adds our own definitions of those
constants, and checks them for correctness at compile-time.

* Actually implement storage of VRF outputs

* Trivial formatting change

* Provide a `hash_randomness` function in BABE

for processing VRF outputs.

* Implement a basic randomness generating function

It just XORs the VRF outputs together.

* Actually implement on-chain randomness

Blake2b is used for hashing.

* Update dependencies

* Run `cargo update` where needed

* Re-add a newline at EOF

* Remove broken and unsafe code

XOR is not a hash function, and must not be used as such.  The
implementation was also needlessly unsafe.

* Run `cargo update` where needed

* Remove spurious dependency

* Document security guarantees of BABE randomness

* Add a `RandomnessBeacon` trait

* Document `RandomnessBeacon::random`

* Fix silly compile error (unexpected type arguments)

* Fix BABE randomness

* Implement `FindAuthor` for `babe::Module`

* Apply suggestions from code review

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

* Respond to suggestions from code review and fix bugs

* Store an authority index, not the authority itself.
* Avoid unnecessary decoding.
* Implement relative slots and BABE randomness fully and correctly.

* Remove spurious dependency

* Fix error reported by rust-analyzer

* Update Cargo.lock files

* `wrapping_add` → `checked_add`

The epoch index will not overflow.  Panic if it does.

* Move randomness documentation to trait

* Fix compile error in test suite

* Explain 2^64 limit

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>
2019-07-03 14:49:07 +02:00
Tomasz Drwięga 2217c1e9a1 Persistent Local Storage for offchain workers. (#2894)
* WiP.

* Implement offchain storage APIs.

* Change compare_and_set to return bool.

* Add offchain http test.

* Fix tests.

* Bump spec version.

* Fix warnings and test.

* Fix compilation.

* Remove unused code.

* Introduce Local (fork-aware) and Persistent storage.

* Fix borked merge.

* Prevent warning on depreacated client.backend

* Fix long lines.

* Clean up dependencies.

* Update core/primitives/src/offchain.rs

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

* Update core/primitives/src/offchain.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>
2019-07-02 20:11:06 +02:00
Gavin Wood 9c6ebfeccd Initial mechanics for 80:20 fee split (#2912)
* Initial mechanics for 80:20 fee split

Also:
- Introduce extra functions for Imbalance manipulation;
- Store treasury pot in an account, letting total issuance account for
  it.

* Fix some tests

* Fix some tests

* Minor cleanups

* Update parity-codec version (#2855)

* Update parity-codec version

* Update grandpa, rhododendron and trie-bench

* Use primitive-types from crates.io

* Bump impl version

* Fix trie-bench version

* Fix lock files

* Fix versions

* Update codec to 4.1

* merge fix

* Revert merge

* More reversions

* Remove accidental code

* Update locks

* Bump runtime

* Update locks

* Tweaks and label TODO

* Update srml/treasury/src/lib.rs

Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com>

* Update issue number

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

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>

* Fix wasm build

* Fix subkey build
2019-07-02 11:41:03 +02:00
Bastian Köcher bfe5347724 Adds a SpawnTaskHandle to core service (#2992)
* Adds a `SpawnTaskHandle` to core service

* Fixes compilation

* Remove `into()`
2019-07-02 10:39:41 +02:00
Weiliang Li 24595c0920 Update without_std.rs (#2990)
fix typo
2019-07-02 08:41:55 +02:00
kaichao 3e2c77aa21 typo fix in core (#2987) 2019-07-01 19:33:38 +02:00
Roman Borschel bd7566ef5e Fix peer discovery delays. (#2982)
* Fix DiscoveryBehaviour::poll.

The previous implementation regularly returned `NotReady` from `poll`
despite the inner Kademlia behaviour having events ready, thus letting
the `poll`ing be largely driven by the task wakeups from the Delay for
the next random Kademlia query, inducing major delays in consuming
the ready Kademlia events and thus slowing progress.

The discovery test now passes quickly, as expected.

* Ensure the Delay is polled right after reset.

For task wakeup.
2019-07-01 12:46:23 +02:00
Niklas Adolfsson 5f1538b834 cargo update -p smallvec (#2983) 2019-07-01 10:04:43 +02:00
Svyatoslav Nikolsky 83e014c214 change meaning of none in blockchain cache (#2973) 2019-06-30 17:54:51 +02:00
Bastian Köcher 18be937cb5 Adds if_std! macro (#2979)
This macro compiles and executes the given code only when `std` feature
is enabled. This can be useful for debugging without needing to worry
that your code does not compile on `no_std`.
2019-06-29 20:12:46 +02:00
Pierre Krieger 7b1e8dc3df Update sysinfo to 0.9 (#2978) 2019-06-29 17:58:12 +02:00
Bastian Köcher 62b7c05def Implement a proper generic resolution in decl_storage! (#2913)
* Add failing test case

* move storage maps to blake2_128 (#2268)

* remove default hash, introduce twox_128 and blake2

* use blake2_128 & create ext_blake2_128

* refactor code

* add benchmark

* factorize generator

* fix

* parameterizable hasher

* some fix

* fix

* fix

* fix

* metadata

* fix

* remove debug print

* map -> blake2_256

* fix test

* fix test

* Apply suggestions from code review

Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>

* impl twox 128 concat (#2353)

* impl twox_128_concat

* comment addressed

* fix

* impl twox_128->64_concat

* fix test

* Fix compilation and cleanup some docs

* Lol

* Remove traits from storage types that are not generic

* Get instance test almost working as wanted

* Make `srml-support-test` compile again :)

* Fixes test of srml-support

* Fix compilation

* Break some lines

* Remove incorrect macro match arm

* Integrates review feedback

* Update documentation

* Fix compilation
2019-06-27 13:40:22 +02:00
Bastian Köcher 23ea5d1795 Remove Mutex from core-service (#2961)
* Remove `Mutex` from `core-service`

* Fixes sync test
2019-06-27 10:07:34 +02:00
Tomasz Drwięga 3f142d0561 Enable hosts filtering. (#2959) 2019-06-26 18:10:31 +02:00
Pierre Krieger 1b73b6532a Remove tokio dependencies (#2935)
* Remove dependencies on tokio

* Make service not depend on tokio

* Fix service tests

* Manually poll the import queue if failed to start

* Spawn all tasks at the end

* Remove executor from TelemetryOnConnect

* Remove TaskExecutor from offchain workers

* Remove TaskExecutor from AuthoritySetup

* Remove TaskExecutor from service

* Remove tokio dependency from RPC

* Remove finality-grandpa from WASM checks

* Fix offchain tests

* Line widths

* Fix RPC tests

* Fix service tests

* Fix bad futures polling

* Address some concerns

* Better error handling

* Is it the connectivity test that's not passing? I don't know, let's try

* Revert "Is it the connectivity test that's not passing? I don't know, let's try"

This reverts commit 28bbe51f0e2e4885fe1f901e11078604604cb212.

* Fix test
2019-06-26 17:21:17 +02:00
cheme f69c48c7b8 Additional state check. (#2915)
* check resulting state root on import.

* get root from last method.

* Fix test runtime (was changing state after root calculation).

* Do reset new authorities (just take before root calculation).

* bump impl runtime version.

* Update core/sr-api-macros/tests/trybuild.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
2019-06-26 16:28:12 +02:00