diff --git a/crates/core/component/community-pool/src/component.rs b/crates/core/component/community-pool/src/component.rs index e34a13c8fe..55756cb3dd 100644 --- a/crates/core/component/community-pool/src/component.rs +++ b/crates/core/component/community-pool/src/component.rs @@ -26,8 +26,8 @@ impl Component for CommunityPool { #[instrument(name = "community_pool", skip(state, app_state))] async fn init_chain(mut state: S, app_state: Option<&Self::AppState>) { match app_state { - Some(content) => { - state.put_community_pool_params(content.community_pool_params.clone()); + Some(genesis) => { + state.put_community_pool_params(genesis.community_pool_params.clone()); } None => {} } diff --git a/crates/core/component/distributions/src/component.rs b/crates/core/component/distributions/src/component.rs index bd37fa8fc0..7d7a3e01d7 100644 --- a/crates/core/component/distributions/src/component.rs +++ b/crates/core/component/distributions/src/component.rs @@ -26,8 +26,8 @@ impl Component for Distributions { async fn init_chain(mut state: S, app_state: Option<&Self::AppState>) { match app_state { None => { /* Checkpoint -- no-op */ } - Some(content) => { - state.put_distributions_params(content.distributions_params.clone()); + Some(genesis) => { + state.put_distributions_params(genesis.distributions_params.clone()); } }; } diff --git a/crates/core/component/fee/src/component.rs b/crates/core/component/fee/src/component.rs index 4586ec2d3e..d7827647b0 100644 --- a/crates/core/component/fee/src/component.rs +++ b/crates/core/component/fee/src/component.rs @@ -2,7 +2,7 @@ mod view; use std::sync::Arc; -use crate::{genesis::Content, state_key}; +use crate::{genesis, state_key}; use async_trait::async_trait; use cnidarium::StateWrite; use cnidarium_component::Component; @@ -15,10 +15,10 @@ pub struct Fee {} #[async_trait] impl Component for Fee { - type AppState = Content; + type AppState = genesis::Content; #[instrument(name = "staking", skip(state, app_state))] - async fn init_chain(mut state: S, app_state: Option<&Content>) { + async fn init_chain(mut state: S, app_state: Option<&Self::AppState>) { match app_state { Some(genesis) => { state.put_fee_params(genesis.fee_params.clone()); diff --git a/crates/core/component/funding/src/component.rs b/crates/core/component/funding/src/component.rs index e106bc06c4..8e33620da5 100644 --- a/crates/core/component/funding/src/component.rs +++ b/crates/core/component/funding/src/component.rs @@ -11,13 +11,13 @@ use cnidarium_component::Component; use tendermint::v0_37::abci; use tracing::instrument; -use crate::genesis::Content; +use crate::genesis; pub struct Funding {} #[async_trait] impl Component for Funding { - type AppState = Content; + type AppState = genesis::Content; #[instrument(name = "funding", skip(state, app_state))] async fn init_chain(mut state: S, app_state: Option<&Self::AppState>) { diff --git a/crates/core/component/governance/src/component.rs b/crates/core/component/governance/src/component.rs index d053fbb139..7c08cf5bf9 100644 --- a/crates/core/component/governance/src/component.rs +++ b/crates/core/component/governance/src/component.rs @@ -34,8 +34,8 @@ impl Component for Governance { #[instrument(name = "governance", skip(state, app_state))] async fn init_chain(mut state: S, app_state: Option<&Self::AppState>) { match app_state { - Some(content) => { - state.put_governance_params(content.governance_params.clone()); + Some(genesis) => { + state.put_governance_params(genesis.governance_params.clone()); // Clients need to be able to read the next proposal number, even when no proposals have // been submitted yet state.init_proposal_counter(); diff --git a/crates/core/component/ibc/src/component/ibc_component.rs b/crates/core/component/ibc/src/component/ibc_component.rs index 7fb00473b2..8e5488cd73 100644 --- a/crates/core/component/ibc/src/component/ibc_component.rs +++ b/crates/core/component/ibc/src/component/ibc_component.rs @@ -17,6 +17,9 @@ use super::HostInterface; pub struct Ibc {} +// Note: [`Ibc`] does not implement the [`cnidarium_component::Component`] trait +// this is because we want to have a bound on [`HostInterface`] in the `begin_block` +// processing. impl Ibc { #[instrument(name = "ibc", skip(state, app_state))] pub async fn init_chain(mut state: S, app_state: Option<&genesis::Content>) { 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 a969df9380..41b71ecc68 100644 --- a/crates/core/component/shielded-pool/src/component/shielded_pool.rs +++ b/crates/core/component/shielded-pool/src/component/shielded_pool.rs @@ -1,5 +1,6 @@ use std::sync::Arc; +use crate::genesis; use anyhow::Result; use async_trait::async_trait; use cnidarium::StateWrite; @@ -8,23 +9,21 @@ use penumbra_sct::CommitmentSource; use tendermint::v0_37::abci; use tracing::instrument; -use crate::genesis::Content as GenesisContent; - use super::{NoteManager, SupplyWrite}; pub struct ShieldedPool {} #[async_trait] impl Component for ShieldedPool { - type AppState = GenesisContent; + type AppState = genesis::Content; #[instrument(name = "shielded_pool", skip(state, app_state))] - async fn init_chain(mut state: S, app_state: Option<&GenesisContent>) { + async fn init_chain(mut state: S, app_state: Option<&Self::AppState>) { match app_state { None => { /* Checkpoint -- no-op */ } - Some(app_state) => { + Some(genesis) => { // Register a denom for each asset in the genesis state - for allocation in &app_state.allocations { + for allocation in &genesis.allocations { tracing::debug!(?allocation, "processing allocation"); assert_ne!( allocation.raw_amount, diff --git a/crates/core/component/stake/src/component.rs b/crates/core/component/stake/src/component.rs index eb8631c25e..48d7260664 100644 --- a/crates/core/component/stake/src/component.rs +++ b/crates/core/component/stake/src/component.rs @@ -31,7 +31,6 @@ use penumbra_proto::{state::future::DomainFuture, StateReadProto, StateWriteProt use penumbra_sct::CommitmentSource; use penumbra_shielded_pool::{ component::{NoteManager, SupplyRead, SupplyWrite}, - genesis::Content as ShieldedPoolGenesisContent, }; use sha2::{Digest, Sha256}; use tendermint::validator::Update; @@ -47,7 +46,6 @@ use tracing::{instrument, Instrument}; use crate::{ funding_stream::Recipient, - genesis::Content as GenesisContent, params::StakeParameters, rate::{BaseRateData, RateData}, state_key, @@ -1128,16 +1126,16 @@ impl StakingImpl for T {} #[async_trait] impl Component for Staking { - type AppState = (GenesisContent, ShieldedPoolGenesisContent); + type AppState = ( + crate::genesis::Content, + penumbra_shielded_pool::genesis::Content, + ); #[instrument(name = "staking", skip(state, app_state))] - async fn init_chain( - mut state: S, - app_state: Option<&(GenesisContent, ShieldedPoolGenesisContent)>, - ) { + async fn init_chain(mut state: S, app_state: Option<&Self::AppState>) { match app_state { - Some((staking_app_state, shielded_pool_app_state)) => { - state.put_stake_params(staking_app_state.stake_params.clone()); + Some((staking_genesis, sp_genesis)) => { + state.put_stake_params(staking_genesis.stake_params.clone()); let starting_height = state .get_block_height() @@ -1159,7 +1157,7 @@ impl Component for Staking { // Compile totals of genesis allocations by denom, which we can use // to compute the delegation tokens for each validator. let mut genesis_allocations = BTreeMap::<_, Amount>::new(); - for allocation in &shielded_pool_app_state.allocations { + for allocation in &sp_genesis.allocations { let value = allocation.value(); *genesis_allocations.entry(value.asset_id).or_default() += value.amount; } @@ -1167,7 +1165,7 @@ impl Component for Staking { // Add initial validators to the JMT // Validators are indexed in the JMT by their public key, // and there is a separate key containing the list of all validator keys. - for validator in &staking_app_state.validators { + for validator in &staking_genesis.validators { // Parse the proto into a domain type. let validator = Validator::try_from(validator.clone()) .expect("should be able to parse genesis validator");