fix: 🔧 implement babe randomness for BabeDataGetter (#148)

Since we are including Storage Hub pallets and we no longer hide the
compilation behind a feature flag, the tests started to fail because the
nodes where panic!ing on each block finalisation.

---------

Co-authored-by: Steve Degosserie <723552+stiiifff@users.noreply.github.com>
This commit is contained in:
Gonza Montiel 2025-09-07 14:35:21 +02:00 committed by GitHub
parent 757a99b7c6
commit 53fc386ce1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 9 deletions

View file

@ -109,13 +109,15 @@ impl pallet_randomness::Config for Runtime {
pub struct BabeDataGetter;
impl pallet_randomness::GetBabeData<u64, Hash> for BabeDataGetter {
fn get_epoch_index() -> u64 {
todo!("implement `get_epoch_index`");
pallet_babe::Pallet::<Runtime>::current_epoch().epoch_index
}
fn get_epoch_randomness() -> Hash {
todo!("implement `get_epoch_randomness`");
sp_core::H256::from(pallet_babe::Pallet::<Runtime>::current_epoch().randomness)
}
fn get_parent_randomness() -> Hash {
todo!("implement `get_parent_randomness`");
sp_core::H256::from(
pallet_babe::Pallet::<Runtime>::author_vrf_randomness().unwrap_or_default(),
)
}
}

View file

@ -109,13 +109,13 @@ impl pallet_randomness::Config for Runtime {
pub struct BabeDataGetter;
impl pallet_randomness::GetBabeData<u64, Hash> for BabeDataGetter {
fn get_epoch_index() -> u64 {
todo!("implement `get_epoch_index`");
pallet_babe::Pallet::<Runtime>::current_epoch().epoch_index
}
fn get_epoch_randomness() -> Hash {
todo!("implement `get_epoch_randomness`");
sp_core::H256::from(pallet_babe::Pallet::<Runtime>::current_epoch().randomness)
}
fn get_parent_randomness() -> Hash {
todo!("implement `get_parent_randomness`");
sp_core::H256::from(pallet_babe::Pallet::<Runtime>::current_epoch().randomness)
}
}

View file

@ -109,13 +109,13 @@ impl pallet_randomness::Config for Runtime {
pub struct BabeDataGetter;
impl pallet_randomness::GetBabeData<u64, Hash> for BabeDataGetter {
fn get_epoch_index() -> u64 {
todo!("implement `get_epoch_index`");
pallet_babe::Pallet::<Runtime>::current_epoch().epoch_index
}
fn get_epoch_randomness() -> Hash {
todo!("implement `get_epoch_randomness`");
sp_core::H256::from(pallet_babe::Pallet::<Runtime>::current_epoch().randomness)
}
fn get_parent_randomness() -> Hash {
todo!("implement `get_parent_randomness`");
sp_core::H256::from(pallet_babe::Pallet::<Runtime>::current_epoch().randomness)
}
}