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" }
@@ -5,6 +5,7 @@ authors = ["Anonymous"]
edition = "2018"
[dependencies]
serde = { version = "1.0", optional = true, features = ["derive"] }
safe-mix = { version = "1.0", default-features = false }
codec = { package = "parity-scale-codec", version = "1.0.0", default-features = false, features = ["derive"] }
+2 -2
View File
@@ -48,10 +48,10 @@ pub type AccountSignature = sr25519::Signature;
pub type Hash = primitives::H256;
/// Index of a block number in the chain.
pub type BlockNumber = u64;
pub type BlockNumber = u32;
/// Index of an account's extrinsic in the chain.
pub type Nonce = u64;
pub type Nonce = u32;
/// Balance type for the node.
pub type Balance = u128;
+1 -1
View File
@@ -49,7 +49,7 @@ keystore = { package = "substrate-keystore", path = "../../core/keystore" }
babe = { package = "substrate-consensus-babe", path = "../../core/consensus/babe", features = ["test-helpers"] }
consensus-common = { package = "substrate-consensus-common", path = "../../core/consensus/common" }
service-test = { package = "substrate-service-test", path = "../../core/service/test" }
futures03 = { package = "futures-preview", version = "0.3.0-alpha.17" }
futures03 = { package = "futures-preview", version = "=0.3.0-alpha.17" }
tempfile = "3.1"
[build-dependencies]
+13 -13
View File
@@ -39,11 +39,11 @@ pub struct FactoryState<N> {
block_no: N,
mode: Mode,
start_number: u64,
rounds: u64,
round: u64,
block_in_round: u64,
num: u64,
start_number: u32,
rounds: u32,
round: u32,
block_in_round: u32,
num: u32,
}
type Number = <<node_primitives::Block as BlockT>::Header as HeaderT>::Number;
@@ -77,9 +77,9 @@ impl RuntimeAdapter for FactoryState<Number> {
) -> FactoryState<Self::Number> {
FactoryState {
mode,
num: num,
num: num as u32,
round: 0,
rounds,
rounds: rounds as u32,
block_in_round: 0,
block_no: 0,
start_number: 0,
@@ -150,7 +150,7 @@ impl RuntimeAdapter for FactoryState<Number> {
}
fn inherent_extrinsics(&self) -> InherentData {
let timestamp = self.block_no * MINIMUM_PERIOD;
let timestamp = self.block_no as u64 * MINIMUM_PERIOD;
let mut inherent = InherentData::new();
inherent.put_data(timestamp::INHERENT_IDENTIFIER, &timestamp)
@@ -194,12 +194,12 @@ impl RuntimeAdapter for FactoryState<Number> {
// This currently prevents the factory from being used
// without a preceding purge of the database.
if self.mode == Mode::MasterToN || self.mode == Mode::MasterTo1 {
self.block_no()
self.block_no() as Self::Index
} else {
match self.round() {
0 =>
// if round is 0 all transactions will be done with master as a sender
self.block_no(),
self.block_no() as Self::Index,
_ =>
// if round is e.g. 1 every sender account will be new and not yet have
// any transactions done
@@ -215,12 +215,12 @@ impl RuntimeAdapter for FactoryState<Number> {
// TODO get correct phase via api. See #2587.
// This currently prevents the factory from being used
// without a preceding purge of the database.
self.block_no
self.block_no() as Self::Phase
}
}
fn gen_seed_bytes(seed: u64) -> [u8; 32] {
let mut rng: StdRng = SeedableRng::seed_from_u64(seed);
fn gen_seed_bytes(seed: u32) -> [u8; 32] {
let mut rng: StdRng = SeedableRng::seed_from_u64(seed as u64);
let mut seed_bytes = [0u8; 32];
for i in 0..32 {
+44 -18
View File
@@ -88,19 +88,32 @@ construct_service_factory! {
RuntimeApi = RuntimeApi,
NetworkProtocol = NodeProtocol { |config| Ok(NodeProtocol::new()) },
RuntimeDispatch = node_executor::Executor,
FullTransactionPoolApi = transaction_pool::ChainApi<client::Client<FullBackend<Self>, FullExecutor<Self>, Block, RuntimeApi>, Block>
{ |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) },
LightTransactionPoolApi = transaction_pool::ChainApi<client::Client<LightBackend<Self>, LightExecutor<Self>, Block, RuntimeApi>, Block>
{ |config, client| Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client))) },
FullTransactionPoolApi =
transaction_pool::ChainApi<
client::Client<FullBackend<Self>, FullExecutor<Self>, Block, RuntimeApi>,
Block
> {
|config, client|
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
},
LightTransactionPoolApi =
transaction_pool::ChainApi<
client::Client<LightBackend<Self>, LightExecutor<Self>, Block, RuntimeApi>,
Block
> {
|config, client|
Ok(TransactionPool::new(config, transaction_pool::ChainApi::new(client)))
},
Genesis = GenesisConfig,
Configuration = NodeConfig<Self>,
FullService = FullComponents<Self>
{ |config: FactoryFullConfiguration<Self>|
FullComponents::<Factory>::new(config) },
FullService = FullComponents<Self> {
|config: FactoryFullConfiguration<Self>| FullComponents::<Factory>::new(config)
},
AuthoritySetup = {
|mut service: Self::FullService| {
let (block_import, link_half, babe_link) = service.config_mut().custom.import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
let (block_import, link_half, babe_link) =
service.config_mut().custom.import_setup.take()
.expect("Link Half and Block Import are present for Full Services or setup failed before. qed");
// spawn any futures that were created in the previous setup steps
if let Some(tasks) = service.config_mut().custom.tasks_to_spawn.take() {
@@ -120,7 +133,8 @@ construct_service_factory! {
};
let client = service.client();
let select_chain = service.select_chain().ok_or(ServiceError::SelectChainRequired)?;
let select_chain = service.select_chain()
.ok_or(ServiceError::SelectChainRequired)?;
let babe_config = babe::BabeParams {
config: Config::get_or_compute(&*client)?,
@@ -130,7 +144,8 @@ construct_service_factory! {
block_import,
env: proposer,
sync_oracle: service.network(),
inherent_data_providers: service.config().custom.inherent_data_providers.clone(),
inherent_data_providers: service.config()
.custom.inherent_data_providers.clone(),
force_authoring: service.config().force_authoring,
time_source: babe_link,
};
@@ -167,7 +182,8 @@ construct_service_factory! {
config: config,
link: link_half,
network: service.network(),
inherent_data_providers: service.config().custom.inherent_data_providers.clone(),
inherent_data_providers:
service.config().custom.inherent_data_providers.clone(),
on_exit: service.on_exit(),
telemetry_on_connect: Some(telemetry_on_connect),
};
@@ -187,8 +203,12 @@ construct_service_factory! {
},
LightService = LightComponents<Self>
{ |config| <LightComponents<Factory>>::new(config) },
FullImportQueue = BabeImportQueue<Self::Block>
{ |config: &mut FactoryFullConfiguration<Self> , client: Arc<FullClient<Self>>, select_chain: Self::SelectChain| {
FullImportQueue = BabeImportQueue<Self::Block> {
|
config: &mut FactoryFullConfiguration<Self>,
client: Arc<FullClient<Self>>,
select_chain: Self::SelectChain
| {
let (block_import, link_half) =
grandpa::block_import::<_, _, _, RuntimeApi, FullClient<Self>, _>(
client.clone(), client.clone(), select_chain
@@ -222,7 +242,8 @@ construct_service_factory! {
)?;
let finality_proof_import = block_import.clone();
let finality_proof_request_builder = finality_proof_import.create_finality_proof_request_builder();
let finality_proof_request_builder =
finality_proof_import.create_finality_proof_request_builder();
// FIXME: pruning task isn't started since light client doesn't do `AuthoritySetup`.
let (import_queue, ..) = import_queue(
@@ -254,7 +275,9 @@ construct_service_factory! {
mod tests {
use std::sync::Arc;
use babe::CompatibleDigestItem;
use consensus_common::{Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy};
use consensus_common::{
Environment, Proposer, BlockImportParams, BlockOrigin, ForkChoiceStrategy
};
use node_primitives::DigestItem;
use node_runtime::{BalancesCall, Call, UncheckedExtrinsic};
use node_runtime::constants::{currency::CENTS, time::SLOT_DURATION};
@@ -306,7 +329,9 @@ mod tests {
auxiliary: Vec::new(),
}
};
let extrinsic_factory = |service: &SyncService<<Factory as service::ServiceFactory>::FullService>| {
let extrinsic_factory =
|service: &SyncService<<Factory as service::ServiceFactory>::FullService>|
{
let payload = (
0,
Call::Balances(BalancesCall::transfer(RawAddress::Id(bob.public().0.into()), 69.into())),
@@ -333,7 +358,8 @@ mod tests {
#[ignore]
fn test_sync() {
let keystore_path = tempfile::tempdir().expect("Creates keystore path");
let keystore = keystore::Store::open(keystore_path.path(), None).expect("Creates keystore");
let keystore = keystore::Store::open(keystore_path.path(), None)
.expect("Creates keystore");
let alice = keystore.write().insert_ephemeral_from_seed::<babe::AuthorityPair>("//Alice")
.expect("Creates authority pair");
+9 -9
View File
@@ -164,7 +164,7 @@ mod tests {
})
}
fn from_block_number(n: u64) -> Header {
fn from_block_number(n: u32) -> Header {
Header::new(n, Default::default(), Default::default(), [69; 32].into(), Default::default())
}
@@ -192,7 +192,7 @@ mod tests {
let r = executor().call::<_, NeverNativeValue, fn() -> _>(
&mut t,
"Core_initialize_block",
&vec![].and(&from_block_number(1u64)),
&vec![].and(&from_block_number(1u32)),
true,
None,
).0;
@@ -228,7 +228,7 @@ mod tests {
let r = executor().call::<_, NeverNativeValue, fn() -> _>(
&mut t,
"Core_initialize_block",
&vec![].and(&from_block_number(1u64)),
&vec![].and(&from_block_number(1u32)),
true,
None,
).0;
@@ -260,7 +260,7 @@ mod tests {
let r = executor().call::<_, NeverNativeValue, fn() -> _>(
&mut t,
"Core_initialize_block",
&vec![].and(&from_block_number(1u64)),
&vec![].and(&from_block_number(1u32)),
true,
None,
).0;
@@ -296,7 +296,7 @@ mod tests {
let r = executor().call::<_, NeverNativeValue, fn() -> _>(
&mut t,
"Core_initialize_block",
&vec![].and(&from_block_number(1u64)),
&vec![].and(&from_block_number(1u32)),
true,
None,
).0;
@@ -523,7 +523,7 @@ mod tests {
(block1, block2)
}
fn block_with_size(time: u64, nonce: u64, size: usize) -> (Vec<u8>, Hash) {
fn block_with_size(time: u64, nonce: u32, size: usize) -> (Vec<u8>, Hash) {
construct_block(
&mut new_test_ext(COMPACT_CODE, false),
1,
@@ -887,7 +887,7 @@ mod tests {
], map![]));
let r = WasmExecutor::new()
.call(&mut t, 8, COMPACT_CODE, "Core_initialize_block", &vec![].and(&from_block_number(1u64)));
.call(&mut t, 8, COMPACT_CODE, "Core_initialize_block", &vec![].and(&from_block_number(1u32)));
assert!(r.is_ok());
let r = WasmExecutor::new()
.call(&mut t, 8, COMPACT_CODE, "BlockBuilder_apply_extrinsic", &vec![].and(&xt())).unwrap();
@@ -909,7 +909,7 @@ mod tests {
], map![]));
let r = WasmExecutor::new()
.call(&mut t, 8, COMPACT_CODE, "Core_initialize_block", &vec![].and(&from_block_number(1u64)));
.call(&mut t, 8, COMPACT_CODE, "Core_initialize_block", &vec![].and(&from_block_number(1u32)));
assert!(r.is_ok());
let r = WasmExecutor::new()
.call(&mut t, 8, COMPACT_CODE, "BlockBuilder_apply_extrinsic", &vec![].and(&xt())).unwrap();
@@ -1080,7 +1080,7 @@ mod tests {
let r = executor().call::<_, NeverNativeValue, fn() -> _>(
&mut t,
"Core_initialize_block",
&vec![].and(&from_block_number(1u64)),
&vec![].and(&from_block_number(1u32)),
true,
None,
).0;
+2 -2
View File
@@ -25,7 +25,7 @@ use sr_primitives::{
};
/// An index to a block.
pub type BlockNumber = u64;
pub type BlockNumber = u32;
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
pub type Signature = AnySignature;
@@ -45,7 +45,7 @@ pub type Balance = u128;
pub type Moment = u64;
/// Index of a transaction in the chain.
pub type Index = u64;
pub type Index = u32;
/// A hash of some data used by the chain.
pub type Hash = primitives::H256;
+7 -7
View File
@@ -27,7 +27,7 @@ pub mod currency {
/// Time.
pub mod time {
use node_primitives::Moment;
use node_primitives::{Moment, BlockNumber};
/// Since BABE is probabilistic this is the average expected block time that
/// we are targetting. Blocks will be produced at a minimum duration defined
@@ -46,17 +46,17 @@ pub mod time {
pub const SLOT_DURATION: Moment = 1650;
pub const EPOCH_DURATION_IN_BLOCKS: Moment = 10 * MINUTES;
pub const EPOCH_DURATION_IN_SLOTS: Moment = {
pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES;
pub const EPOCH_DURATION_IN_SLOTS: u64 = {
const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64;
(EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as Moment
(EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64
};
// These time units are defined in number of blocks.
pub const MINUTES: Moment = 60 / SECS_PER_BLOCK;
pub const HOURS: Moment = MINUTES * 60;
pub const DAYS: Moment = HOURS * 24;
pub const MINUTES: BlockNumber = 60 / (SECS_PER_BLOCK as BlockNumber);
pub const HOURS: BlockNumber = MINUTES * 60;
pub const DAYS: BlockNumber = HOURS * 24;
}
// CRITICAL NOTE: The system module maintains two constants: a _maximum_ block weight and a
+3 -3
View File
@@ -80,8 +80,8 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to equal spec_version. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 137,
impl_version: 137,
spec_version: 138,
impl_version: 138,
apis: RUNTIME_API_VERSIONS,
};
@@ -179,7 +179,7 @@ impl timestamp::Trait for Runtime {
}
parameter_types! {
pub const UncleGenerations: u64 = 5;
pub const UncleGenerations: BlockNumber = 5;
}
impl authorship::Trait for Runtime {
+4 -5
View File
@@ -478,6 +478,10 @@ mod tests {
type MaximumBlockLength = MaximumBlockLength;
}
parameter_types! {
pub const UncleGenerations: u64 = 5;
}
impl Trait for Test {
type FindAuthor = AuthorGiven;
type UncleGenerations = UncleGenerations;
@@ -506,10 +510,6 @@ mod tests {
}
}
parameter_types! {
pub const UncleGenerations: u64 = 5;
}
pub struct VerifyBlock;
impl VerifySeal<Header, u64> for VerifyBlock {
@@ -550,7 +550,6 @@ mod tests {
header
}
fn create_header(number: u64, parent_hash: H256, state_root: H256) -> Header {
Header::new(
number,
+2 -1
View File
@@ -80,6 +80,7 @@ decl_storage! {
decl_event!(
pub enum Event<T, I=DefaultInstance> where
<T as system::Trait>::AccountId,
<T as Trait<I>>::Event,
{
/// The given member was added; see the transaction for who.
MemberAdded,
@@ -90,7 +91,7 @@ decl_event!(
/// The membership was reset; see the transaction for who the new set is.
MembersReset,
/// Phantom member, never used.
Dummy(sr_std::marker::PhantomData<(AccountId, I)>),
Dummy(sr_std::marker::PhantomData<(AccountId, Event)>),
}
);
+5 -4
View File
@@ -90,7 +90,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
use rstd::{result, ops::{Mul, Div}, cmp};
use rstd::{result, cmp};
use codec::Encode;
#[cfg(feature = "std")]
use codec::Decode;
@@ -98,7 +98,9 @@ use codec::Decode;
use inherents::ProvideInherentData;
use srml_support::{StorageValue, Parameter, decl_storage, decl_module, for_each_tuple};
use srml_support::traits::{Time, Get};
use sr_primitives::traits::{SimpleArithmetic, Zero, SaturatedConversion};
use sr_primitives::traits::{
SimpleArithmetic, Zero, SaturatedConversion, Scale
};
use sr_primitives::weights::SimpleDispatchInfo;
use system::ensure_none;
use inherents::{RuntimeString, InherentIdentifier, ProvideInherent, IsFatalError, InherentData};
@@ -207,8 +209,7 @@ for_each_tuple!(impl_timestamp_set);
pub trait Trait: system::Trait {
/// Type used for expressing timestamp.
type Moment: Parameter + Default + SimpleArithmetic
+ Mul<Self::BlockNumber, Output = Self::Moment>
+ Div<Self::BlockNumber, Output = Self::Moment>;
+ Scale<Self::BlockNumber, Output = Self::Moment>;
/// Something which can be notified when the timestamp is set. Set this to `()` if not needed.
type OnTimestampSet: OnTimestampSet<Self::Moment>;