diff --git a/crates/bin/pd/src/migrate.rs b/crates/bin/pd/src/migrate.rs index 99d2f61ca0..5cd991779a 100644 --- a/crates/bin/pd/src/migrate.rs +++ b/crates/bin/pd/src/migrate.rs @@ -62,22 +62,12 @@ impl Migration { ); let rocksdb_dir = pd_home.join("rocksdb"); let storage = Storage::load(rocksdb_dir, SUBSTORE_PREFIXES.to_vec()).await?; - let export_state = storage.latest_snapshot(); - let root_hash = export_state.root_hash().await.expect("can get root hash"); - let height = export_state - .get_block_height() - .await - .expect("can get block height"); - - tracing::debug!(pre_migration_root_hash = ?root_hash, current_height = ?height, ?force, - "determining if the chain is halted and the migration is allowed to run"); - ensure!( - export_state.is_chain_halted().await || force, + storage.latest_snapshot().is_chain_halted().await || force, "to run a migration, the chain halt bit must be set to `true` or use the `--force` cli flag" ); + tracing::info!("started migration"); - tracing::info!(pre_migration_root_hash = ?root_hash, pre_upgrade_height = ?height, ?self, "started migration"); match self { Migration::ReadyToStart => { reset_halt_bit::migrate(storage, pd_home, genesis_start).await?; @@ -86,12 +76,15 @@ impl Migration { Migration::SimpleMigration => { simple::migrate(storage, pd_home.clone(), genesis_start).await? } + Migration::Testnet72 => { testnet72::migrate(storage, pd_home.clone(), genesis_start).await? } + Migration::Testnet74 => { testnet74::migrate(storage, pd_home.clone(), genesis_start).await? } + Migration::Testnet76 => { testnet76::migrate(storage, pd_home.clone(), genesis_start).await? } diff --git a/crates/bin/pd/src/migrate/testnet76.rs b/crates/bin/pd/src/migrate/testnet76.rs index b02b2b5598..48e94022c4 100644 --- a/crates/bin/pd/src/migrate/testnet76.rs +++ b/crates/bin/pd/src/migrate/testnet76.rs @@ -6,7 +6,6 @@ use futures::TryStreamExt; use jmt::RootHash; use pbjson_types::Any; use penumbra_app::app::StateReadExt as _; -use penumbra_app::SUBSTORE_PREFIXES; use penumbra_asset::Balance; use penumbra_auction::auction::dutch::DutchAuction; use penumbra_proto::{DomainType, StateReadProto, StateWriteProto}; @@ -85,18 +84,22 @@ pub async fn migrate( genesis_start: Option, ) -> anyhow::Result<()> { // Setup: - let export_state = storage.latest_snapshot(); - let root_hash = export_state.root_hash().await.expect("can get root hash"); + let initial_state = storage.latest_snapshot(); + let chain_id = initial_state.get_chain_id().await?; + let root_hash = initial_state + .root_hash() + .await + .expect("chain state has a root hash"); let pre_upgrade_root_hash: RootHash = root_hash.into(); - let pre_upgrade_height = export_state + let pre_upgrade_height = initial_state .get_block_height() .await - .expect("can get block height"); + .expect("chain state has a block height"); let post_upgrade_height = pre_upgrade_height.wrapping_add(1); // We initialize a `StateDelta` and start by reaching into the JMT for all entries matching the // swap execution prefix. Then, we write each entry to the nv-storage. - let mut delta = StateDelta::new(export_state); + let mut delta = StateDelta::new(initial_state); let (migration_duration, post_upgrade_root_hash) = { let start_time = std::time::SystemTime::now(); @@ -109,23 +112,18 @@ pub async fn migrate( delta.put_block_height(0u64); let post_upgrade_root_hash = storage.commit_in_place(delta).await?; - tracing::info!(?post_upgrade_root_hash, "post-upgrade root hash"); + tracing::info!(?post_upgrade_root_hash, "post-migration root hash"); ( start_time.elapsed().expect("start time not set"), post_upgrade_root_hash, ) }; - storage.release().await; - let rocksdb_dir = pd_home.join("rocksdb"); - let storage = Storage::load(rocksdb_dir, SUBSTORE_PREFIXES.to_vec()).await?; - let migrated_state = storage.latest_snapshot(); // The migration is complete, now we need to generate a genesis file. To do this, we need // to lookup a validator view from the chain, and specify the post-upgrade app hash and // initial height. - let chain_id = migrated_state.get_chain_id().await?; let app_state = penumbra_app::genesis::Content { chain_id, ..Default::default()