@@ -1074,85 +1074,6 @@ impl pallet_moonbeam_orbiters::Config for Runtime {
10741074 type WeightInfo = pallet_moonbeam_orbiters:: weights:: SubstrateWeight < Runtime > ;
10751075}
10761076
1077- /// Only callable after `set_validation_data` is called which forms this proof the same way
1078- fn relay_chain_state_proof ( ) -> RelayChainStateProof {
1079- let relay_storage_root = ParachainSystem :: validation_data ( )
1080- . expect ( "set in `set_validation_data`" )
1081- . relay_parent_storage_root ;
1082- let relay_chain_state =
1083- ParachainSystem :: relay_state_proof ( ) . expect ( "set in `set_validation_data`" ) ;
1084- RelayChainStateProof :: new ( ParachainInfo :: get ( ) , relay_storage_root, relay_chain_state)
1085- . expect ( "Invalid relay chain state proof, already constructed in `set_validation_data`" )
1086- }
1087-
1088- pub struct BabeDataGetter ;
1089- impl pallet_randomness:: GetBabeData < BlockNumber , u64 , Option < Hash > > for BabeDataGetter {
1090- // Tolerate panic here because only ever called in inherent (so can be omitted)
1091- fn get_relay_block_number ( ) -> BlockNumber {
1092- ParachainSystem :: validation_data ( )
1093- . expect ( "set in `set_validation_data`inherent => available before on_initialize" )
1094- . relay_parent_number
1095- }
1096- // Tolerate panic here because only ever called in inherent (so can be omitted)
1097- fn get_relay_epoch_index ( ) -> u64 {
1098- relay_chain_state_proof ( )
1099- . read_optional_entry ( relay_chain:: well_known_keys:: EPOCH_INDEX )
1100- . ok ( )
1101- . flatten ( )
1102- . unwrap_or_default ( )
1103- // TODO: add back panic, only removing for testing now
1104- //.expect("expected to be able to read epoch index from relay chain state proof")
1105- }
1106- fn get_current_block_randomness ( ) -> Option < Hash > {
1107- relay_chain_state_proof ( )
1108- . read_optional_entry ( relay_chain:: well_known_keys:: CURRENT_BLOCK_RANDOMNESS )
1109- . ok ( )
1110- . flatten ( )
1111- }
1112- fn get_one_epoch_ago_randomness ( ) -> Option < Hash > {
1113- relay_chain_state_proof ( )
1114- . read_optional_entry ( relay_chain:: well_known_keys:: ONE_EPOCH_AGO_RANDOMNESS )
1115- . ok ( )
1116- . flatten ( )
1117- }
1118- fn get_two_epochs_ago_randomness ( ) -> Option < Hash > {
1119- relay_chain_state_proof ( )
1120- . read_optional_entry ( relay_chain:: well_known_keys:: TWO_EPOCHS_AGO_RANDOMNESS )
1121- . ok ( )
1122- . flatten ( )
1123- }
1124- }
1125-
1126- pub struct VrfInputGetter ;
1127- impl pallet_randomness:: GetVrfInput < pallet_randomness:: VrfInput < Slot , Hash > > for VrfInputGetter {
1128- fn get_vrf_input ( ) -> pallet_randomness:: VrfInput < Slot , Hash > {
1129- pallet_randomness:: VrfInput {
1130- slot_number : relay_chain_state_proof ( )
1131- . read_slot ( )
1132- . expect ( "CheckInherents reads slot from state proof QED" ) ,
1133- storage_root : ParachainSystem :: validation_data ( )
1134- . expect ( "set in `set_validation_data`inherent => available before on_initialize" )
1135- . relay_parent_storage_root ,
1136- }
1137- }
1138- }
1139-
1140- // TODO: set reasonable params
1141- parameter_types ! {
1142- pub const RandomnessRequestDeposit : u128 = 10 ;
1143- pub const ExpirationDelay : BlockNumber = 100 ;
1144- }
1145- impl pallet_randomness:: Config for Runtime {
1146- type Event = Event ;
1147- type AddressMapping = moonbeam_runtime_common:: IntoAddressMapping ;
1148- type ReserveCurrency = Balances ;
1149- type BabeDataGetter = BabeDataGetter ;
1150- type VrfInputGetter = VrfInputGetter ;
1151- type VrfKeyLookup = AuthorMapping ;
1152- type Deposit = RandomnessRequestDeposit ;
1153- type ExpirationDelay = ExpirationDelay ;
1154- }
1155-
11561077construct_runtime ! {
11571078 pub enum Runtime where
11581079 Block = Block ,
@@ -1220,9 +1141,6 @@ construct_runtime! {
12201141 XTokens : orml_xtokens:: { Pallet , Call , Storage , Event <T >} = 106 ,
12211142 XcmTransactor : pallet_xcm_transactor:: { Pallet , Call , Storage , Event <T >} = 107 ,
12221143 LocalAssets : pallet_assets:: <Instance1 >:: { Pallet , Call , Storage , Event <T >} = 108 ,
1223-
1224- // Randomness
1225- Randomness : pallet_randomness:: { Pallet , Call , Storage , Config <T >, Event <T >, Inherent } = 120 ,
12261144 }
12271145}
12281146
0 commit comments