Scale trait and move to u32 blocknumbers (#3357)

* Scale trait and move to u32 blocknumbers.

* Fixes

* Cleanups

* Update node/runtime/src/lib.rs

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

* Fix up some of the factory stuff.

* Update core/sr-primitives/src/traits.rs

Co-Authored-By: Shawn Tabrizi <shawntabrizi@gmail.com>

* Move Nonce/Index to u32 (#3361)

* Force a non-borked version of upstream crate

* Line lengths and runtime version bump
This commit is contained in:
Gavin Wood
2019-08-11 15:03:06 +02:00
committed by GitHub
parent d1161b7d36
commit 14bb115193
29 changed files with 151 additions and 82 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ edition = "2018"
[dependencies]
log = "0.4"
futures-preview = "0.3.0-alpha.17"
futures-preview = "=0.3.0-alpha.17"
codec = { package = "parity-scale-codec", version = "1.0.0" }
sr-primitives = { path = "../../core/sr-primitives" }
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
+1 -1
View File
@@ -18,7 +18,7 @@ lazy_static = "1.3"
app_dirs = "1.2"
tokio = "0.1.7"
futures = "0.1.17"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.17", features = ["compat"] }
futures03 = { package = "futures-preview", version = "=0.3.0-alpha.17", features = ["compat"] }
fdlimit = "0.1"
exit-future = "0.1"
serde_json = "1.0"
+1 -1
View File
@@ -10,7 +10,7 @@ fnv = { version = "1.0", optional = true }
log = { version = "0.4", optional = true }
parking_lot = { version = "0.9.0", optional = true }
hex = { package = "hex-literal", version = "0.2", optional = true }
futures-preview = { version = "0.3.0-alpha.17", optional = true }
futures-preview = { version = "=0.3.0-alpha.17", optional = true }
consensus = { package = "substrate-consensus-common", path = "../consensus/common", optional = true }
executor = { package = "substrate-executor", path = "../executor", optional = true }
state-machine = { package = "substrate-state-machine", path = "../state-machine", optional = true }
+1 -1
View File
@@ -21,7 +21,7 @@ substrate-telemetry = { path = "../../telemetry" }
keystore = { package = "substrate-keystore", path = "../../keystore" }
consensus_common = { package = "substrate-consensus-common", path = "../common" }
sr-primitives = { path = "../../sr-primitives" }
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] }
futures-preview = { version = "=0.3.0-alpha.17", features = ["compat"] }
futures01 = { package = "futures", version = "0.1" }
futures-timer = "0.2.1"
parking_lot = "0.9.0"
+1 -1
View File
@@ -26,7 +26,7 @@ uncles = { package = "substrate-consensus-uncles", path = "../uncles" }
slots = { package = "substrate-consensus-slots", path = "../slots" }
sr-primitives = { path = "../../sr-primitives" }
fork-tree = { path = "../../utils/fork-tree" }
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] }
futures-preview = { version = "=0.3.0-alpha.17", features = ["compat"] }
futures01 = { package = "futures", version = "0.1" }
futures-timer = "0.2.1"
parking_lot = "0.9.0"
+1 -1
View File
@@ -82,7 +82,7 @@ use slots::{SlotWorker, SlotData, SlotInfo, SlotCompatible, SignedDuration};
mod aux_schema;
#[cfg(test)]
mod tests;
pub use babe_primitives::AuthorityId;
pub use babe_primitives::{AuthorityId, AuthorityPair, AuthoritySignature};
/// A slot duration. Create with `get_or_compute`.
// FIXME: Once Rust has higher-kinded types, the duplication between this
+1 -1
View File
@@ -11,7 +11,7 @@ libp2p = { version = "0.11.0", default-features = false }
log = "0.4"
primitives = { package = "substrate-primitives", path= "../../primitives" }
inherents = { package = "substrate-inherents", path = "../../inherents" }
futures-preview = "0.3.0-alpha.17"
futures-preview = "=0.3.0-alpha.17"
futures-timer = "0.2.1"
rstd = { package = "sr-std", path = "../../sr-std" }
runtime_version = { package = "sr-version", path = "../../sr-version" }
+1 -1
View File
@@ -12,7 +12,7 @@ primitives = { package = "substrate-primitives", path = "../../primitives" }
sr-primitives = { path = "../../sr-primitives" }
consensus_common = { package = "substrate-consensus-common", path = "../common" }
inherents = { package = "substrate-inherents", path = "../../inherents" }
futures-preview = "0.3.0-alpha.17"
futures-preview = "=0.3.0-alpha.17"
futures-timer = "0.2.1"
parking_lot = "0.9.0"
log = "0.4"
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
fork-tree = { path = "../../core/utils/fork-tree" }
futures = "0.1"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.17", features = ["compat"] }
futures03 = { package = "futures-preview", version = "=0.3.0-alpha.17", features = ["compat"] }
log = "0.4"
parking_lot = "0.9.0"
tokio-executor = "0.1.7"
+1 -1
View File
@@ -15,7 +15,7 @@ parking_lot = "0.9.0"
bitflags = "1.0"
fnv = "1.0"
futures = "0.1.17"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.17", features = ["compat"] }
futures03 = { package = "futures-preview", version = "=0.3.0-alpha.17", features = ["compat"] }
futures-timer = "0.2.1"
linked-hash-map = "0.5"
linked_hash_set = "0.1.3"
+1 -1
View File
@@ -8,7 +8,7 @@ edition = "2018"
[dependencies]
client = { package = "substrate-client", path = "../../core/client" }
futures-preview = "0.3.0-alpha.17"
futures-preview = "=0.3.0-alpha.17"
log = "0.4"
offchain-primitives = { package = "substrate-offchain-primitives", path = "./primitives" }
codec = { package = "parity-scale-codec", version = "1.0.0", features = ["derive"] }
+1 -1
View File
@@ -8,7 +8,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
[dependencies]
futures-preview = "0.3.0-alpha.17"
futures-preview = "=0.3.0-alpha.17"
libp2p = { version = "0.11.0", default-features = false }
linked-hash-map = "0.5"
log = "0.4"
+2 -2
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
derive_more = "0.14.0"
futures = "0.1"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.17", features = ["compat"] }
futures03 = { package = "futures-preview", version = "=0.3.0-alpha.17", features = ["compat"] }
jsonrpc-core = "12.0.0"
jsonrpc-core-client = "12.0.0"
jsonrpc-pubsub = "12.0.0"
@@ -34,4 +34,4 @@ futures = "0.1.17"
sr-io = { path = "../sr-io" }
test-client = { package = "substrate-test-runtime-client", path = "../test-runtime/client" }
rustc-hex = "2.0"
tokio = "0.1.17"
tokio = "0.1.17"
+1 -1
View File
@@ -7,7 +7,7 @@ edition = "2018"
[dependencies]
derive_more = "0.14.0"
futures = "0.1.17"
futures03 = { package = "futures-preview", version = "0.3.0-alpha.17", features = ["compat"] }
futures03 = { package = "futures-preview", version = "=0.3.0-alpha.17", features = ["compat"] }
parking_lot = "0.9.0"
lazy_static = "1.0"
log = "0.4"
@@ -303,6 +303,47 @@ pub trait CheckedConversion {
}
impl<T: Sized> CheckedConversion for T {}
/// Multiply and divide by a number that isn't necessarily the same type. Basically just the same
/// as `Mul` and `Div` except it can be used for all basic numeric types.
pub trait Scale<Other> {
/// The output type of the product of `self` and `Other`.
type Output;
/// @return the product of `self` and `other`.
fn mul(self, other: Other) -> Self::Output;
/// @return the integer division of `self` and `other`.
fn div(self, other: Other) -> Self::Output;
/// @return the modulo remainder of `self` and `other`.
fn rem(self, other: Other) -> Self::Output;
}
macro_rules! impl_scale {
($self:ty, $other:ty) => {
impl Scale<$other> for $self {
type Output = Self;
fn mul(self, other: $other) -> Self::Output { self * (other as Self) }
fn div(self, other: $other) -> Self::Output { self / (other as Self) }
fn rem(self, other: $other) -> Self::Output { self % (other as Self) }
}
}
}
impl_scale!(u128, u128);
impl_scale!(u128, u64);
impl_scale!(u128, u32);
impl_scale!(u128, u16);
impl_scale!(u128, u8);
impl_scale!(u64, u64);
impl_scale!(u64, u32);
impl_scale!(u64, u16);
impl_scale!(u64, u8);
impl_scale!(u32, u32);
impl_scale!(u32, u16);
impl_scale!(u32, u8);
impl_scale!(u16, u16);
impl_scale!(u16, u8);
impl_scale!(u8, u8);
/// Trait for things that can be clear (have no bits set). For numeric types, essentially the same
/// as `Zero`.
pub trait Clear {
+1 -1
View File
@@ -9,7 +9,7 @@ edition = "2018"
bytes = "0.4"
parking_lot = "0.9.0"
futures01 = { package = "futures", version = "0.1" }
futures-preview = { version = "0.3.0-alpha.17", features = ["compat"] }
futures-preview = { version = "=0.3.0-alpha.17", features = ["compat"] }
futures-timer = "0.2.1"
libp2p = { version = "0.11.0", default-features = false, features = ["libp2p-websocket"] }
log = "0.4"
+1 -1
View File
@@ -9,7 +9,7 @@ client = { package = "substrate-client", path = "../client" }
client-db = { package = "substrate-client-db", path = "../client/db", features = ["test-helpers"] }
consensus = { package = "substrate-consensus-common", path = "../consensus/common" }
executor = { package = "substrate-executor", path = "../executor" }
futures-preview = "0.3.0-alpha.17"
futures-preview = "=0.3.0-alpha.17"
hash-db = "0.15.0"
keyring = { package = "substrate-keyring", path = "../keyring" }
codec = { package = "parity-scale-codec", version = "1.0.0" }