Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panics if we are before genesis timestamp #3768

Merged
merged 2 commits into from
Apr 5, 2023
Merged
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
19 changes: 18 additions & 1 deletion massa-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,25 @@ async fn launch(
Option<massa_grpc::server::StopHandle>,
) {
info!("Node version : {}", *VERSION);
let now = MassaTime::now().expect("could not get now time");
// Do not start if genesis is in the future. This is meant to prevent nodes
// from desync if the bootstrap nodes keep a previous ledger
#[cfg(not(feature = "sandbox"))]
{
if *GENESIS_TIMESTAMP > now {
let (days, hours, mins, secs) = GENESIS_TIMESTAMP
.saturating_sub(now)
.days_hours_mins_secs()
.unwrap();
panic!(
"This episode has not started yet, please wait {} days, {} hours, {} minutes, {} seconds for genesis",
days, hours, mins, secs,
)
}
}

if let Some(end) = *END_TIMESTAMP {
if MassaTime::now().expect("could not get now time") > end {
if now > end {
panic!("This episode has come to an end, please get the latest testnet node version to continue");
}
}
Expand Down