Commit Graph

1304 Commits

Author SHA1 Message Date
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
Arkadiy Paronyan 7349a3a217 Don't search for authority set change block if delay is zero (#4076) 2019-11-10 19:09:36 +01:00
Arkadiy Paronyan c58a9b7f05 Don't update common block on ancient block import (#4073) 2019-11-10 13:35:15 +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
Arkadiy Paronyan 9defa6a281 Further fix for common block update (#4071) 2019-11-09 15:46:43 +01:00
Pierre Krieger f90fd34f81 Pass startup_time to telemetry (#4069) 2019-11-09 13:58:00 +01:00
Tomasz Drwięga b5469c6e0c Additional logging for the transaction pool. (#4068)
* Additional logging for the pool.

* Long line.
2019-11-09 13:22:21 +01:00
Arkadiy Paronyan 4e54dfac14 Improved cache documentation (#4067) 2019-11-09 12:36:47 +01:00
Bastian Köcher 38ac53434c Fix the ui tests (#4066) 2019-11-09 10:34:17 +01:00
André Silva 94a5fcd9a6 grandpa: remove the periodic block announcer (#4062)
* grandpa: remove the periodic block announcer

* grandpa: remove periodic block announcer test
2019-11-09 09:11:24 +01:00
Arkadiy Paronyan 4b8578e7e4 Fix sync downloading ancient chains (#4060)
* Update best block on announcement

* Added a test
2019-11-09 09:11:13 +01:00
Arkadiy Paronyan 2cd3b2bce1 Batch gossip messages (#4055) 2019-11-08 21:34:45 +01:00
Tomasz Drwięga c3f6e5bd40 Introduce thread pool for transaction validation. (#4051) 2019-11-08 21:34:30 +01:00
André Silva a8ce80b72d grandpa: progressively increase target gossip peers (#4050)
* grandpa: stricter gossip message filtering

* gossip: remove filtered message on send_message

* gossip: add test for tracking of broadcast attempts

* grandpa: only restrict gossip if we're connected to more than 5 authorities

* grandpa: add test for progressive gossip

* grandpa: add test for gossip filtering on local non-authority node

* grandpa: fix doc

* gossip, grandpa: tabify

* grandpa: relax filtering logic for global messages
2019-11-08 20:08:14 +01:00
thiolliere 77407e1694 fix inmemory (#4049) 2019-11-08 14:07:51 +01:00
Demi Obenour 5a26696432 Remove dependencies on OpenSSL (#4036)
* Remove dependency on hyper-tls

This removes one of the dependencies on native-tls, and thus on OpenSSL.
I will remove the other in a separate commit.

* Remove the `HttpClient` enum

It only had one variant.

* Apply suggestions from code review

Co-Authored-By: Pierre Krieger <pierre.krieger1708@gmail.com>
2019-11-08 13:29:03 +01:00
Arkadiy Paronyan dfded93411 Increase parallel downloads to 5 (#4045)
* Increase parallel downloads to 5

* CLI param
2019-11-08 11:24:46 +01:00
B YI 2125b87cae fix two typos (#4048) 2019-11-08 09:27:33 +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
Nikolay Volf 745b68bfa9 Improve auto-docs a little. (#4032) 2019-11-07 12:04:56 +01:00
Arkadiy Paronyan 8de6279300 Ban incoming invalid transactions (#4037) 2019-11-07 12:03:23 +01:00
Arkadiy Paronyan e73436d818 Decrease peer reputation on bad transactions (#4035)
* Decrease reputation on bad transactions

* Don't punish on duplicate transactions
2019-11-07 12:00:14 +01:00
Bastian Köcher 3022d60d92 Make TestExternalities implement Send (#4030)
* Make `TestExternalities` implement `Send` + `Sync`

* Fixes offchain

* Make it just `Send`
2019-11-06 14:43:55 +01:00
Bastian Köcher b484c4fbc0 Update syn, proc-macro2 and quote to 1.x (#4028) 2019-11-06 14:00:49 +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
Arkadiy Paronyan 1aaf31a34d Less verbose console output (#4029) 2019-11-06 10:06:11 +01:00
Nikolay Volf f093eeba24 fix warnings (#4024) 2019-11-05 19:53:50 +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
Gavin Wood 350e72dac5 Revert "Header-only sync for old forks (#3942)" (#4022)
This reverts commit 172359adad.
2019-11-05 16:05:36 +01:00
Arkadiy Paronyan 172359adad Header-only sync for old forks (#3942)
* Header-only sync for old forks

* Simplified blocks-count

* Update core/consensus/common/src/block_import.rs

Co-Authored-By: Marcio Diaz <marcio.diaz@gmail.com>
2019-11-05 12:17:12 +01:00
Arkadiy Paronyan b92674d88a Traffic statistics (#4017)
* Network stats

* Fixed tests
2019-11-05 12:15:59 +01:00
Arkadiy Paronyan 4ca6f8d1b2 Enable parallel block download (#4014) 2019-11-05 10:27:49 +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
Tengfei Niu 8b6b3d3730 refactor code: remove unused import (#4010)
* remove unused import

* fix test error
2019-11-04 11:34:19 +01:00
brenzi ed5ac30a44 support crypto primitives for no_std introducing full_crypto feature (#3778)
* introduced "with_crypto" feature and applied switches like in substrate-api-client fork

* introduced "with_crypto" feature and applied switches like in substraTEE-worker fork

* distinguishing core::hash vs std::hash

* @bkchr's review requests fulfilled

* fixes

* revert dependency upgrade ed25519-dalek

* added full_crypto features to all crates using app_crypto! macro

* fixing CI complaints.

* fix again

* adding CI test for with_crypto feature

* added full_crypto for ecdsa. now builds wit h--no-deafault-features --features with_crypto

* remove --release from CI test

* @bkchr requested changes. moved full_crypto CI test to build stage

* fixing no_std issue

* CI fresh copy from srml-staking

* gitlab CI with +nightly

* solved no-feature-in-macro dilemma

* cosmetics

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

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

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

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

* even more simple

* undo line delete

* refactoring app_crypto macro. splitting functionalities based on full_crypto feature

* whitespace cosmetics
2019-11-04 10:53:41 +01:00
Wei Tang 2e424f4d9f Substrate EVM (#3927)
* srml-evm: init the basic structures

* srml-evm: finish executor implementation

* srml-evm: implement balance deposit and withdraw

* srml-evm: implement the actuall call/create

* srml-evm: use crates.io version of evm

* srml-evm: fix no-std compile

* Remove dependency patch

* Update to evm 0.14

* Use double map for account storage

* Add precompiles support

* Add some basic docs

* Use runtime_io::chain_id()

* Update srml/evm/src/lib.rs

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

* Update srml/evm/src/lib.rs

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

* Fix WithdrawReason

* Unique saturate balance to u128

* Unique saturate withdraw to u128

* Remove extern crate alloc

* Move account code to a separate storage and use ref for convert_account_id

* More match cause for error message

* Fix potential interger overflow

* Use decode_len for fetching code length
2019-11-03 15:57:46 +01:00
Tomasz Drwięga 69c4e2f7f0 Deprecate ValidateUnsigned and prevent duplicate heartbeats (#3975)
* Add pre-dispatch checks for ValidateUnsigned

* Deprecate ValidateUnsigned.

* Bump specversion.

* Fix test.
2019-11-03 10:52:08 +00:00
Bastian Köcher d233ad55ad Implement color output for wasm builder (#4004)
* Implement color output for wasm builder

* Fix `Cargo.lock`
2019-11-02 19:59:49 +01:00
Kian Paimani 084b158031 Optional serde for phragmen support (#3994)
* Add serde to phragmen

* Update lock file

* and bump a version

* and bump a version again

* Apply suggestions from code review

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

* revert impl-tarit for tuple update

* revert session.

* Revert "revert session."

This reverts commit 98086c9db56677068db85f74320868b2c10d1c00.

* Revert "revert impl-tarit for tuple update"

This reverts commit 28a7fddee2e09c5785b19883f743065e0be8f331.
2019-11-01 22:22:37 +01:00
Benjamin Kampmann 4852763d73 expose offchain worker storage prefix (#3977)
* expose offchain worker storage prefix

* add docs

* move STORAGE_PREFIX to primitives
2019-11-01 19:32:01 +01: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 8fe64173e8 executor: Move runtime version caching out of WasmRuntime interface. (#3993)
* executor: Move runtime caching out of WasmRuntime interface.

The runtime version is now fetched and cached at a higher level, not
within the WasmRuntime trait implementations.

* executor: Require successful querying of runtime version.
2019-11-01 18:22:28 +01:00
Bastian Köcher 6193481352 Don't panic in Offchain test context, when we are already panicking (#3996) 2019-11-01 17:14:21 +01:00
Marcio Diaz 596ac7bd1f Possible fix to storage cache (#3989)
* Comment local_cache propagation

* Add test

* Deny cache when modifications are unknown

* Fix indentation
2019-11-01 15:17:38 +00:00
Caio d5f61d5217 Implement Debug for some structures (#3941)
* Implement Debug for some structures

`NetworkConfiguration`, `TransportConfig`, `NodeKeyConfig` and `Secret`.

Needs a new release of the `rust-libp2p` crate. This PR is just a
reminder.

* Explicitly separate `std` and `core`

* Add manual implementation for Secret
2019-11-01 15:28:19 +01: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
Weiliang Li 34bd4c335b authority-discovery: futures 03 Future (#3848)
* authority-discovery: futures 03 Future

* make ci happy

* use futures timer instead of tokio timer

* Update core/authority-discovery/src/lib.rs

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

* remove tokio 01 runtime

* trigger build

* kill futures01

* rename futures
2019-11-01 12:55:29 +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