* WASM runtime switch to import memory
Up to now runtimes have exported their memory. To unify it with
sandboxing, this pr switches runtimes to import memory as well.
From a functional perspective, exporting/importing memory makes no
difference to the runtime.
To provide backwards compatibility, WASM exported memory is still supported.
* Revert debug stuff
* Revert some stuff
* Introduces `author_hasKey` and `author_hasSessionKeys` rpc endpoints
Both endpoints can be used to check if a key is present in the keystore.
- `hasKey` works on with an individual public key and key type. It
checks if a private key for the given combination exists in the
keystore.
- `hasSessionKeys` works with the full encoded session key blob stored
on-chain in `nextKeys`. This requires that the given blob can be decoded
by the runtime. It will return `true`, iff all public keys of the
session key exist in the storage.
Fixes: https://github.com/paritytech/substrate/issues/4696
* Update client/rpc-api/src/author/error.rs
Co-Authored-By: Nikolay Volf <nikvolf@gmail.com>
* Indentation
Co-authored-by: Nikolay Volf <nikvolf@gmail.com>
* consensus, pow: intermediate separation and fail
* Fix compiles
* Update primitives/consensus/common/src/block_import.rs
Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>
* Update primitives/consensus/common/src/block_import.rs
Co-Authored-By: Robert Habermeier <rphmeier@gmail.com>
* Document what None means for `fork_choice` in block import params
Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
* Make debug builds more usable
This pr makes debug builds more usable in terms of `cargo run -- --dev`.
1. `--dev` activates `--execution native`, iff `--execution` is not
given or no sub `--execution-*` is given.
2. It was probably a mistake to compile WASM in debug for a debug build.
So, we now build the WASM binary always as `release` (if not requested
differently by the user). So, we trade compilation time for a better
debug experience.
* Make sure we only overwrite default values
* Make it work
* Apply suggestion
* Implement runtime version checks in `set_code`
Check that the new runtime code given to `set_code` fullfills some
requirements:
- `spec_name` matches
- `spec_version` does not decreases
- `impl_version` does not decreases
- Either `spec_version` and `impl_version` increase
* Make tests almost work
* Some fixes after master merge
* Fix tests
* Add missed file
* Make depedency check happy?
* Remove leftover `sc-executor`
* AHHHHH
* Reset debug stuff
* Remove some 'static
* More 'static
* Some docs
* Update `Cargo.lock`
* reset a couple of versions down from v0.2.0
* Unstablise browser-utils (very new) and grafana-data-source (going to be replaced with prometheus sometime)
* unmark a bunch more client crates for stabilization
* fix versions in Cargo.tomls
* Downgrade network-test
* Set frame-metadata version to `10.0.0`
* Hide and documented storage generator as internal api
* Downgrade `sp-externalities`
* Downgrade `sc-cli`
* Downgrade sc-executor et al to 0.8.0
* Downgrade sp-state-machine to 0.8.0
* Downgrade pallet-contracts et al to 0.8.0
* Downgrade sp-sandbox to 0.8.0
* downgrade pallet-evm to 0.8.0
* Downgrade pallet-staking to 0.8.0
2.0 should be implementation of lazy payout alongside all the fixes of
current module
* Downgrade node-transaction-factory to 0.8.0
* frame pallets are 2.0.0
Co-authored-by: Ashley <ashley.ruglys@gmail.com>
Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Sergei Pepyakin <s.pepyakin@gmail.com>
Co-authored-by: Wei Tang <accounts@that.world>
Co-authored-by: thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Marcio Diaz <marcio@parity.io>
Instead of having these weird implementation of `BuildStorage for
&ChainSpec` we should just take the `genesis_storage` by ref. The
`BuildStorage` trait changed some time ago to take a self ref anyway,
instead of a self value.
Also fixes warnings in frame-staking
* Extend `Proposer` to optionally generate a proof of the proposal
* Something
* 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
* Introduce new `into_storage_changes` function
* Switch to runtime api for `execute_block` and don't require `H256`
anywhere in the code
* Put the `StorageChanges` into the `Proposal`
* Move the runtime api error to its own trait
* Adds `StorageTransactionCache` to the runtime api
This requires that we add `type NodeBlock = ` to the
`impl_runtime_apis!` macro to work around some bugs in rustc :(
* Remove `type NodeBlock` and switch to a "better" hack
* Start using the transaction cache from the runtime api
* Make it compile
* Move `InMemory` to its own file
* Make all tests work again
* Return block, storage_changes and proof from Blockbuilder::bake()
* Make sure that we use/set `storage_changes` when possible
* Add test
* Fix deadlock
* Remove accidentally added folders
* Introduce `RecordProof` as argument type to be more explicit
* Update client/src/client.rs
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* Update primitives/state-machine/src/ext.rs
Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
* Integrates review feedback
* Remove `unsafe` usage
* Update client/block-builder/src/lib.rs
Co-Authored-By: Benjamin Kampmann <ben@gnunicorn.org>
* Update client/src/call_executor.rs
* Bump versions
Co-authored-by: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
Co-authored-by: Benjamin Kampmann <ben.kampmann@googlemail.com>
* Make `decl_error!` errors usable
This pr implements support for returning errors of different pallets in
a pallet. These errors need to be declared with `decl_error!`.
The pr changes the following:
- Each dispatchable function now returns a `DispatchResult` which is an
alias for `Result<(), DispatchError>`.
- `DispatchError` is an enum that has 4 variants:
- `Other`: For storing string error messages
- `CannotLookup`: Variant that is returned when something returns a
`sp_runtime::LookupError`
- `BadOrigin`: Variant that is returned for any kind of bad origin
- `Module`: The error of a specific module. Contains the `index`,
`error` and the `message`. The index is the index of the module in
`construct_runtime!`. `error` is the index of the error in the error
enum declared by `decl_error!`. `message` is the message to the error
variant (this will not be encoded).
- `construct_runtime!` now creates a new struct `ModuleToIndex`. This
struct implements the trait `ModuleToIndex`.
- `frame_system::Trait` has a new associated type: `ModuleToIndex` that
expects the `ModuleToIndex` generated by `construct_runtime!`.
- All error strings returned in any module are being converted now to `DispatchError`.
- `BadOrigin` is the default error returned by any type that implements `EnsureOrigin`.
* Fix frame system benchmarks
* clean up cargo.toml syntax
* bumping versions to 2.0
* bump networking to 0.8
* move consensus down to 0.8
* bump consensus pallets to 0.8.0, too
* Upping babe and aura pallets
* add remaining, missing version definitions
* missed some
* In progress, runtime io must switch to future proof root +
child_specific (unique id) + u32 type.
* Switch interface, sr-io seems ok, rpc could use similar interface to
sr-io, genesis json broken if there is child trie in existing encoding
genesis.
* test from previous implementation.
* fix proving test.
* Restore Keyspacedb from other branch, only apply to child trie.
* Removing unneeded child_info from child root (child info are stored
if things changed, otherwhise the root does not change).
* Switch rpc to use same format as ext: more future proof.
* use root from child info for trie backend essence.
* Breaking long lines.
* Update doc and clean pr a bit.
* fix error type
* Restore removed doc on merge and update sr-io doc.
* Switch child storage api to use directly unique id, if managed id
where to be put in place, the api will change at this time.
* Clean deprecated host interface from child.
* Removing assertion on child info (can fail depending on root
memoization).
* merging child info in the overlay when possible.
* child iteration by prefix using child_info.
* Using ChainInfo in frame support. ChainInfo gets redesign to avoid
buffers allocation on every calls.
* Add length of root to the data of child info.
* comments
* Encode compact.
* Remove child info with root.
* Fix try_update condition.
* Comment Ext child root caching.
* Replace tuples by struct with field
* remove StorageTuple alias.
* Fix doc tests, and remove StorageOverlay and ChildStorageOverlay
aliases.
* Adding first rough ouline of the repository structure
* Remove old CI stuff
* add title
* formatting fixes
* move node-exits job's script to scripts dir
* Move docs into subdir
* move to bin
* move maintainence scripts, configs and helpers into its own dir
* add .local to ignore
* move core->client
* start up 'test' area
* move test client
* move test runtime
* make test move compile
* Add dependencies rule enforcement.
* Fix indexing.
* Update docs to reflect latest changes
* Moving /srml->/paint
* update docs
* move client/sr-* -> primitives/
* clean old readme
* remove old broken code in rhd
* update lock
* Step 1.
* starting to untangle client
* Fix after merge.
* start splitting out client interfaces
* move children and blockchain interfaces
* Move trie and state-machine to primitives.
* Fix WASM builds.
* fixing broken imports
* more interface moves
* move backend and light to interfaces
* move CallExecutor
* move cli off client
* moving around more interfaces
* re-add consensus crates into the mix
* fix subkey path
* relieve client from executor
* starting to pull out client from grandpa
* move is_decendent_of out of client
* grandpa still depends on client directly
* lemme tests pass
* rename srml->paint
* Make it compile.
* rename interfaces->client-api
* Move keyring to primitives.
* fixup libp2p dep
* fix broken use
* allow dependency enforcement to fail
* move fork-tree
* Moving wasm-builder
* make env
* move build-script-utils
* fixup broken crate depdencies and names
* fix imports for authority discovery
* fix typo
* update cargo.lock
* fixing imports
* Fix paths and add missing crates
* re-add missing crates
* {core,srml}/authority-discovery: Move generic to specific session keys
* {srml,core}/authority-discovery: Verify signature outside of runtime
Given that the `core/authority-discovery` uses concrete authority
identifiers and signatures, one can verify a signature with the
authority discovery within `core`. Given the above, the `verify` runtime
api is obsolete and thus removed.
* *: Add authority discovery to the set of session keys
* *: Sign authority discovery DHT payload with keystore instead of runtime
Instead of calling a runtime function to sign a dht payload, which then
invokes the keystore, pass the keystore to the authority discovery
module and use it directly.
* core/authority-discovery: Give libp2p Kademlia time to start up
* core/authority-discovery: Move authorities priority group name to const
* node/runtime/src/lib.rs: Bump runtime spec version
* *: Fix lints and node/testing test failures
* *: Fix formatting
* core/authority-discovery: Box dht event channel in unit tests
* node/cli/src/service.rs: Fix future import
* node/cli/src/service.rs: Replace unwrap by expect with proof
* node/cli/src/chain_spec: Remove TODO for testnet key generation
* core/authority-discovery/src/lib: Remove scale encoding TODOs
* srml/authority-discovery: Make comment a doc comment
* core/authority-discovery: Remove unused StreamExt import
* node/runtime: Bump impl version to debug CI
* Test ci.
* Change the line width to 100.
* Revert "Change the line width to 100."
This reverts commit edff1f855bc71e0418bf3a967f81a35591d882e3.
* Fix a check for polkadot to work on forked repos.
* Revert "node/runtime: Bump impl version to debug CI"
This reverts commit 1a90903b4c929bc55a9e0a538af34b50b7f65139.
* Revert "Test ci."
This reverts commit a2c9df574e645158f77cd2b3d4d9355bcae33aab.
* Cargo.lock: Fix wrong lock file merge
* srml/authority-discovery: Keep track of new validator set not upcoming
* core/authority-discovery: Document key retrieval functions
* 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
* 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
* core: use trait object for genesis constructor
* chain-spec-builder: use structopt
* chain-spec-builder: add new command to generate authority keys
* chain-spec-builder: use ? in main
* chain-spec-builder: fix stored and printed suri from seed
* chain-spec-builder: add comment about created keystore folders
* chain-spec-builder: simplify file write
* Update all dependencies
* Upgrade dependencies whenever “easy”
“easy” means that there are no major changes required.
* Fix build and bump paste dependency to 0.1.6
* Remove dead code
* Re-add = dependency for futures-preview
* Add missing std features for runtime-io
* Remove git dependencies
as updated versions have been published to crates.io
* try to debug bug
* For sr-io, "std" should imply "no_oom" and "no_panic_handler".
Otherwise, rustc complains (correctly) about duplicate lang items.
* Add missing "runtime-io/std" features
* Fix compilation errors
* Prevent duplicate lang items
Rust does not allow duplicate lang items. When compiled without the
`std` feature, `sr-io` defines two lang items. Therefore, `sr-io`
compiled without `feature = "std"` must not be linked with `std`.
However, `pwasm-utils` and `wasmi-validation` both bring in `std` unless
compiled with `default-features = "false"`. This caused a duplicate
lang item error. Building both with `default-features = "false"`
prevents this error. When building with `feature = "std"`, they should
both be built with the `std` feature, so this feature needs to be
explicitly depended on.
* Bump `impl_version`
* Make tests pass
Three tests used 1 less gas than they had previously.
* Try to un-break build
* Add a Cargo.lock file
* Revert offchain code
* Revert "Revert offchain code"
This reverts commit d216d08cc6ca0344614669c1d24cde3aa5c0d4e2.
* Don’t try to send a body with a GET request
without adding a Transfer-Encoding or Content-Length header.
This has always been wrong, but hyperium/hyper#1925 hid the bug until
hyper was upgraded to 0.12.35.
* Change some more GET requests to POST requests
* Fix excess line width and remove an `extern crate`
* Delete commented-out extern crate
Co-Authored-By: Sergei Pepyakin <sergei@parity.io>
* Fix regression in Cargo.toml files
dev-dependencies need `default-features = false`, too.
* Bump parity-wasm dependency
* Bump `futures-preview`
* Apply suggestions from code review
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Update Cargo.lock files
* Apply suggestions from code review
Co-Authored-By: Bastian Köcher <bkchr@users.noreply.github.com>
* Update core/service/src/chain_ops.rs
Co-Authored-By: Sergei Pepyakin <sergei@parity.io>
* Add some chainspec tests and make sure we validate it.
* Manual implementation of Extension + Forks definitions.
* Move chain spec to separate crate.
* Allow using ChainSpec with extensions.
* Renames.
* Implement Extension derive.
* Implement Extension for Forks.
* Support specifying fork blocks.
* make for_blocks work
* Support forks correctly.
* Add a bunch of docs.
* Make fork blocks optional.
* Add missing docs.
* Fix build.
* Use struct for check_block params.
* Fix tests?
* Clean up.
* 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
* Move Service::new to a macro
* Move function calls to macros
* Extract offchain_workers and start_rpc in separate function
In follow-up commits, we want to be able to directly call maintain_transaction_pool, offchain_workers, and start_rpc, without having to implement the Components trait.
This commit is a preliminary step: we extract the code to freestanding functions.
* Introduce an AbstractService trait
* Introduce NewService as an implementation detail of Service
* Implement traits on NewService instead
Instead of implementing AbstractService, Future, and Executor on Service, we implement them on NewService instead.
The implementations of AbstractService, Future, and Executor on Service still exist, but they just wrap to the respective implementations for NewService.
* Move components creation back to macro invocation
Instead of having multiple $build_ parameters passed to the macro, let's group them all into one.
This change is necessary for the follow-up commits, because we are going to call new_impl! only after all the components have already been built.
* Add a $block parameter to new_impl
This makes it possible to be explicit as what the generic parameter of the NewServiceis, without relying on type inference.
* Introduce the ServiceBuilder struct
Introduces a new builder-like ServiceBuilder struct that creates a NewService.
* Macro-ify import_blocks, export_blocks and revert_chain
Similar to the introduction of new_impl!, we extract the actual code into a macro, letting us get rid of the Components and Factory traits
* Add export_blocks, import_blocks and revert_chain methods on ServiceBuilder
Can be used as a replacement for the chain_ops::* methods
* Add run_with_builder
Instead of just run, adds run_with_builder to ParseAndPrepareExport/Import/Revert. This lets you run these operations with a ServiceBuilder instead of a ServiceFactory.
* Transition node and node-template to ServiceBuilder
* Transition transaction-factory to the new service factory
This is technically a breaking change, but the transaction-factory crate is only ever used from within substrate-node, which this commit updates as well.
* Remove old service factory
* Adjust the AbstractService trait to be more usable
We slightly change the trait bounds in order to make all the methods usable.
* Make substrate-service-test compile
* Fix the node-cli tests
* Remove the old API
* Remove the components module
* Fix indentation on chain_ops
* Line widths
* Fix bad line widths commit
* Line widths again 🤦
* Fix the sync test
* Apply suggestions from code review
Co-Authored-By: Gavin Wood <i@gavwood.com>
* Address some concerns
* Remove TelemetryOnConnect
* Remove informant::start
* Update jsonrpc
* Rename factory to builder
* Line widths 😩
* Add Call type to extensible transactions.
Cleanup some naming
* Merge Resource and BlockExhausted into just Exhausted
* Fix
* Another fix
* Call
* Some fixes
* Fix srml tests.
* Fix all tests.
* Refactor crypto so each application of it has its own type.
* Introduce new AuthorityProvider API into Aura
This will eventually allow for dynamic determination of authority
keys and avoid having to set them directly on CLI.
* Introduce authority determinator for Babe.
Experiment with modular consensus API.
* Work in progress to introduce KeyTypeId and avoid polluting API
with validator IDs
* Finish up drafting imonline
* Rework offchain workers API.
* Rework API implementation.
* Make it compile for wasm, simplify app_crypto.
* Fix compilation of im-online.
* Fix compilation of im-online.
* Fix more compilation errors.
* Make it compile.
* Fixing tests.
* Rewrite `keystore`
* Fix session tests
* Bring back `TryFrom`'s'
* Fix `srml-grandpa`
* Fix `srml-aura`
* Fix consensus babe
* More fixes
* Make service generate keys from dev_seed
* Build fixes
* Remove offchain tests
* More fixes and cleanups
* Fixes finality grandpa
* Fix `consensus-aura`
* Fix cli
* Fix `node-cli`
* Fix chain_spec builder
* Fix doc tests
* Add authority getter for grandpa.
* Test fix
* Fixes
* Make keystore accessible from the runtime
* Move app crypto to its own crate
* Update `Cargo.lock`
* Make the crypto stuff usable from the runtime
* Adds some runtime crypto tests
* Use last finalized block for grandpa authority
* Fix warning
* Adds `SessionKeys` runtime api
* Remove `FinalityPair` and `ConsensusPair`
* Minor governance tweaks to get it inline with docs.
* Make the governance be up to date with the docs.
* Build fixes.
* Generate the inital session keys
* Failing keystore is a hard error
* Make babe work again
* Fix grandpa
* Fix tests
* Disable `keystore` in consensus critical stuff
* Build fix.
* ImOnline supports multiple authorities at once.
* Update core/application-crypto/src/ed25519.rs
* Merge branch 'master' into gav-in-progress
* Remove unneeded code for now.
* Some `session` testing
* Support querying the public keys
* Cleanup offchain
* Remove warnings
* More cleanup
* Apply suggestions from code review
Co-Authored-By: Benjamin Kampmann <ben.kampmann@googlemail.com>
* More cleanups
* JSONRPC API for setting keys.
Also, rename traits::KeyStore* -> traits::BareCryptoStore*
* Bad merge
* Fix integration tests
* Fix test build
* Test fix
* Fixes
* Warnings
* Another warning
* Bump version.