Commit Graph

2382 Commits

Author SHA1 Message Date
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
Arkadiy Paronyan a07e567fe1 Storage tracing (#3614)
* Storage tracing

* Whitepsaces

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

* Apply suggestions from code review

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

* Update Cargo.lock
2019-09-17 20:42:15 +02:00
Bastian Köcher 2b040fe983 Properly detect debug build in slots (#3630)
`debug-assertions` can also be enabled in for release builds. This
introduces a new build-script that extracts the build type from the
`PROFILE` env variable and sets the `build_type` cfg.
2019-09-17 14:39:40 +02:00
Shawn Tabrizi 113d512300 Suggest --release compilation (#3627) 2019-09-17 13:32:52 +02:00
Tomasz Drwięga c4af4fa522 Fix missing contracts RPC on a full node. (#3622)
* Add contracts RPC to full node.

* Instantiate both RPC extensions for light & full.
2019-09-17 13:06:36 +02:00
Bastian Köcher 96c781834d Enable nice wasm panic messages by default (#3619)
By accident it was already enabled in master for quite some time. To
make sure that we don't blow up the wasm binary size, I compiled the
binary with the feature enabled and disabled. With nice panic messages
enabled, the binary size increases by 908 bytes. Given the value that
this feature brings, I think it is okay to have these panic messages
enabled by default.
2019-09-17 11:28:32 +02:00
Arkadiy Paronyan 84d0c790f3 Send block status with announcement (#3607)
* Send block status with announcement

* Fixed tests

* Whitespace

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

* Additional comment

* Update comment

Co-Authored-By: André Silva <andre.beat@gmail.com>
2019-09-17 11:19:46 +02:00
Weiliang Li 6679c8b051 Update mod.rs (#3625)
Add `import_notification_stream` for test client
2019-09-17 11:16:22 +02:00
Svyatoslav Nikolsky 849e824652 Fetching multiple remote values using single message (#3612)
* multiple remote values in single message

* keys_str: String ->keys_str: closure
2019-09-16 13:30:21 +03:00
Tomasz Drwięga c45a15e559 RPC call to get all RPC methods (#3613)
* Add meta rpc_methods call.

* Sort methods.

* Bump runtime.

* Change format a bit to support versioning.
2019-09-13 21:19:04 +02:00
Bastian Köcher 45d64a711c Clean up sr-io (#3609)
* Move trait `Printable` into `sr-primitives`

* Cleanup runtime io trie_root interfaces

* Remove last generic bits from sr-io interface

* Fix srml-sudo after master merge

* Fix benchmarks

* Runtime bump
2019-09-13 16:39:50 +02:00
Michael Müller 5cb8c0dc1c Fixes for allocator + factory + misc improvements (#3534)
* 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
2019-09-13 15:47:15 +02:00
Tomasz Drwięga b7c6bc1ed5 Fix tracking validator set in ImOnline (#3596)
* Use session::validators instead of staking::current_elected

* Basic test framework.

* Initialize validators, attempt to heartbeat.

* Use dummy crypto for im-online testing.

* Remove printlns.

* Finish test, make it invalid.

* Add reporting test.

* Finalize the test.

* Remove dumbness.

* Updates.

* Update AuRa

* Update srml/im-online/src/tests.rs

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

* Derive Ord

* Add some more tests.

* Remove stray todo.

* Bump runtime version.

* Bump impl-trait-for-tuples.

* Enforce new version of trait-for-tuples.
2019-09-13 14:55:33 +02:00
Kian Paimani a7f35680b4 Fix Staking and Democracy locking (#3606)
* Fix locking.

* Some reformattings.

* Fix build.

* Fix doc comment.

* Bump.
2019-09-13 08:52:52 +02:00
Kian Paimani a6b5d1d155 Move phragmen benchmarks out of Staking (#3588)
* Move phragmen benches to.. phragmen.

* Move some basic phragmen tests to.. phragmen.

* Line-width

* Add phragmen equ implementation as flot

* Add phragmen equ implementation as flot

* Add mock and test file.
2019-09-13 08:41:33 +02:00
Bastian Köcher 7b87cd206b Implement support for patch section in wasm-builder (#3599)
* Implement support for `patch` section in wasm-builder

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

* Support patch by path

* Go down to the actual data
2019-09-12 21:59:18 +02:00
Sergei Pepyakin 981b3c79ee Print version when panic (#3608)
* Print version when panic

* Fix tests.
2019-09-12 17:52:26 +02:00
Svyatoslav Nikolsky 634ca73e50 Make light client backend only work with locally available data (#3538)
* removing fetcher dependency from light backend

* fix compilation
2019-09-12 17:13:26 +02:00
André Silva fd924c07ed grandpa: reannounce voted blocks periodically (#3602)
* grandpa: reannounce latest voted blocks periodically

* grandpa: add test for background block announcement

* grandpa: configurable delay for background block announcer

* grandpa: nits
2019-09-12 17:12:04 +02:00
Gavin Wood d864254b7a Sudo can dispatch from an account (#3604)
* Sudo can dispatch from an account.

* Fix

* Bump runtime.

* Update srml/sudo/src/lib.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
2019-09-12 16:47:03 +02:00
Marcio Diaz a643ac6c6f Fix subkey does not verify with pubkey (#3547)
* Decode hex

* Remove log

* Some refactoring to help with testing

* Add own functions for sign and verify.

* Add sign test

* Sign-verify test

* Generate-sign-verify test for both cryptos

* Add aliases

* Print signature

* More refactoring

* Update sign-transaction as transfer

* Simplify transfer and sign-transaction

* main to top file

* rename read_input_message to read_message_from_stdin

* More refactoring

* Add read_required_parameter

* Add format seed

* More refactoring

* format code

* add print_extrinsic

* Remove 0x from print

* fix naming

* Fix readme

* Remove rustfmt

* Remove commented test

* Fix import nits
2019-09-12 15:42:35 +02:00
Sergei Pepyakin 4daac15d22 Add an RPC method for calling a contract. (#3563)
* 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
2019-09-12 13:30:10 +02:00
Xiliang Chen 294d172187 fix inconsistency in block time (#3603) 2019-09-12 10:21:21 +02:00
André Silva 32335cc5e4 grandpa: fix race condition (#3542)
* grandpa: ignore result of voter command send

* grandpa: avoid race condition on environment::finalize_block
2019-09-12 00:03:10 +01:00
Sergei Pepyakin 098d880cf9 read_storage panics (#3589)
* Add a failing test case

* Actual fix

* read_child_storage, fix wasm side

* Bump the impl version.

* Alternative (#3597)

* Update with_std.rs

* Update with_std.rs

* Update wasm_executor.rs

* Update wasm_executor.rs

* Update with_std.rs

* Update wasm_executor.rs
2019-09-11 19:37:19 +02:00
Bastian Köcher d136b8eb81 Switch to new proc-macro crate for implementing traits for tuples (#3598)
* Switch to new proc-macro crate for implementing traits for tuples

* Switch back to stable `Cargo.lock` format

* Reduce tuple number to match rusts default implementation
2019-09-11 19:10:02 +02:00
André Silva 433d752831 grandpa: use periodic neighbor packet sender (#3594) 2019-09-11 18:08:15 +02:00
Gavin Wood d908f32c30 Fixes NPoS reward, along with tests, cleanups & docs corrections (#3595)
* Minor cleanups and tests

* Add another test

* fix

* Fix tests

* Fix tests

* Update srml/staking/src/tests.rs

Co-Authored-By: thiolliere <gui.thiolliere@gmail.com>
2019-09-11 15:11:08 +02:00
Shawn Tabrizi ccc73da289 Use --release for running a Substrate dev node (#3591)
* Use `--release` for running a Substrate dev node

Otherwise users may run into block production time problems.

* Update README.adoc
2019-09-11 09:42:31 +02:00
Svyatoslav Nikolsky 010395e620 Never panic during execution proof check (#3504)
* do not panic during execution proof check

* Update core/state-machine/src/lib.rs

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

* Update core/state-machine/src/lib.rs

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

* Update core/state-machine/src/lib.rs

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

* BackendTrustLevel enum

* up runtime version

* Update core/state-machine/src/lib.rs

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

* Update core/state-machine/src/lib.rs

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

* fixed some grumbles

* Update core/state-machine/src/testing.rs

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

* Update core/state-machine/src/lib.rs

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

* mov where

* spaces -> tabs (to restart build)
2019-09-11 10:27:32 +03:00
Bastian Köcher 9607afd629 Cleanup of the state-machine crate (#3524)
* Start refactoring state-machine crate

* More improvement to state-machine

* Fix tests compilation on master and remove warnings

* Fix compilation

* Apply suggestions from code review

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

* Update core/state-machine/src/basic.rs

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

* Line width

* Update core/primitives/src/storage.rs

Co-Authored-By: Benjamin Kampmann <ben.kampmann@googlemail.com>

* Update core/state-machine/src/error.rs

Co-Authored-By: Benjamin Kampmann <ben.kampmann@googlemail.com>

* Review feedback
2019-09-10 17:00:00 +02:00
Tomasz Drwięga 2beeda1488 Don't initialize block for offchain workers. (#3578) 2019-09-10 16:15:32 +02:00
Bastian Köcher 1450719acc First step for generating host externals out of the function definition in sr-io (#3567)
* Adds new wrapper traits for wasm executor

* Add new crate `substrate-wasm-interface`

Thew new crate holds types and traits for the communicating between the
wasm runtime and the host.

* Rewrite externals with new macro etc

* Fix vec initialization

* Make executor tests working

* Remove unused code + warnings

* Introduce `Pointer` and `WordSize` for working with wasm

* Fix tests and compilation

* Fix compilation

* Apply suggestions from code review

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

* Review feedback

* Remove unused conversions

* Make each host function its own struct

`HostFunctions` now just returns these function structs. Each function
can be executed by using one of the function structs. The inherent host
functions are now moved to the "normal" host functions.

* Remove byteorder

* Add floating point types

* Make pointer interface more safe

* Add type alias for wasm-interface Result

* More review comments
2019-09-10 16:07:25 +02:00
Bastian Köcher 86b3f2e1a7 Augment every task spawned by Service with on_exit (#3581)
* Augment every task spawned by Service with `on_exit`

* Add CI test that the node exits
2019-09-10 12:05:54 +02:00
Benjamin Kampmann a4ba356047 Add section regarding polkadot PRs. (#3579)
* Add section regarding polkadot PRs.

* Also add the comment in the PR template

* Apply suggestions from code review

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

* Rephrase Step 1, add command
2019-09-10 10:21:46 +02:00
Svyatoslav Nikolsky 81af1d140a finalize -> finalize_with_ancestors (#3576) 2019-09-09 14:22:58 +01:00
André Silva ae8bc414ab grandpa: don't require justification of consensus changes on full node (#3540)
* grandpa: don't request justification for consensus changes on full node

* sync: finalize justification/finality proof requests in-order

* sync: ignore result of try_finalize_root on justification import
2019-09-09 07:28:35 +02:00
Xiliang Chen 9dc9e51063 Fix node template build issue (#3570)
* fix unused var warning

* fix node-tempalte build issue
2019-09-07 12:53:11 +02:00
Sergei Pepyakin 4f7e36e072 Update docs for the wasm executor crate (#3569)
* Grammar.

* Update docs for wasm executor.

* Update core/executor/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>
2019-09-06 23:08:08 +02:00
Caio 0fff0d28db Implement Maybe* marker traits using a declarative macro (#3557)
Although simple, the current `Maybe*` trait implementations are based on
a manual approach that uses some code duplication. Now this duplication
is removed using a declarative macro.
Tested locally, the modification don't seem to affect building times.
2019-09-06 21:31:37 +02:00
Arkadiy Paronyan 0df2be5760 Add transactions from retracted blocks back to the pool (#3562)
* Add transactions from retracted blocks back to the pool

* Line width

* Reverse retracted
2019-09-06 21:30:43 +02:00
Kian Paimani a381f033bd Better testing for lock types in staking/democracy. (#3565)
* Better testing for lock types in staking/democracy.

* Update docs.

* Update srml/executive/src/lib.rs

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

* Update srml/executive/src/lib.rs

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

* Fix test
2019-09-06 19:41:29 +02:00
Max Inden 027d88796b core/authority-discovery: Enable authorities to discover each other (#3452)
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
2019-09-06 17:43:03 +02:00
Wei Tang ece0b57d8d Consensus: Proof of Work (#3473)
* consensus-pow: init primtives and verifier

* consensus-pow: add total difficulty auxiliary

* consensus-pow: implement total difficulty chain selection

* consensus-pow: implement pow import queue

* consensus-pow-primitives: add mine into PowApi

* consensus-pow: implement mining

* Update lock file

* Style fixes

No run-on expressions allowed.

* consensus-pow: refactor register_pow_inherent_data_provider

* consensus-pow: make PowApi::mine yieldable

* consensus-pow: better mining loop

* Add missing license header

* consensus-pow-primitives: clarify the meaning of None for PowApi::verify

* consensus-pow: changing total difficulty addition to use saturating add

* consensus-pow: change mine-loop error to log on error! level

* consensus-pow: allow inserting arbitrary preruntime digest for pow

The preruntime digest can be intepreted by the runtime as the block author/coinbase.

* Fix line width

* More line width fixes

* consensus-pow: separate difficulty, verify API

This makes it more apparent that currently in PoW engine, `difficulty` should
be input, not output.

* srml-pow: implementation of average_span difficulty adjustment

* srml-pow: basic blake2 algo example

* srml-pow-average-span: make it not require genesis config

* srml-pow: add support for authorship

* Missing license headers

* consensus-pow: PowAlgorithm trait generalization

* Missing docs for consensus-pow

* More docs

* node-runtime: bump impl_version

* Add rationale for difficulty type

* consensus-pow: refactor aux_key

* Update lock file

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

* Remove PowRuntimeAlgorithm

* block_id -> parent_block_id

* Auxiliary data -> auxiliary storage data

* Fix error message

* Fix compile

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

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

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

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

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

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

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

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

* Fix crate description

* More docs

* Address grumbles

1. Make preruntime Optional.
2. Add more docs on what is `preruntie` and `round`.
3. Replace `Default::default` with the approriate type.
2019-09-06 15:45:53 +02:00
Kian Paimani 202271d0a1 Remove dead code in Staking (#3559)
* Remove some dead code from staking

* Fix var name.
2019-09-06 13:39:55 +02:00
Svyatoslav Nikolsky 551a9e6bcb Changes tries build cache (#2933)
* changes tries build cache

added CT build cache test

* fix lines width

* fixed some grumbles

* clear cache when: digests disabled, top-level or skewed digest is built

* cached_changed_keys -> with_cached_changed_keys
2019-09-05 08:27:04 +03:00