From 53fc386ce1f1ec6034fffd50bcb82922d30995ab Mon Sep 17 00:00:00 2001 From: Gonza Montiel Date: Sun, 7 Sep 2025 14:35:21 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=94=A7=20=20implement=20babe=20ran?= =?UTF-8?q?domness=20for=20BabeDataGetter=20(#148)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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> --- operator/runtime/mainnet/src/configs/storagehub/mod.rs | 8 +++++--- operator/runtime/stagenet/src/configs/storagehub/mod.rs | 6 +++--- operator/runtime/testnet/src/configs/storagehub/mod.rs | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/operator/runtime/mainnet/src/configs/storagehub/mod.rs b/operator/runtime/mainnet/src/configs/storagehub/mod.rs index 6edbb8ea..9389d2c5 100644 --- a/operator/runtime/mainnet/src/configs/storagehub/mod.rs +++ b/operator/runtime/mainnet/src/configs/storagehub/mod.rs @@ -109,13 +109,15 @@ impl pallet_randomness::Config for Runtime { pub struct BabeDataGetter; impl pallet_randomness::GetBabeData for BabeDataGetter { fn get_epoch_index() -> u64 { - todo!("implement `get_epoch_index`"); + pallet_babe::Pallet::::current_epoch().epoch_index } fn get_epoch_randomness() -> Hash { - todo!("implement `get_epoch_randomness`"); + sp_core::H256::from(pallet_babe::Pallet::::current_epoch().randomness) } fn get_parent_randomness() -> Hash { - todo!("implement `get_parent_randomness`"); + sp_core::H256::from( + pallet_babe::Pallet::::author_vrf_randomness().unwrap_or_default(), + ) } } diff --git a/operator/runtime/stagenet/src/configs/storagehub/mod.rs b/operator/runtime/stagenet/src/configs/storagehub/mod.rs index 6edbb8ea..312040bc 100644 --- a/operator/runtime/stagenet/src/configs/storagehub/mod.rs +++ b/operator/runtime/stagenet/src/configs/storagehub/mod.rs @@ -109,13 +109,13 @@ impl pallet_randomness::Config for Runtime { pub struct BabeDataGetter; impl pallet_randomness::GetBabeData for BabeDataGetter { fn get_epoch_index() -> u64 { - todo!("implement `get_epoch_index`"); + pallet_babe::Pallet::::current_epoch().epoch_index } fn get_epoch_randomness() -> Hash { - todo!("implement `get_epoch_randomness`"); + sp_core::H256::from(pallet_babe::Pallet::::current_epoch().randomness) } fn get_parent_randomness() -> Hash { - todo!("implement `get_parent_randomness`"); + sp_core::H256::from(pallet_babe::Pallet::::current_epoch().randomness) } } diff --git a/operator/runtime/testnet/src/configs/storagehub/mod.rs b/operator/runtime/testnet/src/configs/storagehub/mod.rs index 6edbb8ea..312040bc 100644 --- a/operator/runtime/testnet/src/configs/storagehub/mod.rs +++ b/operator/runtime/testnet/src/configs/storagehub/mod.rs @@ -109,13 +109,13 @@ impl pallet_randomness::Config for Runtime { pub struct BabeDataGetter; impl pallet_randomness::GetBabeData for BabeDataGetter { fn get_epoch_index() -> u64 { - todo!("implement `get_epoch_index`"); + pallet_babe::Pallet::::current_epoch().epoch_index } fn get_epoch_randomness() -> Hash { - todo!("implement `get_epoch_randomness`"); + sp_core::H256::from(pallet_babe::Pallet::::current_epoch().randomness) } fn get_parent_randomness() -> Hash { - todo!("implement `get_parent_randomness`"); + sp_core::H256::from(pallet_babe::Pallet::::current_epoch().randomness) } }