Relax types on DigestItemRef, such that byte slices can be used in addition to vector references (#10536)

* Relax types on `DigestItemRef`, such that byte slices can be used in addition to vector references

* Apply clippy suggestions
This commit is contained in:
Nazar Mokrynskyi
2022-01-20 12:02:22 +02:00
committed by GitHub
parent 1344e43d2d
commit 6b60c3dbff
159 changed files with 164 additions and 164 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0", default-features =
sp-api-proc-macro = { version = "4.0.0-dev", path = "proc-macro" }
sp-core = { version = "4.1.0-dev", default-features = false, path = "../core" }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
sp-version = { version = "4.0.0-dev", default-features = false, path = "../version" }
sp-state-machine = { version = "0.10.0", optional = true, path = "../state-machine" }
hash-db = { version = "0.15.2", optional = true }
+1 -1
View File
@@ -16,7 +16,7 @@ sp-api = { version = "4.0.0-dev", path = "../" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
sp-version = { version = "4.0.0-dev", path = "../../version" }
sp-tracing = { version = "4.0.0", path = "../../tracing" }
sp-runtime = { version = "4.0.0", path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../../runtime" }
sp-consensus = { version = "0.10.0-dev", path = "../../consensus/common" }
sc-block-builder = { version = "0.10.0-dev", path = "../../../client/block-builder" }
codec = { package = "parity-scale-codec", version = "2.0.0" }
@@ -16,6 +16,6 @@ targets = ["x86_64-unknown-linux-gnu"]
sp-core = { version = "4.1.0-dev", default-features = false, path = "../../core" }
sp-keystore = { version = "0.10.0", path = "../../keystore", default-features = false }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
sp-runtime = { version = "4.0.0", path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../../runtime" }
sp-api = { version = "4.0.0-dev", path = "../../api" }
sp-application-crypto = { version = "4.0.0", path = "../" }
@@ -18,7 +18,7 @@ codec = { package = "parity-scale-codec", default-features = false, version = "2
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
[features]
default = ["std"]
+1 -1
View File
@@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../inherents" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
async-trait = { version = "0.1.50", optional = true }
+1 -1
View File
@@ -14,7 +14,7 @@ scale-info = { version = "1.0", default-features = false, features = ["derive"]
sp-api = { version = "4.0.0-dev", path = "../api", default-features = false }
sp-application-crypto = { version = "4.0.0", path = "../application-crypto", default-features = false }
sp-core = { version = "4.1.0-dev", path = "../core", default-features = false }
sp-runtime = { version = "4.0.0", path = "../runtime", default-features = false }
sp-runtime = { version = "4.1.0-dev", path = "../runtime", default-features = false }
sp-std = { version = "4.0.0", path = "../std", default-features = false }
[dev-dependencies]
@@ -13,7 +13,7 @@ readme = "README.md"
targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false }
+1 -1
View File
@@ -21,7 +21,7 @@ thiserror = "1.0.30"
futures = "0.3.9"
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
sp-consensus = { version = "0.10.0-dev", path = "../consensus/common" }
sp-runtime = { version = "4.0.0", path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../runtime" }
sp-state-machine = { version = "0.10.0", path = "../state-machine" }
sp-database = { version = "4.0.0-dev", path = "../database" }
sp-api = { version = "4.0.0-dev", path = "../api" }
@@ -18,7 +18,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0", default-features =
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
sp-std = { version = "4.0.0", default-features = false, path = "../../std" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../../runtime" }
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../inherents" }
sp-timestamp = { version = "4.0.0-dev", default-features = false, path = "../../timestamp" }
sp-consensus-slots = { version = "0.10.0-dev", default-features = false, path = "../slots" }
@@ -25,7 +25,7 @@ sp-consensus-vrf = { version = "0.10.0-dev", path = "../vrf", default-features =
sp-core = { version = "4.1.0-dev", default-features = false, path = "../../core" }
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../../inherents" }
sp-keystore = { version = "0.10.0", default-features = false, path = "../../keystore", optional = true }
sp-runtime = { version = "4.0.0", default-features = false, path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../../runtime" }
sp-timestamp = { version = "4.0.0-dev", path = "../../timestamp", optional = true }
serde = { version = "1.0.132", features = ["derive"], optional = true }
async-trait = { version = "0.1.50", optional = true }
@@ -26,7 +26,7 @@ sp-state-machine = { version = "0.10.0", path = "../../state-machine" }
futures-timer = "3.0.1"
sp-std = { version = "4.0.0", path = "../../std" }
sp-version = { version = "4.0.0-dev", path = "../../version" }
sp-runtime = { version = "4.0.0", path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../../runtime" }
thiserror = "1.0.30"
[dev-dependencies]
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../api" }
sp-std = { version = "4.0.0", default-features = false, path = "../../std" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../../runtime" }
sp-core = { version = "4.1.0-dev", default-features = false, path = "../../core" }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
codec = { package = "parity-scale-codec", version = "2.2.0", default-features = false, features = ["derive", "max-encoded-len"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
serde = { version = "1.0", features = ["derive"], optional = true }
sp-runtime = { version = "4.0.0", default-features = false, path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../../runtime" }
sp-arithmetic = { version = "4.0.0", default-features = false, path = "../../arithmetic" }
[features]
@@ -17,7 +17,7 @@ codec = { version = "2.0.0", package = "parity-scale-codec", default-features =
schnorrkel = { version = "0.9.1", features = ["preaudit_deprecated", "u64_backend"], default-features = false }
sp-std = { version = "4.0.0", path = "../../std", default-features = false }
sp-core = { version = "4.1.0-dev", path = "../../core", default-features = false }
sp-runtime = { version = "4.0.0", default-features = false, path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../../runtime" }
[features]
default = ["std"]
@@ -24,7 +24,7 @@ sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
sp-application-crypto = { version = "4.0.0", default-features = false, path = "../application-crypto" }
sp-core = { version = "4.1.0-dev", default-features = false, path = "../core" }
sp-keystore = { version = "0.10.0", default-features = false, path = "../keystore", optional = true }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
[features]
+1 -1
View File
@@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
sp-core = { version = "4.1.0-dev", default-features = false, path = "../core" }
sp-runtime = { version = "4.0.0", path = "../runtime", optional = true }
sp-runtime = { version = "4.1.0-dev", path = "../runtime", optional = true }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
thiserror = { version = "1.0.30", optional = true }
impl-trait-for-tuples = "0.2.0"
+1 -1
View File
@@ -16,6 +16,6 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-core = { version = "4.1.0-dev", path = "../core" }
sp-runtime = { version = "4.0.0", path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../runtime" }
lazy_static = "1.4.0"
strum = { version = "0.22.0", features = ["derive"] }
@@ -20,7 +20,7 @@ sp-std = { version = "4.0.0", default-features = false, path = "../std" }
sp-npos-elections-solution-type = { version = "4.0.0-dev", path = "./solution-type" }
sp-arithmetic = { version = "4.0.0", default-features = false, path = "../arithmetic" }
sp-core = { version = "4.1.0-dev", default-features = false, path = "../core" }
sp-runtime = { version = "4.0.0", path = "../runtime", default-features = false }
sp-runtime = { version = "4.1.0-dev", path = "../runtime", default-features = false }
[dev-dependencies]
substrate-test-utils = { version = "4.0.0-dev", path = "../../test-utils" }
@@ -19,7 +19,7 @@ scale-info = { version = "1.0", default-features = false, features = ["derive"]
honggfuzz = "0.5"
rand = { version = "0.7.3", features = ["std", "small_rng"] }
sp-npos-elections = { version = "4.0.0-dev", path = ".." }
sp-runtime = { version = "4.0.0", path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../../runtime" }
structopt = "0.3.25"
[[bin]]
+1 -1
View File
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-core = { version = "4.1.0-dev", default-features = false, path = "../core" }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
[features]
default = ["std"]
@@ -18,7 +18,7 @@ sc-executor-common = { version = "0.10.0-dev", path = "../../../client/executor/
sp-runtime-interface-test-wasm = { version = "2.0.0", path = "../test-wasm" }
sp-runtime-interface-test-wasm-deprecated = { version = "2.0.0", path = "../test-wasm-deprecated" }
sp-state-machine = { version = "0.10.0", path = "../../state-machine" }
sp-runtime = { version = "4.0.0", path = "../../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../../runtime" }
sp-io = { version = "4.0.0", path = "../../io" }
tracing = "0.1.29"
tracing-core = "0.1.17"
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "sp-runtime"
version = "4.0.0"
version = "4.1.0-dev"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
license = "Apache-2.0"
@@ -177,16 +177,16 @@ pub enum DigestItemRef<'a> {
/// the consensus engine can (and should) read them itself to avoid
/// code and state duplication. It is erroneous for a runtime to produce
/// these, but this is not (yet) checked.
PreRuntime(&'a ConsensusEngineId, &'a Vec<u8>),
PreRuntime(&'a ConsensusEngineId, &'a [u8]),
/// A message from the runtime to the consensus engine. This should *never*
/// be generated by the native code of any consensus engine, but this is not
/// checked (yet).
Consensus(&'a ConsensusEngineId, &'a Vec<u8>),
Consensus(&'a ConsensusEngineId, &'a [u8]),
/// Put a Seal on it. This is only used by native code, and is never seen
/// by runtimes.
Seal(&'a ConsensusEngineId, &'a Vec<u8>),
Seal(&'a ConsensusEngineId, &'a [u8]),
/// Any 'non-system' digest item, opaque to the native code.
Other(&'a Vec<u8>),
Other(&'a [u8]),
/// Runtime code or heap pages updated.
RuntimeEnvironmentUpdated,
}
@@ -358,8 +358,8 @@ impl<'a> DigestItemRef<'a> {
(OpaqueDigestItemId::Seal(w), &Self::Seal(v, s)) |
(OpaqueDigestItemId::PreRuntime(w), &Self::PreRuntime(v, s))
if v == w =>
Some(&s[..]),
(OpaqueDigestItemId::Other, &Self::Other(s)) => Some(&s[..]),
Some(s),
(OpaqueDigestItemId::Other, &Self::Other(s)) => Some(s),
_ => None,
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
sp-core = { version = "4.1.0-dev", default-features = false, path = "../core" }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
sp-staking = { version = "4.0.0-dev", default-features = false, path = "../staking" }
sp-runtime = { version = "4.0.0", optional = true, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", optional = true, path = "../runtime" }
[features]
default = [ "std" ]
+1 -1
View File
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
[features]
@@ -33,7 +33,7 @@ tracing = { version = "0.1.29", optional = true }
[dev-dependencies]
hex-literal = "0.3.4"
sp-runtime = { version = "4.0.0", path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../runtime" }
pretty_assertions = "1.0.0"
rand = "0.7.2"
@@ -16,7 +16,7 @@ sp-application-crypto = { version = "4.0.0", default-features = false, path = ".
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
sp-core = { version = "4.1.0-dev", default-features = false, path = "../core" }
serde = { version = "1.0.132", optional = true, features = ["derive"] }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
parity-util-mem = { version = "0.10.2", default-features = false, features = ["primitive-types"] }
[features]
+1 -1
View File
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../inherents" }
thiserror = { version = "1.0.30", optional = true }
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-api = { version = "4.0.0-dev", default-features = false, path = "../api" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
[features]
default = [ "std" ]
@@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
sp-inherents = { version = "4.0.0-dev", default-features = false, path = "../inherents" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
sp-trie = { version = "4.0.0", optional = true, path = "../trie" }
sp-core = { version = "4.1.0-dev", path = "../core", optional = true }
+1 -1
View File
@@ -32,7 +32,7 @@ trie-bench = "0.29.0"
trie-standardmap = "0.15.2"
criterion = "0.3.3"
hex-literal = "0.3.4"
sp-runtime = { version = "4.0.0", path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", path = "../runtime" }
[features]
default = ["std"]
+1 -1
View File
@@ -19,7 +19,7 @@ serde = { version = "1.0.132", optional = true, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "1.0", default-features = false, features = ["derive"] }
sp-std = { version = "4.0.0", default-features = false, path = "../std" }
sp-runtime = { version = "4.0.0", default-features = false, path = "../runtime" }
sp-runtime = { version = "4.1.0-dev", default-features = false, path = "../runtime" }
sp-version-proc-macro = { version = "4.0.0-dev", default-features = false, path = "proc-macro" }
parity-wasm = { version = "0.42.2", optional = true }
sp-core-hashing-proc-macro = { version = "4.0.0-dev", path = "../core/hashing/proc-macro" }