Skip to content

Commit

Permalink
A0-0000: Use parent hash as seed (#1928)
Browse files Browse the repository at this point in the history
# Description

Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.

## Type of change

Please delete options that are not relevant.

- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing
functionality to not work as expected)

# Checklist:

<!-- delete when not applicable to your PR -->

- I have added tests
- I have made neccessary updates to the Infrastructure
- I have made corresponding changes to the existing documentation
- I have created new documentation
- I have bumped `spec_version` and `transaction_version`
- I have bumped aleph-client version if relevant

---------

Co-authored-by: Michal Swietek <[email protected]>
  • Loading branch information
mike1729 and mike1729 authored Feb 5, 2025
1 parent d3c3a67 commit 8abd4a4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pallets/elections/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ where
T: Config,
{
fn populate_next_era_validators_on_next_era_start(era: EraIndex) {
let mut rng = Pcg32::seed_from_u64(era as u64);
let parent_hash = frame_system::Pallet::<T>::parent_hash();
let mut bytes = [0u8; 8];
bytes.clone_from_slice(&parent_hash.as_ref()[..8]);
let seed = u64::from_le_bytes(bytes);

let mut rng = Pcg32::seed_from_u64(seed);
let elected_committee = BTreeSet::from_iter(T::ValidatorProvider::elected_validators(era));

let mut retain_shuffle_elected = |vals: Vec<T::AccountId>| -> Vec<T::AccountId> {
Expand Down

0 comments on commit 8abd4a4

Please sign in to comment.