Skip to content

Commit

Permalink
assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
AmbientTea committed Feb 24, 2025
1 parent b44cddc commit b6410a8
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions node/node/src/inherent_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use sp_block_production_log::BlockProducerIdInherentProvider;
use sp_block_production_log::BlockProductionLogApi;
use sp_block_rewards::BlockBeneficiaryInherentProvider;
use sp_blockchain::HeaderBackend;
use sp_consensus_aura::AuraApi;
use sp_consensus_aura::{
inherents::InherentDataProvider as AuraIDP, sr25519::AuthorityPair as AuraPair, Slot,
};
Expand All @@ -45,6 +46,7 @@ pub struct ProposalCIDP<T> {
native_token_data_source: Arc<dyn NativeTokenManagementDataSource + Send + Sync>,
}

use sp_consensus_aura::sr25519::AuthorityId as AuraId;
#[async_trait]
impl<T> CreateInherentDataProviders<Block, ()> for ProposalCIDP<T>
where
Expand All @@ -58,6 +60,7 @@ where
>,
T::Api: NativeTokenManagementApi<Block>,
T::Api: BlockProductionLogApi<Block, CommitteeMember<CrossChainPublic, SessionKeys>>,
T::Api: AuraApi<Block, AuraId>,
{
type InherentDataProviders = (
AuraIDP,
Expand Down Expand Up @@ -117,6 +120,24 @@ where
)
.await?;

// temporary for testing purposes
let previous_header = client.expect_header(parent_hash)?;
if previous_header.digest().clone().pop().is_some() {
use sc_consensus_aura::standalone::*;
use sp_session_validator_management::CommitteeMember;

let previous_slot = client.runtime_api().get_current_slot(parent_hash)?;
let authorities = client.runtime_api().authorities(parent_hash)?;

let slot_author_according_to_aura =
slot_author::<AuraPair>(previous_slot, &authorities).unwrap();

let slot_author_according_to_palelt =
client.runtime_api().get_current_author(parent_hash)?.authority_keys().aura;

assert_eq!(*slot_author_according_to_aura, slot_author_according_to_palelt);
}

Ok((
slot,
timestamp,
Expand Down

0 comments on commit b6410a8

Please sign in to comment.