Skip to content

Commit

Permalink
fix?
Browse files Browse the repository at this point in the history
  • Loading branch information
AmbientTea committed Mar 1, 2025
1 parent 43ab55c commit d52b374
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions node/node/src/inherent_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ where
)
.await?;

#[cfg(not(test))]
let payouts = BlockParticipationInherentDataProvider::new_cardano_stake_based(
client.as_ref(),
stake_distribution_data_source.as_ref(),
Expand All @@ -137,6 +138,16 @@ where
config.sc_slot_config.slot_duration,
)
.await?;
#[cfg(test)]
let payouts = BlockParticipationInherentDataProvider::new_cardano_stake_based_if_pallet_present(
client.as_ref(),
stake_distribution_data_source.as_ref(),
parent_hash,
*slot,
mc_epoch_config,
config.sc_slot_config.slot_duration,
)
.await?;

Ok((
slot,
Expand Down
31 changes: 31 additions & 0 deletions toolkit/primitives/block-participation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ pub mod inherent_data {
use core::error::Error;
use sidechain_domain::mainchain_epoch::*;
use sidechain_domain::*;
use sp_api::Core;
use sp_api::RuntimeApiInfo;
use sp_api::{ApiError, ProvideRuntimeApi};
use sp_inherents::{InherentData, InherentDataProvider};
use sp_runtime::traits::Block as BlockT;
Expand Down Expand Up @@ -151,6 +153,35 @@ pub mod inherent_data {
Beneficiary: From<DelegatorKey> + Ord + Debug,
BlockProducer: AsCardanoSPO,
{
pub async fn new_cardano_stake_based_if_pallet_present<Block: BlockT, T>(
client: &T,
data_source: &(dyn StakeDistributionDataSource + Send + Sync),
parent_hash: <Block as BlockT>::Hash,
current_slot: Slot,
mc_epoch_config: &MainchainEpochConfig,
slot_duration: SlotDuration,
) -> Result<Self, InherentDataCreationError<BlockProducer>>
where
T: ProvideRuntimeApi<Block> + Send + Sync,
T::Api: BlockParticipationApi<Block, BlockProducer>,
{
let version = client.runtime_api().version(parent_hash)?;
if version
.has_api_with(&<dyn BlockParticipationApi<Block, BlockProducer>>::ID, |_| true)
{
Self::new_cardano_stake_based(
client,
data_source,
parent_hash,
current_slot,
mc_epoch_config,
slot_duration,
)
.await
} else {
Ok(Self::Inert)
}
}
pub async fn new_cardano_stake_based<Block: BlockT, T>(
client: &T,
data_source: &(dyn StakeDistributionDataSource + Send + Sync),
Expand Down

0 comments on commit d52b374

Please sign in to comment.