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

pd(upgrade): generate a checkpointed genesis post-upgrade #3071

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions crates/bin/pd/src/testnet/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,19 @@ impl TestnetConfig {
Ok(genesis)
}

pub(crate) fn make_checkpoint(
genesis: Genesis<genesis::AppState>,
checkpoint: Option<Vec<u8>>,
) -> Genesis<genesis::AppState> {
match checkpoint {
Some(checkpoint) => Genesis {
app_state: genesis::AppState::Checkpoint(checkpoint),
..genesis
},
None => genesis,
}
}

/// Generate and write to disk the Tendermint configs for each validator at genesis.
pub fn write_configs(&self) -> anyhow::Result<()> {
// Loop over each validator and write its config separately.
Expand Down
2 changes: 2 additions & 0 deletions crates/bin/pd/src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ pub async fn migrate(path_to_export: PathBuf, upgrade: Upgrade) -> anyhow::Resul
.expect("infaillible conversion");
genesis.initial_height = post_ugprade_height as i64;
genesis.genesis_time = tendermint::time::Time::now();
let checkpoint = [32u8; 32].to_vec();
let genesis = TestnetConfig::make_checkpoint(genesis, Some(checkpoint));

let genesis_json = serde_json::to_string(&genesis).expect("can serialize genesis");
tracing::info!("genesis: {}", genesis_json);
Expand Down