Skip to content

Commit

Permalink
Don't touch uninitialized storage for version safeguard
Browse files Browse the repository at this point in the history
This prevents an edge case where PD would crash if starting before the
very first genesis. Not touching storage in that case will prevent nodes
running continuously from genesis from benefitting from the safeguard,
but an upgrade has already happened on mainnet, and so we don't care
about not having the safeguard in this case.
  • Loading branch information
cronokirby committed Nov 13, 2024
1 parent 8141304 commit ce5d667
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/core/app/src/app_version/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ async fn write_app_version_safeguard<S: StateWrite>(s: &mut S, x: u64) -> anyhow
/// This will also result in the current app version being stored, so that future
/// calls to this function will be checked against this state.
pub async fn assert_latest_app_version(s: Storage) -> anyhow::Result<()> {
// If the storage is not initialized, avoid touching it at all,
// to avoid complaints about it already being initialized before the first genesis.
if s.latest_version() == u64::MAX {
return Ok(());
}
let mut delta = StateDelta::new(s.latest_snapshot());
let found = read_app_version_safeguard(&delta).await?;
check_version(CheckContext::Running, APP_VERSION, found)?;
Expand Down

0 comments on commit ce5d667

Please sign in to comment.