Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 40 additions & 39 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/bft/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
futures = "0.1.17"
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
substrate-primitives = { path = "../primitives" }
sr-primitives = { path = "../sr-primitives" }
sr-version = { path = "../sr-version" }
Expand Down
2 changes: 1 addition & 1 deletion core/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ futures = "0.1.17"
slog = "^2"
heapsize = "0.4"
substrate-bft = { path = "../bft" }
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
substrate-executor = { path = "../executor" }
substrate-primitives = { path = "../primitives" }
sr-io = { path = "../sr-io" }
Expand Down
2 changes: 1 addition & 1 deletion core/client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ substrate-primitives = { path = "../../../core/primitives" }
sr-primitives = { path = "../../../core/sr-primitives" }
substrate-client = { path = "../../../core/client" }
substrate-state-machine = { path = "../../../core/state-machine" }
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
parity-codec-derive = { version = "~1.0" }
substrate-executor = { path = "../../../core/executor" }
substrate-state-db = { path = "../../../core/state-db" }
Expand Down
2 changes: 1 addition & 1 deletion core/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
error-chain = "0.12"
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
sr-io = { path = "../sr-io" }
substrate-primitives = { path = "../primitives" }
substrate-serializer = { path = "../serializer" }
Expand Down
10 changes: 5 additions & 5 deletions core/executor/wasm/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/extrinsic-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ sr-primitives = { path = "../../core/sr-primitives" }
[dev-dependencies]
substrate-test-client = { path = "../../core/test-client" }
substrate-keyring = { path = "../../core/keyring" }
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
2 changes: 1 addition & 1 deletion core/metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
parity-codec = { version = "~1.0", default_features = false }
parity-codec = { version = "1.1", default_features = false }

[features]
default = ["std"]
Expand Down
2 changes: 1 addition & 1 deletion core/misbehavior-check/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
parity-codec = { version = "~1.0", default-features = false }
parity-codec = { version = "1.1", default-features = false }
substrate-primitives = { path = "../primitives", default-features = false }
sr-primitives = { path = "../sr-primitives", default-features = false }
sr-io = { path = "../sr-io", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion core/network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rustc-hex = "1.0"
substrate-primitives = { path = "../../core/primitives" }
substrate-client = { path = "../../core/client" }
sr-primitives = { path = "../../core/sr-primitives" }
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
parity-codec-derive = { version = "~1.0" }
substrate-network-libp2p = { path = "../../core/network-libp2p" }

Expand Down
2 changes: 1 addition & 1 deletion core/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
crunchy = "0.1"
sr-std = { path = "../sr-std", default_features = false }
parity-codec = { version = "~1.0", default_features = false }
parity-codec = { version = "1.1", default_features = false }
parity-codec-derive = { version = "~1.0", default_features = false }
elastic-array = {version = "0.10", optional = true }
fixed-hash = { version = "0.2.2", default_features = false }
Expand Down
2 changes: 1 addition & 1 deletion core/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jsonrpc-macros = { git="https://github.com/paritytech/jsonrpc.git" }
jsonrpc-pubsub = { git="https://github.com/paritytech/jsonrpc.git" }
log = "0.3"
parking_lot = "0.4"
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
substrate-client = { path = "../client" }
substrate-executor = { path = "../executor" }
substrate-extrinsic-pool = { path = "../extrinsic-pool" }
Expand Down
1 change: 1 addition & 0 deletions core/rpc/src/chain/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ fn should_return_runtime_version() {
authoring_version: 1,
spec_version: 1,
impl_version: 1,
apis: (&[][..]).into()
}
);
}
2 changes: 1 addition & 1 deletion core/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ substrate-primitives = { path = "../../core/primitives" }
substrate-network = { path = "../../core/network" }
substrate-client = { path = "../../core/client" }
substrate-client-db = { path = "../../core/client/db" }
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
substrate-executor = { path = "../../core/executor" }
substrate-extrinsic-pool = { path = "../../core/extrinsic-pool" }
substrate-rpc = { path = "../../core/rpc" }
Expand Down
2 changes: 1 addition & 1 deletion core/sr-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sr-std = { path = "../sr-std", default_features = false }
environmental = { version = "~1.0", optional = true }
substrate-state-machine = { path = "../state-machine", optional = true }
substrate-primitives = { path = "../primitives", default_features = false }
parity-codec = { version = "~1.0", default_features = false }
parity-codec = { version = "1.1", default_features = false }
triehash = { version = "0.2", optional = true }
hashdb = { version = "0.2", default_features = false }
rlp = { version = "0.2", optional = true, default_features = false }
Expand Down
2 changes: 1 addition & 1 deletion core/sr-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ num-traits = { version = "0.2", default_features = false }
integer-sqrt = { git = "https://github.com/paritytech/integer-sqrt-rs.git", branch = "master" }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
parity-codec = { version = "~1.0", default_features = false }
parity-codec = { version = "1.1", default_features = false }
parity-codec-derive = { version = "~1.0", default_features = false }
substrate-primitives = { path = "../primitives", default_features = false }
sr-std = { path = "../sr-std", default_features = false }
Expand Down
1 change: 1 addition & 0 deletions core/sr-primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub mod testing;
pub mod traits;
pub mod generic;
pub mod bft;
pub mod transaction_validity;

use traits::{Verify, Lazy};

Expand Down
37 changes: 37 additions & 0 deletions core/sr-primitives/src/transaction_validity.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2017 Parity Technologies (UK) Ltd.
// This file is part of Substrate.

// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

