Commit Graph

660 Commits

Author SHA1 Message Date
Kian Paimani efedac734d Weight annotation for block hooks. (#4058)
* Initial version that works with proper tests.

* get rid of todos and grumbles and such.

* Cleanup and fix line-width

* fix test runtime test
2019-11-12 14:42:38 +01:00
Gavin Wood c91d42712a Do nothing for zero imbalances (#4089) 2019-11-12 09:42:32 +01:00
Bastian Köcher 2ecffa1cd0 Refactor sr-api to not depend on client anymore (#4086)
* Refactor sr-api to not depend on client anymore

* Fix benches

* Apply suggestions from code review

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

* Apply suggestions from code review
2019-11-11 16:26:49 +01:00
Bastian Köcher b691cfe093 Substrate runtime interface 2.0 (#4057)
* Adds first version of traits for generating the host functions

* First steps of the procedural macro

* Implements generation of the host extern functions

* Prefix ext host function with snake case trait name

* Implement host functions implementation on the host

* Change `HostFunctions` interface

* Implement `HostFunctions` for tuples

* Make `WasmExecutor` generic over the host functions

* Begin to add a test and make it compile

* Make the test succeed

* Add test to ensure that host functions are not found

* It's alive! Make the `set_storage` test work

* Add test for mutable references

* Code cleanup and documentation etc

* Add marker trait for types that should be passed as SCALE encoded

* Inherit the visibility from the trait and more improvements

* More impls and move them into their own file

* Code simplification by dropping one trait

* Give it a better name

* Implement traits for arrays

* Refactor code to support pass by codec/inner

* Docs

* Implement pass by inner for some crypto types and add a test

* Implement exchangeable function support

* Rewrite sr-io with as runtime interface

* Start reworking after master merge

* Adds `PassByCodec` derive

* Adds `PassByInner` derive

* Fix compilation errors

* More implementations

* Implement runtime interface traits for `str`

* Make `sr-io` compile again

* Fix more compilation errors

* More progress on getting stuff back to compile

* More compilation fixes

* Fix warnings

* Remove le conversions

* Add support for `wasm_only` interfaces

* Implement `Allocator` interface

* Improve error message

* Move `WasmAllocator` to `sr-io` and more clean ups

* Use correct function signature for wasm functions

* Store the host functions with the Wasm runtime

* Docs update

* Fix compilation after master merge

* Remove `sr-io/without_std`

* Make `srml-support` tests run again

* More compilation error fixes

* Use correct doc syntax

* Fix test-runtime

* Fix compilation

* Catch native panics when executing the wasm runtime

As with the native runtime, we now catch all native panics when we
execute the wasm runtime. The panics inside the wasm runtime were
already catched before by the wasm executor automatically, but any panic
in the host functions could bring down the node. The recent switch to
execute the native counterpart of the host function in `sr-io`, makes
this change required. The native `sr-io` functions just `panic` when
something is not provided or any other error occured.

* Fix compilation

* Don't panic in a panic

* Move `sr-sandbox` to new runtime interface

* Fixes tests after sandbox changes

* Make sure we detect invalid utf8

* Fixes after master merge

* Adds pass by enum strategy

* Fix wasmtime integration

* Some macro structure clean up

* Rework and test exchangebale host functions

* PassBy derive macros documentation

* Docs for `runtime_interface` macro

* Support wild card argument names

* Adds ui tests

* Make sure that we are backwards compatible to the old runtime interfaces

* Documentation

* Fixes after latest master merge

* Make `wasmtime` happy

* Make `full_crypto` work

* Make the new interface versionable

* Rename `Sanboxing` to `Sandbox`

* Don't finalize in test while importing

* Fix Performance regression

* Fix test
2019-11-10 21:59:30 +01:00
Pierre Krieger 401e213aa2 Add a --no-private-ipv4 CLI option (#4042)
* Add a --no-private-ipv4 CLI option

* Fix tests

* Fix tests
2019-11-10 11:14:36 +01:00
Weiliang Li 63a1a5b7f8 clean node/cli/Cargo.toml (#4046)
* clean node/cli/Cargo.toml

* minor fix

* clean node/runtime/Cargo.toml
2019-11-08 08:54:45 +01:00
Arkadiy Paronyan cca9ab436c Allow import withouth state verification (#4031)
* Allow import without state verification

* Explicit None

Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>
2019-11-07 15:25:41 +01:00
Jim Posen 021f3a3f06 grandpa: Use storage proofs for Grandpa authorities (#3985) 2019-11-07 14:31:17 +01:00
Gavin Wood bb6b3db57e Refactor out MaxPossibleReward, fix staking arithmetic (#4041)
* Refactor out MaxPossibleReward, fix staking arithmetic

* Fix rounding error in test
2019-11-07 12:34:13 +01:00
Gavin Wood 24d82d9717 Treasury rewards should pay the remainder of the 10% (#4026)
* Treasury rewards should pay the remainder of the 10%..

* Event for deposits coming into treasury

* Fix tests

* Remove OnDilution
2019-11-06 17:36:23 +01:00
Pierre Krieger cc09bfbd09 Apply breaking changes of new libp2p versions (#3877)
* Apply breaking changes of new libp2p versions

* Oops, forgot to update version

* Fix tests

* Fix imports with WASM

* Fix WASM for real

* Update core/network/src/debug_info.rs

Co-Authored-By: Roman Borschel <romanb@users.noreply.github.com>

* Fix compilation
2019-11-06 14:00:12 +01:00
Bastian Köcher 508c52a08a Don't re-compile on every cargo run (#4019)
- Add new crate `substrate-build-script-utils` to unify the code of
`node`, `node-template` and `polkadot-node`.
- The `node-cli` build script needs to search upwards for the
`.git/HEAD` file to find it.
2019-11-05 19:36:10 +01:00
Tomasz Drwięga 279391f9c1 Limit longevity of im-online heartbeats. (#4011)
* Limit longevity of im-online heartbeats.

* Unused import.

* Use parameter for session duration.
2019-11-05 12:16:46 +01:00
Kian Paimani 093f1c46e5 Update RPC deps. (#4012)
* Bump rpc deps

* Update core/test-runtime/src/genesismap.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
2019-11-04 12:53:58 +01:00
joe petrowski 77ed0dc2bc fix formula in comment (#4006) 2019-11-03 15:09:45 +01:00
Tomasz Drwięga 45e79d617b Avoid sending heartbeat if we are already considered online. (#3981)
* Don't send a heartbeat if already online.

* Remove env_logger.

* Update lock.

* Bump runtime.

* Merge master
2019-11-03 10:51:33 +00:00
Benjamin Kampmann 2ff04d332d Move config path generation into the service config for reusability (#3978)
* Move config path generation into the service config for reusability

* Make NoCostum Default and fix tests

* Apply suggestions from code review

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

* remove function not used anymore

* Make path into an option

* remove database_path function and call it directly

* remove helper functions, use consts
2019-11-01 17:51:06 +00:00
Jim Posen 8676c25ef4 Integrate Wasmtime for runtime execution (#3869)
* executor: Use non wasmi-specific execution in tests.

* executor: Move all runtime execution tests into tests file.

* executor: Use test_case macro to easily execute tests with different
Wasm execution methods.

* executor: Convert errors to strings with Display, not Debug.

* node-executor: Rewrite benchmarks with criterion.

They were not passing compilation before and criterion seems to be more
widely used in Substrate.

* executor: Begin implementation of Wasm runtime.

The implementation demonstrates the outline of the execution, but does
not link against the external host functions.

* executor: Define and implement basic FunctionExecutor.

The SandboxCapabilities::invoke is still left unimplemented.

* executor: Implement host function trampoline generation.

* executor: Instantiate and link runtime module to env module.

* executor: Provide input data during wasmtime execution.

* executor: Implement SandboxCapabilites::invoke for wasmtime executor.

* executor: Integrate and test wasmtime execution method.

* executor: Improve FunctionExecution error messages.

* Scope the unsafe blocks to be smaller.

* Rename TrampolineState to EnvState.

* Let EnvState own its own compiler instead of unsafe lifetime cast.

* Refactor out some common wasmi/wasmtime logic.

* Typos and cosmetic changes.

* More trampoline comments.

* Cargo.lock update.

* cli: CLI option for running Substrate with compiled Wasm execution.

* executor: Switch dependency from fork to official wasmtime repo.

* Quiet down cranelift logs.

* Explicitly catch panics during host calls.

We do this to ensure that panics do not cross language boundaries.

* Additional checks and clarifications in make_trampoline.

* Fixes after merge from master and panic safety for wasmtime
instantiation.
2019-11-01 13:32:14 +01:00
Gavin Wood 26f4084f95 Add events for im_online (#3991)
* Add AllGood event for im_online

* Another event just in case.

* Bump runtime
2019-11-01 11:07:46 +00:00
Jim Posen 8207b4fceb Revert "grandpa: Use storage proofs for Grandpa authorities (#3734)" (#3983)
This reverts commit c0a1926704.
2019-10-31 22:48:04 +00:00
Benjamin Kampmann 363c8989d4 and backend reference to rpc builder (#3979) 2019-10-31 15:44:52 +00:00
Pierre Krieger 4264613a96 Add the code for compiling node-cli for WASM-browser (#3974)
* Extract CLI to separate module in node/cli

* Make node/cli compile for WASM

* More work on node/cli browser

* More work on browser node

* More work

* More work

* Purge a bit the CI script

* More clean up

* Remove substrate-finality-grandpa from the CI

Its tests use tokio, which fails to compile.

* Address review

* Add rocksdb feature to the service

* Fix substrate-service WASM CI

* Apply suggestions from code review

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

* Don't WASM-compile substrate-service altogether
2019-10-31 16:34:12 +01:00
Jim Posen c0a1926704 grandpa: Use storage proofs for Grandpa authorities (#3734)
* grandpa: Write Grandpa authorities to well known key.

Instead of requiring execution proofs for Grandpa authorities, this
enables much simpler storage proofs.

* grandpa: Introduce named AuthorityList type.

* grandpa: Storage migration for srml-grandpa module.

* Remove no-longer-used GrandpaApi runtime API.

* grandpa: Write AuthorityList to storage with encoding version.

We expect the AuthorityList type may change (eg. key changes). To make
upgrades smoother, include a version in the stored value.

* Bump node runtime spec version.

* Update srml/grandpa/src/lib.rs

Co-Authored-By: André Silva <andre.beat@gmail.com>
2019-10-31 14:33:34 +01:00
André Silva 3cbc28ab59 im-online: account for block authorship (#3973)
* im-online: account for block authorship

* im-online: add test for block authorship onlineness

* im-online: cleanup

* im-online: fix test
2019-10-31 11:11:11 +01:00
Tomasz Drwięga a73334f769 Increase priority of ImOnline heartbeats (#3972)
* Make sure im-online reports are high priority.

* Bump runtime.
2019-10-30 16:19:31 -07:00
Pierre Krieger 14e4cf9155 Remove node/src/main.rs (#3969) 2019-10-30 16:49:17 +01:00
Sergei Pepyakin 5486d7add2 Implement contract_getStorage RPC API (#3944) 2019-10-30 13:54:57 +01:00
André Silva c92eda9809 node: add sentry mode flag (#3959)
* node: add sentry mode flag

* cli: extend docs on validator and sentry modes

* service: add missing field in test Configuration

* node: Display instead of Debug when printing node role
2019-10-29 19:58:34 +01:00
André Silva dc14809804 grandpa: fix handling of catch-up requests (#3956)
* grandpa: fix handling of catch-up requests

* grandpa: fix tests

* grandpa: add test for catch-up handling when observer disabled

* grandpa: extend doc comment

* grandpa: rename existing catch up test
2019-10-29 19:15:49 +01:00
Gavin Wood 3aecf32824 More robust punishment (#3952)
* Introduce new option "always force new era".

* Take appropriate action, even for small offences.

- Deselect the offender in all circumstances
- Ensure that deselection forces a new era
- Ensure that forcing a new era works with the always-forcing.

* Bump runtime
2019-10-29 17:03:17 +01:00
Bastian Köcher 057636fd1f Remove footgun around session keys/handlers (#3949)
* Remove footgun around session keys/handlers

- `OpaqueKeys` now has an associated type `KeyTypeIdProviders`. This can
be used in the runtime as input for `SessionHandler` from the session
trait.
- `impl_opaque_keys` now works with modules and extracts the `KeyTypeId`
from the module directly.
- Added some checks to the `session` storage initialization that checks
that the `SessionHandler` and `Keys` use the same number of keys and
that the order is equal.

* Update core/sr-primitives/src/traits.rs
2019-10-29 00:58:58 +01:00
Kian Paimani 7e87dfdc07 RPC to query transaction fee + weight + info (#3876)
* initial version for testing

* New version that compiles

* optional at block parameter

* Fix some more view grumbles.

* Update srml/transaction-payment/src/lib.rs
2019-10-28 16:04:45 +01:00
Kian Paimani 9b1dd268bf Updates to elections-phragmen and some runtime docs. (#3940)
* minor changes

* Refactors for phragmen-election

* Bump.

* Fix genesis stuff

* Fix rest of the errors
2019-10-28 15:29:53 +01:00
Max Inden e110cd7ae8 *: Disable authority discovery module (#3914)
The authority discovery module enables authorities to be discoverable
and discover other authorities to improve interconnection among them. In
order to achieve this the module needs to know when the authority set
changes, thus when a session changes.

One has to register a module as a *session handler* in order for it to
be notified of changing sessions. The order and number of these *session
handlers* **MUST** correspond to the order and number of the *session
keys*.

Commit 027d887 added the authority discovery to the `SessionHandlers`.
Given that the authority discovery module piggybacks on the Babe session
keys the commit violated the above constraint.

This commit reverts most of 027d887, leaving `core/authority-discovery`
and `srml/authority-discovery` untouched.
2019-10-28 11:06:16 +01:00
Gavin Wood 580e32101e runtime: Add ability to force a name change (#3934)
* Add ability to force a name change

* Fix tests

* Bump runtime.
2019-10-27 16:20:35 +01:00
Gavin Wood c08ac2277f runtime: Expose const params for nicks module (#3932)
* Expose const params for nicks module

* Bump runtime
2019-10-27 14:36:35 +01:00
Gavin Wood d41a5ce00f Revert "Watch existing extrinsics RPC (#3873)" (#3931)
This reverts commit d149c2f719.
2019-10-27 13:19:06 +01:00
Nikolay Volf d149c2f719 Watch existing extrinsics RPC (#3873)
* Transaction pool watch intristics.

* Track extrinsic rpc methods.

* Test for pool watcher.

* Track extrinsic rpc test.

* Fix rpc naming.

* review fixes

* Update jsonrpc and use une subcription.

* Naming and dependencies.
2019-10-27 12:55:44 +01:00
Xiliang Chen f7ee9ab235 Fix node-template (#3924)
* fix node-template
Use MultiSignature to maintain compatibility with substrate-node
Reset version to 1
Remove unused const

* fix chain_spec

* line width
2019-10-27 12:54:41 +01:00
Gavin Wood 3d6127ade0 runtime: Account nicknames (#3930)
* Add Nicknames module for accounts.

* Integrate into node.

* Fix build

* Update srml/nicks/src/lib.rs

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

* Bump runtime

* Improve weight docs

* Docs.

* Apply suggestions from code review

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
2019-10-27 12:53:41 +01:00
Gavin Wood a0094e72e5 Add force_unstake to staking as root operation. (#3918)
* Add force_unstake to staking as root operation.

* Bump runtime

* Tests

* Update srml/staking/src/lib.rs

Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
2019-10-25 15:14:49 +02:00
Gavin Wood b88b6b5418 Remove MintedForSpending (now unused) (#3917) 2019-10-25 14:22:25 +02:00
Tomasz Drwięga cecf3a1438 Bring back SubmitSignedTransaction trait. (#3908)
* Bring back SubmitSignedTransaction.

* Fix long lines.

* Add missing docs.

* Update core/primitives/src/crypto.rs

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

* Update node/runtime/src/lib.rs

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

* Update core/primitives/src/crypto.rs

Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
2019-10-25 12:24:58 +02:00
Jim Posen e05e624a3a support: BuildStorage methods to take self reference (#3884)
* support: BuildStorage methods to take self reference.

There is no reason to consume the GenesisConfig when using it to
initialize a new storage backend. Instead, build_storage and
assimilate_storage now operator on self references.

* Bump node runtime impl_version.
2019-10-25 11:44:57 +02:00
thiolliere d49c36428d Fix treasury kept and spend when emptied (#3880)
* Now construct_runtime must include treasury config so account is created at genesis.
* if it doesn't though it is ok, account will be created when the amount put is more than existential deposit.
2019-10-24 17:26:26 +02:00
Pierre Krieger 002057dcc5 Service builder clean-up (#3906)
* Rename NewService to Service

* Move new_impl! macro to builder module

* Inline new_impl!

* Minor cleanup

* Inline the offchain_workers() function

* Fix indentation level

* Inline start_rpc

* Remove RpcBuilder trait
2019-10-24 15:11:38 +02:00
Kian Paimani ecd1ed7b65 Better Parameterisation for Fee system (#3823)
* Better fee parameters

* Fix build

* Better runtime tests

* Price to Weight ratio as type parameter (#3856)

* Price to Weight ration as type parameter

* Kian feedback

* Some renames.

* Fix executor tests

* Getting Closer.

* Phantom Data

* Actually fix executor tests.

* Fix tests.

* Remove todo

* Fix build
2019-10-24 15:03:52 +02:00
Gavin Wood d97775542a Add SECP256k1/ECDSA support for transaction signing (#3861)
* Add SECP256k1/ECDSA support for transaction signing.

* Refactoring and fixes

* Fix for contracts

* Avoid breaking runtime host function

* Build fixes, make subkey work more generaically.

* Fix tests

* Dedpulicate a bit of code, remove unneeded code, docs

* Bump runtime version

* Fix a test and clean up some code.

* Derivation can derive seed.

* Whitespace

* Bump runtime again.

* Update core/primitives/src/crypto.rs

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

* Update core/primitives/src/ecdsa.rs

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

* Fix AppVerify
2019-10-24 10:59:09 +02:00
André Silva 62a238a81b node: spawn grandpa voter as essential task (#3899)
* node: spawn grandpa voter as essential task

* node: stop babe authoring task on exit

* node: remove unnecessary future boxing

* Apply suggestions from code review
2019-10-24 10:14:32 +02:00
Kian Paimani 311be1d071 Fix phragmen election to wasm (#3898)
* Fix phragmen-election compile to wasm

* Fix chain_spec stuff

* Fix panic with no term duration
2019-10-23 22:04:42 +02:00