Commit Graph

224 Commits

Author SHA1 Message Date
Toralf Wittner 3de2a88075 Update to libp2p v0.20.1 (#6465)
* Update to libp2p-0.20.0

* Update to `libp2p-0.20.1`.

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-06-30 08:02:51 +00:00
Wei Tang bd5ad9fd6d Pallet: Atomic Swap (#6349)
* Init atomic swap pallet

* Implement module swap operations

* Add successful swap test

* Bump node spec_version

* Fix storage name

* Add ProofLimit parameter to prevent proof size being too large

* Add missing events

* Basic weight support

* Add basic docs

* Mark swap on claim

This handles the additional case if `repatriate_reserved` fails.

* Add additional expire handler

* Update frame/atomic-swap/src/lib.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Add docs on ProofLimit

* Fix test

* Return Ok(()) even when the transfer fails

Because we need to mark the swap as claimed no matter what.

* Remove retry logic

It's overkill. Swap is about something being executed, not necessarily successful.
Although there should be logic (reserve and unreserve) to make it so that both parties *believes*
that the execution is successful.

* succeed -> succeeded

* Add docs on duration -- revealer should use duration shorter than counterparty

* Missing trait type

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
2020-06-18 09:42:31 +02:00
Seun Lanlege b0aa4cfe0d new crate sc-light (#6235)
* sc-light

* remove unused deps

* fix line width

* move more fns to sc_light
2020-06-09 16:35:35 +02:00
Gavin Wood 15ecac5cb6 Introduce stacked filtering (#6273)
* Introduce stacked filtering.

* Benchmarks

* Remove unneeded crates

* Fix proxy type's permissiveness checks.

* Repot multisig to make utility stateless.

* Repot filter stack impl into macro

* Fix wasm build

* Tests

* Final test.

* Tests for the macro

* Fix test

* Line width

* Fix

* Update frame/multisig/src/benchmarking.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update primitives/std/with_std.rs

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

* Grumble

* Update frame/support/src/traits.rs

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

* Update frame/support/src/traits.rs

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

* Update frame/support/src/traits.rs

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

* Update frame/support/src/traits.rs

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

* Update frame/support/src/traits.rs

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

* Update frame/multisig/src/tests.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Update frame/multisig/src/tests.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Grumble

* Migration

* Grumble

* Comments

* Migration

* Fix

* Fix

* Line width

* Allow unused

* Update frame/multisig/src/lib.rs

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Fix up grumble.

* Remove Utility constraint in NonTransfer

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
2020-06-08 13:09:12 +02:00
Kian Paimani 8a8b4f99c3 Rename all the election operations (#6245)
* Rename and move sp-phragmen

* More renames for equalise

* Update main module doc

* Fix line width

* Line width
2020-06-05 17:33:13 +02:00
Pierre Krieger e77490714d Fix libp2p features (#6229)
* Fix libp2p features

* Remove the opt-level of some now-unused crates
2020-06-03 13:24:44 +00:00
Pierre Krieger 0c6ae6f3d4 Make dev profile faster by compiling deps with opt-level=3 (#6228)
* Make dev profile faster by compiling deps with opt-level=3

* More comment

* More comment refinment

* Remove soketto as it doesn't fit criterias

* Fix style
2020-06-03 12:45:57 +02:00
Gavin Wood 4adac40c07 Generalised proxies (#6156)
* Initial work

* It should work

* Fix node

* Fix tests

* Initial test

* Tests

* Expunge proxy functionality from democracy and elections

* Allow different proxy types

* Repotted

* Build

* Build

* Making a start on weights

* Undo breaking change

* Line widths.

* Fix

* fix tests

* finish benchmarks?

* Storage name!

* Utility -> Proxy

* proxy weight

* add proxy weight

* remove weights

* Update transfer constraint

* Again, fix constraints

* Fix negation

* Update frame/proxy/Cargo.toml

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

* Remove unneeded event.

* Grumbles

* Apply suggestions from code review

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

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2020-06-02 18:15:15 +02:00
Nikolay Volf dd573374e0 Add block construction prometheus metrics (#6030)
* Add basic authorship metrics

* fixes

* no arc

* move to crate

* Update client/proposer-metrics/Cargo.toml

Co-authored-by: Max Inden <mail@max-inden.de>

* remove prefix

* use HistogramTimer

* Update client/proposer-metrics/src/lib.rs

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

* Update client/basic-authorship/src/basic_authorship.rs

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

* Update client/basic-authorship/src/basic_authorship.rs

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

* Update client/basic-authorship/src/basic_authorship.rs

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

* Update client/basic-authorship/src/basic_authorship.rs

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

* Update client/basic-authorship/src/basic_authorship.rs

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

* Update client/proposer-metrics/src/lib.rs

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

* Update client/proposer-metrics/src/lib.rs

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

Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-05-18 13:48:44 +00:00
Marcio Diaz 4b44c73a4d Remove tx factory (#5890)
* Remove tx factory files.

* Remove unused imports.

* Revert cargo lock.
2020-05-05 13:54:51 +02:00
Shawn Tabrizi b301451c85 Frame System Benchmarking (#5834)
* Frame System Benchmarking

* Add to substrate node, avoid divide by zero errors in analysis

* reduce features

* some fixes

* copy pasta
2020-04-30 15:46:44 +02:00
Seun Lanlege 4fa5941f44 Move sc-client into sc-service (#5502)
* Drop client from sc-network and sc-client-db, move LongestChain to sc-client-api

* move leaves, cht, in_mem to sc-client-api, drop client from sc-finality-grandpa

* drop sc-service from sc-rpc

* drop sc-service from sc-consensus-aura

* drop sc-client from manual-seal and babe

* drop sc-client from utils/frame/rpc/system and utils/frame/benchmarking-cli

* drop sc-client from bin/node and bin/node-template

* drop sc-client

* fix tests

* remove check -p sc-client from gitlab.yml

* fix warnings

* fixes ui test

* fix light client tests

* adds associated Client type to AbstractService

* adds UsageProvider to Client

* fixed ui test, again

* tried and failed to get node-cli to compile for wasm

* thanks to tomaka for helping me get node-cli to compile for wasmm

* ui test pls pas 🙏🏾

* all tests passing 🪄

* no_run documentation code

* rm -f documentation code

* ClientProvider

* fix mega trait

* move LongestChain to sc-consensus, use adds minimal bounds to AbstractService::Client

* adds license to sc-consensus

Co-authored-by: Benjamin Kampmann <ben@parity.io>
2020-04-28 11:59:31 +00:00
Kian Paimani ee54eff488 Enable Offchain Equalise (#5683)
* Master.into()

* Remove debug stuff

* Better license

* Migrate away from SimpleDispatchInfo

* Fix test

* Revert "Migrate away from SimpleDispatchInfo"

This reverts commit dbdd27fa19948f16bd17defdc01d3dd32986df11.

* Move to offchain randomness

* Fix tests

* Fix tests more
2020-04-27 18:51:46 +02:00
Ashley 319a00fb1c Add a crate to test the in-browser light client. (#4887)
Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
2020-04-20 14:45:13 +02:00
Bastian Köcher 1d1caed335 Improve tracing (#5698)
* Improve tracing implementation

* Enable tracing in runtime interfaces

* Switch to `TRACE` level
2020-04-20 14:37:27 +02:00
Kian Paimani 762c741c55 Clean Phragmén Equlise API (#5452)
* Clean phragmen API and equalise()

* Stabilize new api

* Fix phragmen fuzzers

* More fixes

* Make fuzzers reproducible

* improvements

* Make equalize update assignments as well.

* total function for staked_assignment.

* Fix fuzzer build

* remvoe TODO

* Fix a bunch more.

* clean stray debug stuff

* Update primitives/phragmen/src/lib.rs

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

* fix range function

* fix number generator

Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
2020-04-17 09:53:30 +02:00
Gavin Wood 91af5b6fcc New database trait (#5549)
* Introduce trait

* The trait

* Generic

* Basic impls.

* Remove unneeded bounds

* Minor changes

* Switch over to the new DB trait

* Integrated parity-db and added CLI for db selection

* Default impl.

* Fix logs.

* Started integrating subdb

* Apply suggestions from code review

Co-Authored-By: Cecile Tonglet <cecile@parity.io>

* Apply suggestions from code review

Co-Authored-By: Nikolay Volf <nikvolf@gmail.com>

* Enable subdb

* Bump parity-db

* Fixed CLI macro

* Fixed browser build

* Fixed features

* Sort out features

* Use parity-db from crates.io

* Typo

Co-authored-by: arkpar <arkady.paronyan@gmail.com>
Co-authored-by: Cecile Tonglet <cecile@parity.io>
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
2020-04-15 14:38:39 +02:00
Bastian Köcher 7cdfaff12b Add new RPC method to get the chain type (#5576)
* Add new RPC method to get the chain type

This adds a new RPC method to get the chain type of the running chain.
The chain type needs to be specified in the chain spec. This should make
it easier for tools/UI to display extra information without needing to
rely on parsing the chain name.

* Update client/rpc-api/src/system/mod.rs

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Primitive crate

* Feedback

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
2020-04-08 20:41:51 +02:00
Roman Borschel f8c8355ac7 libp2p-next (#5278)
* Adapt to rust-libp2p#1440.

* Further adapt to libp2p/master.

* Update to libp2p-0.17

* Finishing touches.

* Remove stray TODO.

* Incorporate review feedback.

* Remove unused import.
2020-04-08 09:23:21 +02:00
Benjamin Kampmann 247822bb33 Additional Metrics collected and exposed via prometheus (#5414)
This PR refactors the metrics measuring and Prometheus exposing entity in sc-service into its own submodule and extends the parameters it exposes by:

- system load average (over one, five and 15min)
- the TCP connection state of the process (lsof), refs #5304
- number of tokio threads
- number of known forks
- counter for items in each unbounded queue (with internal unbounded channels)
- number of file descriptors opened by this process (*nix only at this point)
- number of system threads (*nix only at this point)

refs #4679

Co-authored-by: Max Inden <mail@max-inden.de>
Co-authored-by: Ashley <ashley.ruglys@gmail.com>
2020-04-04 15:13:35 +02:00
Nikolay Volf 6eea144f04 Use custom runner for import benchmarks (#5477)
* custom benchmark runner

* add license preamble

* delete old benchmarks

* update toml

* imporove macro

* tabs

* add size

* size fixes

* add docs for cli
2020-04-03 16:41:33 +02:00
Gavin Wood eac1a1964e Introduce scheduler and use it for the democracy dispatch queue (#5412)
* Initial draft of the logic

* Build and tests

* Make work with new initialize infratructure.

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Fix test

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

* Rejig interface to make it more useful for democracy.

* Try to get democraxy module to make use of scheduler.

* Make democracy use scheduler.

* Use actual max weight for enactent

* Remove TODO

* Fix runtime build

* Minor cleanup

* Fix scheduler.

* Fix benchmarks

* Fix

* Fix

* Fix

* More bench fixes

* Fix

* Fix.

* Add more bench constants.

* Fix cancel_queued bench.

* Fix test comment.

* Update frame/scheduler/src/lib.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>

Co-authored-by: Marcio Diaz <marcio.diaz@gmail.com>
2020-04-01 15:52:39 +02:00
Kian Paimani 970c5f94f2 Offchain Phragmén BREAKING. (#4517)
* Initial skeleton for offchain phragmen

* Basic compact encoding decoding for results

* add compact files

* Bring back Self::ensure_storage_upgraded();

* Make staking use compact stuff.

* First seemingly working version of reduce, full of todos

* Everything phragmen related works again.

* Signing made easier, still issues.

* Signing from offchain compile fine 😎

* make compact work with staked asssignment

* Evaluation basics are in place.

* Move reduce into crate. Document stuff

* move reduce into no_std

* Add files

* Remove other std deps. Runtime compiles

* Seemingly it is al stable; cycle implemented but not integrated.

* Add fuzzing code.

* Cleanup reduce a bit more.

* a metric ton of tests for staking; wip 🔨

* Implement a lot more of the tests.

* wip getting the unsigned stuff to work

* A bit gleanup for unsigned debug

* Clean and finalize compact code.

* Document reduce.

* Still problems with signing

* We officaly duct taped the transaction submission stuff. 🤓

* Deadlock with keys again

* Runtime builds

* Unsigned test works 🙌

* Some cleanups

* Make all the tests compile and stuff

* Minor cleanup

* fix more merge stuff

* Most tests work again.

* a very nasty bug in reduce

* Fix all integrations

* Fix more todos

* Revamp everything and everything

* Remove bogus test

* Some review grumbles.

* Some fixes

* Fix doc test

* loop for submission

* Fix cli, keyring etc.

* some cleanup

* Fix staking tests again

* fix per-things; bring patches from benchmarking

* better score prediction

* Add fuzzer, more patches.

* Some fixes

* More docs

* Remove unused generics

* Remove max-nominator footgun

* Better fuzzer

* Disable it 

* Bump.

* Another round of self-review

* Refactor a lot

* More major fixes in perThing

* Add new fuzz file

* Update lock

* fix fuzzing code.

* Fix nominator retain test

* Add slashing check

* Update frame/staking/src/tests.rs

Co-Authored-By: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>

* Some formatting nits

* Review comments.

* Fix cargo file

* Almost all tests work again

* Update frame/staking/src/tests.rs

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

* Fix review comments

* More review stuff

* Some nits

* Fix new staking / session / babe relation

* Update primitives/phragmen/src/lib.rs

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

* Update primitives/phragmen/src/lib.rs

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

* Update primitives/phragmen/compact/src/lib.rs

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

* Some doc updates to slashing

* Fix derive

* Remove imports

* Remove unimplemented tests

* nits

* Remove dbg

* Better fuzzing params

* Remove unused pref map

* Deferred Slashing/Offence for offchain Phragmen  (#5151)

* Some boilerplate

* Add test

* One more test

* Review comments

* Fix build

* review comments

* fix more

* fix build

* Some cleanups and self-reviews

* More minor self reviews

* Final nits

* Some merge fixes.

* opt comment

* Fix build

* Fix build again.

* Update frame/staking/fuzz/fuzz_targets/submit_solution.rs

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

* Update frame/staking/src/slashing.rs

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

* Update frame/staking/src/offchain_election.rs

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

* Fix review comments

* fix test

* === 🔑 Revamp without staking key.

* final round of changes.

* Fix cargo-deny

* Update frame/staking/src/lib.rs

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

Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Gavin Wood <gavin@parity.io>
2020-03-26 15:37:40 +01:00
André Silva 3a136bdcf9 Internal version dependencies cleanup (#5401)
* always depend on latest alpha version

* integrate arithmetic fuzzer into root workspace
2020-03-25 15:02:39 +01:00
Nikolay Volf 4d3557d5a1 Versioning for #[runtime-interface] (#5328)
* versionned runtime-interface

* use only one additional wasm blob

* alter docs

* formatting, naming and docs

* add comment for test

* version duplicate err

* RuntimeInterfaceItem -> RuntimeInterfaceFunction<

* test naming

* version checking

* remove spaces

* Update primitives/runtime-interface/proc-macro/src/runtime_interface/bare_function_interface.rs

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

* remove sanity checks and reduce coverage

* add doc comment

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
2020-03-23 15:09:05 +01:00
Wei Tang 9c7261fab3 Simplify BABE pre-digest definitions (#5289)
* Init vrf crate without type alias

* Generic PreDigest definition for BABE

* Fix BABE vrf interface change

* Missing default-features def in sp-consensus-babe

* Fix sp-consensus-babe compile

* frame-babe: fix type inference

* Unify type definitions of vrf output/proof and randomness

* frame-babe: fix tests

* Bump node impl version

* Update cargo lock

* Derive Copy for RawVRFOutput and RawVRFProof

* Fix duplicated derive

Co-authored-by: Gavin Wood <gavin@parity.io>
2020-03-23 11:53:41 +01:00
Shawn Tabrizi 9c06d8c6f4 Benchmark Staking and Session Pallet (#5183)
* starting bench

* More

* more

* Payout Validator

* Give each validator exactly n nominators

* Update with test

* Try to add accounts to chain spec

* Undo changes to chainspec

* Payout nominator

* Rebond and Reap Stash

* Set history depth

* fix smelly code

* cancel deferred slash

* new_era bench

* do_slash benchmark

* Add features

* undo extrinsic move

* lower

* Update new era

* Update benchmarking.rs

* whitespace

* Apply suggestions from code review

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

* fixes

* nit

* Refactor tests, initial code

* Move session benchmarks to avoid cyclic deps

* Update lib.rs

* Fix warnings

* Move impl

* Update to do random nominator allocation

* add feature to benchmark pallet

* Remove extra stuff

* Update based on feedback

* Less intrusive

* Remove `transfer_idle_users`

* remove again

* unused dep

* test feature flag

* Update to latest substrate

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2020-03-17 14:12:04 +01:00
Shawn Tabrizi 3d6329a22d A Pallet for Benchmarking Common Runtime Operations (#4902)
* Benchmark pallet

* Add a bunch more benchmarks

* do nothing test

* new benchmarks

* Clean up extra tests

* Encode and Decode Vec<T::AccountId>

* Starting to migrate benchmarks to macro

* Use macro

* Remove call and storage

* Update Cargo.toml

* Add storage recalc benchmark

* Add support for custom functions in benchmark! macro

* Reset DB for storage recalc

* Feedback from review

* Add more comments

* Remove benchmark pallet from node

* Fix cargo files

* Fix comments

* Change `crate` to `super`

* missed one

* Use results of benchmark encode/decode

* Pass generic to extra functions

* reset macro to master

* Update lib.rs

* Update to use standard syntax
2020-03-04 17:21:42 +01:00
Tomasz Drwięga 9a0b8b5be5 Offchain Workers: Example Pallet (#4989)
* Example of offchain worker pallet.

* Fix compilation issues.

* Use serde_json to parse JSON.

* Add some basic tests.

* Working on docs.

* Fix compilation

* Finish docs for signed.

* Work on unsigned send.

* Add some tests and missing docs.

* Add example of StorageValueRef

* Add weight.

* Extra \n

* Fix im-online test.

* Bump runtime.

* Fix tests.

* Apply suggestions from code review

Co-Authored-By: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>
Co-Authored-By: Gavin Wood <gavin@parity.io>

* Address review comments.

Co-authored-by: Joshy Orndorff <JoshOrndorff@users.noreply.github.com>
Co-authored-by: Gavin Wood <github@gavwood.com>
2020-02-20 15:21:34 +01:00
Max Inden d8230ecf4b Introduce Prometheus metric endpoint replacing Grafana endpoint (#4981)
* Refactor rebase master prometheus_v0.3

* Milestone1: Final Version of v0.3

* no-std or warm compatibility issues, grapana-data -source code reference and correction,applicable

* Cargo.lock paritytech/master rebase

* prometheus networking.rs del, grafana-data-source networking.rs pub edit and note

* chore: reflect various feedback

* Spaces to tabs.

* Replace grafana and tidy

* Add generics

* Add photo back

* Re-fix spaces in primitives/consensus/babe/src/inherents.rs

* Refactor rebase master prometheus_v0.3

* Milestone1: Final Version of v0.3

* no-std or warm compatibility issues, grapana-data -source code reference and correction,applicable

* prometheus networking.rs del, grafana-data-source networking.rs pub edit and note

* chore: reflect various feedback

* Replace grafana and tidy

* Add generics

* Add photo back

* Re-fix spaces in primitives/consensus/babe/src/inherents.rs

* chore: revert this file back to paritytech/master inherents.rs.

* Add newline at EOF

* Tidy

* Use local registry

* fix typo

Co-Authored-By: Max Inden <mail@max-inden.de>

* chore:  Apply review feedback

* endpoint -> exporter

* fix readme

* Remove lazy_static, use ServiceMetrics struct instead

* Switch to using GaugeVecs

* chore: without nightly , edit README

* block_height -> block_height_number

* Switch to a ready_transactions_number gauge

* Update utils/prometheus/src/lib.rs

Co-Authored-By: Max Inden <mail@max-inden.de>

* no-prometheus flag add

* /metrics url Input check

* remove prometheus in Tracing

* remove prometheus in Tracing

* chore: master code rebase edit

* gitlab-check-web-wasm edit code

* From:from and cargo.lock update

* with_prometheus_registry add background_tasks

* utils/prometheus/src/lib.rs: Restructure #[cfg] for wasm without hyper

Given that Hyper is not compatible with WASM targets it needs to be
excluded from WASM builds. Instead of introducing #[cfg] lines
throughout the crate, this patch splits the crate into two: known_os and
unknown_os (WASM).

* utils/prometheus/src/lib.rs: Feature gate known_os module

* client/cli/src/lib.rs: Re-add newline at end of file

Co-authored-by: JeseonLEE <zeroday26@gmail.com>
Co-authored-by: Gavin Wood <github@gavwood.com>
Co-authored-by: Ashley <ashley.ruglys@gmail.com>
Co-authored-by: Hyungsuk Kang <hskang9@gmail.com>
2020-02-19 15:36:24 +01:00
Bastian Köcher b4ebd41c21 Consolidate frame benchmarking into a frame crate (#4977)
This prs cleans up some of the frame benchmarking stuff:
- Move CLI into `frame-benchmarking-cli`. No frame related CLI should
exists in the default Substrate CLI.
- Move all traits and types related to frame benchmarking into the
`frame-benchmarking` trait. Frame types should be isolated in Frame.
2020-02-19 10:22:36 +01:00
Seun Lanlege 5567d18b6a Adds babe rpc support (#4729)
* babe_epochAuthorship
remove test-helpers from sp-keyring, bump spec_version, impl_version

* bump Cargo.lock

* add BabeRPC to node-rpc

* rename to BabeApi, remove err_derive

* pass &ServiceBuilder to with_rpc_extensions callback

* sc-consensus-babe-rpc

* Update client/consensus/babe/src/lib.rs

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

* Better docs, code style chanegs

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

* new line at the end of Cargo.toml

Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: André Silva <andre.beat@gmail.com>
2020-02-17 18:05:30 +00:00
Ashley ead6815ae4 Fix timer panics in the wasm light client (#4561)
* Make WASM browser thing compile

* Fix

* updated exit-future (github repo)

* Switch to broadcast crate

* Migrate client/cli

* Switch exit-future to modernize branch

* Small changes

* Switch to cargo version and fix fg tests

* fix basic-authorship

* Fix crash on grafana macro

* Fix grafana macro

* Switch node python version

* Disable record_metrics_slice in grafana macro on wasm

* Update client/grafana-data-source/src/lib.rs

* Revert "Update client/grafana-data-source/src/lib.rs"

This reverts commit 888009a8e0b7051bd4bfbbfdb0448bcf2e2aae93.

* Add wasm support for state machine

* Switch to my own libp2p version

* Revert "Switch to my own libp2p version"

This reverts commit ce613871b59264b3165b45c37943e6560240daa7.

* Revert "Add wasm support for state machine"

This reverts commit de7eaa0694d9534fc3b164621737968e9a6a7c5f.

* Add sc-browser

* Squash

* remove sc-browser

* Fix keystore on wasm

* stubs for removed functions to make env compatible with old runtimes

* Add test (that doesn't work)

* Fix build scripts

* Revert basic-authorship due to no panics

* Revert cli/informant

* Revert consensus

* revert offchain

* Update utils/browser/Cargo.toml

Co-Authored-By: Benjamin Kampmann <ben@gnunicorn.org>

* export console functions

* Add new chainspec

* Fix ws in chain spec

* revert chainspec

* Fix chainspec

* Use an Option<PathBuf> in keystore instead of cfg flags

* Remove crud

* Only use wasm-timer for instant and systemtime

* Remove telemetry changes

* Assuming this is ok

* Add a KeystoreConfig

* Add stubs back in

* Update libp2p

* Revert "Add stubs back in"

This reverts commit 4690cf1882aa0f99f7f00a58c4080c8aa9b77c36.

* Remove commented js again

* Bump kvdb-web version

* Fix cli

* Switch branch on futures-timer

* Fix tests

* Remove sc-client test build in check-web-wasm because there isn't a good way to build futures-timer with wasm-bindgen support in the build

* Remove more things ^^

* Switch branch on futures-timer back

* Put DB io stats behind a cfg flag

* Fix things

* Don't timeout transports on wasm

* Update branch of futures-timer and fix bad merge

* Spawn informant

* Fix network test

* Fix delay resets

* Changes

* Fix tests

* use wasm_timer for transaction pool

* Fixes

* Switch futures-timer to crates

* Only diagnose futures on native

* Fix sc-network-test tests

* Select log level in js

* Fix syncing ;^)

* Allow disabling colours in the informant

* Use OutputFormat enum for informant

* MallocSizeOf impl on transaction pool broke stuff because wasm_timer::Instant doesnt impl it so just revert the transaction pool to master

* Update futures-diagnose

* Revert "MallocSizeOf impl on transaction pool broke stuff because wasm_timer::Instant doesnt impl it so just revert the transaction pool to master"

This reverts commit baa4ffc94fd968b6660a2c17ba8113e06af15548.

* Pass whole chain spec in start_client

* Get Instant::now to work in transaction pool again

* Informant dep reordering

Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Svyatoslav Nikolsky <svyatonik@gmail.com>
Co-authored-by: Benjamin Kampmann <ben.kampmann@googlemail.com>
Co-authored-by: Demi Obenour <48690212+DemiMarie-parity@users.noreply.github.com>
2020-02-10 12:23:55 +01:00
Wei Tang 4df27e760e Refactor epoch changes to a separate crate (#4785)
* Init epoch changes module

* Initial integration of new epoch changes module for BABE

* Fix all initial compile errors

* rename: digest -> digests

* Fix babe tests

* Bump impl_version

* Fix more test issues

* Remove test flag for tree

It unfortunately won't work for multiple crates.

* Update cargo lock

* Fix duplicate parking_lot version

* Add missing license header
2020-02-06 16:48:38 +01:00
Jimmy Chu acb66f0699 Node template folders restructuring (#4811)
* Restructure node-template so it is clear that node, runtime, and pallets are separated
* Separating to mock and tests
* restructuring runtime to top-level
* updated release script
* updated Cargo.lock
2020-02-06 20:13:44 +08:00
Gavin Wood d52d8692f9 Refactor the balances module (#4649)
* Initially scoping out of the problem

* Remove need for exiry in balance locks.

* Remove expiry from locks.

* Remove supefluous balance test

* Amalgamate pieces of balance module

* Split out vesting

* Fix tests

* Fixes for vesting.

* Docs.

* Weight docs.

* Refactor things in terms of set_balances.

* Switch out ED to be free + reserved.

* Remove on_free_balance_zero and some docs.

* Build fixes

* Update frame/vesting/src/lib.rs

Co-Authored-By: Xiliang Chen <xlchen1291@gmail.com>

* Update frame/vesting/src/lib.rs

Co-Authored-By: Xiliang Chen <xlchen1291@gmail.com>

* Migration

* Remove superfluous code.

* Test fixes

* Fix some tests

* Fix repatriate reserve

* Fixes

* Add test for migration

* Final cleanups

* Fix

* Indentation.

* Undo unneeded referencing

* Bump runtime version

* Fixes

Co-authored-by: Xiliang Chen <xlchen1291@gmail.com>
2020-02-01 13:20:16 +00:00
Bastian Köcher 709a899f9d Cleanup transaction pool deps (#4782)
* Cleanup transaction pool deps

* Fix it properly

* Fix doc test
2020-01-31 12:40:32 +01:00
Seun LanLege 9cea98e950 Manual Seal (#4143)
* instant/manual seal

unbounded queues are evil

Apply suggestions from code review

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

add fork tests, docs, remove todos

moar docs

Update client/consensus/manual-seal/src/rpc.rs

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

remove unbound generic, parameter, docs, deps, code style changes

Apply suggestions from code review

Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>

code style chnges

remove unused deps, remove dep renames, check if block is empty before importing, use ? for error propagation

fix tests

log errors for instant seal

use debug

code style changes, updated copyright dates

use txpool::Pool instead of BasicPool, code style changes

fixed tests

* fix tests

* requested changes from review

* check inherents len

* rebase
2020-01-27 10:59:40 +01:00
Bastian Köcher 5bd6e94e64 Move "wasm" allocator into its own crate (#4716)
This moves the wasm-allocator (`FreeingBumpHeapAllocator`) into its own
crate `sp-allocator`. This new crate can theoretically provide multiple
different allocators. Besides moving the allocator, this pr also makes
`FreeingBumpHeapAllocator` compile on `no_std`.
2020-01-22 18:13:17 +01:00
Shawn Tabrizi d16d57884a A Social Account Recovery Pallet (#4531)
* Initial sketch of social recovery pallet

* Fix compilation issues

* Use a single total delay, rename stuff

* Check possible overflow

* Copyright bump

* Add mock for tests

* Add basic end to end test

* Add `create_recovery` tests

* Add malicious recovery lifecycle test

* Make clear we check for sorted and unique friends

* Work on some tests, clean up imports

* Change `if let Some(_)` to `ok_or()`

* More tests

* Finish tests, except issue with `on_free_balance_zero`

* Fix `on_free_balance_zero`

* Pallet docs

* Add function/weight docs

* Fix merge master

* OnReapAccount for System too

* Update weight docs

* Allow passthrough to support fee-less extrinsics
2020-01-13 17:52:04 +01:00
Gavin Wood c81e9df162 Society pallet (#4170)
* Introduce efficient Hash-based RNG streamer

* Initial draft of the society module

* Introduce a test

* Dual-pot logic

* Vouching

* Use chacha

* Half way through moving to cliff payout.

* Fixes

* Add some tests

* Remove printlns

* Merge remote-tracking branch 'origin/gav-verified-id' into gav-verified-id

# Conflicts:
#	frame/identity/src/lib.rs

* Merge remote-tracking branch 'origin/gav-verified-id' into gav-verified-id

# Conflicts:
#	frame/identity/src/lib.rs

* Fix `slash_payout`, add test

* Test for multi-slash_payout

* Add docs to `put_bid` function and `bidding_works` test

* Add strikes to test

* Add comments to `rotate_period`

* Implement `suspend_member`

* Off chain iteration of suspended members using linked_map

* Half of suspended candidate

* Finish suspend_candidate, need tests

* Resolve mistakes and feedback, add `suspended_candidate_rejected` test

* Remove logic which increases payout time after un-suspension

* Fix error in `slash_suspended_candidates`, add member check to `vote`

* Fix vouch rewards, dont create zero payouts, add tests for vouch

* Test unvouch

* Unbid tests

* Add lifecycle events, fix `add_member` to update `MembershipChanged`

* Head cannot be removed from society

* Use `add_member` in `found` to ensure `MembershipChanged` is triggered

* Use `Judgement` enum for suspended candidate judgement

* Make society instantiable

* Implement challenges

* Remove extra text in test

* Remove `BlockNumber` return from `slash_payout`

* Add bad vote causes slash test

* Update frame/society/src/lib.rs

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

* Add consts to module metadata

* Check `suspended_member` cant bid

* Increase strength of payout check, **must** be a member.

* Start pallet documentation

* Finish docs

* Update library names, use decl_error

* Prevent double bids, add test

* Use `map` for vouching member, and introduce banned vouchers

* Remove leftover docs

* Vouching handles removed member lifecycles w/ tests

* `take` the votes when tallying, add comprehensive checks before vouch or bid

* Check votes are cleaned up

* Check vote is for a valid candidate, add vote event

* Defender vote event

* Fix `judge_suspended_candidate`, add weight docs

* First pass fixes (blank lines, formatting, no operational)

* Bump copyright year

* Make `add_member` infallible

* More feedback updates

* Add storage access complexity

* Fix logic for AutoUnbid

* Complete weight documentation

* Optimize logic which used to result in double storage read.

* Use Bid struct rather than tuple

* Introduce `MaxMembers` configuration constant

* Add comment about fringe scenario where `MaxMembers` could go over, NBD

* Change MaxMembership to configurable storage item with ability for root to update

* Make membership challenges skew toward failure.

If no one at all votes, or the vote is tied, the user will be suspended from society. This means, that the user simply needs to vote for themselves to stay in society assuming no one else participates.

* Refactor `is_candidate`as to avoid possible double storage reads in the future.

* Blank lines

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
2020-01-10 10:55:16 +01:00
Ashley bb44f8fc24 Add a browser-utils crate (#4394)
* Squash

* Fix keystore on wasm

* Update utils/browser/Cargo.toml

Co-Authored-By: Benjamin Kampmann <ben@gnunicorn.org>

* export console functions

* Use an Option<PathBuf> in keystore instead of cfg flags

* Add a KeystoreConfig

* Update libp2p

* Bump kvdb-web version

* Fix cli

* Upgrade versions

* Update wasm-bindgen stuff

Co-authored-by: Benjamin Kampmann <ben.kampmann@googlemail.com>
2020-01-07 16:30:04 +01:00
Sergei Pepyakin 1782fbbbba Extract execution engines definitions into their own crates (#4489)
* Clean imports in wasmi_execution

* Replace `interpret_runtime_api_result` with `pointer_and_len_from_u64`.

* Extract sc-executor-common crate

* Extract `sc-executor-wasmi` into its own crate

* Extract `sc-executor-wasmtime` into its own crate.

* Add missing headers.

* Clean and docs

* Docs for sc-executor-wasmi

* Expand a comment about sandboxing

* Fix assert_matches

* Rename (un)pack_ptr_and_len and move them into util module

* Remove wasmtime errors in sc-executor-common
2019-12-24 13:17:41 +01:00
Pierre Krieger c66c191b68 Extract consensus_gossip.rs and put it in its own crate (#4284)
* Extract gossiping system from network

* Finish porting GRANDPA tests

* Try put correct engine ID

* Fix messages encoding

* Fix communication tests

* Use a threads pool to spawn stuff

* Fix compilation everywhere

* Fix bad merge conflict

* Remove dependency on async-std

* Apply suggestions from code review

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

* More suggestions

* Remove network startup GP future

* Update to futures_timer

* adjust wait_when_behind test

* Pass correct Roles after handshake

* Revert "adjust wait_when_behind test"

This reverts commit 23cb3a0a6d25ed732c2cd648607bc44ef2ab0919.

* Crate root documentation

* Remove MessageRecipient

* Address concerns

* Fix more concerns

* Forgot Cargo.lock
2019-12-13 19:16:10 +01:00
Benjamin Kampmann c5a709a882 Fix folder names in client and test (#4360)
* client/rpc/api -> client/rpc-api

* client/util/wasm-builder-runner -> utils/wasm-builder-runner

* client/grafana-data-source -> utils/grafana-data-source

* test/utils -> test-utils

* fix moved path

* Update Cargo.lock

* Update Cargo.lock
2019-12-11 16:41:38 +01:00
Benjamin Kampmann 7773daaf5b Clean up crate names and locations (#4361)
* rename crate: sp-transaction-pool-api -> sp-transaction-pool

* move primitives/core/derive-debug -> primitives/derive-debug; primitives/core/storage -> primitives/storage

* rename crate sp-core-storage -> sp-storage

* rename and move: test/utils/transaction-factory -> client/transaction-factory

* move transaction-factory -> node/transaction-factory

* fix missing rename

* Move chain-spec-builder into bin/utils

* move subkey into bin/utils

* Update new subkey location

* Update docs to reflect new location for utils

* fixing import name
2019-12-11 15:33:00 +01:00
Benjamin Kampmann df133d6be3 Fix folder names in primitives (#4358)
* sr-arithmetic -> arithmetic

* sr-sandbox -> sandbox

* primitives/sr-staking-primitives -> primitives/staking

* primitives/sr-version -> primitives/version

* primitives/block-builder/runtime-api -> primitives/block-builder
2019-12-11 11:36:29 +01:00
Benjamin Kampmann 605c0e655e Fix a bunch of low work dependency cycles (#4354)
* take test-client off sp-consensus

* use test primitives rather than test client in authority discovery tests

* move runtime-interface tests

* don't forget to remove the dev-dependency

* remove more unneeded dev deps

* add changes_trie_config to test prrimitives

* Separate network crates from its integration tests

* Fix up consensus crates for networking test changes

* remove unnecessary dependencies

* remove unused addition

* remove unnecessary dev-dependencies

* fixing finality grandpa tests

* removing unnecessary executor dependencies
2019-12-11 10:27:34 +01:00
Benjamin Kampmann f0cc89a4b0 Break appcrypto dep cycle (#4347)
* move application-crypto tests into seperate crate

* Fix crate name, update script and add docs

* pressing 'save' helps

* remove useless lines

* adding header

* split into actual modules
2019-12-10 22:12:57 +01:00
Benjamin Kampmann 8721d98dd6 break sp-api dependency cycle (#4352)
* move benches into tests, ignore non-passing doctests

* Rename sr-api folder

* Move test-primitives to primitives, use that for sp-api doctests
2019-12-10 20:18:01 +01:00