Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pd): add --ready-to-start flag to pd migrate #4499

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
avahowell marked this conversation as resolved.
Show resolved Hide resolved
.instrument(pd_migrate_span)
Expand Down
Loading