Skip to content

Commit

Permalink
pd(migrate): add vcb migration variant
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor committed May 20, 2024
1 parent 812a73d commit 24210b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions crates/bin/pd/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod reset_halt_bit;
mod simple;
mod testnet72;
mod testnet74;
mod testnet76;

use anyhow::{ensure, Context};
use penumbra_governance::StateReadExt;
Expand Down Expand Up @@ -38,6 +39,9 @@ pub enum Migration {
/// - Update arb executions to include the amount of filled input in the output
/// - Add `AuctionParameters` to the consensus state
Testnet74,
/// Testnet-76 migration:
/// - Heal the auction component's VCB tally.
Testnet76,
}

impl Migration {
Expand Down Expand Up @@ -87,6 +91,9 @@ impl Migration {
Migration::Testnet74 => {
testnet74::migrate(storage, pd_home.clone(), genesis_start).await?
}
Migration::Testnet76 => {
testnet76::migrate(storage, pd_home.clone(), genesis_start).await?
}
};

if let Some(comet_home) = comet_home {
Expand Down
6 changes: 3 additions & 3 deletions crates/bin/pd/src/migrate/testnet76.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,11 @@ async fn heal_auction_vcb(delta: &mut StateDelta<Snapshot>) -> anyhow::Result<()
/// - Reconstruct a correct VCB balance for the auction component.
#[instrument(skip_all)]
pub async fn migrate(
storage: Storage,
path_to_export: PathBuf,
genesis_start: Option<tendermint::time::Time>,
) -> anyhow::Result<()> {
// Setup:
let rocksdb_dir = path_to_export.join("rocksdb");
let storage = Storage::load(rocksdb_dir.clone(), 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 pre_upgrade_root_hash: RootHash = root_hash.into();
Expand Down Expand Up @@ -101,8 +100,9 @@ pub async fn migrate(
};

tracing::info!(?post_upgrade_root_hash, "post-upgrade root hash");

storage.release().await;

let rocksdb_dir = path_to_export.join("rocksdb");
let storage = Storage::load(rocksdb_dir, SUBSTORE_PREFIXES.to_vec()).await?;
let migrated_state = storage.latest_snapshot();

Expand Down

0 comments on commit 24210b4

Please sign in to comment.