Use milliseconds for timestamp resolution (#3210)

* node: tabify constants file

* node: define minimum period and slot duration in milliseconds

* core: srml: use milliseconds for timestamp resolution

* core: update slot_duration to millis in tests

* node: bump spec_version

* node: fix integration test

* node: fix executor test

* Update node/runtime/src/lib.rs

Co-Authored-By: Kian Peymani <Kianenigma@users.noreply.github.com>

* node: fix docs on timestamp resolution

* node: add docs on u64 for millis
This commit is contained in:
André Silva
2019-07-26 01:40:15 +01:00
committed by Gavin Wood
parent 23fba990ba
commit a5efdd05d7
10 changed files with 47 additions and 42 deletions
+17 -13
View File
@@ -18,21 +18,25 @@
/// Money matters.
pub mod currency {
use node_primitives::Balance;
use node_primitives::Balance;
pub const MILLICENTS: Balance = 1_000_000_000;
pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent.
pub const DOLLARS: Balance = 100 * CENTS;
pub const MILLICENTS: Balance = 1_000_000_000;
pub const CENTS: Balance = 1_000 * MILLICENTS; // assume this is worth about a cent.
pub const DOLLARS: Balance = 100 * CENTS;
}
/// Time.
pub mod time {
use node_primitives::Moment;
use node_primitives::Moment;
pub const SECS_PER_BLOCK: Moment = 6;
pub const MINUTES: Moment = 60 / SECS_PER_BLOCK;
pub const HOURS: Moment = MINUTES * 60;
pub const DAYS: Moment = HOURS * 24;
pub const MILLISECS_PER_BLOCK: Moment = 6000;
pub const SECS_PER_BLOCK: Moment = MILLISECS_PER_BLOCK / 1000;
pub const SLOT_DURATION: Moment = 6000;
// 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;
}
// CRITICAL NOTE: The system module maintains two constants: a _maximum_ block weight and a
@@ -45,8 +49,8 @@ pub mod time {
// the ratio that `system` module uses to find normal transaction quota.
/// Fee-related.
pub mod fee {
pub use runtime_primitives::Perbill;
pub use runtime_primitives::Perbill;
/// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
}
/// The block saturation level. Fees will be updates based on this value.
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
}
+2 -2
View File
@@ -79,7 +79,7 @@ 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: 121,
spec_version: 122,
impl_version: 122,
apis: RUNTIME_API_VERSIONS,
};
@@ -166,7 +166,7 @@ impl balances::Trait for Runtime {
}
parameter_types! {
pub const MinimumPeriod: u64 = SECS_PER_BLOCK / 2;
pub const MinimumPeriod: Moment = SLOT_DURATION / 2;
}
impl timestamp::Trait for Runtime {
type Moment = Moment;