From b6410a820a44a6bee599f02bbed532a827784a0b Mon Sep 17 00:00:00 2001 From: Nikolaos Dymitriadis Date: Sat, 22 Feb 2025 00:30:40 +0100 Subject: [PATCH] assertion --- node/node/src/inherent_data.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/node/node/src/inherent_data.rs b/node/node/src/inherent_data.rs index 214bfeeb3..796f0ea99 100644 --- a/node/node/src/inherent_data.rs +++ b/node/node/src/inherent_data.rs @@ -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, }; @@ -45,6 +46,7 @@ pub struct ProposalCIDP { native_token_data_source: Arc, } +use sp_consensus_aura::sr25519::AuthorityId as AuraId; #[async_trait] impl CreateInherentDataProviders for ProposalCIDP where @@ -58,6 +60,7 @@ where >, T::Api: NativeTokenManagementApi, T::Api: BlockProductionLogApi>, + T::Api: AuraApi, { type InherentDataProviders = ( AuraIDP, @@ -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::(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,