Skip to content

Commit

Permalink
Trace entire plan
Browse files Browse the repository at this point in the history
  • Loading branch information
cronokirby committed Jan 23, 2025
1 parent cc73656 commit 82f32fa
Showing 1 changed file with 6 additions and 31 deletions.
37 changes: 6 additions & 31 deletions src/penumbra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use crate::{cometbft::Genesis, indexer::Indexer, storage::Storage as Archive};

mod v0o79;
mod v0o80;
mod v0o81;

#[async_trait]
trait Penumbra {
Expand All @@ -40,31 +39,24 @@ async fn make_a_penumbra(version: Version, working_dir: &Path) -> anyhow::Result
match version {
Version::V0o79 => Ok(Box::new(v0o79::Penumbra::load(working_dir).await?)),
Version::V0o80 => Ok(Box::new(v0o80::Penumbra::load(working_dir).await?)),
Version::V0o81 => Ok(Box::new(v0o81::Penumbra::load(working_dir).await?)),
}
}

#[derive(Debug, Clone, Copy, PartialEq)]
enum Version {
V0o79,
V0o80,
V0o81,
}

#[derive(Debug, Clone, Copy, PartialEq)]
enum RegenerationStep {
/// Represents a migration, as would be performed by `pd migrate`,
/// so munge node state on a planned upgrade boundary.
Migrate { from: Version, to: Version },
Migrate {
from: Version,
to: Version,
},
InitThenRunTo {
/// The `genesis_height` is the block at which the chain will resume, post-upgrade.
/// For reference, this is the same block specified in an `upgrade-plan` proposal,
/// as the `upgradePlan.height` field.
genesis_height: u64,
version: Version,
/// The `last_block` is the block immediately preceding a planned chain upgrade.
/// For reference, this is the block specified in an `upgrade-plan` proposal,
/// minus 1. For chains with no known upgrade, this should be `None`.
last_block: Option<u64>,
},
RunTo {
Expand Down Expand Up @@ -152,6 +144,7 @@ impl RegenerationStep {
///
/// This also makes the resulting logic in terms of creating and destroying penumbra applications
/// easier, because we know the given lifecycle of a version of the penumbra logic.
#[derive(Debug)]
struct RegenerationPlan {
pub steps: Vec<(u64, RegenerationStep)>,
}
Expand Down Expand Up @@ -201,7 +194,6 @@ impl RegenerationPlan {

Self {
steps: vec![
/*
(
0,
InitThenRunTo {
Expand All @@ -222,22 +214,6 @@ impl RegenerationPlan {
InitThenRunTo {
genesis_height: 501975,
version: V0o80,
last_block: Some(2611799),
},
),
*/
(
0,
Migrate {
from: V0o80,
to: V0o81,
},
),
(
2611799,
InitThenRunTo {
genesis_height: 2611800,
version: V0o81,
last_block: None,
},
),
Expand Down Expand Up @@ -286,7 +262,6 @@ impl Regenerator {
//
// It's regeneratin' time.
let metadata = self.find_current_metadata().await?;
tracing::info!(?metadata);
if let Some((_, chain_id)) = &metadata {
anyhow::ensure!(
chain_id.as_ref() == self.chain_id,
Expand Down Expand Up @@ -319,6 +294,7 @@ impl Regenerator {

async fn run_from(mut self, start: Option<u64>, stop: Option<u64>) -> anyhow::Result<()> {
let plan = RegenerationPlan::penumbra_1().truncate(start, stop);
tracing::info!("plan for {:?}..={:?}: {:?}", start, stop, plan);
for (start, step) in plan.steps.into_iter() {
use RegenerationStep::*;
match step {
Expand All @@ -345,7 +321,6 @@ impl Regenerator {
tracing::info!("regeneration step");
match to {
Version::V0o80 => v0o80::migrate(from, &self.working_dir).await?,
Version::V0o81 => v0o81::migrate(from, &self.working_dir).await?,
v => anyhow::bail!("impossible version {:?} to migrate from", v),
}
Ok(())
Expand Down

0 comments on commit 82f32fa

Please sign in to comment.