mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 00:11:01 +00:00
Validate encoding of extrinsics passed to runtime (#6442)
* Validate encoding of extrinsics passed to runtime * Bump codec version explicitly
This commit is contained in:
@@ -12,7 +12,7 @@ description = "Substrate runtime api primitives"
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
sp-api-proc-macro = { version = "2.0.0-rc3", path = "proc-macro" }
|
||||
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../core" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
|
||||
@@ -191,7 +191,8 @@ fn generate_native_call_generators(decl: &ItemTrait) -> Result<TokenStream> {
|
||||
input: &I, error_desc: &'static str,
|
||||
) -> std::result::Result<R, String>
|
||||
{
|
||||
<R as #crate_::Decode>::decode(
|
||||
<R as #crate_::DecodeLimit>::decode_with_depth_limit(
|
||||
#crate_::MAX_EXTRINSIC_DEPTH,
|
||||
&mut &#crate_::Encode::encode(input)[..],
|
||||
).map_err(|e| format!("{} {}", error_desc, e.what()))
|
||||
}
|
||||
|
||||
@@ -83,7 +83,10 @@ fn generate_impl_call(
|
||||
Ok(
|
||||
quote!(
|
||||
#(
|
||||
let #pnames : #ptypes = match #c_iter::Decode::decode(&mut #input) {
|
||||
let #pnames : #ptypes = match #c_iter::DecodeLimit::decode_all_with_depth_limit(
|
||||
#c_iter::MAX_EXTRINSIC_DEPTH,
|
||||
&mut #input
|
||||
) {
|
||||
Ok(input) => input,
|
||||
Err(e) => panic!("Bad input data provided to {}: {}", #fn_name_str, e.what()),
|
||||
};
|
||||
|
||||
@@ -69,11 +69,14 @@ pub use sp_std::{slice, mem};
|
||||
#[cfg(feature = "std")]
|
||||
use sp_std::result;
|
||||
#[doc(hidden)]
|
||||
pub use codec::{Encode, Decode};
|
||||
pub use codec::{Encode, Decode, DecodeLimit};
|
||||
use sp_core::OpaqueMetadata;
|
||||
#[cfg(feature = "std")]
|
||||
use std::{panic::UnwindSafe, cell::RefCell};
|
||||
|
||||
/// Maximum nesting level for extrinsics.
|
||||
pub const MAX_EXTRINSIC_DEPTH: u32 = 256;
|
||||
|
||||
/// Declares given traits as runtime apis.
|
||||
///
|
||||
/// The macro will create two declarations, one for using on the client side and one for using
|
||||
|
||||
@@ -19,7 +19,7 @@ sp-runtime = { version = "2.0.0-rc3", path = "../../runtime" }
|
||||
sp-blockchain = { version = "2.0.0-rc3", path = "../../blockchain" }
|
||||
sp-consensus = { version = "0.8.0-rc3", path = "../../../primitives/consensus/common" }
|
||||
sc-block-builder = { version = "0.8.0-rc3", path = "../../../client/block-builder" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1" }
|
||||
sp-state-machine = { version = "0.8.0-rc3", path = "../../../primitives/state-machine" }
|
||||
trybuild = "1.0.17"
|
||||
rustversion = "1.0.0"
|
||||
|
||||
@@ -16,9 +16,9 @@ error[E0277]: the trait bound `u32: std::convert::From<std::string::String>` is
|
||||
27 | | }
|
||||
| |_^ the trait `std::convert::From<std::string::String>` is not implemented for `u32`
|
||||
|
|
||||
::: $WORKSPACE/primitives/api/src/lib.rs:347:35
|
||||
::: $WORKSPACE/primitives/api/src/lib.rs:350:35
|
||||
|
|
||||
347 | type Error: std::fmt::Debug + From<String>;
|
||||
350 | type Error: std::fmt::Debug + From<String>;
|
||||
| ------------ required by this bound in `sp_api_hidden_includes_DECL_RUNTIME_APIS::sp_api::ApiErrorExt`
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../core" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
sp-io = { version = "2.0.0-rc3", default-features = false, path = "../../primitives/io" }
|
||||
|
||||
@@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
integer-sqrt = "0.1.2"
|
||||
num-traits = { version = "0.2.8", default-features = false }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
|
||||
@@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
sp-application-crypto = { version = "2.0.0-rc3", default-features = false, path = "../application-crypto" }
|
||||
codec = { package = "parity-scale-codec", default-features = false, version = "1.3.0" }
|
||||
codec = { package = "parity-scale-codec", default-features = false, version = "1.3.1" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
sp-api = { version = "2.0.0-rc3", default-features = false, path = "../api" }
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../runtime" }
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
sp-inherents = { version = "2.0.0-rc3", default-features = false, path = "../inherents" }
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../runtime" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../runtime" }
|
||||
sp-api = { version = "2.0.0-rc3", default-features = false, path = "../api" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
sp-inherents = { version = "2.0.0-rc3", default-features = false, path = "../inherents" }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -17,7 +17,7 @@ log = "0.4.8"
|
||||
lru = "0.4.0"
|
||||
parking_lot = "0.10.0"
|
||||
derive_more = "0.99.2"
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
sp-consensus = { version = "0.8.0-rc3", path = "../consensus/common" }
|
||||
sp-runtime = { version = "2.0.0-rc3", path = "../runtime" }
|
||||
sp-block-builder = { version = "2.0.0-rc3", path = "../block-builder" }
|
||||
|
||||
@@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
sp-application-crypto = { version = "2.0.0-rc3", default-features = false, path = "../../application-crypto" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../../std" }
|
||||
sp-api = { version = "2.0.0-rc3", default-features = false, path = "../../api" }
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../../runtime" }
|
||||
|
||||
@@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
sp-application-crypto = { version = "2.0.0-rc3", default-features = false, path = "../../application-crypto" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
merlin = { version = "2.0", default-features = false }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../../std" }
|
||||
sp-api = { version = "2.0.0-rc3", default-features = false, path = "../../api" }
|
||||
|
||||
@@ -26,7 +26,7 @@ sp-std = { version = "2.0.0-rc3", path = "../../std" }
|
||||
sp-version = { version = "2.0.0-rc3", path = "../../version" }
|
||||
sp-runtime = { version = "2.0.0-rc3", path = "../../runtime" }
|
||||
sp-utils = { version = "2.0.0-rc3", path = "../../utils" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", features = ["derive"] }
|
||||
parking_lot = "0.10.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.8.0-rc3"}
|
||||
|
||||
@@ -16,7 +16,7 @@ sp-api = { version = "2.0.0-rc3", default-features = false, path = "../../api" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../../std" }
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../../runtime" }
|
||||
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../../core" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
derive_more = "0.99.2"
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
log = { version = "0.4.8", default-features = false }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
byteorder = { version = "1.3.2", default-features = false }
|
||||
|
||||
@@ -16,4 +16,4 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
sp-storage = { version = "2.0.0-rc3", path = "../storage" }
|
||||
sp-std = { version = "2.0.0-rc3", path = "../std" }
|
||||
environmental = { version = "1.1.1" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1" }
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
sp-application-crypto = { version = "2.0.0-rc3", default-features = false, path = "../application-crypto" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
grandpa = { package = "finality-grandpa", version = "0.12.3", default-features = false, features = ["derive-codec"] }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
|
||||
@@ -12,7 +12,7 @@ description = "FRAME module that tracks the last finalized block, as perceived b
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
sp-inherents = { version = "2.0.0-rc3", default-features = false, path = "../../primitives/inherents" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../../primitives/std" }
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
parking_lot = { version = "0.10.0", optional = true }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../core" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
derive_more = { version = "0.99.2", optional = true }
|
||||
|
||||
[features]
|
||||
|
||||
@@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
hash-db = { version = "0.15.2", default-features = false }
|
||||
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../core" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
|
||||
@@ -18,7 +18,7 @@ sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
sp-tracing = { version = "2.0.0-rc3", default-features = false, path = "../tracing" }
|
||||
sp-runtime-interface-proc-macro = { version = "2.0.0-rc3", path = "proc-macro" }
|
||||
sp-externalities = { version = "0.8.0-rc3", optional = true, path = "../externalities" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
static_assertions = "1.0.0"
|
||||
primitive-types = { version = "0.7.0", default-features = false }
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../core" }
|
||||
sp-application-crypto = { version = "2.0.0-rc3", default-features = false, path = "../application-crypto" }
|
||||
sp-arithmetic = { version = "2.0.0-rc3", default-features = false, path = "../arithmetic" }
|
||||
|
||||
@@ -17,7 +17,7 @@ sp-core = { version = "2.0.0-rc3", default-features = false, path = "../core" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
sp-io = { version = "2.0.0-rc3", default-features = false, path = "../io" }
|
||||
sp-wasm-interface = { version = "2.0.0-rc3", default-features = false, path = "../wasm-interface" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.9.2"
|
||||
|
||||
@@ -12,7 +12,7 @@ description = "Primitives for sessions"
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
sp-api = { version = "2.0.0-rc3", default-features = false, path = "../api" }
|
||||
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../core" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
|
||||
@@ -12,7 +12,7 @@ description = "A crate which contains primitives that are useful for implementat
|
||||
targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../runtime" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ trie-root = "0.16.0"
|
||||
sp-trie = { version = "2.0.0-rc3", path = "../trie" }
|
||||
sp-core = { version = "2.0.0-rc3", path = "../core" }
|
||||
sp-panic-handler = { version = "2.0.0-rc3", path = "../panic-handler" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1" }
|
||||
num-traits = "0.2.8"
|
||||
rand = "0.7.2"
|
||||
sp-externalities = { version = "0.8.0-rc3", path = "../externalities" }
|
||||
|
||||
@@ -13,7 +13,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
sp-application-crypto = { version = "2.0.0-rc3", default-features = false, path = "../application-crypto" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
sp-core = { version = "2.0.0-rc3", default-features = false, path = "../core" }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../runtime" }
|
||||
|
||||
@@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
sp-api = { version = "2.0.0-rc3", default-features = false, path = "../api" }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../runtime" }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
sp-inherents = { version = "2.0.0-rc3", default-features = false, path = "../inherents" }
|
||||
impl-trait-for-tuples = "0.1.3"
|
||||
wasm-timer = { version = "0.2", optional = true }
|
||||
|
||||
@@ -14,7 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", optional = true }
|
||||
derive_more = { version = "0.99.2", optional = true }
|
||||
futures = { version = "0.3.1", optional = true }
|
||||
log = { version = "0.4.8", optional = true }
|
||||
|
||||
@@ -17,7 +17,7 @@ name = "bench"
|
||||
harness = false
|
||||
|
||||
[dependencies]
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
hash-db = { version = "0.15.2", default-features = false }
|
||||
trie-db = { version = "0.21.0", default-features = false }
|
||||
|
||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
impl-serde = { version = "0.2.3", optional = true }
|
||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
sp-std = { version = "2.0.0-rc3", default-features = false, path = "../std" }
|
||||
sp-runtime = { version = "2.0.0-rc3", default-features = false, path = "../runtime" }
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
wasmi = { version = "0.6.2", optional = true }
|
||||
impl-trait-for-tuples = "0.1.2"
|
||||
sp-std = { version = "2.0.0-rc3", path = "../std", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.0", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false, features = ["derive"] }
|
||||
|
||||
[features]
|
||||
default = [ "std" ]
|
||||
|
||||
Reference in New Issue
Block a user