Skip to content

Commit

Permalink
feat(pd): add --ready-to-start flag to pd migrate
Browse files Browse the repository at this point in the history
Adds a new flag to `pd migrate --ready-to-start` that makes an in-place
edit to local state, setting an enabled halt bit to false.

Refs #4494.
  • Loading branch information
conorsch committed May 30, 2024
1 parent 58b389b commit 47dbb9a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
6 changes: 6 additions & 0 deletions crates/bin/pd/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ pub enum RootCommand {
/// If set, force a migration to occur even if the chain is not halted.
#[clap(long, display_order = 1000)]
force: bool,
/// If set, edit local state to to permit the node to start, despite
/// a pre-existing halt order, e.g. via governance. This option
/// can be useful for relayer operators, to run a temporary archive node
/// across upgrade boundaries.
#[clap(long, display_order = 1000)]
ready_to_start: bool,
},
}

Expand Down
18 changes: 15 additions & 3 deletions crates/bin/pd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use cnidarium::Storage;
use metrics_exporter_prometheus::PrometheusBuilder;
use pd::{
cli::{Opt, RootCommand, TestnetCommand},
migrate::Migration::Testnet76,
migrate::Migration::{ReadyToStart, Testnet76},
testnet::{
config::{get_testnet_dir, parse_tm_address, url_has_necessary_parts},
generate::TestnetConfig,
Expand Down Expand Up @@ -431,6 +431,7 @@ async fn main() -> anyhow::Result<()> {
home,
comet_home,
force,
ready_to_start,
} => {
let (pd_home, comet_home) = match home {
Some(h) => (h, comet_home),
Expand All @@ -441,11 +442,22 @@ async fn main() -> anyhow::Result<()> {
(base.join("pd"), Some(base.join("cometbft")))
}
};
let genesis_start = pd::migrate::last_block_timestamp(pd_home.clone()).await?;
tracing::info!(?genesis_start, "last block timestamp");
let pd_migrate_span = tracing::error_span!("pd_migrate");
pd_migrate_span
.in_scope(|| tracing::info!("migrating pd state in {}", pd_home.display()));

if ready_to_start {
tracing::info!("disabling halt order in local state");
ReadyToStart
.migrate(pd_home, comet_home, None, force)
.instrument(pd_migrate_span)
.await
.context("failed to disable halt bit in local state")?;
exit(0)
}

let genesis_start = pd::migrate::last_block_timestamp(pd_home.clone()).await?;
tracing::info!(?genesis_start, "last block timestamp");
Testnet76
.migrate(pd_home.clone(), comet_home, Some(genesis_start), force)
.instrument(pd_migrate_span)
Expand Down

0 comments on commit 47dbb9a

Please sign in to comment.