Skip to content

Commit

Permalink
fix(pd): use post-upgrade hash in migration
Browse files Browse the repository at this point in the history
  • Loading branch information
conorsch committed Aug 4, 2024
1 parent 09a822e commit 0481d9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion crates/bin/pd/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub enum Migration {
/// - Populate the DEX NV price idnexes with position data
Testnet78,
/// Mainnet-1 migration:
/// - Reset the halt bit
/// - Restore IBC packet commitments for improperly handled withdrawal attempts
Mainnet1,
}

Expand Down
8 changes: 3 additions & 5 deletions crates/bin/pd/src/migrate/mainnet1.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
//! Migration for shipping consensus-breaking IBC changes, fixing
//! how withdrawals from Penumbra to Noble are handled, and ensures that IBC
//! error messages from counterparty chains are processed.
//!
//! There's no state-altering logic in this migration: the migration simply
//! flips the halt bit off, permitting the chain to restart post-upgrade.
use cnidarium::Snapshot;
use cnidarium::{StateDelta, Storage};
use ibc_types::core::channel::{Packet, PortId};
Expand Down Expand Up @@ -102,6 +99,7 @@ pub async fn migrate(
.root_hash()
.await
.expect("chain state has a root hash");
// We obtain the pre-upgrade hash solely to log it as a result.
let pre_upgrade_root_hash: RootHash = root_hash.into();
let pre_upgrade_height = initial_state
.get_block_height()
Expand Down Expand Up @@ -139,7 +137,7 @@ pub async fn migrate(
..Default::default()
};
let mut genesis = NetworkConfig::make_genesis(app_state.clone()).expect("can make genesis");
genesis.app_hash = pre_upgrade_root_hash
genesis.app_hash = post_upgrade_root_hash
.0
.to_vec()
.try_into()
Expand All @@ -151,7 +149,7 @@ pub async fn migrate(
tracing::info!(%now, "no genesis time provided, detecting a testing setup");
now
});
let checkpoint = pre_upgrade_root_hash.0.to_vec();
let checkpoint = post_upgrade_root_hash.0.to_vec();
let genesis = NetworkConfig::make_checkpoint(genesis, Some(checkpoint));
let genesis_json = serde_json::to_string(&genesis).expect("can serialize genesis");
tracing::info!("genesis: {}", genesis_json);
Expand Down

0 comments on commit 0481d9e

Please sign in to comment.