Is it possible to get the list of validators which validate a particular block?
For instance, let's say we have at block 10 and if this block is finalised then I need to find the list of validators who approved this 10th block.
Is it possible to get the list of validators which validate a particular block?
For instance, let's say we have at block 10 and if this block is finalised then I need to find the list of validators who approved this 10th block.
In polkadot the author index should be found in the digest like you can see this code in BABE:
impl<T: Config> FindAuthor<u32> for Pallet<T> { fn find_author<'a, I>(digests: I) -> Option<u32> where I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>, { for (id, mut data) in digests.into_iter() { if id == BABE_ENGINE_ID { let pre_digest: PreDigest = PreDigest::decode(&mut data).ok()?; return Some(pre_digest.authority_index()) } } None } } Then authority index is the index of the author in the validator set. The validator set can be found in the storage of the session pallet. The storage is Validators in the pallet session.
For inspiration you can this code in session:
impl<T: Config, Inner: FindAuthor<u32>> FindAuthor<T::ValidatorId> for FindAccountFromAuthorIndex<T, Inner> { fn find_author<'a, I>(digests: I) -> Option<T::ValidatorId> where I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>, { let i = Inner::find_author(digests)?; let validators = <Pallet<T>>::validators(); validators.get(i as usize).cloned() } } That said maybe tools have function implemented already to get it more easily.
If you want to know the list of active validators, I can see this on Polkadot.js under developer -> chain state -> storage -> session -> validators(). It also looks like you can provide a block hash to query the chain as of a specific block.