Skip to content

Commit

Permalink
Merge pull request #25 from penumbra-zone/cronokirby/testnets
Browse files Browse the repository at this point in the history
Dynamically choose which plan to run based on archive chain id
  • Loading branch information
conorsch authored Jan 28, 2025
2 parents 099b16d + b5fad45 commit 850647d
Showing 1 changed file with 47 additions and 2 deletions.
49 changes: 47 additions & 2 deletions src/penumbra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,48 @@ impl RegenerationPlan {
Self { steps }
}

/// Some regeneration plans are pre-specified, by a chain id.
pub fn from_known_chain_id(chain_id: &str) -> Option<Self> {
match chain_id {
"penumbra-1" => Some(Self::penumbra_1()),
"penumbra-testnet-phobos-2" => Some(Self::penumbra_testnet_phobos_2()),
_ => None,
}
}

pub fn penumbra_testnet_phobos_2() -> Self {
use RegenerationStep::*;
use Version::*;

Self {
steps: vec![
(
0,
InitThenRunTo {
genesis_height: 1,
version: V0o80,
last_block: Some(1459799),
},
),
(
1459799,
Migrate {
from: V0o80,
to: V0o81,
},
),
(
1459799,
InitThenRunTo {
genesis_height: 1459800,
version: V0o80,
last_block: None,
},
),
],
}
}

/// The regeneration plan for penumbra_1 chain.
pub fn penumbra_1() -> Self {
use RegenerationStep::*;
Expand Down Expand Up @@ -316,9 +358,12 @@ impl Regenerator {
}

async fn run_from(mut self, start: Option<u64>, stop: Option<u64>) -> anyhow::Result<()> {
let plan = RegenerationPlan::penumbra_1().truncate(start, stop);
let plan = RegenerationPlan::from_known_chain_id(&self.chain_id)
.map(|x| x.truncate(start, stop))
.ok_or(anyhow!("no plan known for chain id '{}'", &self.chain_id))?;
tracing::info!(
"plan truncated between {:?}..={:?}: {:?}",
"plan for {} truncated between {:?}..={:?}: {:?}",
&self.chain_id,
start,
stop,
plan
Expand Down

0 comments on commit 850647d

Please sign in to comment.