//! Transaction validity interface.

use rstd::prelude::*;

/// Priority for a transaction. Additive. Higher is better.
pub type TransactionPriority = u64;

/// Minimum number of blocks a transaction will remain valid for.
/// `TransactionLongevity::max_value()` means "forever".
pub type TransactionLongevity = u64;

/// Tag for a transaction. No two transactions with the same tag should be placed on-chain.
pub type TransactionTag = Vec<u8>;

/// Information on a transaction's validity and, if valid, on how it relates to other transactions.
#[derive(Clone, PartialEq, Eq, Encode, Decode)]
pub enum TransactionValidity {
Invalid,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we allow also allow to give an optional reason for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps, but a 'static str/String isn't especially suitable as it's wasm -> runtime.

Valid(TransactionPriority, Vec<TransactionTag>, Vec<TransactionTag>, TransactionLongevity),
Unknown,
}
2 changes: 1 addition & 1 deletion core/sr-sandbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ wasmi = { version = "0.4", optional = true }
substrate-primitives = { path = "../primitives", default_features = false }
sr-std = { path = "../sr-std", default_features = false }
sr-io = { path = "../sr-io", default_features = false }
parity-codec = { version = "~1.0", default_features = false }
parity-codec = { version = "1.1", default_features = false }

[dev-dependencies]
wabt = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion core/sr-version/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
serde = { version = "1.0", default_features = false }
serde_derive = { version = "1.0", optional = true }
parity-codec = { version = "~1.0", default_features = false }
parity-codec = { version = "1.1", default_features = false }
parity-codec-derive = { version = "~1.0", default_features = false }
sr-std = { path = "../sr-std", default_features = false }

Expand Down
38 changes: 25 additions & 13 deletions core/sr-version/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ pub type VersionString = ::std::borrow::Cow<'static, str>;
#[cfg(not(feature = "std"))]
pub type VersionString = &'static str;

/// The identity of a particular API interface that the runtime might provide.
pub type ApiId = [u8; 8];

/// A vector of pairs of `ApiId` and a `u32` for version. For `"std"` builds, this
/// is a `Cow`.
#[cfg(feature = "std")]
pub type ApisVec = ::std::borrow::Cow<'static, [(ApiId, u32)]>;
/// A vector of pairs of `ApiId` and a `u32` for version. For `"no-std"` builds, this
/// is just a reference.
#[cfg(not(feature = "std"))]
pub type ApisVec = &'static [(ApiId, u32)];

#[cfg(feature = "std")]
#[macro_export]
macro_rules! ver_str {
Expand All @@ -54,6 +66,12 @@ macro_rules! ver_str {
( $y:expr ) => {{ $y }}
}

/// Create a vector of Api declarations.
#[macro_export]
macro_rules! apis_vec {
( $y:expr ) => { ver_str!(& $y) }
}

/// Runtime version.
/// This should not be thought of as classic Semver (major/minor/tiny).
/// This triplet have different semantics and mis-interpretation could cause problems.
Expand Down Expand Up @@ -90,20 +108,9 @@ pub struct RuntimeVersion {
/// Non-consensus-breaking optimisations are about the only changes that could be made which
/// would result in only the `impl_version` changing.
pub impl_version: u32,
}

// TODO: remove this after PoC-2
#[cfg(feature = "std")]
impl Default for RuntimeVersion {
fn default() -> RuntimeVersion {
RuntimeVersion {
spec_name: ver_str!("polkadot"),
impl_name: ver_str!("parity-polkadot"),
authoring_version: 0,
spec_version: 0,
impl_version: 0,
}
}
/// List of supported API "features" along with their versions.
pub apis: ApisVec,
}

#[cfg(feature = "std")]
Expand All @@ -127,4 +134,9 @@ impl RuntimeVersion {
self.authoring_version == other.authoring_version &&
self.spec_name == other.spec_name
}

/// Check if this version supports a particular API.
pub fn has_api(&self, api: ApiId, version: u32) -> bool {
self.apis.iter().any(|&(ref s, v)| &api == s && version == v)
}
}
2 changes: 1 addition & 1 deletion core/state-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
parking_lot = "0.5"
log = "0.4"
substrate-primitives = { path = "../../core/primitives" }
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
parity-codec-derive = { version = "~1.0" }

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion core/state-machine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ triehash = "0.2"
rlp = "0.2.4"

substrate-primitives = { path = "../primitives", version = "0.1.0" }
parity-codec = { version = "~1.0", default_features = false }
parity-codec = { version = "1.1", default_features = false }

2 changes: 1 addition & 1 deletion core/test-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
rhododendron = "0.3"
substrate-bft = { path = "../bft" }
substrate-client = { path = "../client" }
parity-codec = { version = "~1.0" }
parity-codec = { version = "1.1" }
substrate-executor = { path = "../executor" }
substrate-keyring = { path = "../../core/keyring" }
substrate-primitives = { path = "../primitives" }
Expand Down
2 changes: 1 addition & 1 deletion core/test-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ log = { version = "0.3", optional = true }
hex-literal = { version = "0.1.0", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
parity-codec = { version = "~1.0", default-features = false }
parity-codec = { version = "1.1", default-features = false }
parity-codec-derive = { version = "~1.0", default-features = false }
substrate-keyring = { path = "../keyring", optional = true }
substrate-primitives = { path = "../primitives", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions core/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
authoring_version: 1,
spec_version: 1,
impl_version: 1,
apis: apis_vec!([]),
};

fn version() -> RuntimeVersion {
Expand Down
Loading