Update to parity-scale-codec (#3232)

* WIP: update codec

* WIP

* compiling

* WIP

* rename parity-scale-codec to codec

* WIP

* fix

* remove old comments

* use published crates

* fix expected error msg

* bump version

* fmt and fix

* remove old comment

* fix wrong decoding impl

* implement encode like for structures

* undo removal of old pending changes

* trailingzeroinput

* Apply suggestions from code review

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

* update codec

* fmt

* version is 1.0.0

* show more error

* fmt
This commit is contained in:
thiolliere
2019-08-06 19:36:23 +02:00
committed by Bastian Köcher
parent a0d442333f
commit 4ed67e03a4
211 changed files with 867 additions and 682 deletions
+134 -99
View File
@@ -833,15 +833,15 @@ dependencies = [
[[package]]
name = "finality-grandpa"
version = "0.8.1"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"hashmap_core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -892,7 +892,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
name = "fork-tree"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -1300,10 +1300,10 @@ dependencies = [
[[package]]
name = "impl-codec"
version = "0.3.0"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -2010,6 +2010,14 @@ dependencies = [
"scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "lock_api"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "log"
version = "0.3.9"
@@ -2249,7 +2257,7 @@ dependencies = [
"node-executor 2.0.0",
"node-primitives 2.0.0",
"node-runtime 2.0.0",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -2287,7 +2295,7 @@ version = "2.0.0"
dependencies = [
"node-primitives 2.0.0",
"node-runtime 2.0.0",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
"srml-balances 2.0.0",
@@ -2314,7 +2322,7 @@ dependencies = [
name = "node-primitives"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
@@ -2342,7 +2350,7 @@ version = "2.0.0"
dependencies = [
"integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"node-primitives 2.0.0",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -2387,7 +2395,7 @@ dependencies = [
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"node-template-runtime 2.0.0",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"substrate-basic-authorship 2.0.0",
@@ -2409,7 +2417,7 @@ dependencies = [
name = "node-template-runtime"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -2583,21 +2591,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bitvec 0.11.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parity-codec-derive"
version = "3.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parity-multiaddr"
version = "0.5.0"
@@ -2631,16 +2627,28 @@ dependencies = [
[[package]]
name = "parity-scale-codec"
version = "1.0.3"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"arrayvec 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"bitvec 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",
"byte-slice-cast 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec-derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"vecarray 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parity-scale-codec-derive"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.15.42 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parity-send-wrapper"
version = "0.1.0"
@@ -2701,6 +2709,16 @@ dependencies = [
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parking_lot"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parking_lot_core"
version = "0.2.14"
@@ -2751,6 +2769,20 @@ dependencies = [
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "parking_lot_core"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.60 (registry+https://github.com/rust-lang/crates.io-index)",
"redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "paste"
version = "0.1.5"
@@ -2827,11 +2859,11 @@ dependencies = [
[[package]]
name = "primitive-types"
version = "0.4.0"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"fixed-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"impl-codec 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"impl-codec 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"uint 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -3159,13 +3191,13 @@ dependencies = [
[[package]]
name = "rhododendron"
version = "0.6.0"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -3559,7 +3591,7 @@ version = "2.0.0"
dependencies = [
"blake2-rfc 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)",
"criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3581,7 +3613,7 @@ dependencies = [
"environmental 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-std 2.0.0",
"substrate-offchain 2.0.0",
@@ -3598,9 +3630,9 @@ dependencies = [
"integer-sqrt 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
"primitive-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -3613,7 +3645,7 @@ name = "sr-sandbox"
version = "2.0.0"
dependencies = [
"assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-std 2.0.0",
"substrate-primitives 2.0.0",
@@ -3633,7 +3665,7 @@ name = "sr-version"
version = "2.0.0"
dependencies = [
"impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"sr-std 2.0.0",
@@ -3643,7 +3675,7 @@ dependencies = [
name = "srml-assets"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -3658,7 +3690,7 @@ name = "srml-aura"
version = "2.0.0"
dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -3678,7 +3710,7 @@ dependencies = [
name = "srml-authorship"
version = "0.1.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
"sr-std 2.0.0",
@@ -3693,7 +3725,7 @@ version = "2.0.0"
dependencies = [
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -3713,7 +3745,7 @@ dependencies = [
name = "srml-balances"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -3730,7 +3762,7 @@ name = "srml-collective"
version = "2.0.0"
dependencies = [
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -3749,7 +3781,7 @@ dependencies = [
"assert_matches 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)",
"pwasm-utils 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3770,7 +3802,7 @@ dependencies = [
name = "srml-democracy"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -3787,7 +3819,7 @@ name = "srml-elections"
version = "2.0.0"
dependencies = [
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -3803,7 +3835,7 @@ dependencies = [
name = "srml-example"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -3818,7 +3850,7 @@ name = "srml-executive"
version = "2.0.0"
dependencies = [
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -3834,7 +3866,7 @@ dependencies = [
name = "srml-finality-tracker"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -3849,7 +3881,7 @@ dependencies = [
name = "srml-generic-asset"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -3863,7 +3895,7 @@ dependencies = [
name = "srml-grandpa"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -3880,7 +3912,7 @@ dependencies = [
name = "srml-im-online"
version = "0.1.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -3895,7 +3927,7 @@ dependencies = [
name = "srml-indices"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"ref_thread_local 0.0.0 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3912,7 +3944,7 @@ dependencies = [
name = "srml-metadata"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-std 2.0.0",
"substrate-primitives 2.0.0",
@@ -3923,7 +3955,7 @@ name = "srml-session"
version = "2.0.0"
dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -3940,7 +3972,7 @@ dependencies = [
name = "srml-staking"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3961,7 +3993,7 @@ dependencies = [
name = "srml-sudo"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -3978,7 +4010,7 @@ version = "2.0.0"
dependencies = [
"bitmask 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"once_cell 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"paste 0.1.5 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4027,7 +4059,7 @@ dependencies = [
name = "srml-support-test"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -4042,7 +4074,7 @@ name = "srml-system"
version = "2.0.0"
dependencies = [
"criterion 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (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.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -4056,7 +4088,7 @@ dependencies = [
name = "srml-timestamp"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -4071,7 +4103,7 @@ dependencies = [
name = "srml-treasury"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -4163,7 +4195,7 @@ dependencies = [
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"node-primitives 2.0.0",
"node-runtime 2.0.0",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4191,7 +4223,7 @@ version = "2.0.0"
dependencies = [
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"substrate-client 2.0.0",
"substrate-consensus-common 2.0.0",
@@ -4261,7 +4293,7 @@ dependencies = [
"kvdb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
"kvdb-memorydb 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-api-macros 2.0.0",
"sr-primitives 2.0.0",
@@ -4289,7 +4321,7 @@ dependencies = [
"kvdb-rocksdb 0.1.4 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)",
"linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"substrate-client 2.0.0",
@@ -4312,7 +4344,7 @@ dependencies = [
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -4338,7 +4370,7 @@ dependencies = [
name = "substrate-consensus-aura-primitives"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"sr-std 2.0.0",
"substrate-client 2.0.0",
@@ -4359,7 +4391,7 @@ dependencies = [
"num-bigint 0.2.2 (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.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4387,7 +4419,7 @@ dependencies = [
name = "substrate-consensus-babe-primitives"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"schnorrkel 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"sr-std 2.0.0",
@@ -4405,7 +4437,7 @@ dependencies = [
"futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"libp2p 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"sr-std 2.0.0",
@@ -4419,7 +4451,7 @@ dependencies = [
name = "substrate-consensus-common-primitives"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"sr-std 2.0.0",
"substrate-client 2.0.0",
@@ -4433,9 +4465,9 @@ dependencies = [
"exit-future 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rhododendron 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rhododendron 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
"sr-version 2.0.0",
@@ -4456,7 +4488,7 @@ dependencies = [
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-timer 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"substrate-client 2.0.0",
@@ -4477,7 +4509,7 @@ dependencies = [
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libsecp256k1 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
@@ -4500,12 +4532,12 @@ name = "substrate-finality-grandpa"
version = "2.0.0"
dependencies = [
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"finality-grandpa 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"fork-tree 2.0.0",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4530,7 +4562,7 @@ dependencies = [
name = "substrate-finality-grandpa-primitives"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"sr-std 2.0.0",
@@ -4542,7 +4574,7 @@ dependencies = [
name = "substrate-inherents"
version = "2.0.0"
dependencies = [
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"sr-std 2.0.0",
@@ -4592,7 +4624,7 @@ dependencies = [
"linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quickcheck 0.8.5 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4626,7 +4658,7 @@ dependencies = [
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"substrate-client 2.0.0",
@@ -4684,10 +4716,10 @@ dependencies = [
"impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.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.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)",
"regex 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4716,7 +4748,7 @@ dependencies = [
"jsonrpc-derive 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"jsonrpc-pubsub 12.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-hex 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4779,8 +4811,8 @@ dependencies = [
"node-executor 2.0.0",
"node-primitives 2.0.0",
"node-runtime 2.0.0",
"parity-codec 4.1.3 (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.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -4830,7 +4862,7 @@ version = "2.0.0"
dependencies = [
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"substrate-primitives 2.0.0",
]
@@ -4843,7 +4875,7 @@ dependencies = [
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"substrate-panic-handler 2.0.0",
"substrate-primitives 2.0.0",
@@ -4879,7 +4911,7 @@ version = "2.0.0"
dependencies = [
"futures-preview 0.3.0-alpha.17 (registry+https://github.com/rust-lang/crates.io-index)",
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"substrate-client 2.0.0",
"substrate-client-db 2.0.0",
@@ -4897,7 +4929,7 @@ dependencies = [
"cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 2.0.0",
"sr-primitives 2.0.0",
@@ -4942,7 +4974,7 @@ dependencies = [
"env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
@@ -4957,7 +4989,7 @@ dependencies = [
"derive_more 0.14.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"substrate-client 2.0.0",
@@ -4976,7 +5008,7 @@ dependencies = [
"hex-literal 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-std 2.0.0",
"substrate-primitives 2.0.0",
"trie-bench 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -5388,7 +5420,7 @@ name = "transaction-factory"
version = "0.0.1"
dependencies = [
"log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 2.0.0",
"substrate-cli 2.0.0",
"substrate-client 2.0.0",
@@ -5406,7 +5438,7 @@ dependencies = [
"hash-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"keccak-hasher 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"memory-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-db 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-root 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
"trie-standardmap 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -6063,7 +6095,7 @@ dependencies = [
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
"checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
"checksum fdlimit 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1ee15a7050e5580b3712877157068ea713b245b080ff302ae2ca973cfcd9baa"
"checksum finality-grandpa 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b9e7cba2aaadf09932452a4fc054a77451b31eb99bc0b42bf54bd44f01a9daf4"
"checksum finality-grandpa 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9681c1f75941ea47584573dd2bc10558b2067d460612945887e00744e43393be"
"checksum fixed-hash 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "516877b7b9a1cc2d0293cbce23cd6203f0edbfd4090e6ca4489fecb5aa73050e"
"checksum flate2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "550934ad4808d5d39365e5d61727309bf18b3b02c6c56b729cb92e7dd84bc3d8"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
@@ -6113,7 +6145,7 @@ dependencies = [
"checksum hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273"
"checksum hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)" = "7cb44cbce9d8ee4fb36e4c0ad7b794ac44ebaad924b9c8291a63215bb44c2c8f"
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
"checksum impl-codec 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62ed8ff267bc916dd848a800b96d3129aec73d5b23a5e3d018c83655d0c55371"
"checksum impl-codec 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "78c441b3d2b5e24b407161e76d482b7bbd29b5da357707839ac40d95152f031f"
"checksum impl-serde 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5158079de9d4158e0ce1de3ae0bd7be03904efc40b3d7dd8b8c301cbf6b52b56"
"checksum impl-serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7d26be4b97d738552ea423f76c4f681012ff06c3fa36fa968656b3679f60b4a1"
"checksum indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7e81a7c05f79578dbc15793d8b619db9ba32b4577003ef3af1a91c416798c58d"
@@ -6171,6 +6203,7 @@ dependencies = [
"checksum linked_hash_set 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3c7c91c4c7bbeb4f2f7c4e5be11e6a05bd6830bc37249c47ce1ad86ad453ff9c"
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
"checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff"
"checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c275b6ad54070ac2d665eef9197db647b32239c9d244bfb6f041a766d00da5b3"
"checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c"
@@ -6213,10 +6246,10 @@ dependencies = [
"checksum owning_ref 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "49a4b8ea2179e6a2e27411d3bca09ca6dd630821cf6894c6c7c8467a8ee7ef13"
"checksum parity-bytes 0.1.0 (git+https://github.com/paritytech/parity-common?rev=b0317f649ab2c665b7987b8475878fc4d2e1f81d)" = "<none>"
"checksum parity-codec 4.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2900f06356edf90de66a2922db622b36178dca71e85625eae58d0d9cc6cff2ac"
"checksum parity-codec-derive 3.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "00a486fd383382ddcb2de928364b1f82571c1e48274fc43b7667a4738ee4056c"
"checksum parity-multiaddr 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "045b3c7af871285146300da35b1932bb6e4639b66c7c98e85d06a32cbc4e8fa7"
"checksum parity-multihash 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "df3a17dc27848fd99e4f87eb0f8c9baba6ede0a6d555400c850ca45254ef4ce3"
"checksum parity-scale-codec 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7b72212671aded3ca515379ea16aa774289e06cd595c7e31f06afdc48d6516e3"
"checksum parity-scale-codec 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "00fd14ff806ad82cea9a8f909bb116443d92efda7c9acd4502690af64741ad81"
"checksum parity-scale-codec-derive 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a81f3cd93ed368a8e41c4e79538e99ca6e8f536096de23e3a0bc3e782093ce28"
"checksum parity-send-wrapper 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aa9777aa91b8ad9dd5aaa04a9b6bcb02c7f1deb952fca5a66034d5e63afc5c6f"
"checksum parity-util-mem 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2005637ccf93dbb60c85081ccaaf3f945f573da48dcc79f27f9646caa3ec1dc"
"checksum parity-wasm 0.31.3 (registry+https://github.com/rust-lang/crates.io-index)" = "511379a8194230c2395d2f5fa627a5a7e108a9f976656ce723ae68fca4097bfc"
@@ -6224,10 +6257,12 @@ dependencies = [
"checksum parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f0802bff09003b291ba756dc7e79313e51cc31667e94afbe847def490424cde5"
"checksum parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab41b4aed082705d1056416ae4468b6ea99d52599ecf3169b00088d43113e337"
"checksum parking_lot 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa7767817701cce701d5585b9c4db3cdd02086398322c1d7e8bf5094a96a2ce7"
"checksum parking_lot 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252"
"checksum parking_lot_core 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "4db1a8ccf734a7bce794cc19b3df06ed87ab2f3907036b693c68f56b4d4537fa"
"checksum parking_lot_core 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ad7f7e6ebdc79edff6fdcb87a55b620174f7a989e3eb31b65231f4af57f00b8c"
"checksum parking_lot_core 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94c8c7923936b28d546dfd14d4472eaf34c99b14e1c973a32b3e6d4eb04298c9"
"checksum parking_lot_core 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cb88cb1cb3790baa6776844f968fea3be44956cf184fa1be5a03341f5491278c"
"checksum parking_lot_core 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b"
"checksum paste 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "1f4a4a1c555c6505821f9d58b8779d0f630a6b7e4e1be24ba718610acf01fa79"
"checksum paste-impl 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "26e796e623b8b257215f27e6c80a5478856cae305f5b59810ff9acdaa34570e6"
"checksum pbkdf2 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "006c038a43a45995a9670da19e67600114740e8511d4333bf97a56e66a7542d9"
@@ -6238,7 +6273,7 @@ dependencies = [
"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b"
"checksum pretty_assertions 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a029430f0d744bc3d15dd474d591bed2402b645d024583082b9f63bb936dac6"
"checksum pretty_assertions 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f81e1644e1b54f5a68959a29aa86cde704219254669da328ecfdf6a1f09d427"
"checksum primitive-types 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "366ef730e56c11fd21ab3e518866cf7feb0fdf7f7c16ddc68485579e9d802787"
"checksum primitive-types 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e44400d651ca5276415dc8e00541c5c9d03844f1f0a87ad28f0a8fadcb2300bc"
"checksum proc-macro-crate 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "e10d4b51f154c8a7fb96fd6dad097cb74b863943ec010ac94b9fd1be8861fe1e"
"checksum proc-macro-hack 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "982a35d1194084ba319d65c4a68d24ca28f5fdb5b8bc20899e4eef8641ea5178"
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
@@ -6275,7 +6310,7 @@ dependencies = [
"checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9"
"checksum regex-syntax 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "cd5485bf1523a9ed51c4964273f22f63f24e31632adb5dad134f488f86a3875c"
"checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"
"checksum rhododendron 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "057fecd57cc69e24d9d215c9f283a42133c3f48952e4fc06b088ecf3ce3d90bb"
"checksum rhododendron 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "36542aafc2429a4c010fafa079a20dee953b663cb2427f51d86cf1d436846b4d"
"checksum ring 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)" = "426bc186e3e95cac1e4a4be125a4aca7e84c2d616ffc02244eef36e2a60a093c"
"checksum rocksdb 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1651697fefd273bfb4fd69466cc2a9d20de557a0213b97233b22b5e95924b5e"
"checksum rpassword 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c34fa7bcae7fca3c8471e8417088bbc3ad9af8066b0ecf4f3c0d98a0d772716e"
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
log = "0.4"
futures-preview = "0.3.0-alpha.17"
codec = { package = "parity-codec", version = "4.1.1" }
codec = { package = "parity-scale-codec", version = "1.0.0" }
sr-primitives = { path = "../../core/sr-primitives" }
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
client = { package = "substrate-client", path = "../../core/client" }
@@ -213,7 +213,7 @@ impl<Block, B, E, RA, A> Proposer<Block, SubstrateClient<B, E, Block, RA>, A> wh
"hash" => ?<Block as BlockT>::Hash::from(block.header().hash()),
);
if Decode::decode(&mut block.encode().as_slice()).as_ref() != Some(&block) {
if Decode::decode(&mut block.encode().as_slice()).as_ref() != Ok(&block) {
error!("Failed to verify block encoding/decoding");
}
+13 -4
View File
@@ -37,8 +37,8 @@ use network::{
use primitives::H256;
use std::{
io::{Write, Read, stdin, stdout, ErrorKind}, iter, fs::{self, File}, net::{Ipv4Addr, SocketAddr},
path::{Path, PathBuf}, str::FromStr,
io::{Write, Read, Seek, Cursor, stdin, stdout, ErrorKind}, iter, fs::{self, File},
net::{Ipv4Addr, SocketAddr}, path::{Path, PathBuf}, str::FromStr,
};
use names::{Generator, Name};
@@ -628,6 +628,11 @@ where
).map_err(Into::into)
}
/// Internal trait used to cast to a dynamic type that implements Read and Seek.
trait ReadPlusSeek: Read + Seek {}
impl<T: Read + Seek> ReadPlusSeek for T {}
fn import_blocks<F, E, S>(
cli: ImportBlocksCmd,
spec_factory: S,
@@ -646,9 +651,13 @@ where
..Default::default()
};
let file: Box<dyn Read> = match cli.input {
let file: Box<dyn ReadPlusSeek> = match cli.input {
Some(filename) => Box::new(File::open(filename)?),
None => Box::new(stdin()),
None => {
let mut buffer = Vec::new();
stdin().read_to_end(&mut buffer)?;
Box::new(Cursor::new(buffer))
},
};
let fut = service::chain_ops::import_blocks::<F, _, _>(config, exit.into_exit(), file)?;
+2 -2
View File
@@ -19,7 +19,7 @@ trie = { package = "substrate-trie", path = "../trie", optional = true }
substrate-telemetry = { path = "../telemetry", optional = true }
hash-db = { version = "0.15.0", default-features = false }
kvdb = { git = "https://github.com/paritytech/parity-common", optional = true, rev="b0317f649ab2c665b7987b8475878fc4d2e1f81d" }
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
sr-primitives = { path = "../sr-primitives", default-features = false }
runtime-version = { package = "sr-version", path = "../sr-version", default-features = false }
@@ -36,7 +36,7 @@ kvdb-memorydb = { git = "https://github.com/paritytech/parity-common", rev="b031
default = ["std"]
std = [
"rstd/std",
"parity-codec/std",
"codec/std",
"primitives/std",
"inherents/std",
"sr-primitives/std",
+1 -1
View File
@@ -17,7 +17,7 @@ primitives = { package = "substrate-primitives", path = "../../primitives" }
sr-primitives = { path = "../../sr-primitives" }
client = { package = "substrate-client", path = "../../client" }
state-machine = { package = "substrate-state-machine", path = "../../state-machine" }
parity-codec = { version = "4.1.1", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
executor = { package = "substrate-executor", path = "../../executor" }
state_db = { package = "substrate-state-db", path = "../../state-db" }
trie = { package = "substrate-trie", path = "../../trie" }
+1 -1
View File
@@ -18,7 +18,7 @@
use client::error::Result as ClientResult;
use sr_primitives::traits::{Block as BlockT, NumberFor};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use crate::cache::{CacheItemT, ComplexBlockId};
use crate::cache::list_storage::{Storage};
+4 -4
View File
@@ -21,7 +21,7 @@ use std::sync::Arc;
use kvdb::{KeyValueDB, DBTransaction};
use client::error::{Error as ClientError, Result as ClientResult};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use sr_primitives::generic::BlockId;
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use crate::utils::{self, db_err, meta_keys};
@@ -151,7 +151,7 @@ impl<Block: BlockT, T: CacheItemT> Storage<Block, T> for DbStorage {
.map_err(db_err)
.and_then(|entry| match entry {
Some(entry) => StorageEntry::<Block, T>::decode(&mut &entry[..])
.ok_or_else(|| ClientError::Backend("Failed to decode cache entry".into()))
.map_err(|_| ClientError::Backend("Failed to decode cache entry".into()))
.map(Some),
None => Ok(None),
})
@@ -236,9 +236,9 @@ mod meta {
pub fn decode<Block: BlockT>(encoded: &[u8]) -> ClientResult<Metadata<Block>> {
let input = &mut &*encoded;
let finalized: Option<ComplexBlockId<Block>> = Decode::decode(input)
.ok_or_else(|| ClientError::from(ClientError::Backend("Error decoding cache meta".into())))?;
.map_err(|_| ClientError::from(ClientError::Backend("Error decoding cache meta".into())))?;
let unfinalized: Vec<ComplexBlockId<Block>> = Decode::decode(input)
.ok_or_else(|| ClientError::from(ClientError::Backend("Error decoding cache meta".into())))?;
.map_err(|_| ClientError::from(ClientError::Backend("Error decoding cache meta".into())))?;
Ok(Metadata { finalized, unfinalized })
}
+1 -1
View File
@@ -23,7 +23,7 @@ use kvdb::{KeyValueDB, DBTransaction};
use client::blockchain::Cache as BlockchainCache;
use client::error::Result as ClientResult;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use sr_primitives::generic::BlockId;
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero};
use consensus_common::well_known_cache_keys::Id as CacheKeyId;
+10 -6
View File
@@ -42,7 +42,7 @@ use client::backend::NewBlockState;
use client::blockchain::HeaderBackend;
use client::ExecutionStrategies;
use client::backend::{StorageCollection, ChildStorageCollection};
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use hash_db::{Hasher, Prefix};
use kvdb::{KeyValueDB, DBTransaction};
use trie::{MemoryDB, PrefixedMemoryDB, prefixed_key};
@@ -338,8 +338,10 @@ impl<Block: BlockT> client::blockchain::Backend<Block> for BlockchainDb<Block> {
fn body(&self, id: BlockId<Block>) -> Result<Option<Vec<Block::Extrinsic>>, client::error::Error> {
match read_db(&*self.db, columns::KEY_LOOKUP, columns::BODY, id)? {
Some(body) => match Decode::decode(&mut &body[..]) {
Some(body) => Ok(Some(body)),
None => return Err(client::error::Error::Backend("Error decoding body".into())),
Ok(body) => Ok(Some(body)),
Err(err) => return Err(client::error::Error::Backend(
format!("Error decoding body: {}", err)
)),
}
None => Ok(None),
}
@@ -348,8 +350,10 @@ impl<Block: BlockT> client::blockchain::Backend<Block> for BlockchainDb<Block> {
fn justification(&self, id: BlockId<Block>) -> Result<Option<Justification>, client::error::Error> {
match read_db(&*self.db, columns::KEY_LOOKUP, columns::JUSTIFICATION, id)? {
Some(justification) => match Decode::decode(&mut &justification[..]) {
Some(justification) => Ok(Some(justification)),
None => return Err(client::error::Error::Backend("Error decoding justification".into())),
Ok(justification) => Ok(Some(justification)),
Err(err) => return Err(client::error::Error::Backend(
format!("Error decoding justification: {}", err)
)),
}
None => Ok(None),
}
@@ -838,7 +842,7 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
let changes_trie_config = self
.state_at(BlockId::Hash(block))?
.storage(well_known_keys::CHANGES_TRIE_CONFIG)?
.and_then(|v| Decode::decode(&mut &*v));
.and_then(|v| Decode::decode(&mut &*v).ok());
*cached_changes_trie_config = Some(changes_trie_config.clone());
Ok(changes_trie_config)
},
+4 -3
View File
@@ -29,7 +29,7 @@ use client::cht;
use client::leaves::{LeafSet, FinalizationDisplaced};
use client::error::{Error as ClientError, Result as ClientResult};
use client::light::blockchain::Storage as LightBlockchainStorage;
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use primitives::Blake2Hasher;
use sr_primitives::generic::{DigestItem, BlockId};
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, Zero, One, NumberFor};
@@ -360,7 +360,7 @@ impl<Block: BlockT> LightStorage<Block> {
let cht_start = cht::start_number(cht_size, cht_number);
self.db.get(columns::CHT, &cht_key(cht_type, cht_start)?).map_err(db_err)?
.ok_or_else(no_cht_for_block)
.and_then(|hash| Block::Hash::decode(&mut &*hash).ok_or_else(no_cht_for_block))
.and_then(|hash| Block::Hash::decode(&mut &*hash).map_err(|_| no_cht_for_block()))
}
}
@@ -887,7 +887,8 @@ pub(crate) mod tests {
}
fn get_authorities(cache: &dyn BlockchainCache<Block>, at: BlockId<Block>) -> Option<Vec<AuthorityId>> {
cache.get_at(&well_known_cache_keys::AUTHORITIES, &at).and_then(|val| Decode::decode(&mut &val[..]))
cache.get_at(&well_known_cache_keys::AUTHORITIES, &at)
.and_then(|val| Decode::decode(&mut &val[..]).ok())
}
let auth1 = || AuthorityId::from_raw([1u8; 32]);
+8 -6
View File
@@ -27,7 +27,7 @@ use kvdb_rocksdb::{Database, DatabaseConfig};
use log::debug;
use client;
use parity_codec::Decode;
use codec::Decode;
use trie::DBValue;
use sr_primitives::generic::BlockId;
use sr_primitives::traits::{
@@ -260,8 +260,8 @@ pub fn read_header<Block: BlockT>(
) -> client::error::Result<Option<Block::Header>> {
match read_db(db, col_index, col, id)? {
Some(header) => match Block::Header::decode(&mut &header[..]) {
Some(header) => Ok(Some(header)),
None => return Err(
Ok(header) => Ok(Some(header)),
Err(_) => return Err(
client::error::Error::Backend("Error decoding header".into())
),
}
@@ -290,8 +290,10 @@ pub fn read_meta<Block>(db: &dyn KeyValueDB, col_meta: Option<u32>, col_header:
{
let genesis_hash: Block::Hash = match db.get(col_meta, meta_keys::GENESIS_HASH).map_err(db_err)? {
Some(h) => match Decode::decode(&mut &h[..]) {
Some(h) => h,
None => return Err(client::error::Error::Backend("Error decoding genesis hash".into())),
Ok(h) => h,
Err(err) => return Err(client::error::Error::Backend(
format!("Error decoding genesis hash: {}", err)
)),
},
None => return Ok(Meta {
best_hash: Default::default(),
@@ -305,7 +307,7 @@ pub fn read_meta<Block>(db: &dyn KeyValueDB, col_meta: Option<u32>, col_header:
let load_meta_block = |desc, key| -> Result<_, client::error::Error> {
if let Some(Some(header)) = db.get(col_meta, key).and_then(|id|
match id {
Some(id) => db.get(col_header, &id).map(|h| h.map(|b| Block::Header::decode(&mut &b[..]))),
Some(id) => db.get(col_header, &id).map(|h| h.map(|b| Block::Header::decode(&mut &b[..]).ok())),
None => Ok(None),
}).map_err(db_err)?
{
@@ -16,7 +16,7 @@
use super::api::BlockBuilder as BlockBuilderApi;
use std::vec::Vec;
use parity_codec::Encode;
use codec::Encode;
use sr_primitives::ApplyOutcome;
use sr_primitives::generic::BlockId;
use sr_primitives::traits::{
+1 -1
View File
@@ -15,7 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use std::{sync::Arc, cmp::Ord, panic::UnwindSafe, result, cell::RefCell, rc::Rc};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use sr_primitives::{
generic::BlockId, traits::Block as BlockT,
};
+3 -3
View File
@@ -17,7 +17,7 @@
//! Functionality for reading and storing children hashes from db.
use kvdb::{KeyValueDB, DBTransaction};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use crate::error;
use std::hash::Hash;
@@ -41,8 +41,8 @@ pub fn read_children<
};
let children: Vec<V> = match Decode::decode(&mut &raw_val[..]) {
Some(children) => children,
None => return Err(error::Error::Backend("Error decoding children".into())),
Ok(children) => children,
Err(_) => return Err(error::Error::Backend("Error decoding children".into())),
};
Ok(children)
+1 -1
View File
@@ -26,7 +26,7 @@
use std::collections::HashSet;
use hash_db;
use parity_codec::Encode;
use codec::Encode;
use trie;
use primitives::{H256, convert_hash};
+2 -2
View File
@@ -50,7 +50,7 @@ use primitives::{
};
use primitives::storage::{StorageKey, StorageData};
use primitives::storage::well_known_keys;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use state_machine::{
DBValue, Backend as StateBackend, CodeExecutor, ChangesTrieAnchorBlockId,
ExecutionStrategy, ExecutionManager, prove_read, prove_child_read,
@@ -1327,7 +1327,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
Ok(self.backend.state_at(BlockId::Number(self.backend.blockchain().info().best_number))?
.storage(well_known_keys::CHANGES_TRIE_CONFIG)
.map_err(|e| error::Error::from_state(Box::new(e)))?
.and_then(|c| Decode::decode(&mut &*c)))
.and_then(|c| Decode::decode(&mut &*c).ok()))
}
/// Prepare in-memory header that is used in execution environment.
+3 -3
View File
@@ -74,11 +74,11 @@ pub enum Error {
#[display(fmt = "Remote data fetch has been failed")]
RemoteFetchFailed,
/// Error decoding call result.
#[display(fmt = "Error decoding call result of {}", _0)]
CallResultDecode(&'static str),
#[display(fmt = "Error decoding call result of {}: {}", _0, _1)]
CallResultDecode(&'static str, codec::Error),
/// Error converting a parameter between runtime and node.
#[display(fmt = "Error converting `{}` between runtime and node", _0)]
RuntimeParamConversion(&'static str),
RuntimeParamConversion(String),
/// Changes tries are not supported.
#[display(fmt = "Changes tries are not supported by the runtime")]
ChangesTriesNotSupported,
+1 -1
View File
@@ -40,7 +40,7 @@ pub fn construct_genesis_block<
#[cfg(test)]
mod tests {
use super::*;
use parity_codec::{Encode, Decode, Joiner};
use codec::{Encode, Decode, Joiner};
use executor::native_executor_instance;
use state_machine::{self, OverlayedChanges, ExecutionStrategy, InMemoryChangesTrieStorage};
use state_machine::backend::InMemory;
+5 -5
View File
@@ -20,7 +20,7 @@ use std::collections::BTreeMap;
use std::cmp::Reverse;
use kvdb::{KeyValueDB, DBTransaction};
use sr_primitives::traits::SimpleArithmetic;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use crate::error;
#[derive(Debug, Clone, PartialEq, Eq)]
@@ -84,12 +84,12 @@ impl<H, N> LeafSet<H, N> where
if !key.starts_with(prefix) { break }
let raw_hash = &mut &key[prefix.len()..];
let hash = match Decode::decode(raw_hash) {
Some(hash) => hash,
None => return Err(error::Error::Backend("Error decoding hash".into())),
Ok(hash) => hash,
Err(_) => return Err(error::Error::Backend("Error decoding hash".into())),
};
let number = match Decode::decode(&mut &value[..]) {
Some(number) => number,
None => return Err(error::Error::Backend("Error decoding number".into())),
Ok(number) => number,
Err(_) => return Err(error::Error::Backend("Error decoding number".into())),
};
storage.entry(Reverse(number)).or_insert_with(Vec::new).push(hash);
}
@@ -22,7 +22,7 @@ use std::{
marker::PhantomData, cell::RefCell, rc::Rc,
};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use primitives::{offchain, H256, Blake2Hasher, convert_hash, NativeOrEncoded};
use sr_primitives::generic::BlockId;
use sr_primitives::traits::{One, Block as BlockT, Header as HeaderT};
@@ -149,7 +149,7 @@ where
fn runtime_version(&self, id: &BlockId<Block>) -> ClientResult<RuntimeVersion> {
let call_result = self.call(id, "Core_version", &[], ExecutionStrategy::NativeElseWasm, NeverOffchainExt::new())?;
RuntimeVersion::decode(&mut call_result.as_slice())
.ok_or_else(|| ClientError::VersionInvalid.into())
.map_err(|_| ClientError::VersionInvalid.into())
}
fn call_at_state<
+3 -3
View File
@@ -22,7 +22,7 @@ use std::marker::PhantomData;
use std::future::Future;
use hash_db::{HashDB, Hasher, EMPTY_PREFIX};
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use primitives::{ChangesTrieConfiguration, convert_hash};
use sr_primitives::traits::{
Block as BlockT, Header as HeaderT, Hash, HashFor, NumberFor,
@@ -486,7 +486,7 @@ impl<'a, H, Number, Hash> ChangesTrieRootsStorage<H, Number> for RootsStorage<'a
pub mod tests {
use futures::future::Ready;
use parking_lot::Mutex;
use parity_codec::Decode;
use codec::Decode;
use crate::client::tests::prepare_client_with_key_changes;
use executor::{self, NativeExecutor};
use crate::error::Error as ClientError;
@@ -566,7 +566,7 @@ pub mod tests {
// 'fetch' read proof from remote node
let heap_pages = remote_client.storage(&remote_block_id, &StorageKey(well_known_keys::HEAP_PAGES.to_vec()))
.unwrap()
.and_then(|v| Decode::decode(&mut &v.0[..])).unwrap();
.and_then(|v| Decode::decode(&mut &v.0[..]).ok()).unwrap();
let remote_read_proof = remote_client.read_proof(&remote_block_id, well_known_keys::HEAP_PAGES).unwrap();
// check remote read proof locally
+1 -1
View File
@@ -39,7 +39,7 @@ pub use rstd::{slice, mem};
#[cfg(feature = "std")]
use rstd::result;
#[doc(hidden)]
pub use parity_codec::{Encode, Decode};
pub use codec::{Encode, Decode};
#[cfg(feature = "std")]
use crate::error;
use sr_api_macros::decl_runtime_apis;
+1 -1
View File
@@ -6,7 +6,7 @@ description = "Aura consensus algorithm for substrate"
edition = "2018"
[dependencies]
parity-codec = "4.1.1"
codec = { package = "parity-scale-codec", version = "1.0.0" }
primitives = { package = "substrate-primitives", path = "../../primitives" }
runtime_support = { package = "srml-support", path = "../../../srml/support" }
runtime_version = { package = "sr-version", path = "../../sr-version" }
@@ -6,7 +6,7 @@ description = "Primitives for Aura consensus"
edition = "2018"
[dependencies]
parity-codec = { version = "4.1.1", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
substrate-client = { path = "../../../client", default-features = false }
primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false }
rstd = { package = "sr-std", path = "../../../sr-std", default-features = false }
@@ -16,7 +16,7 @@ sr-primitives = { path = "../../../sr-primitives", default-features = false }
default = ["std"]
std = [
"rstd/std",
"parity-codec/std",
"codec/std",
"sr-primitives/std",
"substrate-client/std",
"primitives/std",
@@ -18,7 +18,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use parity_codec::{Encode, Decode, Codec};
use codec::{Encode, Decode, Codec};
use substrate_client::decl_runtime_apis;
use rstd::vec::Vec;
use sr_primitives::ConsensusEngineId;
+1 -1
View File
@@ -22,7 +22,7 @@
use primitives::Pair;
use aura_primitives::AURA_ENGINE_ID;
use sr_primitives::generic::{DigestItem, OpaqueDigestItemId};
use parity_codec::{Encode, Codec};
use codec::{Encode, Codec};
use std::fmt::Debug;
type Signature<P> = <P as Pair>::Signature;
+3 -3
View File
@@ -30,7 +30,7 @@
#![forbid(missing_docs, unsafe_code)]
use std::{sync::Arc, time::Duration, thread, marker::PhantomData, hash::Hash, fmt::Debug, pin::Pin};
use parity_codec::{Encode, Decode, Codec};
use codec::{Encode, Decode, Codec};
use consensus_common::{self, BlockImport, Environment, Proposer,
ForkChoiceStrategy, BlockImportParams, BlockOrigin, Error as ConsensusError,
SelectChain, well_known_cache_keys::{self, Id as CacheKeyId}
@@ -623,7 +623,7 @@ fn initialize_authorities_cache<A, B, C>(client: &C) -> Result<(), ConsensusErro
let genesis_id = BlockId::Number(Zero::zero());
let genesis_authorities: Option<Vec<A>> = cache
.get_at(&well_known_cache_keys::AUTHORITIES, &genesis_id)
.and_then(|v| Decode::decode(&mut &v[..]));
.and_then(|v| Decode::decode(&mut &v[..]).ok());
if genesis_authorities.is_some() {
return Ok(());
}
@@ -651,7 +651,7 @@ fn authorities<A, B, C>(client: &C, at: &BlockId<B>) -> Result<Vec<A>, Consensus
.cache()
.and_then(|cache| cache
.get_at(&well_known_cache_keys::AUTHORITIES, at)
.and_then(|v| Decode::decode(&mut &v[..]))
.and_then(|v| Decode::decode(&mut &v[..]).ok())
)
.or_else(|| AuraApi::authorities(&*client.runtime_api(), at).ok())
.ok_or_else(|| consensus_common::Error::InvalidAuthoritiesSet.into())
+2 -2
View File
@@ -6,8 +6,8 @@ description = "BABE consensus algorithm for substrate"
edition = "2018"
[dependencies]
parity-codec = { version = "4.1.1", features = ["derive"] }
babe-primitives = { package = "substrate-consensus-babe-primitives", path = "primitives" }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
babe_primitives = { package = "substrate-consensus-babe-primitives", path = "primitives" }
primitives = { package = "substrate-primitives", path = "../../primitives" }
num-bigint = "0.2"
num-rational = "0.2"
@@ -11,7 +11,7 @@ rstd = { package = "sr-std", path = "../../../sr-std", default-features = false
sr-primitives = { path = "../../../sr-primitives", default-features = false }
primitives = { package = "substrate-primitives", path = "../../../primitives", default-features = false }
slots = { package = "substrate-consensus-slots", path = "../../slots", optional = true }
parity-codec = { version = "4.1.1", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
schnorrkel = { version = "0.1.1", optional = true }
[features]
@@ -20,7 +20,7 @@ std = [
"rstd/std",
"sr-primitives/std",
"substrate-client/std",
"parity-codec/std",
"codec/std",
"schnorrkel",
"slots",
]
@@ -27,11 +27,14 @@ use super::SlotNumber;
use sr_primitives::{DigestItem, generic::OpaqueDigestItemId};
#[cfg(feature = "std")]
use std::fmt::Debug;
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
#[cfg(feature = "std")]
use parity_codec::{Codec, Input};
use codec::{Codec, Input, Error};
#[cfg(feature = "std")]
use schnorrkel::vrf::{VRFProof, VRFOutput, VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH};
use schnorrkel::{
SignatureError, errors::MultiSignatureStage,
vrf::{VRFProof, VRFOutput, VRF_OUTPUT_LENGTH, VRF_PROOF_LENGTH}
};
/// A BABE pre-digest
#[cfg(feature = "std")]
@@ -72,21 +75,26 @@ impl Encode for BabePreDigest {
authority_index: self.authority_index,
slot_number: self.slot_number,
};
parity_codec::Encode::encode(&tmp)
codec::Encode::encode(&tmp)
}
}
#[cfg(feature = "std")]
impl codec::EncodeLike for BabePreDigest {}
#[cfg(feature = "std")]
impl Decode for BabePreDigest {
fn decode<R: Input>(i: &mut R) -> Option<Self> {
fn decode<R: Input>(i: &mut R) -> Result<Self, Error> {
let RawBabePreDigest { vrf_output, vrf_proof, authority_index, slot_number } = Decode::decode(i)?;
// Verify (at compile time) that the sizes in babe_primitives are correct
let _: [u8; super::VRF_OUTPUT_LENGTH] = vrf_output;
let _: [u8; super::VRF_PROOF_LENGTH] = vrf_proof;
Some(BabePreDigest {
vrf_proof: VRFProof::from_bytes(&vrf_proof).ok()?,
vrf_output: VRFOutput::from_bytes(&vrf_output).ok()?,
Ok(BabePreDigest {
vrf_proof: VRFProof::from_bytes(&vrf_proof)
.map_err(convert_error)?,
vrf_output: VRFOutput::from_bytes(&vrf_output)
.map_err(convert_error)?,
authority_index,
slot_number,
})
@@ -136,3 +144,33 @@ impl<Hash> CompatibleDigestItem for DigestItem<Hash> where
self.try_to(OpaqueDigestItemId::Consensus(&BABE_ENGINE_ID))
}
}
#[cfg(feature = "std")]
fn convert_error(e: SignatureError) -> codec::Error {
use SignatureError::*;
use MultiSignatureStage::*;
match e {
EquationFalse => "Signature error: `EquationFalse`".into(),
PointDecompressionError => "Signature error: `PointDecompressionError`".into(),
ScalarFormatError => "Signature error: `ScalarFormatError`".into(),
BytesLengthError { .. } => "Signature error: `BytesLengthError`".into(),
MuSigAbsent { musig_stage: Commitment } =>
"Signature error: `MuSigAbsent` at stage `Commitment`".into(),
MuSigAbsent { musig_stage: Reveal } =>
"Signature error: `MuSigAbsent` at stage `Reveal`".into(),
MuSigAbsent { musig_stage: Cosignature } =>
"Signature error: `MuSigAbsent` at stage `Commitment`".into(),
MuSigInconsistent { musig_stage: Commitment, duplicate: true } =>
"Signature error: `MuSigInconsistent` at strage `Commitment` on duplicate".into(),
MuSigInconsistent { musig_stage: Commitment, duplicate: false } =>
"Signature error: `MuSigInconsistent` at strage `Commitment` on not duplicate".into(),
MuSigInconsistent { musig_stage: Reveal, duplicate: true } =>
"Signature error: `MuSigInconsistent` at strage `Reveal` on duplicate".into(),
MuSigInconsistent { musig_stage: Reveal, duplicate: false } =>
"Signature error: `MuSigInconsistent` at strage `Reveal` on not duplicate".into(),
MuSigInconsistent { musig_stage: Cosignature, duplicate: true } =>
"Signature error: `MuSigInconsistent` at strage `Cosignature` on duplicate".into(),
MuSigInconsistent { musig_stage: Cosignature, duplicate: false } =>
"Signature error: `MuSigInconsistent` at strage `Cosignature` on not duplicate".into(),
}
}
@@ -21,7 +21,7 @@
mod digest;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use rstd::vec::Vec;
use sr_primitives::ConsensusEngineId;
use primitives::sr25519;
@@ -17,7 +17,7 @@
//! Schema for BABE epoch changes in the aux-db.
use log::info;
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use client::backend::AuxStore;
use client::error::{Result as ClientResult, Error as ClientError};
@@ -32,10 +32,12 @@ fn load_decode<B, T>(backend: &B, key: &[u8]) -> ClientResult<Option<T>>
B: AuxStore,
T: Decode,
{
let corrupt = || ClientError::Backend(format!("BABE DB is corrupted.")).into();
let corrupt = |e: codec::Error| {
ClientError::Backend(format!("BABE DB is corrupted. Decode error: {}", e.what())).into()
};
match backend.get_aux(key)? {
None => Ok(None),
Some(t) => T::decode(&mut &t[..]).ok_or_else(corrupt).map(Some)
Some(t) => T::decode(&mut &t[..]).map(Some).map_err(corrupt)
}
}
+3 -3
View File
@@ -33,7 +33,7 @@ use sr_primitives::traits::{
};
use std::{collections::HashMap, sync::Arc, u64, fmt::{Debug, Display}, pin::Pin, time::{Instant, Duration}};
use runtime_support::serde::{Serialize, Deserialize};
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use parking_lot::{Mutex, MutexGuard};
use primitives::{Blake2Hasher, H256, Pair, Public, sr25519};
use merlin::Transcript;
@@ -733,7 +733,7 @@ fn epoch<B, C>(client: &C, at: &BlockId<B>) -> Result<Epoch, ConsensusError> whe
client
.cache()
.and_then(|cache| cache.get_at(&well_known_cache_keys::EPOCH, at)
.and_then(|v| Decode::decode(&mut &v[..])))
.and_then(|v| Decode::decode(&mut &v[..]).ok()))
.or_else(|| {
if client.runtime_api().has_api::<dyn BabeApi<B>>(at).unwrap_or(false) {
let s = BabeApi::epoch(&*client.runtime_api(), at).ok()?;
@@ -856,7 +856,7 @@ fn initialize_authorities_cache<B, C>(client: &C) -> Result<(), ConsensusError>
let genesis_id = BlockId::Number(Zero::zero());
let genesis_epoch: Option<Epoch> = cache
.get_at(&well_known_cache_keys::EPOCH, &genesis_id)
.and_then(|v| Decode::decode(&mut &v[..]));
.and_then(|v| Decode::decode(&mut &v[..]).ok());
if genesis_epoch.is_some() {
return Ok(());
}
@@ -165,12 +165,6 @@ impl TestNetFactory for BabeTestNet {
}
}
#[test]
fn can_serialize_block() {
let _ = env_logger::try_init();
assert!(BabePreDigest::decode(&mut &b""[..]).is_none());
}
#[test]
#[should_panic]
fn rejects_empty_block() {
+1 -1
View File
@@ -16,7 +16,7 @@ futures-timer = "0.2.1"
rstd = { package = "sr-std", path = "../../sr-std" }
runtime_version = { package = "sr-version", path = "../../sr-version" }
sr-primitives = { path = "../../sr-primitives" }
parity-codec = { version = "4.1.1", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
parking_lot = "0.8.0"
[dev-dependencies]
@@ -6,7 +6,7 @@ description = "Common consensus primitives"
edition = "2018"
[dependencies]
parity-codec = { version = "4.1.1", default-features = false }
codec = { package = "parity-scale-codec", default-features = false, version = "1.0.3" }
client = { package = "substrate-client", path = "../../../client", default-features = false }
sr-primitives = { path = "../../../sr-primitives", default-features = false }
rstd = { package = "sr-std", path = "../../../sr-std", default-features = false }
@@ -16,6 +16,6 @@ default = ["std"]
std = [
"rstd/std",
"client/std",
"parity-codec/std",
"codec/std",
"sr-primitives/std"
]
@@ -18,7 +18,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use parity_codec::Codec;
use codec::Codec;
use client::decl_runtime_apis;
use rstd::vec::Vec;
@@ -18,7 +18,7 @@
use super::MAX_BLOCK_SIZE;
use parity_codec::Encode;
use codec::Encode;
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, One, CheckedConversion};
// This is just a best effort to encode the number. None indicated that it's too big to encode
@@ -32,8 +32,8 @@ pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, derive_more::Display)]
pub enum Error {
/// Proposal provided not a block.
#[display(fmt="Proposal provided not a block.")]
BadProposalFormat,
#[display(fmt="Proposal provided not a block: decoding error: {}", _0)]
BadProposalFormat(codec::Error),
/// Proposal had wrong parent hash.
#[display(fmt="Proposal had wrong parent hash. Expected {:?}, got {:?}", expected, got)]
WrongParentHash { expected: String, got: String },
@@ -60,7 +60,7 @@ pub fn evaluate_initial<Block: BlockT>(
let encoded = Encode::encode(proposal);
let proposal = Block::decode(&mut &encoded[..])
.ok_or_else(|| Error::BadProposalFormat)?;
.map_err(|e| Error::BadProposalFormat(e))?;
if encoded.len() > MAX_BLOCK_SIZE {
return Err(Error::ProposalTooLarge(encoded.len()))
+2 -2
View File
@@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
derive_more = "0.14.0"
futures = "0.1.17"
codec = { package = "parity-codec", version = "4.1.1", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
primitives = { package = "substrate-primitives", path = "../../primitives" }
consensus = { package = "substrate-consensus-common", path = "../common" }
client = { package = "substrate-client", path = "../../client" }
@@ -21,7 +21,7 @@ runtime_io = { package = "sr-io", path = "../../sr-io" }
tokio = "0.1.7"
parking_lot = "0.8.0"
log = "0.4"
rhododendron = { version = "0.6.0", features = ["codec"] }
rhododendron = { version = "0.7.0", features = ["codec"] }
exit-future = "0.1"
[dev-dependencies]
+1 -1
View File
@@ -40,7 +40,7 @@ use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::time::{self, Instant, Duration};
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use consensus::offline_tracker::OfflineTracker;
use consensus::error::{ErrorKind as CommonErrorKind};
use consensus::{Authorities, BlockImport, Environment, Proposer as BaseProposer};
+1 -1
View File
@@ -6,7 +6,7 @@ description = "Generic slots-based utilities for consensus"
edition = "2018"
[dependencies]
codec = { package = "parity-codec", version = "4.1.1" }
codec = { package = "parity-scale-codec", version = "1.0.0" }
client = { package = "substrate-client", path = "../../client" }
primitives = { package = "substrate-primitives", path = "../../primitives" }
sr-primitives = { path = "../../sr-primitives" }
@@ -37,8 +37,8 @@ fn load_decode<C, T>(backend: &C, key: &[u8]) -> ClientResult<Option<T>>
match backend.get_aux(key)? {
None => Ok(None),
Some(t) => T::decode(&mut &t[..])
.ok_or_else(
|| ClientError::Backend(format!("Slots DB is corrupted.")).into(),
.map_err(
|e| ClientError::Backend(format!("Slots DB is corrupted. Decode error: {}", e.what())).into(),
)
.map(Some)
}
+1 -1
View File
@@ -188,7 +188,7 @@ impl<T: Clone> SlotDuration<T> {
match client.get_aux(T::SLOT_KEY)? {
Some(v) => <T as codec::Decode>::decode(&mut &v[..])
.map(SlotDuration)
.ok_or_else(|| {
.map_err(|_| {
::client::error::Error::Backend({
error!(target: "slots", "slot duration kept in invalid format");
format!("slot duration kept in invalid format")
+1 -1
View File
@@ -6,7 +6,7 @@ edition = "2018"
[dependencies]
derive_more = "0.14.0"
parity-codec = "4.1.1"
codec = { package = "parity-scale-codec", version = "1.0.0" }
runtime_io = { package = "sr-io", path = "../sr-io" }
primitives = { package = "substrate-primitives", path = "../primitives" }
trie = { package = "substrate-trie", path = "../trie" }
+1 -1
View File
@@ -44,7 +44,7 @@ pub use native_executor::{with_native_environment, NativeExecutor, NativeExecuti
pub use wasm_runtimes_cache::RuntimesCache;
pub use state_machine::Externalities;
pub use runtime_version::{RuntimeVersion, NativeVersion};
pub use parity_codec::Codec;
pub use codec::Codec;
#[doc(hidden)]
pub use primitives::Blake2Hasher;
@@ -19,7 +19,7 @@ use crate::error::{Error, Result};
use state_machine::{CodeExecutor, Externalities};
use crate::wasm_executor::WasmExecutor;
use runtime_version::{NativeVersion, RuntimeVersion};
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use crate::RuntimeInfo;
use primitives::{Blake2Hasher, NativeOrEncoded};
use log::trace;
+3 -3
View File
@@ -20,7 +20,7 @@
use crate::error::{Result, Error};
use std::{collections::HashMap, rc::Rc};
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use primitives::sandbox as sandbox_primitives;
use wasmi::{
Externals, FuncRef, ImportResolver, MemoryInstance, MemoryRef, Module, ModuleInstance,
@@ -193,7 +193,7 @@ fn trap(msg: &'static str) -> Trap {
fn deserialize_result(serialized_result: &[u8]) -> std::result::Result<Option<RuntimeValue>, Trap> {
use self::sandbox_primitives::{HostError, ReturnValue};
let result_val = std::result::Result::<ReturnValue, HostError>::decode(&mut &serialized_result[..])
.ok_or_else(|| trap("Decoding Result<ReturnValue, HostError> failed!"))?;
.map_err(|_| trap("Decoding Result<ReturnValue, HostError> failed!"))?;
match result_val {
Ok(return_value) => Ok(match return_value {
@@ -361,7 +361,7 @@ fn decode_environment_definition(
memories: &[Option<MemoryRef>],
) -> std::result::Result<(Imports, GuestToSupervisorFunctionMapping), InstantiationError> {
let env_def = sandbox_primitives::EnvironmentDefinition::decode(&mut &raw_env_def[..])
.ok_or_else(|| InstantiationError::EnvironmentDefinitionCorrupted)?;
.map_err(|_| InstantiationError::EnvironmentDefinitionCorrupted)?;
let mut func_map = HashMap::new();
let mut memories_map = HashMap::new();
+5 -5
View File
@@ -26,7 +26,7 @@ use wasmi::{
};
use state_machine::{Externalities, ChildStorageKey};
use crate::error::{Error, Result};
use parity_codec::Encode;
use codec::Encode;
use primitives::{blake2_128, blake2_256, twox_64, twox_128, twox_256, ed25519, sr25519, Pair};
use primitives::offchain;
use primitives::hexdisplay::HexDisplay;
@@ -1081,7 +1081,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
request_id: u32,
written_out: *mut u32
) -> *mut u8 => {
use parity_codec::Encode;
use codec::Encode;
let headers = this.ext.offchain()
.map(|api| api.http_response_headers(offchain::HttpRequestId(request_id as u16)))
@@ -1172,7 +1172,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
return_val_len: usize,
state: usize
) -> u32 => {
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
trace!(target: "sr-sandbox", "invoke, instance_idx={}", instance_idx);
let export = this.memory.get(export_ptr, export_len as usize)
@@ -1186,7 +1186,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
let serialized_args = this.memory.get(args_ptr, args_len as usize)
.map_err(|_| "OOB while ext_sandbox_invoke: args")?;
let args = Vec::<sandbox_primitives::TypedValue>::decode(&mut &serialized_args[..])
.ok_or_else(|| "Can't decode serialized arguments for the invocation")?
.map_err(|_| "Can't decode serialized arguments for the invocation")?
.into_iter()
.map(Into::into)
.collect::<Vec<_>>();
@@ -1443,7 +1443,7 @@ impl WasmExecutor {
mod tests {
use super::*;
use parity_codec::Encode;
use codec::Encode;
use state_machine::TestExternalities as CoreTestExternalities;
use hex_literal::hex;
@@ -19,7 +19,7 @@
use crate::error::Error;
use crate::wasm_executor::WasmExecutor;
use log::{trace, warn};
use parity_codec::Decode;
use codec::Decode;
use parity_wasm::elements::{deserialize_buffer, DataSegment, Instruction, Module as RawModule};
use primitives::storage::well_known_keys;
use primitives::Blake2Hasher;
@@ -288,7 +288,7 @@ impl RuntimesCache {
let heap_pages = ext
.storage(well_known_keys::HEAP_PAGES)
.and_then(|pages| u64::decode(&mut &pages[..]))
.and_then(|pages| u64::decode(&mut &pages[..]).ok())
.or(default_heap_pages)
.unwrap_or(DEFAULT_HEAP_PAGES);
@@ -308,7 +308,7 @@ impl RuntimesCache {
let version = wasm_executor
.call_in_wasm_module(ext, &instance, "Core_version", &[])
.ok()
.and_then(|v| RuntimeVersion::decode(&mut v.as_slice()));
.and_then(|v| RuntimeVersion::decode(&mut v.as_slice()).ok());
Ok(Rc::new(CachedRuntime {
instance,
version,
+3 -3
View File
@@ -13,7 +13,7 @@ parking_lot = "0.8.0"
tokio-executor = "0.1.7"
tokio-timer = "0.2.11"
rand = "0.6"
parity-codec = { version = "4.1.1", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
sr-primitives = { path = "../sr-primitives" }
consensus_common = { package = "substrate-consensus-common", path = "../consensus/common" }
primitives = { package = "substrate-primitives", path = "../primitives" }
@@ -25,10 +25,10 @@ network = { package = "substrate-network", path = "../network" }
service = { package = "substrate-service", path = "../service", optional = true }
srml-finality-tracker = { path = "../../srml/finality-tracker" }
fg_primitives = { package = "substrate-finality-grandpa-primitives", path = "primitives" }
grandpa = { package = "finality-grandpa", version = "0.8.1", features = ["derive-codec"] }
grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec"] }
[dev-dependencies]
grandpa = { package = "finality-grandpa", version = "0.8.1", features = ["derive-codec", "test-helpers"] }
grandpa = { package = "finality-grandpa", version = "0.9.0", features = ["derive-codec", "test-helpers"] }
network = { package = "substrate-network", path = "../network", features = ["test-helpers"] }
keyring = { package = "substrate-keyring", path = "../keyring" }
test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client"}
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
client = { package = "substrate-client", path = "../../client", default-features = false }
primitives = { package = "substrate-primitives", path = "../../primitives", default-features = false }
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
sr-primitives = { path = "../../sr-primitives", default-features = false }
rstd = { package = "sr-std", path = "../../sr-std", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"] }
@@ -17,7 +17,7 @@ default = ["std"]
std = [
"primitives/std",
"client/std",
"parity-codec/std",
"codec/std",
"sr-primitives/std",
"rstd/std",
"serde",
@@ -23,7 +23,7 @@ extern crate alloc;
#[cfg(feature = "std")]
use serde::Serialize;
use parity_codec::{Encode, Decode, Codec};
use codec::{Encode, Decode, Codec};
use sr_primitives::{ConsensusEngineId, traits::{DigestFor, NumberFor}};
use client::decl_runtime_apis;
use rstd::vec::Vec;
@@ -19,7 +19,7 @@
use fork_tree::ForkTree;
use parking_lot::RwLock;
use grandpa::voter_set::VoterSet;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use log::{debug, info};
use substrate_telemetry::{telemetry, CONSENSUS_INFO};
use fg_primitives::AuthorityId;
@@ -403,7 +403,7 @@ pub(crate) struct PendingChange<H, N> {
}
impl<H: Decode, N: Decode> Decode for PendingChange<H, N> {
fn decode<I: parity_codec::Input>(value: &mut I) -> Option<Self> {
fn decode<I: codec::Input>(value: &mut I) -> Result<Self, codec::Error> {
let next_authorities = Decode::decode(value)?;
let delay = Decode::decode(value)?;
let canon_height = Decode::decode(value)?;
@@ -411,7 +411,7 @@ impl<H: Decode, N: Decode> Decode for PendingChange<H, N> {
let delay_kind = DelayKind::decode(value).unwrap_or(DelayKind::Finalized);
Some(PendingChange {
Ok(PendingChange {
next_authorities,
delay,
canon_height,
@@ -18,7 +18,7 @@
use std::fmt::Debug;
use std::sync::Arc;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use client::backend::AuxStore;
use client::error::{Result as ClientResult, Error as ClientError};
use fork_tree::ForkTree;
@@ -108,8 +108,8 @@ pub(crate) fn load_decode<B: AuxStore, T: Decode>(backend: &B, key: &[u8]) -> Cl
match backend.get_aux(key)? {
None => Ok(None),
Some(t) => T::decode(&mut &t[..])
.ok_or_else(
|| ClientError::Backend(format!("GRANDPA DB is corrupted.")),
.map_err(
|e| ClientError::Backend(format!("GRANDPA DB is corrupted: {}", e.what())),
)
.map(Some)
}
@@ -85,7 +85,7 @@
use sr_primitives::traits::{NumberFor, Block as BlockT, Zero};
use network::consensus_gossip::{self as network_gossip, MessageIntent, ValidatorContext};
use network::{config::Roles, PeerId};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use crate::ed25519::Public as AuthorityId;
use substrate_telemetry::{telemetry, CONSENSUS_DEBUG};
@@ -977,10 +977,10 @@ impl<Block: BlockT> GossipValidator<Block> {
let action = {
match GossipMessage::<Block>::decode(&mut data) {
Some(GossipMessage::VoteOrPrecommit(ref message))
Ok(GossipMessage::VoteOrPrecommit(ref message))
=> self.inner.write().validate_round_message(who, message),
Some(GossipMessage::Commit(ref message)) => self.inner.write().validate_commit_message(who, message),
Some(GossipMessage::Neighbor(update)) => {
Ok(GossipMessage::Commit(ref message)) => self.inner.write().validate_commit_message(who, message),
Ok(GossipMessage::Neighbor(update)) => {
let (topics, action, catch_up, report) = self.inner.write().import_neighbor_message(
who,
update.into_neighbor_packet(),
@@ -994,9 +994,9 @@ impl<Block: BlockT> GossipValidator<Block> {
peer_reply = catch_up;
action
}
Some(GossipMessage::CatchUp(ref message))
Ok(GossipMessage::CatchUp(ref message))
=> self.inner.write().validate_catch_up_message(who, message),
Some(GossipMessage::CatchUpRequest(request)) => {
Ok(GossipMessage::CatchUpRequest(request)) => {
let (reply, action) = self.inner.write().handle_catch_up_request(
who,
request,
@@ -1006,8 +1006,8 @@ impl<Block: BlockT> GossipValidator<Block> {
peer_reply = reply;
action
}
None => {
debug!(target: "afg", "Error decoding message");
Err(e) => {
debug!(target: "afg", "Error decoding message: {}", e.what());
telemetry!(CONSENSUS_DEBUG; "afg.err_decoding_msg"; "" => "");
let len = std::cmp::min(i32::max_value() as usize, data.len()) as i32;
@@ -1127,17 +1127,17 @@ impl<Block: BlockT> network_gossip::Validator<Block> for GossipValidator<Block>
let peer_best_commit = peer.view.last_commit;
match GossipMessage::<Block>::decode(&mut data) {
None => false,
Some(GossipMessage::Commit(full)) => {
Err(_) => false,
Ok(GossipMessage::Commit(full)) => {
// we only broadcast our best commit and only if it's
// better than last received by peer.
Some(full.message.target_number) == our_best_commit
&& Some(full.message.target_number) > peer_best_commit
}
Some(GossipMessage::Neighbor(_)) => false,
Some(GossipMessage::CatchUpRequest(_)) => false,
Some(GossipMessage::CatchUp(_)) => false,
Some(GossipMessage::VoteOrPrecommit(_)) => false, // should not be the case.
Ok(GossipMessage::Neighbor(_)) => false,
Ok(GossipMessage::CatchUpRequest(_)) => false,
Ok(GossipMessage::CatchUp(_)) => false,
Ok(GossipMessage::VoteOrPrecommit(_)) => false, // should not be the case.
}
})
}
@@ -1162,10 +1162,10 @@ impl<Block: BlockT> network_gossip::Validator<Block> for GossipValidator<Block>
let best_commit = local_view.last_commit;
match GossipMessage::<Block>::decode(&mut data) {
None => true,
Some(GossipMessage::Commit(full))
Err(_) => true,
Ok(GossipMessage::Commit(full))
=> Some(full.message.target_number) != best_commit,
Some(_) => true,
Ok(_) => true,
}
})
}
@@ -35,7 +35,7 @@ use futures::prelude::*;
use futures::sync::{oneshot, mpsc};
use log::{debug, trace};
use tokio_executor::Executor;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use primitives::{ed25519, Pair};
use substrate_telemetry::{telemetry, CONSENSUS_DEBUG, CONSENSUS_INFO};
use sr_primitives::traits::{Block as BlockT, Hash as HashT, Header as HeaderT};
@@ -367,10 +367,10 @@ impl<B: BlockT, N: Network<B>> NetworkBridge<B, N> {
let incoming = self.service.messages_for(topic)
.filter_map(|notification| {
let decoded = GossipMessage::<B>::decode(&mut &notification.message[..]);
if decoded.is_none() {
debug!(target: "afg", "Skipping malformed message {:?}", notification);
if let Err(ref e) = decoded {
debug!(target: "afg", "Skipping malformed message {:?}: {}", notification, e);
}
decoded
decoded.ok()
})
.and_then(move |msg| {
match msg {
@@ -583,10 +583,10 @@ fn incoming_global<B: BlockT, N: Network<B>>(
.filter_map(|notification| {
// this could be optimized by decoding piecewise.
let decoded = GossipMessage::<B>::decode(&mut &notification.message[..]);
if decoded.is_none() {
trace!(target: "afg", "Skipping malformed commit message {:?}", notification);
if let Err(ref e) = decoded {
trace!(target: "afg", "Skipping malformed commit message {:?}: {}", notification, e);
}
decoded.map(move |d| (notification, d))
decoded.map(move |d| (notification, d)).ok()
})
.filter_map(move |(notification, msg)| {
match msg {
@@ -23,7 +23,7 @@ use sr_primitives::traits::{NumberFor, Block as BlockT};
use network::PeerId;
use tokio_timer::Delay;
use log::warn;
use parity_codec::Encode;
use codec::Encode;
use std::time::{Instant, Duration};
@@ -24,7 +24,7 @@ use network_gossip::Validator;
use tokio::runtime::current_thread;
use std::sync::Arc;
use keyring::Ed25519Keyring;
use parity_codec::Encode;
use codec::Encode;
use crate::environment::SharedVoterSetState;
use super::gossip::{self, GossipValidator};
@@ -15,7 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
use std::sync::Arc;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
/// Consensus-related data changes tracker.
#[derive(Clone, Debug, Encode, Decode)]
@@ -20,7 +20,7 @@ use std::sync::Arc;
use std::time::{Duration, Instant};
use log::{debug, warn, info};
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use futures::prelude::*;
use tokio_timer::Delay;
use parking_lot::RwLock;
@@ -95,8 +95,10 @@ impl<Block: BlockT> Encode for CompletedRounds<Block> {
}
}
impl<Block: BlockT> codec::EncodeLike for CompletedRounds<Block> {}
impl<Block: BlockT> Decode for CompletedRounds<Block> {
fn decode<I: parity_codec::Input>(value: &mut I) -> Option<Self> {
fn decode<I: codec::Input>(value: &mut I) -> Result<Self, codec::Error> {
<(Vec<CompletedRound<Block>>, u64, Vec<AuthorityId>)>::decode(value)
.map(|(rounds, set_id, voters)| CompletedRounds {
rounds: rounds.into(),
@@ -43,7 +43,7 @@ use client::{
light::fetcher::{FetchChecker, RemoteCallRequest},
ExecutionStrategy, NeverOffchainExt,
};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use grandpa::BlockNumberOps;
use sr_primitives::{Justification, generic::BlockId};
use sr_primitives::traits::{
@@ -81,8 +81,8 @@ impl<B, E, Block: BlockT<Hash=H256>, RA> AuthoritySetForFinalityProver<Block> fo
ExecutionStrategy::NativeElseWasm,
NeverOffchainExt::new(),
).and_then(|call_result| Decode::decode(&mut &call_result[..])
.ok_or_else(|| ClientError::CallResultDecode(
"failed to decode GRANDPA authorities set proof".into(),
.map_err(|err| ClientError::CallResultDecode(
"failed to decode GRANDPA authorities set proof".into(), err
)))
}
@@ -121,8 +121,8 @@ impl<Block: BlockT> AuthoritySetForFinalityChecker<Block> for Arc<dyn FetchCheck
self.check_execution_proof(&request, proof)
.and_then(|authorities| {
let authorities: Vec<(AuthorityId, u64)> = Decode::decode(&mut &authorities[..])
.ok_or_else(|| ClientError::CallResultDecode(
"failed to decode GRANDPA authorities set proof".into(),
.map_err(|err| ClientError::CallResultDecode(
"failed to decode GRANDPA authorities set proof".into(), err
))?;
Ok(authorities.into_iter().collect())
})
@@ -167,8 +167,8 @@ impl<B, E, Block, RA> network::FinalityProofProvider<Block> for FinalityProofPro
request: &[u8],
) -> Result<Option<Vec<u8>>, ClientError> {
let request: FinalityProofRequest<Block::Hash> = Decode::decode(&mut &request[..])
.ok_or_else(|| {
warn!(target: "finality", "Unable to decode finality proof request.");
.map_err(|e| {
warn!(target: "finality", "Unable to decode finality proof request: {}", e.what());
ClientError::Backend(format!("Invalid finality proof request"))
})?;
match request {
@@ -445,7 +445,7 @@ fn do_check_finality_proof<Block: BlockT<Hash=H256>, B, J>(
{
// decode finality proof
let proof = FinalityProof::<Block::Header>::decode(&mut &remote_proof[..])
.ok_or_else(|| ClientError::BadJustification("failed to decode finality proof".into()))?;
.map_err(|_| ClientError::BadJustification("failed to decode finality proof".into()))?;
// empty proof can't prove anything
if proof.is_empty() {
@@ -500,7 +500,7 @@ fn check_finality_proof_fragment<Block: BlockT<Hash=H256>, B, J>(
// verify justification using previous authorities set
let (mut current_set_id, mut current_authorities) = authority_set.extract_authorities();
let justification: J = Decode::decode(&mut &proof_fragment.justification[..])
.ok_or_else(|| ClientError::JustificationDecode)?;
.map_err(|_| ClientError::JustificationDecode)?;
justification.verify(current_set_id, &current_authorities)?;
// and now verify new authorities proof (if provided)
@@ -560,7 +560,8 @@ pub(crate) trait ProvableJustification<Header: HeaderT>: Encode + Decode {
set_id: u64,
authorities: &[(AuthorityId, u64)],
) -> ClientResult<Self> {
let justification = Self::decode(&mut &**justification).ok_or(ClientError::JustificationDecode)?;
let justification = Self::decode(&mut &**justification)
.map_err(|_| ClientError::JustificationDecode)?;
justification.verify(set_id, authorities)?;
Ok(justification)
}
@@ -17,7 +17,7 @@
use std::{sync::Arc, collections::HashMap};
use log::{debug, trace, info};
use parity_codec::Encode;
use codec::Encode;
use futures::sync::mpsc;
use parking_lot::RwLockWriteGuard;
@@ -20,7 +20,7 @@ use client::{CallExecutor, Client};
use client::backend::Backend;
use client::blockchain::HeaderBackend;
use client::error::Error as ClientError;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use grandpa::voter_set::VoterSet;
use grandpa::{Error as GrandpaError};
use sr_primitives::generic::BlockId;
@@ -104,7 +104,7 @@ impl<Block: BlockT<Hash=H256>> GrandpaJustification<Block> {
{
let justification = GrandpaJustification::<Block>::decode(&mut &*encoded)
.ok_or(ClientError::JustificationDecode)?;
.map_err(|_| ClientError::JustificationDecode)?;
if (justification.commit.target_hash, justification.commit.target_number) != finalized_target {
let msg = "invalid commit target in grandpa justification".to_string();
+1 -1
View File
@@ -57,7 +57,7 @@ use log::{debug, info, warn};
use futures::sync::mpsc;
use client::{BlockchainEvents, CallExecutor, Client, backend::Backend, error::Error as ClientError};
use client::blockchain::HeaderBackend;
use parity_codec::Encode;
use codec::Encode;
use sr_primitives::traits::{
NumberFor, Block as BlockT, DigestFor, ProvideRuntimeApi,
};
@@ -25,7 +25,7 @@ use client::{
blockchain::HeaderBackend,
error::Error as ClientError,
};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use consensus_common::{
import_queue::Verifier, well_known_cache_keys,
BlockOrigin, BlockImport, FinalityProofImport, BlockImportParams, ImportResult, ImportedAux,
+2 -2
View File
@@ -34,7 +34,7 @@ use consensus_common::{BlockOrigin, ForkChoiceStrategy, ImportedAux, BlockImport
use consensus_common::import_queue::{BoxBlockImport, BoxJustificationImport, BoxFinalityProofImport};
use std::collections::{HashMap, HashSet};
use std::result;
use parity_codec::Decode;
use codec::Decode;
use sr_primitives::traits::{ApiRef, ProvideRuntimeApi, Header as HeaderT};
use sr_primitives::generic::BlockId;
use primitives::{NativeOrEncoded, ExecutionContext};
@@ -336,7 +336,7 @@ impl AuthoritySetForFinalityChecker<Block> for TestApi {
proof: Vec<Vec<u8>>,
) -> Result<Vec<(AuthorityId, u64)>> {
Decode::decode(&mut &proof[0][..])
.ok_or_else(|| unreachable!("incorrect value is passed as GRANDPA authorities proof"))
.map_err(|_| unreachable!("incorrect value is passed as GRANDPA authorities proof"))
}
}
+2 -2
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
parking_lot = { version = "0.8.0", optional = true }
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
sr-primitives = { path = "../sr-primitives", default-features = false }
[features]
@@ -15,6 +15,6 @@ default = [ "std" ]
std = [
"parking_lot",
"rstd/std",
"parity-codec/std",
"codec/std",
"sr-primitives/std",
]
+2 -3
View File
@@ -33,7 +33,6 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![warn(missing_docs)]
use parity_codec as codec;
use codec::{Encode, Decode};
use rstd::{collections::btree_map::{BTreeMap, IntoIter, Entry}, vec::Vec};
@@ -52,7 +51,7 @@ pub type InherentIdentifier = [u8; 8];
/// Inherent data to include in a block.
#[derive(Clone, Default, Encode, Decode)]
pub struct InherentData {
/// All inherent data encoded with parity-codec and an identifier.
/// All inherent data encoded with parity-scale-codec and an identifier.
data: BTreeMap<InherentIdentifier, Vec<u8>>
}
@@ -111,7 +110,7 @@ impl InherentData {
match self.data.get(identifier) {
Some(inherent) =>
I::decode(&mut &inherent[..])
.ok_or_else(|| {
.map_err(|_| {
"Could not decode requested inherent type!".into()
})
.map(Some),
+1 -1
View File
@@ -28,7 +28,7 @@ consensus = { package = "substrate-consensus-common", path = "../../core/consens
client = { package = "substrate-client", path = "../../core/client" }
sr-primitives = { path = "../../core/sr-primitives" }
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
parity-codec = { version = "4.1.1", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
peerset = { package = "substrate-peerset", path = "../../core/peerset" }
serde = { version = "1.0.70", features = ["derive"] }
serde_json = "1.0.24"
+7 -6
View File
@@ -27,7 +27,6 @@ use crate::on_demand_layer::OnDemand;
use crate::service::{ExHashT, TransactionPool};
use bitflags::bitflags;
use consensus::import_queue::ImportQueue;
use parity_codec;
use sr_primitives::traits::{Block as BlockT};
use std::sync::Arc;
use libp2p::identity::{Keypair, secp256k1, ed25519};
@@ -109,15 +108,17 @@ impl Roles {
}
}
impl parity_codec::Encode for Roles {
fn encode_to<T: parity_codec::Output>(&self, dest: &mut T) {
impl codec::Encode for Roles {
fn encode_to<T: codec::Output>(&self, dest: &mut T) {
dest.push_byte(self.bits())
}
}
impl parity_codec::Decode for Roles {
fn decode<I: parity_codec::Input>(input: &mut I) -> Option<Self> {
Self::from_bits(input.read_byte()?)
impl codec::EncodeLike for Roles {}
impl codec::Decode for Roles {
fn decode<I: codec::Input>(input: &mut I) -> Result<Self, codec::Error> {
Self::from_bits(input.read_byte()?).ok_or_else(|| codec::Error::from("Invalid bytes"))
}
}
@@ -22,7 +22,7 @@ use libp2p::tokio_codec::Framed;
use log::warn;
use std::{collections::VecDeque, io, marker::PhantomData, vec::IntoIter as VecIntoIter};
use futures::{prelude::*, future, stream};
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode};
use sr_primitives::traits::Block as BlockT;
use tokio_io::{AsyncRead, AsyncWrite};
use unsigned_varint::codec::UviBytes;
@@ -179,7 +179,7 @@ where TSubstream: AsyncRead + AsyncWrite, B: BlockT {
self.clogged_fuse = true;
return Ok(Async::Ready(Some(RegisteredProtocolEvent::Clogged {
messages: self.send_queue.iter()
.map(|m| Decode::decode(&mut &m[..]).ok_or(()))
.map(|m| Decode::decode(&mut &m[..]))
.filter_map(Result::ok)
.collect(),
})))
@@ -199,9 +199,12 @@ where TSubstream: AsyncRead + AsyncWrite, B: BlockT {
// Note that `inner` is wrapped in a `Fuse`, therefore we can poll it forever.
match self.inner.poll()? {
Async::Ready(Some(data)) => {
let message = <Message<B> as Decode>::decode(&mut &data[..]).ok_or(())
.map_err(|()| {
warn!(target: "sub-libp2p", "Couldn't decode packet sent by the remote: {:?}", data);
let message = <Message<B> as Decode>::decode(&mut &data[..])
.map_err(|err| {
warn!(
target: "sub-libp2p",
"Couldn't decode packet sent by the remote: {:?}: {}", data, err.what(),
);
io::ErrorKind::InvalidData
})?;
Ok(Async::Ready(Some(RegisteredProtocolEvent::Message(message))))
@@ -18,7 +18,7 @@
use bitflags::bitflags;
use sr_primitives::{ConsensusEngineId, traits::{Block as BlockT, Header as HeaderT}};
use parity_codec::{Encode, Decode, Input, Output};
use codec::{Encode, Decode, Input, Output, Error};
pub use self::generic::{
BlockAnnounce, RemoteCallRequest, RemoteReadRequest,
RemoteHeaderRequest, RemoteHeaderResponse,
@@ -90,9 +90,11 @@ impl Encode for BlockAttributes {
}
}
impl codec::EncodeLike for BlockAttributes {}
impl Decode for BlockAttributes {
fn decode<I: Input>(input: &mut I) -> Option<Self> {
Self::from_bits(input.read_byte()?)
fn decode<I: Input>(input: &mut I) -> Result<Self, Error> {
Self::from_bits(input.read_byte()?).ok_or_else(|| Error::from("Invalid bytes"))
}
}
@@ -125,7 +127,7 @@ pub struct RemoteReadResponse {
/// Generic types.
pub mod generic {
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use sr_primitives::Justification;
use crate::config::Roles;
use super::{
+1 -1
View File
@@ -11,7 +11,7 @@ client = { package = "substrate-client", path = "../../core/client" }
futures = "0.1.25"
log = "0.4"
offchain-primitives = { package = "substrate-offchain-primitives", path = "./primitives" }
parity-codec = { version = "4.1.1", features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
parking_lot = "0.8.0"
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
sr-primitives = { path = "../../core/sr-primitives" }
+8 -8
View File
@@ -25,7 +25,7 @@ use client::backend::OffchainStorage;
use crate::AuthorityKeyProvider;
use futures::{Stream, Future, sync::mpsc};
use log::{info, debug, warn, error};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use primitives::offchain::{
Timestamp,
HttpRequestId, HttpRequestStatus, HttpError,
@@ -219,7 +219,7 @@ impl<Storage, KeyProvider, Block> Api<Storage, KeyProvider, Block> where
match key {
CryptoKey::LocalKey { id, kind } => {
let key = self.db.get(KEYS_PREFIX, &id.encode())
.and_then(|key| StoredKey::decode(&mut &*key))
.and_then(|key| StoredKey::decode(&mut &*key).ok())
.ok_or(())?;
if key.kind != kind {
warn!(
@@ -266,7 +266,7 @@ where
let (id, id_encoded) = loop {
let encoded = self.db.get(KEYS_PREFIX, NEXT_ID);
let encoded_slice = encoded.as_ref().map(|x| x.as_slice());
let new_id = encoded_slice.and_then(|mut x| u16::decode(&mut x)).unwrap_or_default()
let new_id = encoded_slice.and_then(|mut x| u16::decode(&mut x).ok()).unwrap_or_default()
.checked_add(1)
.ok_or(())?;
let new_id_encoded = new_id.encode();
@@ -473,14 +473,14 @@ impl TryFrom<OpaqueNetworkState> for NetworkState {
fn try_from(state: OpaqueNetworkState) -> Result<Self, Self::Error> {
let inner_vec = state.peer_id.0;
let bytes: Vec<u8> = Decode::decode(&mut &inner_vec[..]).ok_or(())?;
let bytes: Vec<u8> = Decode::decode(&mut &inner_vec[..]).map_err(|_| ())?;
let peer_id = PeerId::from_bytes(bytes).map_err(|_| ())?;
let external_addresses: Result<Vec<Multiaddr>, Self::Error> = state.external_addresses
.iter()
.map(|enc_multiaddr| -> Result<Multiaddr, Self::Error> {
let inner_vec = &enc_multiaddr.0;
let bytes = <Vec<u8>>::decode(&mut &inner_vec[..]).ok_or(())?;
let bytes = <Vec<u8>>::decode(&mut &inner_vec[..]).map_err(|_| ())?;
let multiaddr_str = String::from_utf8(bytes).map_err(|_| ())?;
let multiaddr = Multiaddr::from_str(&multiaddr_str).map_err(|_| ())?;
Ok(multiaddr)
@@ -548,9 +548,9 @@ impl<A: ChainApi> AsyncApi<A> {
fn submit_extrinsic(&mut self, ext: Vec<u8>) {
let xt = match <A::Block as traits::Block>::Extrinsic::decode(&mut &*ext) {
Some(xt) => xt,
None => {
warn!("Unable to decode extrinsic: {:?}", ext);
Ok(xt) => xt,
Err(e) => {
warn!("Unable to decode extrinsic: {:?}: {}", ext, e.what());
return
},
};
+3 -3
View File
@@ -6,12 +6,12 @@ edition = "2018"
[dependencies]
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
parity-codec = { version = "4.1.1", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
rustc-hex = { version = "2.0", default-features = false }
serde = { version = "1.0", optional = true, features = ["derive"] }
twox-hash = { version = "1.2.0", optional = true }
byteorder = { version = "1.3.1", default-features = false }
primitive-types = { version = "0.4.0", default-features = false, features = ["codec"] }
primitive-types = { version = "0.5.0", default-features = false, features = ["codec"] }
impl-serde = { version = "0.1", optional = true }
wasmi = { version = "0.5.0", optional = true }
hash-db = { version = "0.15.0", default-features = false }
@@ -57,7 +57,7 @@ std = [
"primitive-types/rustc-hex",
"primitive-types/libc",
"impl-serde",
"parity-codec/std",
"codec/std",
"hash256-std-hasher/std",
"hash-db/std",
"rstd/std",
@@ -18,7 +18,7 @@
#[cfg(any(feature = "std", test))]
use serde::{Serialize, Deserialize};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use num_traits::Zero;
/// Substrate changes trie configuration.
+1 -1
View File
@@ -25,7 +25,7 @@ use parking_lot::Mutex;
#[cfg(feature = "std")]
use rand::{RngCore, rngs::OsRng};
#[cfg(feature = "std")]
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
#[cfg(feature = "std")]
use regex::Regex;
#[cfg(feature = "std")]
+1 -1
View File
@@ -20,7 +20,7 @@
use crate::{hash::H256, hash::H512};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
#[cfg(feature = "std")]
use blake2_rfc;
+12 -9
View File
@@ -33,7 +33,7 @@ macro_rules! map {
use rstd::prelude::*;
use rstd::ops::Deref;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
#[cfg(feature = "std")]
use std::borrow::Cow;
#[cfg(feature = "std")]
@@ -138,14 +138,14 @@ pub enum NativeOrEncoded<R> {
}
#[cfg(feature = "std")]
impl<R: parity_codec::Encode> ::std::fmt::Debug for NativeOrEncoded<R> {
impl<R: codec::Encode> ::std::fmt::Debug for NativeOrEncoded<R> {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
self.as_encoded().as_ref().fmt(f)
}
}
#[cfg(feature = "std")]
impl<R: parity_codec::Encode> NativeOrEncoded<R> {
impl<R: codec::Encode> NativeOrEncoded<R> {
/// Return the value as the encoded format.
pub fn as_encoded<'a>(&'a self) -> Cow<'a, [u8]> {
match self {
@@ -164,13 +164,13 @@ impl<R: parity_codec::Encode> NativeOrEncoded<R> {
}
#[cfg(feature = "std")]
impl<R: PartialEq + parity_codec::Decode> PartialEq for NativeOrEncoded<R> {
impl<R: PartialEq + codec::Decode> PartialEq for NativeOrEncoded<R> {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(NativeOrEncoded::Native(l), NativeOrEncoded::Native(r)) => l == r,
(NativeOrEncoded::Native(n), NativeOrEncoded::Encoded(e)) |
(NativeOrEncoded::Encoded(e), NativeOrEncoded::Native(n)) =>
Some(n) == parity_codec::Decode::decode(&mut &e[..]).as_ref(),
Some(n) == codec::Decode::decode(&mut &e[..]).ok().as_ref(),
(NativeOrEncoded::Encoded(l), NativeOrEncoded::Encoded(r)) => l == r,
}
}
@@ -183,7 +183,7 @@ impl<R: PartialEq + parity_codec::Decode> PartialEq for NativeOrEncoded<R> {
pub enum NeverNativeValue {}
#[cfg(feature = "std")]
impl parity_codec::Encode for NeverNativeValue {
impl codec::Encode for NeverNativeValue {
fn encode(&self) -> Vec<u8> {
// The enum is not constructable, so this function should never be callable!
unreachable!()
@@ -191,8 +191,11 @@ impl parity_codec::Encode for NeverNativeValue {
}
#[cfg(feature = "std")]
impl parity_codec::Decode for NeverNativeValue {
fn decode<I: parity_codec::Input>(_: &mut I) -> Option<Self> {
None
impl codec::EncodeLike for NeverNativeValue {}
#[cfg(feature = "std")]
impl codec::Decode for NeverNativeValue {
fn decode<I: codec::Input>(_: &mut I) -> Result<Self, codec::Error> {
Err("`NeverNativeValue` should never be decoded".into())
}
}
+2 -2
View File
@@ -17,7 +17,7 @@
//! Offchain workers types
use crate::crypto;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use rstd::prelude::{Vec, Box};
use rstd::convert::TryFrom;
@@ -397,7 +397,7 @@ pub trait Externalities {
/// Initiates a http request given HTTP verb and the URL.
///
/// Meta is a future-reserved field containing additional, parity-codec encoded parameters.
/// Meta is a future-reserved field containing additional, parity-scale-codec encoded parameters.
/// Returns the id of newly started request.
fn http_request_start(
&mut self,
+2 -2
View File
@@ -16,7 +16,7 @@
//! Definition of a sandbox environment.
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use rstd::vec::Vec;
/// Error error that can be returned from host function.
@@ -184,7 +184,7 @@ pub const ERR_EXECUTION: u32 = -3i32 as u32;
mod tests {
use super::*;
use std::fmt;
use parity_codec::Codec;
use codec::Codec;
fn roundtrip<S: Codec + PartialEq + fmt::Debug>(s: S) {
let encoded = s.encode();
+1 -1
View File
@@ -33,7 +33,7 @@ use bip39::{Mnemonic, Language, MnemonicType};
use crate::crypto::{Pair as TraitPair, DeriveJunction, Infallible, SecretStringError, Derive, Ss58Codec};
use crate::crypto::{key_types, KeyTypeId, Public as TraitPublic, TypedKey, UncheckedFrom};
use crate::hash::{H256, H512};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
#[cfg(feature = "std")]
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
+3 -3
View File
@@ -21,7 +21,7 @@ pub use primitive_types::U256;
#[cfg(test)]
mod tests {
use super::*;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use substrate_serializer as ser;
macro_rules! test {
@@ -78,10 +78,10 @@ mod tests {
res2);
assert_eq!(
U256::decode(&mut &res1[..]),
Some(U256::from(120)));
Ok(U256::from(120)));
assert_eq!(
U256::decode(&mut &res2[..]),
Some(U256::max_value()));
Ok(U256::max_value()));
}
#[test]
+1 -1
View File
@@ -14,7 +14,7 @@ jsonrpc-pubsub = "12.0.0"
jsonrpc-derive = "12.0.0"
log = "0.4"
parking_lot = "0.8.0"
parity-codec = "4.1.1"
codec = { package = "parity-scale-codec", version = "1.0.0" }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
client = { package = "substrate-client", path = "../client" }
+4 -5
View File
@@ -19,7 +19,6 @@
use client;
use transaction_pool::txpool;
use crate::rpc;
use crate::errors;
/// Author RPC Result type.
@@ -36,8 +35,8 @@ pub enum Error {
#[display(fmt="Extrinsic verification error: {}", _0)]
Verification(Box<dyn std::error::Error + Send>),
/// Incorrect extrinsic format.
#[display(fmt="Invalid extrinsic format")]
BadFormat,
#[display(fmt="Invalid extrinsic format: {}", _0)]
BadFormat(codec::Error),
}
impl std::error::Error for Error {
@@ -78,9 +77,9 @@ impl From<Error> for rpc::Error {
use txpool::error::{Error as PoolError};
match e {
Error::BadFormat => rpc::Error {
Error::BadFormat(e) => rpc::Error {
code: rpc::ErrorCode::ServerError(BAD_FORMAT),
message: "Extrinsic has invalid format.".into(),
message: format!("Extrinsic has invalid format: {}", e).into(),
data: None,
},
Error::Verification(e) => rpc::Error {
+4 -5
View File
@@ -30,7 +30,7 @@ use crate::subscriptions::Subscriptions;
use jsonrpc_derive::rpc;
use jsonrpc_pubsub::{typed::Subscriber, SubscriptionId};
use log::warn;
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use primitives::{Bytes, Blake2Hasher, H256};
use sr_primitives::{generic, traits};
use self::error::Result;
@@ -110,7 +110,7 @@ impl<B, E, P, RA> AuthorApi<ExHash<P>, BlockHash<P>> for Author<B, E, P, RA> whe
type Metadata = crate::metadata::Metadata;
fn submit_extrinsic(&self, ext: Bytes) -> Result<ExHash<P>> {
let xt = Decode::decode(&mut &ext[..]).ok_or(error::Error::BadFormat)?;
let xt = Decode::decode(&mut &ext[..])?;
let best_block_hash = self.client.info().chain.best_hash;
self.pool
.submit_one(&generic::BlockId::hash(best_block_hash), xt)
@@ -129,7 +129,7 @@ impl<B, E, P, RA> AuthorApi<ExHash<P>, BlockHash<P>> for Author<B, E, P, RA> whe
.map(|x| match x {
hash::ExtrinsicOrHash::Hash(h) => Ok(h),
hash::ExtrinsicOrHash::Extrinsic(bytes) => {
let xt = Decode::decode(&mut &bytes[..]).ok_or(error::Error::BadFormat)?;
let xt = Decode::decode(&mut &bytes[..])?;
Ok(self.pool.hash_of(&xt))
},
})
@@ -146,8 +146,7 @@ impl<B, E, P, RA> AuthorApi<ExHash<P>, BlockHash<P>> for Author<B, E, P, RA> whe
fn watch_extrinsic(&self, _metadata: Self::Metadata, subscriber: Subscriber<Status<ExHash<P>, BlockHash<P>>>, xt: Bytes) {
let submit = || -> Result<_> {
let best_block_hash = self.client.info().chain.best_hash;
let dxt = <<P as PoolChainApi>::Block as traits::Block>::Extrinsic::decode(&mut &xt[..])
.ok_or(error::Error::BadFormat)?;
let dxt = <<P as PoolChainApi>::Block as traits::Block>::Extrinsic::decode(&mut &xt[..])?;
self.pool
.submit_and_watch(&generic::BlockId::hash(best_block_hash), dxt)
.map_err(|e| e.into_pool_error()
+1 -1
View File
@@ -18,7 +18,7 @@ use super::*;
use std::sync::Arc;
use assert_matches::assert_matches;
use parity_codec::Encode;
use codec::Encode;
use transaction_pool::{
txpool::Pool,
ChainApi,
+1 -1
View File
@@ -27,7 +27,7 @@ consensus_common = { package = "substrate-consensus-common", path = "../../core/
network = { package = "substrate-network", path = "../../core/network" }
client = { package = "substrate-client", path = "../../core/client" }
client_db = { package = "substrate-client-db", path = "../../core/client/db", features = ["kvdb-rocksdb"] }
parity-codec = "4.1.1"
codec = { package = "parity-scale-codec", version = "1.0.0" }
substrate-executor = { path = "../../core/executor" }
transaction_pool = { package = "substrate-transaction-pool", path = "../../core/transaction-pool" }
rpc = { package = "substrate-rpc-servers", path = "../../core/rpc-servers" }
+34 -29
View File
@@ -16,7 +16,7 @@
//! Chain utilities.
use std::{self, io::{Read, Write}};
use std::{self, io::{Read, Write, Seek}};
use futures::prelude::*;
use futures03::TryFutureExt as _;
use log::{info, warn};
@@ -29,7 +29,7 @@ use network::message;
use consensus_common::BlockOrigin;
use crate::components::{self, Components, ServiceFactory, FactoryFullConfiguration, FactoryBlockNumber, RuntimeGenesis};
use crate::new_client;
use parity_codec::{Decode, Encode};
use codec::{Decode, Encode, IoReader};
use crate::error;
use crate::chain_spec::ChainSpec;
@@ -136,9 +136,9 @@ impl<B: Block> Link<B> for WaitLink {
pub fn import_blocks<F, E, R>(
mut config: FactoryFullConfiguration<F>,
exit: E,
mut input: R
input: R
) -> error::Result<impl Future<Item = (), Error = ()>>
where F: ServiceFactory, E: Future<Item=(),Error=()> + Send + 'static, R: Read,
where F: ServiceFactory, E: Future<Item=(),Error=()> + Send + 'static, R: Read + Seek,
{
let client = new_client::<F>(&config)?;
// FIXME #1134 this shouldn't need a mutable config.
@@ -155,37 +155,42 @@ pub fn import_blocks<F, E, R>(
let _ = exit_send.send(());
});
let count: u64 = Decode::decode(&mut input).ok_or("Error reading file")?;
let mut io_reader_input = IoReader(input);
let count: u64 = Decode::decode(&mut io_reader_input)
.map_err(|e| format!("Error reading file: {}", e))?;
info!("Importing {} blocks", count);
let mut block_count = 0;
for b in 0 .. count {
if exit_recv.try_recv().is_ok() {
break;
}
if let Some(signed) = SignedBlock::<F::Block>::decode(&mut input) {
let (header, extrinsics) = signed.block.deconstruct();
let hash = header.hash();
let block = message::BlockData::<F::Block> {
hash,
justification: signed.justification,
header: Some(header),
body: Some(extrinsics),
receipt: None,
message_queue: None
};
// import queue handles verification and importing it into the client
queue.import_blocks(BlockOrigin::File, vec![
IncomingBlock::<F::Block>{
hash: block.hash,
header: block.header,
body: block.body,
justification: block.justification,
origin: None,
}
]);
} else {
warn!("Error reading block data at {}.", b);
break;
match SignedBlock::<F::Block>::decode(&mut io_reader_input) {
Ok(signed) => {
let (header, extrinsics) = signed.block.deconstruct();
let hash = header.hash();
let block = message::BlockData::<F::Block> {
hash,
justification: signed.justification,
header: Some(header),
body: Some(extrinsics),
receipt: None,
message_queue: None
};
// import queue handles verification and importing it into the client
queue.import_blocks(BlockOrigin::File, vec![
IncomingBlock::<F::Block> {
hash: block.hash,
header: block.header,
body: block.body,
justification: block.justification,
origin: None,
}
]);
}
Err(e) => {
warn!("Error reading block data at {}: {}", b, e);
break;
}
}
block_count = b;
+24 -21
View File
@@ -40,7 +40,7 @@ use futures03::stream::{StreamExt as _, TryStreamExt as _};
use keystore::Store as Keystore;
use network::{NetworkState, NetworkStateInfo};
use log::{log, info, warn, debug, error, Level};
use parity_codec::{Encode, Decode};
use codec::{Encode, Decode};
use primitives::{Pair, ed25519, sr25519, crypto};
use sr_primitives::generic::BlockId;
use sr_primitives::traits::{Header, NumberFor, SaturatedConversion, Zero};
@@ -877,28 +877,31 @@ impl<C: Components> network::TransactionPool<ComponentExHash<C>, ComponentBlock<
}
let encoded = transaction.encode();
if let Some(uxt) = Decode::decode(&mut &encoded[..]) {
let best_block_id = self.best_block_id()?;
match self.pool.submit_one(&best_block_id, uxt) {
Ok(hash) => Some(hash),
Err(e) => match e.into_pool_error() {
Ok(txpool::error::Error::AlreadyImported(hash)) => {
hash.downcast::<ComponentExHash<C>>().ok()
.map(|x| x.as_ref().clone())
},
Ok(e) => {
debug!("Error adding transaction to the pool: {:?}", e);
None
},
Err(e) => {
debug!("Error converting pool error: {:?}", e);
None
},
match Decode::decode(&mut &encoded[..]) {
Ok(uxt) => {
let best_block_id = self.best_block_id()?;
match self.pool.submit_one(&best_block_id, uxt) {
Ok(hash) => Some(hash),
Err(e) => match e.into_pool_error() {
Ok(txpool::error::Error::AlreadyImported(hash)) => {
hash.downcast::<ComponentExHash<C>>().ok()
.map(|x| x.as_ref().clone())
},
Ok(e) => {
debug!("Error adding transaction to the pool: {:?}", e);
None
},
Err(e) => {
debug!("Error converting pool error: {:?}", e);
None
},
}
}
}
} else {
debug!("Error decoding transaction");
None
Err(e) => {
debug!("Error decoding transaction {}", e);
None
}
}
}
+1 -1
View File
@@ -23,7 +23,7 @@ sr-version = { path = "../sr-version" }
primitives = { package = "substrate-primitives", path = "../primitives" }
criterion = "0.2"
consensus_common = { package = "substrate-consensus-common", path = "../consensus/common" }
codec = { package = "parity-codec", version = "4.1.1" }
codec = { package = "parity-scale-codec", version = "1.0.0" }
trybuild = "1.0"
[[bench]]
@@ -192,7 +192,7 @@ fn generate_native_call_generators(decl: &ItemTrait) -> Result<TokenStream> {
{
<R as #crate_::runtime_api::Decode>::decode(
&mut &#crate_::runtime_api::Encode::encode(input)[..]
).ok_or_else(|| error_desc)
).map_err(|_| error_desc)
}
));
@@ -682,9 +682,9 @@ impl<'a> ToClientSideDecl<'a> {
},
#crate_::runtime_api::NativeOrEncoded::Encoded(r) => {
<#ret_type as #crate_::runtime_api::Decode>::decode(&mut &r[..])
.ok_or_else(||
.map_err(|err|
#crate_::error::Error::CallResultDecode(
#function_name
#function_name, err
).into()
)
}
@@ -77,8 +77,8 @@ fn generate_impl_call(
quote!(
#(
let #pnames : #ptypes = match #c_iter::runtime_api::Decode::decode(&mut #input) {
Some(input) => input,
None => panic!("Bad input data provided to {}", #fn_name_str),
Ok(input) => input,
Err(e) => panic!("Bad input data provided to {}: {}", #fn_name_str, e.what()),
};
)*
+1 -1
View File
@@ -11,7 +11,7 @@ rustc_version = "0.2"
[dependencies]
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
codec = { package = "parity-codec", version = "4.1.1", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false }
hash-db = { version = "0.15.0", default-features = false }
libsecp256k1 = { version = "0.2.1", optional = true }
tiny-keccak = { version = "1.4.2", optional = true }
+1 -1
View File
@@ -324,7 +324,7 @@ export_api! {
/// Initiates a http request given HTTP verb and the URL.
///
/// Meta is a future-reserved field containing additional, parity-codec encoded parameters.
/// Meta is a future-reserved field containing additional, parity-scale-codec encoded parameters.
/// Returns the id of newly started request.
fn http_request_start(
method: &str,
+2 -2
View File
@@ -529,7 +529,7 @@ pub mod ext {
/// Initiates a http request.
///
/// `meta` is parity-codec encoded additional parameters to the request (like redirection policy,
/// `meta` is parity-scale-codec encoded additional parameters to the request (like redirection policy,
/// timeouts, certificates policy, etc). The format is not yet specified and the field is currently
/// only reserved for future use.
///
@@ -596,7 +596,7 @@ pub mod ext {
///
/// # Returns
///
/// - A pointer to parity-codec encoded vector of pairs `(HeaderKey, HeaderValue)`.
/// - A pointer to parity-scale-codec encoded vector of pairs `(HeaderKey, HeaderValue)`.
/// - In case invalid `id` is passed it returns a pointer to parity-encoded empty vector.
fn ext_http_response_headers(
id: u32,
+2 -2
View File
@@ -8,7 +8,7 @@ edition = "2018"
num-traits = { version = "0.2", default-features = false }
integer-sqrt = { version = "0.1.2" }
serde = { version = "1.0", optional = true, features = ["derive"] }
codec = { package = "parity-codec", version = "4.1.1", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
primitives = { package = "substrate-primitives", path = "../primitives", default-features = false }
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
runtime_io = { package = "sr-io", path = "../sr-io", default-features = false }
@@ -17,7 +17,7 @@ paste = { version = "0.1"}
[dev-dependencies]
serde_json = "1.0"
primitive-types = "0.4"
primitive-types = "0.5.0"
[features]
default = ["std"]
@@ -22,7 +22,7 @@ use serde::Serialize;
use rstd::prelude::*;
use crate::ConsensusEngineId;
use crate::codec::{Decode, Encode, Input};
use crate::codec::{Decode, Encode, Input, Error};
/// Generic header digest.
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
@@ -221,27 +221,29 @@ impl<Hash: Encode> Encode for DigestItem<Hash> {
}
}
impl<Hash: Encode> codec::EncodeLike for DigestItem<Hash> {}
impl<Hash: Decode> Decode for DigestItem<Hash> {
#[allow(deprecated)]
fn decode<I: Input>(input: &mut I) -> Option<Self> {
fn decode<I: Input>(input: &mut I) -> Result<Self, Error> {
let item_type: DigestItemType = Decode::decode(input)?;
match item_type {
DigestItemType::ChangesTrieRoot => Some(DigestItem::ChangesTrieRoot(
DigestItemType::ChangesTrieRoot => Ok(DigestItem::ChangesTrieRoot(
Decode::decode(input)?,
)),
DigestItemType::PreRuntime => {
let vals: (ConsensusEngineId, Vec<u8>) = Decode::decode(input)?;
Some(DigestItem::PreRuntime(vals.0, vals.1))
Ok(DigestItem::PreRuntime(vals.0, vals.1))
},
DigestItemType::Consensus => {
let vals: (ConsensusEngineId, Vec<u8>) = Decode::decode(input)?;
Some(DigestItem::Consensus(vals.0, vals.1))
Ok(DigestItem::Consensus(vals.0, vals.1))
}
DigestItemType::Seal => {
let vals: (ConsensusEngineId, Vec<u8>) = Decode::decode(input)?;
Some(DigestItem::Seal(vals.0, vals.1))
Ok(DigestItem::Seal(vals.0, vals.1))
},
DigestItemType::Other => Some(DigestItem::Other(
DigestItemType::Other => Ok(DigestItem::Other(
Decode::decode(input)?,
)),
}
@@ -305,7 +307,7 @@ impl<'a, Hash> DigestItemRef<'a, Hash> {
/// Try to match this digest item to the given opaque item identifier; if it matches, then
/// try to cast to the given datatype; if that works, return it.
pub fn try_to<T: Decode>(&self, id: OpaqueDigestItemId) -> Option<T> {
self.try_as_raw(id).and_then(|mut x| Decode::decode(&mut x))
self.try_as_raw(id).and_then(|mut x| Decode::decode(&mut x).ok())
}
}
@@ -340,6 +342,8 @@ impl<'a, Hash: Encode> Encode for DigestItemRef<'a, Hash> {
}
}
impl<'a, Hash: Encode> codec::EncodeLike for DigestItemRef<'a, Hash> {}
#[cfg(test)]
mod tests {
use super::*;
@@ -19,7 +19,7 @@
#[cfg(feature = "std")]
use serde::{Serialize, Deserialize};
use crate::codec::{Decode, Encode, Input, Output};
use crate::codec::{Decode, Encode, Input, Output, Error};
/// Era period
pub type Period = u64;
@@ -111,20 +111,22 @@ impl Encode for Era {
}
}
impl codec::EncodeLike for Era {}
impl Decode for Era {
fn decode<I: Input>(input: &mut I) -> Option<Self> {
fn decode<I: Input>(input: &mut I) -> Result<Self, Error> {
let first = input.read_byte()?;
if first == 0 {
Some(Era::Immortal)
Ok(Era::Immortal)
} else {
let encoded = first as u64 + ((input.read_byte()? as u64) << 8);
let period = 2 << (encoded % (1 << 4));
let quantize_factor = (period >> 12).max(1);
let phase = (encoded >> 4) * quantize_factor;
if period >= 4 && phase < period {
Some(Era::Mortal(period, phase))
Ok(Era::Mortal(period, phase))
} else {
None
Err("Invalid period and phase".into())
}
}
}

Some files were not shown because too many files have changed in this diff Show More