-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a new migration, which resets the halt bit. No other migration logic is required, as no state-breaking changes are slated for testnet 77. This way, we preserve `pd migrate` as the default invocation for node operators. Also changed here are the APP_VERSION and corresponding docs entries. Refs #4497.
- Loading branch information
Showing
6 changed files
with
90 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//! Contains functions related to the migration script of Testnet77. | ||
//! The Testnet 77 release included several consensus-breaking changes, | ||
//! but no state-breaking changes, so the migration is essentially a no-op, | ||
//! other than resetting the halt bit. | ||
use anyhow; | ||
use cnidarium::Storage; | ||
use jmt::RootHash; | ||
use penumbra_app::app::StateReadExt as _; | ||
use penumbra_sct::component::clock::EpochRead; | ||
use std::path::PathBuf; | ||
use tracing::instrument; | ||
|
||
use crate::testnet::generate::TestnetConfig; | ||
|
||
/// Run the full migration, given an export path and a start time for genesis. | ||
/// | ||
/// Menu: | ||
/// - Reconstruct a correct VCB balance for the auction component. | ||
#[instrument] | ||
pub async fn migrate( | ||
storage: Storage, | ||
pd_home: PathBuf, | ||
genesis_start: Option<tendermint::time::Time>, | ||
) -> anyhow::Result<()> { | ||
// Setup: | ||
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 = initial_state | ||
.get_block_height() | ||
.await | ||
.expect("chain state has a block height"); | ||
let post_upgrade_height = pre_upgrade_height.wrapping_add(1); | ||
storage.release().await; | ||
|
||
// 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 app_state = penumbra_app::genesis::Content { | ||
chain_id, | ||
..Default::default() | ||
}; | ||
let mut genesis = TestnetConfig::make_genesis(app_state.clone()).expect("can make genesis"); | ||
genesis.app_hash = pre_upgrade_root_hash | ||
.0 | ||
.to_vec() | ||
.try_into() | ||
.expect("infallible conversion"); | ||
|
||
genesis.initial_height = post_upgrade_height as i64; | ||
genesis.genesis_time = genesis_start.unwrap_or_else(|| { | ||
let now = tendermint::time::Time::now(); | ||
tracing::info!(%now, "no genesis time provided, detecting a testing setup"); | ||
now | ||
}); | ||
let checkpoint = pre_upgrade_root_hash.0.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); | ||
let genesis_path = pd_home.join("genesis.json"); | ||
std::fs::write(genesis_path, genesis_json).expect("can write genesis"); | ||
|
||
let validator_state_path = pd_home.join("priv_validator_state.json"); | ||
let fresh_validator_state = crate::testnet::generate::TestnetValidator::initial_state(); | ||
std::fs::write(validator_state_path, fresh_validator_state).expect("can write validator state"); | ||
|
||
tracing::info!( | ||
pre_upgrade_height, | ||
?pre_upgrade_root_hash, | ||
"successful migration!" | ||
); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters