diff --git a/bin/node/runtime/build.rs b/bin/node/runtime/build.rs index fb90e537a..3f0af8359 100644 --- a/bin/node/runtime/build.rs +++ b/bin/node/runtime/build.rs @@ -1,22 +1,21 @@ -// Copyright 2019 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 . +use std::{ + env, fs, + path::Path, + time::{SystemTime, UNIX_EPOCH}, +}; use wasm_builder_runner::{build_current_project_with_rustflags, WasmBuilderSource}; fn main() { + fs::write( + &Path::new(&env::var_os("OUT_DIR").unwrap()).join("timestamp_now.rs"), + &format!( + "pub const NOW: u64 = {};", + SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis() as u64, + ), + ) + .unwrap(); + build_current_project_with_rustflags( "wasm_binary.rs", // TODO: update version diff --git a/bin/node/runtime/src/constants.rs b/bin/node/runtime/src/constants.rs index a84301c26..9fa653816 100644 --- a/bin/node/runtime/src/constants.rs +++ b/bin/node/runtime/src/constants.rs @@ -31,11 +31,8 @@ pub mod time { use node_primitives::{BlockNumber, Moment}; use sp_staking::SessionIndex; - /// Date in Los Angeles*: 19/02/2020, 03:30:00 - /// Date in Berlin* :19/02/2020, 18:30:00 - /// Date in Beijing*: 19/02/2020, 17:30:00 - /// Date in New York* :19/02/2020, 05:30:00 - pub const GENESIS_TIME: Moment = 1_582_108_200_000; + include!(concat!(env!("OUT_DIR"), "/timestamp_now.rs")); + pub const GENESIS_TIME: Moment = NOW; /// Since BABE is probabilistic this is the average expected block time that /// we are targetting. Blocks will be produced at a minimum duration defined