diff --git a/crates/bin/pd/src/cli.rs b/crates/bin/pd/src/cli.rs index 06374cd32f..e41b953b5b 100644 --- a/crates/bin/pd/src/cli.rs +++ b/crates/bin/pd/src/cli.rs @@ -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, }, } diff --git a/crates/bin/pd/src/main.rs b/crates/bin/pd/src/main.rs index 493a68135a..33c07f3415 100644 --- a/crates/bin/pd/src/main.rs +++ b/crates/bin/pd/src/main.rs @@ -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, @@ -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), @@ -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)