diff --git a/crates/bin/pd/src/consensus.rs b/crates/bin/pd/src/consensus.rs index 78cbb9050f..681b8080b4 100644 --- a/crates/bin/pd/src/consensus.rs +++ b/crates/bin/pd/src/consensus.rs @@ -98,16 +98,18 @@ impl Consensus { match &app_state { genesis::AppState::Checkpoint(h) => { println!("checkpoint: {h:?}"); + // finalize a compact block + // start an epoch? /* fast-forward to commit */ } - genesis::AppState::Content(_) => { + genesis::AppState::Content(genesis_app_state) => { /* run application init_chain */ // Check that we haven't got a duplicated InitChain message for some reason: if self.storage.latest_version() != u64::MAX { anyhow::bail!("database already initialized"); } - self.app.init_chain(&app_state).await; + self.app.init_chain(&genesis_app_state).await; } } diff --git a/crates/core/app/src/app/mod.rs b/crates/core/app/src/app/mod.rs index 02422993b5..a8406df3a5 100644 --- a/crates/core/app/src/app/mod.rs +++ b/crates/core/app/src/app/mod.rs @@ -78,13 +78,7 @@ impl App { events } - pub async fn init_chain(&mut self, app_state_general: &genesis::AppState) { - let app_state = match app_state_general { - genesis::AppState::Checkpoint(_) => { - unimplemented!("adding support with init handshake pr") - } - genesis::AppState::Content(state) => state, - }; + pub async fn init_chain(&mut self, app_state: &genesis::Content) { let mut state_tx = self .state .try_begin_transaction() @@ -117,12 +111,12 @@ impl App { }, ); - Distributions::init_chain(&mut state_tx, app_state_general).await; - Staking::init_chain(&mut state_tx, app_state_general).await; + Distributions::init_chain(&mut state_tx, app_state).await; + Staking::init_chain(&mut state_tx, app_state).await; IBCComponent::init_chain(&mut state_tx, &()).await; Dex::init_chain(&mut state_tx, &()).await; Governance::init_chain(&mut state_tx, &()).await; - ShieldedPool::init_chain(&mut state_tx, app_state_general).await; + ShieldedPool::init_chain(&mut state_tx, app_state).await; // Create a synthetic height-zero block App::finish_block(&mut state_tx).await; diff --git a/crates/core/app/src/temp_storage_ext.rs b/crates/core/app/src/temp_storage_ext.rs index 69ba1726d4..36b67ad7b9 100644 --- a/crates/core/app/src/temp_storage_ext.rs +++ b/crates/core/app/src/temp_storage_ext.rs @@ -8,13 +8,13 @@ use crate::app::App; #[async_trait] pub trait TempStorageExt: Sized { - async fn apply_genesis(self, genesis: genesis::AppState) -> anyhow::Result; + async fn apply_genesis(self, genesis: genesis::Content) -> anyhow::Result; async fn apply_default_genesis(self) -> anyhow::Result; } #[async_trait] impl TempStorageExt for TempStorage { - async fn apply_genesis(self, genesis: genesis::AppState) -> anyhow::Result { + async fn apply_genesis(self, genesis: genesis::Content) -> anyhow::Result { // Check that we haven't already applied a genesis state: if self.latest_version() != u64::MAX { anyhow::bail!("database already initialized"); diff --git a/crates/core/component/distributions/src/component.rs b/crates/core/component/distributions/src/component.rs index 6475c011bb..ad8c73f01a 100644 --- a/crates/core/component/distributions/src/component.rs +++ b/crates/core/component/distributions/src/component.rs @@ -16,7 +16,7 @@ pub struct Distributions {} #[async_trait] impl Component for Distributions { - type AppState = genesis::AppState; + type AppState = genesis::Content; async fn init_chain(_state: S, _app_state: &Self::AppState) {} diff --git a/crates/core/component/shielded-pool/src/component/shielded_pool.rs b/crates/core/component/shielded-pool/src/component/shielded_pool.rs index 4f613df861..bb9678e367 100644 --- a/crates/core/component/shielded-pool/src/component/shielded_pool.rs +++ b/crates/core/component/shielded-pool/src/component/shielded_pool.rs @@ -20,17 +20,10 @@ pub struct ShieldedPool {} #[async_trait] impl Component for ShieldedPool { - type AppState = genesis::AppState; + type AppState = genesis::Content; #[instrument(name = "shielded_pool", skip(state, app_state))] - async fn init_chain(mut state: S, app_state: &genesis::AppState) { - let app_state = match app_state { - genesis::AppState::Checkpoint(_) => { - unimplemented!("adding support with init handshake pr") - } - genesis::AppState::Content(app_state) => app_state, - }; - + async fn init_chain(mut state: S, app_state: &genesis::Content) { // Register a denom for each asset in the genesis state for allocation in &app_state.allocations { tracing::debug!(?allocation, "processing allocation"); diff --git a/crates/core/component/stake/src/component.rs b/crates/core/component/stake/src/component.rs index 822723dcc4..2546f323f6 100644 --- a/crates/core/component/stake/src/component.rs +++ b/crates/core/component/stake/src/component.rs @@ -889,17 +889,10 @@ impl StakingImpl for T {} #[async_trait] impl Component for Staking { - type AppState = genesis::AppState; + type AppState = genesis::Content; #[instrument(name = "staking", skip(state, app_state))] - async fn init_chain(mut state: S, app_state: &genesis::AppState) { - let app_state = match app_state { - genesis::AppState::Checkpoint(_) => { - unimplemented!("adding support with init handshake pr") - } - genesis::AppState::Content(state) => state, - }; - + async fn init_chain(mut state: S, app_state: &genesis::Content) { let starting_height = state .get_block_height() .await