Implement runtime version checks in set_code (#4548)

* 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`
This commit is contained in:
Bastian Köcher
2020-01-16 13:58:37 +01:00
committed by Gavin Wood
parent 437772be9e
commit afc3318f21
38 changed files with 584 additions and 279 deletions
+117 -118
View File
@@ -1088,7 +1088,7 @@ dependencies = [
[[package]]
name = "environmental"
version = "1.0.2"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
@@ -1238,7 +1238,7 @@ dependencies = [
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -1293,7 +1293,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "fork-tree"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1306,7 +1306,7 @@ dependencies = [
"pallet-balances 2.0.0",
"pallet-indices 2.0.0",
"pallet-transaction-payment 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -1318,7 +1318,7 @@ dependencies = [
name = "frame-metadata"
version = "10.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-std 2.0.0",
@@ -1335,7 +1335,7 @@ dependencies = [
"impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"once_cell 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1384,7 +1384,7 @@ name = "frame-support-test"
version = "2.0.0"
dependencies = [
"frame-support 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -1402,21 +1402,23 @@ dependencies = [
"criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"frame-support 2.0.0",
"impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-externalities 0.8.0",
"sp-io 2.0.0",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
"sp-version 2.0.0",
"substrate-test-runtime-client 2.0.0",
]
[[package]]
name = "frame-system-rpc-runtime-api"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
]
@@ -2042,7 +2044,7 @@ name = "impl-codec"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -3041,7 +3043,7 @@ dependencies = [
"pallet-indices 2.0.0",
"pallet-timestamp 2.0.0",
"pallet-transaction-payment 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-authority-discovery 0.8.0",
"sc-basic-authorship 0.8.0",
@@ -3101,7 +3103,7 @@ dependencies = [
"pallet-timestamp 2.0.0",
"pallet-transaction-payment 2.0.0",
"pallet-treasury 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-executor 0.8.0",
"sp-application-crypto 2.0.0",
"sp-core 2.0.0",
@@ -3191,7 +3193,7 @@ dependencies = [
"pallet-transaction-payment-rpc-runtime-api 2.0.0",
"pallet-treasury 2.0.0",
"pallet-utility 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3221,7 +3223,7 @@ dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"node-template-runtime 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-basic-authorship 0.8.0",
"sc-cli 0.8.0",
@@ -3261,7 +3263,7 @@ dependencies = [
"pallet-sudo 2.0.0",
"pallet-timestamp 2.0.0",
"pallet-transaction-payment 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
@@ -3297,7 +3299,7 @@ dependencies = [
"pallet-timestamp 2.0.0",
"pallet-transaction-payment 2.0.0",
"pallet-treasury 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client 0.8.0",
"sc-executor 0.8.0",
"sp-core 2.0.0",
@@ -3313,7 +3315,7 @@ name = "node-transaction-factory"
version = "0.8.0"
dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-cli 0.8.0",
"sc-client 0.8.0",
"sc-client-api 2.0.0",
@@ -3476,7 +3478,7 @@ version = "2.0.0"
dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3493,7 +3495,7 @@ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-session 2.0.0",
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
@@ -3513,7 +3515,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-session 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-authority-discovery 2.0.0",
@@ -3531,7 +3533,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-authorship 2.0.0",
"sp-core 2.0.0",
"sp-inherents 2.0.0",
@@ -3550,7 +3552,7 @@ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-session 2.0.0",
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-consensus-babe 0.8.0",
@@ -3572,7 +3574,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-transaction-payment 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -3589,7 +3591,7 @@ dependencies = [
"frame-system 2.0.0",
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -3609,7 +3611,7 @@ dependencies = [
"pallet-balances 2.0.0",
"pallet-randomness-collective-flip 2.0.0",
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pwasm-utils 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3630,7 +3632,7 @@ dependencies = [
"jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-contracts-rpc-runtime-api 0.8.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
@@ -3644,7 +3646,7 @@ dependencies = [
name = "pallet-contracts-rpc-runtime-api"
version = "0.8.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
@@ -3657,7 +3659,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -3674,7 +3676,7 @@ dependencies = [
"frame-system 2.0.0",
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -3691,7 +3693,7 @@ dependencies = [
"frame-system 2.0.0",
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3710,7 +3712,7 @@ dependencies = [
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rlp 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3728,7 +3730,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3743,7 +3745,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-finality-tracker 2.0.0",
@@ -3759,7 +3761,7 @@ version = "2.0.0"
dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3775,7 +3777,7 @@ dependencies = [
"frame-system 2.0.0",
"pallet-finality-tracker 2.0.0",
"pallet-session 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-finality-grandpa 2.0.0",
@@ -3793,7 +3795,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3809,7 +3811,7 @@ dependencies = [
"frame-system 2.0.0",
"pallet-authorship 2.0.0",
"pallet-session 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-core 2.0.0",
@@ -3825,7 +3827,7 @@ version = "2.0.0"
dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -3841,7 +3843,7 @@ version = "2.0.0"
dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3856,7 +3858,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3871,7 +3873,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3886,7 +3888,7 @@ version = "2.0.0"
dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3902,7 +3904,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3917,7 +3919,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -3934,7 +3936,7 @@ dependencies = [
"impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
@@ -3953,7 +3955,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -3973,7 +3975,7 @@ dependencies = [
"pallet-session 2.0.0",
"pallet-staking-reward-curve 2.0.0",
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"safe-mix 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -4003,7 +4005,7 @@ version = "2.0.0"
dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -4018,7 +4020,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-inherents 2.0.0",
@@ -4036,7 +4038,7 @@ dependencies = [
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"pallet-transaction-payment-rpc-runtime-api 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
"sp-runtime 2.0.0",
@@ -4051,7 +4053,7 @@ dependencies = [
"jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-transaction-payment-rpc-runtime-api 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-blockchain 2.0.0",
@@ -4065,7 +4067,7 @@ name = "pallet-transaction-payment-rpc-runtime-api"
version = "2.0.0"
dependencies = [
"frame-support 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
@@ -4080,7 +4082,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -4095,7 +4097,7 @@ dependencies = [
"frame-support 2.0.0",
"frame-system 2.0.0",
"pallet-balances 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -4172,7 +4174,7 @@ dependencies = [
[[package]]
name = "parity-scale-codec"
version = "1.1.0"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5018,7 +5020,7 @@ dependencies = [
"futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.14.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"prost 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"prost-build 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5042,7 +5044,7 @@ version = "0.8.0"
dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-block-builder 0.8.0",
"sc-client 0.8.0",
@@ -5064,7 +5066,7 @@ dependencies = [
name = "sc-block-builder"
version = "0.8.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client-api 2.0.0",
"sp-api 2.0.0",
"sp-block-builder 2.0.0",
@@ -5147,7 +5149,7 @@ dependencies = [
"kvdb 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb-memorydb 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-block-builder 0.8.0",
"sc-client-api 2.0.0",
@@ -5182,7 +5184,7 @@ dependencies = [
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"kvdb 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-executor 0.8.0",
"sc-telemetry 2.0.0",
@@ -5213,7 +5215,7 @@ dependencies = [
"kvdb-rocksdb 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-util-mem 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5241,7 +5243,7 @@ dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client 0.8.0",
"sc-client-api 2.0.0",
@@ -5285,7 +5287,7 @@ dependencies = [
"num-bigint 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"num-rational 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pdqselect 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5326,7 +5328,7 @@ dependencies = [
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client-api 2.0.0",
"sp-api 2.0.0",
"sp-block-builder 2.0.0",
@@ -5346,7 +5348,7 @@ dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client-api 2.0.0",
"sc-telemetry 2.0.0",
@@ -5383,7 +5385,7 @@ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libsecp256k1 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-executor-common 0.8.0",
@@ -5412,7 +5414,7 @@ version = "0.8.0"
dependencies = [
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-runtime-interface 2.0.0",
"sp-serializer 2.0.0",
@@ -5425,11 +5427,10 @@ name = "sc-executor-wasmi"
version = "0.8.0"
dependencies = [
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-executor-common 0.8.0",
"sp-core 2.0.0",
"sp-externalities 0.8.0",
"sp-runtime-interface 2.0.0",
"sp-wasm-interface 2.0.0",
"wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5446,11 +5447,10 @@ dependencies = [
"cranelift-native 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cranelift-wasm 0.50.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wasm 0.41.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-executor-common 0.8.0",
"sp-core 2.0.0",
"sp-externalities 0.8.0",
"sp-runtime-interface 2.0.0",
"sp-wasm-interface 2.0.0",
"wasmi 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5470,7 +5470,7 @@ dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-timer 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client 0.8.0",
@@ -5532,7 +5532,7 @@ dependencies = [
"linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quickcheck 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5618,7 +5618,7 @@ dependencies = [
"hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"num_cpus 1.11.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client-api 2.0.0",
@@ -5658,7 +5658,7 @@ dependencies = [
"jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-pubsub 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client 0.8.0",
@@ -5694,7 +5694,7 @@ dependencies = [
"jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-pubsub 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5743,7 +5743,7 @@ dependencies = [
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-chain-spec 2.0.0",
"sc-client 0.8.0",
@@ -5807,7 +5807,7 @@ version = "0.8.0"
dependencies = [
"env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
]
@@ -5857,7 +5857,7 @@ dependencies = [
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -5873,7 +5873,7 @@ dependencies = [
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client-api 2.0.0",
"sc-transaction-graph 2.0.0",
@@ -6179,7 +6179,7 @@ name = "sp-api"
version = "2.0.0"
dependencies = [
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api-proc-macro 2.0.0",
"sp-core 2.0.0",
"sp-runtime 2.0.0",
@@ -6205,7 +6205,7 @@ name = "sp-api-test"
version = "2.0.0"
dependencies = [
"criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-blockchain 2.0.0",
@@ -6221,7 +6221,7 @@ dependencies = [
name = "sp-application-crypto"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
@@ -6246,7 +6246,7 @@ dependencies = [
"criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6258,7 +6258,7 @@ dependencies = [
name = "sp-authority-discovery"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-runtime 2.0.0",
@@ -6269,7 +6269,7 @@ dependencies = [
name = "sp-authorship"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-inherents 2.0.0",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
@@ -6279,7 +6279,7 @@ dependencies = [
name = "sp-block-builder"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-inherents 2.0.0",
"sp-runtime 2.0.0",
@@ -6293,7 +6293,7 @@ dependencies = [
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"lru 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-block-builder 2.0.0",
"sp-consensus 0.8.0",
@@ -6310,7 +6310,7 @@ dependencies = [
"futures-timer 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.14.0-alpha.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-inherents 2.0.0",
@@ -6325,7 +6325,7 @@ dependencies = [
name = "sp-consensus-aura"
version = "0.8.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
"sp-inherents 2.0.0",
@@ -6338,7 +6338,7 @@ dependencies = [
name = "sp-consensus-babe"
version = "0.8.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"schnorrkel 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
@@ -6353,7 +6353,7 @@ dependencies = [
name = "sp-consensus-pow"
version = "0.8.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-core 2.0.0",
"sp-runtime 2.0.0",
@@ -6378,7 +6378,7 @@ dependencies = [
"libsecp256k1 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6416,7 +6416,7 @@ dependencies = [
name = "sp-externalities"
version = "0.8.0"
dependencies = [
"environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-std 2.0.0",
"sp-storage 2.0.0",
]
@@ -6425,7 +6425,7 @@ dependencies = [
name = "sp-finality-grandpa"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-application-crypto 2.0.0",
@@ -6437,7 +6437,7 @@ dependencies = [
name = "sp-finality-tracker"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-inherents 2.0.0",
"sp-std 2.0.0",
]
@@ -6447,7 +6447,7 @@ name = "sp-inherents"
version = "2.0.0"
dependencies = [
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-std 2.0.0",
@@ -6460,7 +6460,7 @@ dependencies = [
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libsecp256k1 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-externalities 0.8.0",
"sp-runtime-interface 2.0.0",
@@ -6522,7 +6522,7 @@ version = "2.0.0"
dependencies = [
"impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"paste 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6539,8 +6539,7 @@ dependencies = [
name = "sp-runtime-interface"
version = "2.0.0"
dependencies = [
"environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"primitive-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
"rustversion 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -6594,7 +6593,7 @@ name = "sp-sandbox"
version = "0.8.0"
dependencies = [
"assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-io 2.0.0",
"sp-std 2.0.0",
@@ -6623,7 +6622,7 @@ dependencies = [
name = "sp-staking"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
]
@@ -6636,7 +6635,7 @@ dependencies = [
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
@@ -6665,7 +6664,7 @@ dependencies = [
name = "sp-test-primitives"
version = "2.0.0"
dependencies = [
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-application-crypto 2.0.0",
"sp-core 2.0.0",
@@ -6677,7 +6676,7 @@ name = "sp-timestamp"
version = "2.0.0"
dependencies = [
"impl-trait-for-tuples 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-inherents 2.0.0",
"sp-runtime 2.0.0",
@@ -6691,7 +6690,7 @@ dependencies = [
"derive_more 0.99.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-api 2.0.0",
"sp-runtime 2.0.0",
@@ -6705,7 +6704,7 @@ dependencies = [
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hex-literal 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-core 2.0.0",
"sp-std 2.0.0",
"trie-bench 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6719,7 +6718,7 @@ name = "sp-version"
version = "2.0.0"
dependencies = [
"impl-serde 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-runtime 2.0.0",
"sp-std 2.0.0",
@@ -6834,7 +6833,7 @@ dependencies = [
"node-runtime 2.0.0",
"pallet-balances 2.0.0",
"pallet-transaction-payment 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rpassword 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6869,7 +6868,7 @@ dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-client-transports 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-core 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-rpc-api 0.8.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"sp-storage 2.0.0",
@@ -6887,7 +6886,7 @@ dependencies = [
"jsonrpc-core-client 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-derive 14.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client 0.8.0",
"sc-transaction-pool 2.0.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6905,7 +6904,7 @@ version = "2.0.0"
dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client 0.8.0",
"sc-client-api 2.0.0",
"sc-client-db 0.8.0",
@@ -6931,7 +6930,7 @@ dependencies = [
"memory-db 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"pallet-babe 2.0.0",
"pallet-timestamp 2.0.0",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-client 0.8.0",
"sc-executor 0.8.0",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6963,7 +6962,7 @@ name = "substrate-test-runtime-client"
version = "2.0.0"
dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sc-block-builder 0.8.0",
"sc-client 0.8.0",
"sc-client-api 2.0.0",
@@ -7502,7 +7501,7 @@ dependencies = [
"hash-db 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.18.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.18.1 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-root 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-standardmap 0.15.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -8355,7 +8354,7 @@ dependencies = [
"checksum enumflags2_derive 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "ecf634c5213044b8d54a46dd282cf5dd1f86bb5cb53e92c409cb4680a7fb9894"
"checksum env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "aafcde04e90a5226a6443b7aabdb016ba2f8307c847d524724bd9b346dd1a2d3"
"checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36"
"checksum environmental 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "34f8467a0284de039e6bd0e25c14519538462ba5beb548bb1f03e645097837a8"
"checksum environmental 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "516aa8d7a71cb00a1c4146f0798549b93d083d4f189b3ced8f3de6b8f11ee6c4"
"checksum erased-serde 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3beee4bc16478a1b26f2e80ad819a52d24745e292f521a63c16eea5f74b7eb60"
"checksum errno 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "c2a071601ed01b988f896ab14b95e67335d1eeb50190932a1320f7fe3cadc84e"
"checksum errno-dragonfly 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067"
@@ -8549,7 +8548,7 @@ dependencies = [
"checksum parity-multiaddr 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6de20a133b50f5120c6b8284ee88c5017fb167149208b3ee2e95f8719a434dc4"
"checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3"
"checksum parity-multihash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70a4d7b05e51bff5ae2c29c7b8c3d889985bbd8f4e15b3542fcc1f6f9666d292"
"checksum parity-scale-codec 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f9f9d99dae413590a5f37e43cd99b94d4e62a244160562899126913ea7108673"
"checksum parity-scale-codec 1.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f747c06d9f3b2ad387ac881b9667298c81b1243aa9833f086e05996937c35507"
"checksum parity-scale-codec-derive 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34e513ff3e406f3ede6796dcdc83d0b32ffb86668cea1ccf7363118abeb00476"
"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
"checksum parity-util-mem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8174d85e62c4d615fddd1ef67966bdc5757528891d0742f15b131ad04667b3f9"
@@ -57,6 +57,10 @@ pub enum Error {
/// Runtime failed.
#[display(fmt="Runtime error")]
Runtime,
/// Runtime panicked.
#[display(fmt="Runtime panicked: {}", _0)]
#[from(ignore)]
RuntimePanicked(String),
/// Invalid memory reference.
#[display(fmt="Invalid memory reference")]
InvalidMemoryReference,
@@ -17,7 +17,6 @@
//! Definitions for a wasm runtime.
use crate::error::Error;
use sp_core::traits::Externalities;
use sp_wasm_interface::Function;
/// A trait that defines an abstract wasm runtime.
@@ -34,6 +33,5 @@ pub trait WasmRuntime {
fn host_functions(&self) -> &[&'static dyn Function];
/// Call a method in the Substrate runtime by name. Returns the encoded result on success.
fn call(&mut self, ext: &mut dyn Externalities, method: &str, data: &[u8])
-> Result<Vec<u8>, Error>;
fn call(&mut self, method: &str, data: &[u8]) -> Result<Vec<u8>, Error>;
}
@@ -83,7 +83,7 @@ fn call_in_wasm<E: Externalities>(
code: &[u8],
heap_pages: u64,
) -> crate::error::Result<Vec<u8>> {
crate::call_in_wasm::<E, HostFunctions>(
crate::call_in_wasm::<HostFunctions>(
function,
call_data,
execution_method,
+36 -7
View File
@@ -39,7 +39,7 @@ mod wasm_runtime;
mod integration_tests;
pub use wasmi;
pub use native_executor::{with_native_environment, NativeExecutor, NativeExecutionDispatch};
pub use native_executor::{with_externalities_safe, NativeExecutor, NativeExecutionDispatch};
pub use sp_version::{RuntimeVersion, NativeVersion};
pub use codec::Codec;
#[doc(hidden)]
@@ -57,26 +57,55 @@ pub use sc_executor_common::{error, allocator, sandbox};
/// - `call_data`: Will be given as input parameters to `function`
/// - `execution_method`: The execution method to use.
/// - `ext`: The externalities that should be set while executing the wasm function.
/// If `None` is given, no externalities will be set.
/// - `heap_pages`: The number of heap pages to allocate.
///
/// Returns the `Vec<u8>` that contains the return value of the function.
pub fn call_in_wasm<E: Externalities, HF: sp_wasm_interface::HostFunctions>(
pub fn call_in_wasm<HF: sp_wasm_interface::HostFunctions>(
function: &str,
call_data: &[u8],
execution_method: WasmExecutionMethod,
ext: &mut E,
ext: &mut dyn Externalities,
code: &[u8],
heap_pages: u64,
allow_missing_imports: bool,
) -> error::Result<Vec<u8>> {
let mut instance = wasm_runtime::create_wasm_runtime_with_code(
call_in_wasm_with_host_functions(
function,
call_data,
execution_method,
ext,
code,
heap_pages,
HF::host_functions(),
allow_missing_imports,
)
}
/// Non-generic version of [`call_in_wasm`] that takes the `host_functions` as parameter.
/// For more information please see [`call_in_wasm`].
pub fn call_in_wasm_with_host_functions(
function: &str,
call_data: &[u8],
execution_method: WasmExecutionMethod,
ext: &mut dyn Externalities,
code: &[u8],
heap_pages: u64,
host_functions: Vec<&'static dyn sp_wasm_interface::Function>,
allow_missing_imports: bool,
) -> error::Result<Vec<u8>> {
let instance = wasm_runtime::create_wasm_runtime_with_code(
execution_method,
heap_pages,
code,
HF::host_functions(),
host_functions,
allow_missing_imports,
)?;
instance.call(ext, function, call_data)
// It is safe, as we delete the instance afterwards.
let mut instance = std::panic::AssertUnwindSafe(instance);
with_externalities_safe(ext, move || instance.call(function, call_data)).and_then(|r| r)
}
/// Provides runtime information.
@@ -98,7 +127,7 @@ mod tests {
fn call_in_interpreted_wasm_works() {
let mut ext = TestExternalities::default();
let mut ext = ext.ext();
let res = call_in_wasm::<_, sp_io::SubstrateHostFunctions>(
let res = call_in_wasm::<sp_io::SubstrateHostFunctions>(
"test_empty_return",
&[],
WasmExecutionMethod::Interpreted,
@@ -22,7 +22,7 @@ use sp_version::{NativeVersion, RuntimeVersion};
use codec::{Decode, Encode};
use sp_core::{NativeOrEncoded, traits::{CodeExecutor, Externalities}};
use log::trace;
use std::{result, cell::RefCell, panic::{UnwindSafe, AssertUnwindSafe}};
use std::{result, cell::RefCell, panic::{UnwindSafe, AssertUnwindSafe}, sync::Arc};
use sp_wasm_interface::{HostFunctions, Function};
use sc_executor_common::wasm_runtime::WasmRuntime;
@@ -33,22 +33,29 @@ thread_local! {
/// Default num of pages for the heap
const DEFAULT_HEAP_PAGES: u64 = 1024;
pub(crate) fn safe_call<F, U>(f: F) -> Result<U>
where F: UnwindSafe + FnOnce() -> U
{
// Substrate uses custom panic hook that terminates process on panic. Disable
// termination for the native call.
let _guard = sp_panic_handler::AbortGuard::force_unwind();
std::panic::catch_unwind(f).map_err(|_| Error::Runtime)
}
/// Set up the externalities and safe calling environment to execute calls to a native runtime.
/// Set up the externalities and safe calling environment to execute runtime calls.
///
/// If the inner closure panics, it will be caught and return an error.
pub fn with_native_environment<F, U>(ext: &mut dyn Externalities, f: F) -> Result<U>
pub fn with_externalities_safe<F, U>(ext: &mut dyn Externalities, f: F) -> Result<U>
where F: UnwindSafe + FnOnce() -> U
{
sp_externalities::set_and_run_with_externalities(ext, move || safe_call(f))
sp_externalities::set_and_run_with_externalities(
ext,
move || {
// Substrate uses custom panic hook that terminates process on panic. Disable
// termination for the native call.
let _guard = sp_panic_handler::AbortGuard::force_unwind();
std::panic::catch_unwind(f).map_err(|e| {
if let Some(err) = e.downcast_ref::<String>() {
Error::RuntimePanicked(err.clone())
} else if let Some(err) = e.downcast_ref::<&'static str>() {
Error::RuntimePanicked(err.to_string())
} else {
Error::RuntimePanicked("Unknown panic".into())
}
})
},
)
}
/// Delegate for dispatching a CodeExecutor call.
@@ -80,7 +87,7 @@ pub struct NativeExecutor<D> {
/// The number of 64KB pages to allocate for Wasm execution.
default_heap_pages: u64,
/// The host functions registered with this instance.
host_functions: Vec<&'static dyn Function>,
host_functions: Arc<Vec<&'static dyn Function>>,
}
impl<D: NativeExecutionDispatch> NativeExecutor<D> {
@@ -107,7 +114,7 @@ impl<D: NativeExecutionDispatch> NativeExecutor<D> {
fallback_method,
native_version: D::native_version(),
default_heap_pages: default_heap_pages.unwrap_or(DEFAULT_HEAP_PAGES),
host_functions,
host_functions: Arc::new(host_functions),
}
}
@@ -139,7 +146,7 @@ impl<D: NativeExecutionDispatch> NativeExecutor<D> {
ext,
self.fallback_method,
self.default_heap_pages,
&self.host_functions,
&*self.host_functions,
)?;
let runtime = AssertUnwindSafe(runtime);
@@ -181,7 +188,7 @@ impl<D: NativeExecutionDispatch> RuntimeInfo for NativeExecutor<D> {
}
}
impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
impl<D: NativeExecutionDispatch + 'static> CodeExecutor for NativeExecutor<D> {
type Error = Error;
fn call
@@ -212,13 +219,15 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
onchain_version,
);
safe_call(
move || runtime.call(&mut **ext, method, data).map(NativeOrEncoded::Encoded)
with_externalities_safe(
&mut **ext,
move || runtime.call(method, data).map(NativeOrEncoded::Encoded)
)
}
(false, _, _) => {
safe_call(
move || runtime.call(&mut **ext, method, data).map(NativeOrEncoded::Encoded)
with_externalities_safe(
&mut **ext,
move || runtime.call(method, data).map(NativeOrEncoded::Encoded)
)
},
(true, true, Some(call)) => {
@@ -230,7 +239,7 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
);
used_native = true;
let res = with_native_environment(&mut **ext, move || (call)())
let res = with_externalities_safe(&mut **ext, move || (call)())
.and_then(|r| r
.map(NativeOrEncoded::Native)
.map_err(|s| Error::ApiError(s.to_string()))
@@ -255,6 +264,27 @@ impl<D: NativeExecutionDispatch> CodeExecutor for NativeExecutor<D> {
}
}
impl<D: NativeExecutionDispatch> sp_core::traits::CallInWasm for NativeExecutor<D> {
fn call_in_wasm(
&self,
wasm_blob: &[u8],
method: &str,
call_data: &[u8],
ext: &mut dyn Externalities,
) -> std::result::Result<Vec<u8>, String> {
crate::call_in_wasm_with_host_functions(
method,
call_data,
self.fallback_method,
ext,
wasm_blob,
self.default_heap_pages,
(*self.host_functions).clone(),
false,
).map_err(|e| e.to_string())
}
}
/// Implements a `NativeExecutionDispatch` for provided parameters.
///
/// # Example
@@ -318,7 +348,7 @@ macro_rules! native_executor_instance {
method: &str,
data: &[u8]
) -> $crate::error::Result<Vec<u8>> {
$crate::with_native_environment(ext, move || $dispatcher(method, data))?
$crate::with_externalities_safe(ext, move || $dispatcher(method, data))?
.ok_or_else(|| $crate::error::Error::MethodNotFound(method.to_owned()))
}
@@ -223,8 +223,9 @@ fn create_versioned_wasm_runtime<E: Externalities>(
// The following unwind safety assertion is OK because if the method call panics, the
// runtime will be dropped.
let mut runtime = AssertUnwindSafe(runtime.as_mut());
crate::native_executor::safe_call(
move || runtime.call(&mut **ext, "Core_version", &[])
crate::native_executor::with_externalities_safe(
&mut **ext,
move || runtime.call("Core_version", &[])
).map_err(|_| WasmError::Instantiation("panic in call to get runtime version".into()))?
};
let encoded_version = version_result
@@ -13,4 +13,3 @@ sc-executor-common = { version = "0.8", path = "../common" }
sp-wasm-interface = { version = "2.0.0", path = "../../../primitives/wasm-interface" }
sp-runtime-interface = { version = "2.0.0", path = "../../../primitives/runtime-interface" }
sp-core = { version = "2.0.0", path = "../../../primitives/core" }
sp-externalities = { version = "0.8.0", path = "../../../primitives/externalities" }
+5 -11
View File
@@ -27,7 +27,7 @@ use wasmi::{
memory_units::Pages, RuntimeValue::{I32, I64, self},
};
use codec::{Encode, Decode};
use sp_core::{sandbox as sandbox_primitives, traits::Externalities};
use sp_core::sandbox as sandbox_primitives;
use log::{error, trace};
use parity_wasm::elements::{deserialize_buffer, DataSegment, Instruction, Module as RawModule};
use sp_wasm_interface::{
@@ -381,7 +381,6 @@ fn get_heap_base(module: &ModuleRef) -> Result<u32, Error> {
/// Call a given method in the given wasm-module runtime.
fn call_in_wasm_module(
ext: &mut dyn Externalities,
module_instance: &ModuleRef,
method: &str,
data: &[u8],
@@ -410,13 +409,10 @@ fn call_in_wasm_module(
let offset = fec.allocate_memory(data.len() as u32)?;
fec.write_memory(offset, data)?;
let result = sp_externalities::set_and_run_with_externalities(
ext,
|| module_instance.invoke_export(
method,
&[I32(u32::from(offset) as i32), I32(data.len() as i32)],
&mut fec,
),
let result = module_instance.invoke_export(
method,
&[I32(u32::from(offset) as i32), I32(data.len() as i32)],
&mut fec,
);
match result {
@@ -599,7 +595,6 @@ impl WasmRuntime for WasmiRuntime {
fn call(
&mut self,
ext: &mut dyn Externalities,
method: &str,
data: &[u8],
) -> Result<Vec<u8>, Error> {
@@ -612,7 +607,6 @@ impl WasmRuntime for WasmiRuntime {
e
})?;
call_in_wasm_module(
ext,
&self.instance,
method,
data,
@@ -13,7 +13,6 @@ sc-executor-common = { version = "0.8", path = "../common" }
sp-wasm-interface = { version = "2.0.0", path = "../../../primitives/wasm-interface" }
sp-runtime-interface = { version = "2.0.0", path = "../../../primitives/runtime-interface" }
sp-core = { version = "2.0.0", path = "../../../primitives/core" }
sp-externalities = { version = "0.8.0", path = "../../../primitives/externalities" }
cranelift-codegen = "0.50"
cranelift-entity = "0.50"
@@ -24,7 +24,6 @@ use sc_executor_common::{
error::{Error, Result, WasmError},
wasm_runtime::WasmRuntime,
};
use sp_core::traits::Externalities;
use sp_wasm_interface::{Pointer, WordSize, Function};
use sp_runtime_interface::unpack_ptr_and_len;
@@ -70,11 +69,10 @@ impl WasmRuntime for WasmtimeRuntime {
&self.host_functions
}
fn call(&mut self, ext: &mut dyn Externalities, method: &str, data: &[u8]) -> Result<Vec<u8>> {
fn call(&mut self, method: &str, data: &[u8]) -> Result<Vec<u8>> {
call_method(
&mut self.context,
&mut self.module,
ext,
method,
data,
self.heap_pages,
@@ -146,7 +144,6 @@ fn create_compiled_unit(
fn call_method(
context: &mut Context,
module: &mut CompiledModule,
ext: &mut dyn Externalities,
method: &str,
data: &[u8],
heap_pages: u32,
@@ -176,11 +173,9 @@ fn call_method(
let args = [RuntimeValue::I32(u32::from(data_ptr) as i32), RuntimeValue::I32(data_len as i32)];
// Invoke the function in the runtime.
let outcome = sp_externalities::set_and_run_with_externalities(ext, || {
context
.invoke(&mut instance, method, &args[..])
.map_err(|e| Error::Other(format!("error calling runtime: {}", e)))
})?;
let outcome = context
.invoke(&mut instance, method, &args[..])
.map_err(|e| Error::Other(format!("error calling runtime: {}", e)))?;
let trap_error = reset_env_state_and_take_trap(context, None)?;
let (output_ptr, output_len) = match outcome {
ActionOutcome::Returned { values } => match values.as_slice() {
@@ -412,7 +412,7 @@ for Environment<B, E, Block, N, RA, SC, VR>
where
Block: 'static,
B: Backend<Block> + 'static,
E: CallExecutor<Block> + Send + Sync + 'static,
E: CallExecutor<Block> + Send + Sync,
N: NetworkT<Block> + 'static + Send,
SC: SelectChain<Block> + 'static,
VR: VotingRule<Block, Client<B, E, Block, RA>>,
+2 -2
View File
@@ -372,7 +372,7 @@ pub trait GenesisAuthoritySetProvider<Block: BlockT> {
impl<B, E, Block: BlockT, RA> GenesisAuthoritySetProvider<Block> for Client<B, E, Block, RA>
where
B: Backend<Block> + Send + Sync + 'static,
E: CallExecutor<Block> + 'static + Clone + Send + Sync,
E: CallExecutor<Block> + Send + Sync,
RA: Send + Sync,
{
fn get(&self) -> Result<AuthorityList, ClientError> {
@@ -408,7 +408,7 @@ pub fn block_import<B, E, Block: BlockT, RA, SC>(
), ClientError>
where
B: Backend<Block> + 'static,
E: CallExecutor<Block> + 'static + Clone + Send + Sync,
E: CallExecutor<Block> + Send + Sync,
RA: Send + Sync,
SC: SelectChain<Block>,
Client<B, E, Block, RA>: AuxStore,
@@ -67,7 +67,7 @@ fn grandpa_observer<B, E, Block: BlockT, RA, S, F>(
) -> impl Future<Item=(), Error=CommandOrError<Block::Hash, NumberFor<Block>>> where
NumberFor<Block>: BlockNumberOps,
B: Backend<Block>,
E: CallExecutor<Block> + Send + Sync,
E: CallExecutor<Block> + Send + Sync + 'static,
RA: Send + Sync,
S: Stream<
Item = CommunicationIn<Block>,
+1 -1
View File
@@ -399,7 +399,7 @@ fn should_return_runtime_version() {
let api = new_full(client.clone(), Subscriptions::new(Arc::new(core.executor())));
let result = "{\"specName\":\"test\",\"implName\":\"parity-test\",\"authoringVersion\":1,\
\"specVersion\":1,\"implVersion\":1,\"apis\":[[\"0xdf6acb689907609b\",2],\
\"specVersion\":1,\"implVersion\":2,\"apis\":[[\"0xdf6acb689907609b\",2],\
[\"0x37e397fc7c91f5e4\",1],[\"0xd2bc9897eed08f15\",1],[\"0x40fe3ad401f8959a\",4],\
[\"0xc6e9a76309f39b09\",1],[\"0xdd718d5cc53262d4\",1],[\"0xcbca25e39f142387\",1],\
[\"0xf78b278be53f454c\",2],[\"0xab3c0572291feb8b\",1],[\"0xbc9d89904f5b923f\",1]]}";
+3 -3
View File
@@ -147,7 +147,7 @@ pub fn new_full_client<TBl, TRtApi, TExecDisp, TCfg, TGen, TCSExt>(
config: &Configuration<TCfg, TGen, TCSExt>,
) -> Result<TFullClient<TBl, TRtApi, TExecDisp>, Error> where
TBl: BlockT,
TExecDisp: NativeExecutionDispatch,
TExecDisp: NativeExecutionDispatch + 'static,
TGen: sp_runtime::BuildStorage + serde::Serialize + for<'de> serde::Deserialize<'de>,
TCSExt: Extension,
{
@@ -158,7 +158,7 @@ fn new_full_parts<TBl, TRtApi, TExecDisp, TCfg, TGen, TCSExt>(
config: &Configuration<TCfg, TGen, TCSExt>,
) -> Result<TFullParts<TBl, TRtApi, TExecDisp>, Error> where
TBl: BlockT,
TExecDisp: NativeExecutionDispatch,
TExecDisp: NativeExecutionDispatch + 'static,
TGen: sp_runtime::BuildStorage + serde::Serialize + for<'de> serde::Deserialize<'de>,
TCSExt: Extension,
{
@@ -226,7 +226,7 @@ fn new_full_parts<TBl, TRtApi, TExecDisp, TCfg, TGen, TCSExt>(
impl<TCfg, TGen, TCSExt> ServiceBuilder<(), (), TCfg, TGen, TCSExt, (), (), (), (), (), (), (), (), (), ()>
where TGen: RuntimeGenesis, TCSExt: Extension {
/// Start the service builder with a configuration.
pub fn new_full<TBl: BlockT, TRtApi, TExecDisp: NativeExecutionDispatch>(
pub fn new_full<TBl: BlockT, TRtApi, TExecDisp: NativeExecutionDispatch + 'static>(
config: Configuration<TCfg, TGen, TCSExt>
) -> Result<ServiceBuilder<
TBl,
+2 -2
View File
@@ -61,7 +61,7 @@ impl<B, E> Clone for LocalCallExecutor<B, E> where E: Clone {
impl<B, E, Block> CallExecutor<Block> for LocalCallExecutor<B, E>
where
B: backend::Backend<Block>,
E: CodeExecutor + RuntimeInfo,
E: CodeExecutor + RuntimeInfo + Clone + 'static,
Block: BlockT,
{
type Error = E::Error;
@@ -225,7 +225,7 @@ where
impl<B, E, Block> sp_version::GetRuntimeVersion<Block> for LocalCallExecutor<B, E>
where
B: backend::Backend<Block>,
E: CodeExecutor + RuntimeInfo,
E: CodeExecutor + RuntimeInfo + Clone + 'static,
Block: BlockT,
{
fn native_version(&self) -> &sp_version::NativeVersion {
+5 -7
View File
@@ -156,7 +156,7 @@ pub fn new_with_backend<B, E, Block, S, RA>(
E: CodeExecutor + RuntimeInfo,
S: BuildStorage,
Block: BlockT,
B: backend::LocalBackend<Block>
B: backend::LocalBackend<Block> + 'static,
{
let call_executor = LocalCallExecutor::new(backend.clone(), executor);
let extensions = ExecutionExtensions::new(Default::default(), keystore);
@@ -750,7 +750,6 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
import_block: BlockImportParams<Block, backend::TransactionFor<B, Block>>,
new_cache: HashMap<CacheKeyId, Vec<u8>>,
) -> sp_blockchain::Result<ImportResult> where
E: CallExecutor<Block> + Send + Sync + Clone,
Self: ProvideRuntimeApi<Block>,
<Self as ProvideRuntimeApi<Block>>::Api: CoreApi<Block, Error = Error> +
ApiExt<Block, StateBackend = B::State>,
@@ -829,7 +828,6 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
fork_choice: ForkChoiceStrategy,
import_existing: bool,
) -> sp_blockchain::Result<ImportResult> where
E: CallExecutor<Block> + Send + Sync + Clone,
Self: ProvideRuntimeApi<Block>,
<Self as ProvideRuntimeApi<Block>>::Api: CoreApi<Block, Error = Error> +
ApiExt<Block, StateBackend = B::State>,
@@ -1387,7 +1385,7 @@ impl<B, E, Block, RA> ProvideCache<Block> for Client<B, E, Block, RA> where
impl<B, E, Block, RA> ProvideRuntimeApi<Block> for Client<B, E, Block, RA> where
B: backend::Backend<Block>,
E: CallExecutor<Block, Backend = B> + Clone + Send + Sync,
E: CallExecutor<Block, Backend = B> + Send + Sync,
Block: BlockT,
RA: ConstructRuntimeApi<Block, Self>,
{
@@ -1400,7 +1398,7 @@ impl<B, E, Block, RA> ProvideRuntimeApi<Block> for Client<B, E, Block, RA> where
impl<B, E, Block, RA> CallApiAt<Block> for Client<B, E, Block, RA> where
B: backend::Backend<Block>,
E: CallExecutor<Block, Backend = B> + Clone + Send + Sync,
E: CallExecutor<Block, Backend = B> + Send + Sync,
Block: BlockT,
{
type Error = Error;
@@ -1448,7 +1446,7 @@ impl<B, E, Block, RA> CallApiAt<Block> for Client<B, E, Block, RA> where
/// important verification work.
impl<B, E, Block, RA> sp_consensus::BlockImport<Block> for &Client<B, E, Block, RA> where
B: backend::Backend<Block>,
E: CallExecutor<Block> + Clone + Send + Sync,
E: CallExecutor<Block> + Send + Sync,
Block: BlockT,
Client<B, E, Block, RA>: ProvideRuntimeApi<Block>,
<Client<B, E, Block, RA> as ProvideRuntimeApi<Block>>::Api: CoreApi<Block, Error = Error> +
@@ -1552,7 +1550,7 @@ impl<B, E, Block, RA> sp_consensus::BlockImport<Block> for &Client<B, E, Block,
impl<B, E, Block, RA> sp_consensus::BlockImport<Block> for Client<B, E, Block, RA> where
B: backend::Backend<Block>,
E: CallExecutor<Block> + Clone + Send + Sync,
E: CallExecutor<Block> + Send + Sync,
Block: BlockT,
Self: ProvideRuntimeApi<Block>,
<Self as ProvideRuntimeApi<Block>>::Api: CoreApi<Block, Error = Error> +
+1 -1
View File
@@ -59,7 +59,7 @@ mod tests {
native_executor_instance!(
Executor,
substrate_test_runtime_client::runtime::api::dispatch,
substrate_test_runtime_client::runtime::native_version
substrate_test_runtime_client::runtime::native_version,
);
fn executor() -> sc_executor::NativeExecutor<Executor> {
+2 -2
View File
@@ -222,7 +222,7 @@ pub fn check_execution_proof<Header, E, H>(
) -> ClientResult<Vec<u8>>
where
Header: HeaderT,
E: CodeExecutor,
E: CodeExecutor + Clone + 'static,
H: Hasher,
H::Out: Ord + codec::Codec + 'static,
{
@@ -248,7 +248,7 @@ fn check_execution_proof_with_make_header<Header, E, H, MakeNextHeader: Fn(&Head
) -> ClientResult<Vec<u8>>
where
Header: HeaderT,
E: CodeExecutor,
E: CodeExecutor + Clone + 'static,
H: Hasher,
H::Out: Ord + codec::Codec + 'static,
{
+1 -1
View File
@@ -197,7 +197,7 @@ impl<E, H, B: BlockT, S: BlockchainStorage<B>> LightDataChecker<E, H, B, S> {
impl<E, Block, H, S> FetchChecker<Block> for LightDataChecker<E, H, Block, S>
where
Block: BlockT,
E: CodeExecutor,
E: CodeExecutor + Clone + 'static,
H: Hasher,
H::Out: Ord + codec::Codec + 'static,
S: BlockchainStorage<Block>,
+1 -1
View File
@@ -73,7 +73,7 @@ pub fn new_light<B, S, GS, RA, E>(
B: BlockT,
S: BlockchainStorage<B> + 'static,
GS: BuildStorage,
E: CodeExecutor + RuntimeInfo,
E: CodeExecutor + RuntimeInfo + Clone + 'static,
{
let local_executor = LocalCallExecutor::new(backend.clone(), code_executor);
let executor = GenesisCallExecutor::new(backend.clone(), local_executor);
+2
View File
@@ -18,6 +18,8 @@ impl-trait-for-tuples = "0.1.3"
[dev-dependencies]
criterion = "0.2.11"
sp-externalities = { version = "0.8.0", path = "../../primitives/externalities" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../test-utils/runtime/client" }
[features]
default = ["std"]
+119 -6
View File
@@ -259,11 +259,38 @@ decl_module! {
storage::unhashed::put_raw(well_known_keys::HEAP_PAGES, &pages.encode());
}
/// Set the new code.
/// Set the new runtime code.
#[weight = SimpleDispatchInfo::FixedOperational(200_000)]
pub fn set_code(origin, new: Vec<u8>) {
pub fn set_code(origin, code: Vec<u8>) {
ensure_root(origin)?;
storage::unhashed::put_raw(well_known_keys::CODE, &new);
let current_version = T::Version::get();
let new_version = sp_io::misc::runtime_version(&code)
.and_then(|v| RuntimeVersion::decode(&mut &v[..]).ok())
.ok_or_else(|| Error::<T>::FailedToExtractRuntimeVersion)?;
if new_version.spec_name != current_version.spec_name {
Err(Error::<T>::InvalidSpecName)?
}
if new_version.spec_version < current_version.spec_version {
Err(Error::<T>::SpecVersionNotAllowedToDecrease)?
} else if new_version.spec_version == current_version.spec_version {
if new_version.impl_version < current_version.impl_version {
Err(Error::<T>::ImplVersionNotAllowedToDecrease)?
} else if new_version.impl_version == current_version.impl_version {
Err(Error::<T>::SpecOrImplVersionNeedToIncrease)?
}
}
storage::unhashed::put_raw(well_known_keys::CODE, &code);
}
/// Set the new runtime code without doing any checks of the given `code`.
#[weight = SimpleDispatchInfo::FixedOperational(200_000)]
pub fn set_code_without_checks(origin, code: Vec<u8>) {
ensure_root(origin)?;
storage::unhashed::put_raw(well_known_keys::CODE, &code);
}
/// Set some items of storage.
@@ -327,7 +354,24 @@ decl_event!(
decl_error! {
/// Error for the System module
pub enum Error for Module<T: Trait> {}
pub enum Error for Module<T: Trait> {
/// The name of specification does not match between the current runtime
/// and the new runtime.
InvalidSpecName,
/// The specification version is not allowed to decrease between the current runtime
/// and the new runtime.
SpecVersionNotAllowedToDecrease,
/// The implementation version is not allowed to decrease between the current runtime
/// and the new runtime.
ImplVersionNotAllowedToDecrease,
/// The specification or the implementation version need to increase between the
/// current runtime and the new runtime.
SpecOrImplVersionNeedToIncrease,
/// Failed to extract the runtime version from the new runtime.
///
/// Either calling `Core_version` or decoding `RuntimeVersion` failed.
FailedToExtractRuntimeVersion,
}
}
/// Origin for the System module.
@@ -1189,6 +1233,14 @@ mod tests {
pub const MaximumBlockWeight: Weight = 1024;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
pub const MaximumBlockLength: u32 = 1024;
pub const Version: RuntimeVersion = RuntimeVersion {
spec_name: sp_version::create_runtime_str!("test"),
impl_name: sp_version::create_runtime_str!("system-test"),
authoring_version: 1,
spec_version: 1,
impl_version: 1,
apis: sp_version::create_apis_vec!([]),
};
}
impl Trait for Test {
@@ -1206,7 +1258,7 @@ mod tests {
type MaximumBlockWeight = MaximumBlockWeight;
type AvailableBlockRatio = AvailableBlockRatio;
type MaximumBlockLength = MaximumBlockLength;
type Version = ();
type Version = Version;
type ModuleToIndex = ();
}
@@ -1503,7 +1555,7 @@ mod tests {
.validate(&1, CALL, op, len)
.unwrap()
.priority;
assert_eq!(priority, Bounded::max_value());
assert_eq!(priority, u64::max_value());
})
}
@@ -1562,4 +1614,65 @@ mod tests {
assert_eq!(ext.validate(&1, CALL, normal, len).unwrap().longevity, 15);
})
}
#[test]
fn set_code_checks_works() {
struct CallInWasm(Vec<u8>);
impl sp_core::traits::CallInWasm for CallInWasm {
fn call_in_wasm(
&self,
_: &[u8],
_: &str,
_: &[u8],
_: &mut dyn sp_externalities::Externalities,
) -> Result<Vec<u8>, String> {
Ok(self.0.clone())
}
}
let test_data = vec![
("test", 1, 2, Ok(())),
("test", 1, 1, Err(Error::<Test>::SpecOrImplVersionNeedToIncrease)),
("test2", 1, 1, Err(Error::<Test>::InvalidSpecName)),
("test", 2, 1, Ok(())),
("test", 0, 1, Err(Error::<Test>::SpecVersionNotAllowedToDecrease)),
("test", 1, 0, Err(Error::<Test>::ImplVersionNotAllowedToDecrease)),
];
for (spec_name, spec_version, impl_version, expected) in test_data.into_iter() {
let version = RuntimeVersion {
spec_name: spec_name.into(),
spec_version,
impl_version,
..Default::default()
};
let call_in_wasm = CallInWasm(version.encode());
let mut ext = new_test_ext();
ext.register_extension(sp_core::traits::CallInWasmExt::new(call_in_wasm));
ext.execute_with(|| {
let res = System::set_code(
RawOrigin::Root.into(),
vec![1, 2, 3, 4],
);
assert_eq!(expected.map_err(DispatchError::from), res);
});
}
}
#[test]
fn set_code_with_real_wasm_blob() {
let executor = substrate_test_runtime_client::new_native_executor();
let mut ext = new_test_ext();
ext.register_extension(sp_core::traits::CallInWasmExt::new(executor));
ext.execute_with(|| {
System::set_code(
RawOrigin::Root.into(),
substrate_test_runtime_client::runtime::WASM_BINARY.to_vec(),
).unwrap();
});
}
}
+28 -1
View File
@@ -80,7 +80,7 @@ sp_externalities::decl_extension! {
}
/// Code execution engine.
pub trait CodeExecutor: Sized + Send + Sync {
pub trait CodeExecutor: Sized + Send + Sync + CallInWasm + Clone + 'static {
/// Externalities error type.
type Error: Display + Debug + Send + 'static;
@@ -99,3 +99,30 @@ pub trait CodeExecutor: Sized + Send + Sync {
native_call: Option<NC>,
) -> (Result<crate::NativeOrEncoded<R>, Self::Error>, bool);
}
/// Something that can call a method in a WASM blob.
pub trait CallInWasm: Send + Sync {
/// Call the given `method` in the given `wasm_blob` using `call_data` (SCALE encoded arguments)
/// to decode the arguments for the method.
///
/// Returns the SCALE encoded return value of the method.
fn call_in_wasm(
&self,
wasm_blob: &[u8],
method: &str,
call_data: &[u8],
ext: &mut dyn Externalities,
) -> Result<Vec<u8>, String>;
}
sp_externalities::decl_extension! {
/// The call-in-wasm extension to register/retrieve from the externalities.
pub struct CallInWasmExt(Box<dyn CallInWasm>);
}
impl CallInWasmExt {
/// Creates a new instance of `Self`.
pub fn new<T: CallInWasm + 'static>(inner: T) -> Self {
Self(Box::new(inner))
}
}
@@ -8,4 +8,4 @@ edition = "2018"
[dependencies]
sp-storage = { version = "2.0.0", path = "../storage" }
sp-std = { version = "2.0.0", path = "../std" }
environmental = { version = "1.0.2" }
environmental = { version = "1.1.1" }
+21 -2
View File
@@ -35,7 +35,7 @@ use sp_std::ops::Deref;
#[cfg(feature = "std")]
use sp_core::{
crypto::Pair,
traits::KeystoreExt,
traits::{KeystoreExt, CallInWasmExt},
offchain::{OffchainExt, TransactionPoolExt},
hexdisplay::HexDisplay,
storage::{ChildStorageKey, ChildInfo},
@@ -49,7 +49,7 @@ use sp_core::{
};
#[cfg(feature = "std")]
use ::sp_trie::{TrieConfiguration, trie_types::Layout};
use sp_trie::{TrieConfiguration, trie_types::Layout};
use sp_runtime_interface::{runtime_interface, Pointer};
@@ -351,6 +351,25 @@ pub trait Misc {
fn print_hex(data: &[u8]) {
log::debug!(target: "runtime", "{}", HexDisplay::from(&data));
}
/// Extract the runtime version of the given wasm blob by calling `Core_version`.
///
/// Returns the SCALE encoded runtime version and `None` if the call failed.
///
/// # Performance
///
/// Calling this function is very expensive and should only be done very occasionally.
/// For getting the runtime version, it requires instantiating the wasm blob and calling a
/// function in this blob.
fn runtime_version(&mut self, wasm: &[u8]) -> Option<Vec<u8>> {
// Create some dummy externalities, `Core_version` should not write data anyway.
let mut ext = sp_state_machine::BasicExternalities::default();
self.extension::<CallInWasmExt>()
.expect("No `CallInWasmExt` associated for the current context!")
.call_in_wasm(wasm, "Core_version", &[], &mut ext)
.ok()
}
}
/// Interfaces for working with crypto related types from within the runtime.
@@ -10,7 +10,6 @@ sp-std = { version = "2.0.0", default-features = false, path = "../std" }
sp-runtime-interface-proc-macro = { version = "2.0.0", path = "proc-macro" }
sp-externalities = { version = "0.8.0", optional = true, path = "../externalities" }
codec = { package = "parity-scale-codec", version = "1.0.6", default-features = false }
environmental = { version = "1.0.2", optional = true }
static_assertions = "1.0.0"
primitive-types = { version = "0.6.1", default-features = false }
@@ -29,7 +28,6 @@ std = [
"sp-std/std",
"codec/std",
"sp-externalities",
"environmental",
"primitive-types/std",
]
@@ -30,7 +30,6 @@ fn call_wasm_method<HF: HostFunctionsT>(method: &str) -> TestExternalities {
let mut ext_ext = ext.ext();
sc_executor::call_in_wasm::<
_,
(
HF,
sp_io::SubstrateHostFunctions,
+3 -21
View File
@@ -53,6 +53,9 @@ pub mod testing;
pub mod traits;
pub mod transaction_validity;
pub mod random_number_generator;
mod runtime_string;
pub use crate::runtime_string::*;
/// Re-export these since they're only "kind of" generic.
pub use generic::{DigestItem, Digest};
@@ -92,27 +95,6 @@ impl TypeId for ModuleId {
const TYPE_ID: [u8; 4] = *b"modl";
}
/// A String that is a `&'static str` on `no_std` and a `Cow<'static, str>` on `std`.
#[cfg(feature = "std")]
pub type RuntimeString = std::borrow::Cow<'static, str>;
/// A String that is a `&'static str` on `no_std` and a `Cow<'static, str>` on `std`.
#[cfg(not(feature = "std"))]
pub type RuntimeString = &'static str;
/// Create a const [`RuntimeString`].
#[cfg(feature = "std")]
#[macro_export]
macro_rules! create_runtime_str {
( $y:expr ) => {{ std::borrow::Cow::Borrowed($y) }}
}
/// Create a const [`RuntimeString`].
#[cfg(not(feature = "std"))]
#[macro_export]
macro_rules! create_runtime_str {
( $y:expr ) => {{ $y }}
}
#[cfg(feature = "std")]
pub use serde::{Serialize, Deserialize, de::DeserializeOwned};
use crate::traits::IdentifyAccount;
@@ -0,0 +1,117 @@
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use codec::{Encode, Decode};
use sp_core::RuntimeDebug;
use sp_std::vec::Vec;
/// A string that wraps a `&'static str` in the runtime and `String`/`Vec<u8>` on decode.
#[derive(Eq, RuntimeDebug, Clone)]
pub enum RuntimeString {
/// The borrowed mode that wraps a `&'static str`.
Borrowed(&'static str),
/// The owned mode that wraps a `String`.
#[cfg(feature = "std")]
Owned(String),
/// The owned mode that wraps a `Vec<u8>`.
#[cfg(not(feature = "std"))]
Owned(Vec<u8>),
}
impl From<&'static str> for RuntimeString {
fn from(data: &'static str) -> Self {
Self::Borrowed(data)
}
}
#[cfg(feature = "std")]
impl From<RuntimeString> for String {
fn from(string: RuntimeString) -> Self {
match string {
RuntimeString::Borrowed(data) => data.to_owned(),
RuntimeString::Owned(data) => data,
}
}
}
impl Default for RuntimeString {
fn default() -> Self {
Self::Borrowed(Default::default())
}
}
impl PartialEq for RuntimeString {
fn eq(&self, other: &Self) -> bool {
self.as_ref() == other.as_ref()
}
}
impl AsRef<[u8]> for RuntimeString {
fn as_ref(&self) -> &[u8] {
match self {
Self::Borrowed(val) => val.as_ref(),
Self::Owned(val) => val.as_ref(),
}
}
}
impl Encode for RuntimeString {
fn encode(&self) -> Vec<u8> {
match self {
Self::Borrowed(val) => val.encode(),
Self::Owned(val) => val.encode(),
}
}
}
impl Decode for RuntimeString {
fn decode<I: codec::Input>(value: &mut I) -> Result<Self, codec::Error> {
Decode::decode(value).map(Self::Owned)
}
}
#[cfg(feature = "std")]
impl std::fmt::Display for RuntimeString {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
match self {
Self::Borrowed(val) => write!(f, "{}", val),
Self::Owned(val) => write!(f, "{}", val),
}
}
}
#[cfg(feature = "std")]
impl serde::Serialize for RuntimeString {
fn serialize<S: serde::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
match self {
Self::Borrowed(val) => val.serialize(serializer),
Self::Owned(val) => val.serialize(serializer),
}
}
}
#[cfg(feature = "std")]
impl<'de> serde::Deserialize<'de> for RuntimeString {
fn deserialize<D: serde::Deserializer<'de>>(de: D) -> Result<Self, D::Error> {
String::deserialize(de).map(Self::Owned)
}
}
/// Create a const [`RuntimeString`].
#[macro_export]
macro_rules! create_runtime_str {
( $y:expr ) => {{ $crate::RuntimeString::Borrowed($y) }}
}
+22 -7
View File
@@ -24,7 +24,7 @@ use hash_db::Hasher;
use codec::{Decode, Encode, Codec};
use sp_core::{
storage::{well_known_keys, ChildInfo}, NativeOrEncoded, NeverNativeValue,
traits::CodeExecutor, hexdisplay::HexDisplay
traits::{CodeExecutor, CallInWasmExt}, hexdisplay::HexDisplay
};
use overlayed_changes::OverlayedChangeSet;
use sp_externalities::Extensions;
@@ -191,7 +191,7 @@ pub struct StateMachine<'a, B, H, N, T, Exec>
impl<'a, B, H, N, T, Exec> StateMachine<'a, B, H, N, T, Exec> where
H: Hasher,
H::Out: Ord + 'static + codec::Codec,
Exec: CodeExecutor,
Exec: CodeExecutor + Clone + 'static,
B: Backend<H>,
T: ChangesTrieStorage<H, N>,
N: crate::changes_trie::BlockNumber,
@@ -204,8 +204,10 @@ impl<'a, B, H, N, T, Exec> StateMachine<'a, B, H, N, T, Exec> where
exec: &'a Exec,
method: &'a str,
call_data: &'a [u8],
extensions: Extensions,
mut extensions: Extensions,
) -> Self {
extensions.register(CallInWasmExt::new(exec.clone()));
Self {
backend,
exec,
@@ -451,7 +453,7 @@ where
B: Backend<H>,
H: Hasher,
H::Out: Ord + 'static + codec::Codec,
Exec: CodeExecutor,
Exec: CodeExecutor + Clone + 'static,
{
let trie_backend = backend.as_trie_backend()
.ok_or_else(|| Box::new(ExecutionError::UnableToGenerateProof) as Box<dyn Error>)?;
@@ -478,7 +480,7 @@ where
S: trie_backend_essence::TrieBackendStorage<H>,
H: Hasher,
H::Out: Ord + 'static + codec::Codec,
Exec: CodeExecutor,
Exec: CodeExecutor + 'static + Clone,
{
let proving_backend = proving_backend::ProvingBackend::new(trie_backend);
let mut sm = StateMachine::<_, H, _, InMemoryChangesTrieStorage<H, u64>, Exec>::new(
@@ -504,7 +506,7 @@ pub fn execution_proof_check<H, Exec>(
) -> Result<Vec<u8>, Box<dyn Error>>
where
H: Hasher,
Exec: CodeExecutor,
Exec: CodeExecutor + Clone + 'static,
H::Out: Ord + 'static + codec::Codec,
{
let trie_backend = create_proof_check_backend::<H>(root.into(), proof)?;
@@ -522,7 +524,7 @@ pub fn execution_proof_check_on_trie_backend<H, Exec>(
where
H: Hasher,
H::Out: Ord + 'static + codec::Codec,
Exec: CodeExecutor,
Exec: CodeExecutor + Clone + 'static,
{
let mut sm = StateMachine::<_, H, _, InMemoryChangesTrieStorage<H, u64>, Exec>::new(
trie_backend, None, overlay, exec, method, call_data, Extensions::default(),
@@ -741,6 +743,7 @@ mod tests {
};
use sp_core::{Blake2Hasher, map, traits::Externalities, storage::ChildStorageKey};
#[derive(Clone)]
struct DummyCodeExecutor {
change_changes_trie_config: bool,
native_available: bool,
@@ -797,6 +800,18 @@ mod tests {
}
}
impl sp_core::traits::CallInWasm for DummyCodeExecutor {
fn call_in_wasm(
&self,
_: &[u8],
_: &str,
_: &[u8],
_: &mut dyn Externalities,
) -> std::result::Result<Vec<u8>, String> {
unimplemented!("Not required in tests.")
}
}
#[test]
fn execute_works() {
let backend = trie_backend::tests::test_trie();
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
impl-serde = { version = "0.2.3", optional = true }
serde = { version = "1.0.101", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.5", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.1.2", default-features = false, features = ["derive"] }
sp-std = { version = "2.0.0", default-features = false, path = "../std" }
sp-runtime = { version = "2.0.0", default-features = false, path = "../runtime" }
+8 -20
View File
@@ -25,11 +25,11 @@ use std::fmt;
#[cfg(feature = "std")]
use std::collections::HashSet;
use codec::Encode;
#[cfg(feature = "std")]
use codec::Decode;
use codec::{Encode, Decode};
use sp_runtime::RuntimeString;
pub use sp_runtime::create_runtime_str;
#[doc(hidden)]
pub use sp_std;
#[cfg(feature = "std")]
use sp_runtime::{traits::Block as BlockT, generic::BlockId};
@@ -37,25 +37,13 @@ use sp_runtime::{traits::Block as BlockT, generic::BlockId};
/// The identity of a particular API interface that the runtime might provide.
pub type ApiId = [u8; 8];
/// A vector of pairs of `ApiId` and a `u32` for version. For `"std"` builds, this
/// is a `Cow`.
#[cfg(feature = "std")]
pub type ApisVec = std::borrow::Cow<'static, [(ApiId, u32)]>;
/// A vector of pairs of `ApiId` and a `u32` for version. For `"no-std"` builds, this
/// is just a reference.
#[cfg(not(feature = "std"))]
pub type ApisVec = &'static [(ApiId, u32)];
/// A vector of pairs of `ApiId` and a `u32` for version.
pub type ApisVec = sp_std::borrow::Cow<'static, [(ApiId, u32)]>;
/// Create a vector of Api declarations.
#[macro_export]
#[cfg(feature = "std")]
macro_rules! create_apis_vec {
( $y:expr ) => { std::borrow::Cow::Borrowed(& $y) }
}
#[macro_export]
#[cfg(not(feature = "std"))]
macro_rules! create_apis_vec {
( $y:expr ) => { & $y }
( $y:expr ) => { $crate::sp_std::borrow::Cow::Borrowed(& $y) }
}
/// Runtime version.
@@ -63,8 +51,8 @@ macro_rules! create_apis_vec {
/// This triplet have different semantics and mis-interpretation could cause problems.
/// In particular: bug fixes should result in an increment of `spec_version` and possibly `authoring_version`,
/// absolutely not `impl_version` since they change the semantics of the runtime.
#[derive(Clone, PartialEq, Eq, Encode, Default, sp_runtime::RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Decode))]
#[derive(Clone, PartialEq, Eq, Encode, Decode, Default, sp_runtime::RuntimeDebug)]
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
pub struct RuntimeVersion {
/// Identifies the different Substrate runtimes. There'll be at least polkadot and node.
@@ -64,7 +64,7 @@ pub trait ClientBlockImportExt<Block: BlockT>: Sized {
impl<B, E, RA, Block> ClientExt<Block> for Client<B, E, Block, RA>
where
B: sc_client_api::backend::Backend<Block>,
E: sc_client::CallExecutor<Block>,
E: sc_client::CallExecutor<Block> + 'static,
Self: BlockImport<Block, Error = ConsensusError>,
Block: BlockT,
{
+3 -3
View File
@@ -165,7 +165,7 @@ impl<Executor, Backend, G: GenesisInit> TestClientBuilder<Executor, Backend, G>
>,
sc_client::LongestChain<Backend, Block>,
) where
Executor: sc_client::CallExecutor<Block>,
Executor: sc_client::CallExecutor<Block> + 'static,
Backend: sc_client_api::backend::Backend<Block>,
Block: BlockT,
{
@@ -224,8 +224,8 @@ impl<E, Backend, G: GenesisInit> TestClientBuilder<
sc_client::LongestChain<Backend, Block>,
) where
I: Into<Option<NativeExecutor<E>>>,
E: sc_executor::NativeExecutionDispatch,
Backend: sc_client_api::backend::Backend<Block>,
E: sc_executor::NativeExecutionDispatch + 'static,
Backend: sc_client_api::backend::Backend<Block> + 'static,
Block: BlockT,
{
let executor = executor.into().unwrap_or_else(||
+11 -15
View File
@@ -59,21 +59,12 @@ pub mod prelude {
pub use super::{AccountKeyring, Sr25519Keyring};
}
mod local_executor {
#![allow(missing_docs)]
use substrate_test_runtime;
use crate::sc_executor::native_executor_instance;
// FIXME #1576 change the macro and pass in the `BlakeHasher` that dispatch needs from here instead
native_executor_instance!(
pub LocalExecutor,
substrate_test_runtime::api::dispatch,
substrate_test_runtime::native_version
);
sc_executor::native_executor_instance! {
pub LocalExecutor,
substrate_test_runtime::api::dispatch,
substrate_test_runtime::native_version,
}
/// Native executor used for tests.
pub use self::local_executor::LocalExecutor;
/// Test client database backend.
pub type Backend = substrate_test_client::Backend<substrate_test_runtime::Block>;
@@ -245,7 +236,7 @@ impl<B> TestClientBuilderExt<B> for TestClientBuilder<
sc_client::LocalCallExecutor<B, sc_executor::NativeExecutor<LocalExecutor>>,
B
> where
B: sc_client_api::backend::Backend<substrate_test_runtime::Block>,
B: sc_client_api::backend::Backend<substrate_test_runtime::Block> + 'static,
// Rust bug: https://github.com/rust-lang/rust/issues/24159
<B as sc_client_api::backend::Backend<substrate_test_runtime::Block>>::State:
sp_api::StateBackend<HasherFor<substrate_test_runtime::Block>>,
@@ -353,7 +344,7 @@ pub fn new_light() -> (
let storage = sc_client_db::light::LightStorage::new_test();
let blockchain = Arc::new(sc_client::light::blockchain::Blockchain::new(storage));
let backend = Arc::new(LightBackend::new(blockchain.clone()));
let executor = NativeExecutor::new(WasmExecutionMethod::Interpreted, None);
let executor = new_native_executor();
let local_call_executor = sc_client::LocalCallExecutor::new(backend.clone(), executor);
let call_executor = LightExecutor::new(
backend.clone(),
@@ -372,3 +363,8 @@ pub fn new_light() -> (
pub fn new_light_fetcher() -> LightFetcher {
LightFetcher::default()
}
/// Create a new native executor.
pub fn new_native_executor() -> sc_executor::NativeExecutor<LocalExecutor> {
sc_executor::NativeExecutor::new(sc_executor::WasmExecutionMethod::Interpreted, None)
}
+3
View File
@@ -65,7 +65,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("parity-test"),
authoring_version: 1,
spec_version: 1,
#[cfg(feature = "std")]
impl_version: 1,
#[cfg(not(feature = "std"))]
impl_version: 2,
apis: RUNTIME_API_VERSIONS,
};