From fcb215332f589c65c16a9986701c3b97e378b03c Mon Sep 17 00:00:00 2001 From: Shawn Tabrizi Date: Tue, 23 Mar 2021 14:35:27 +0100 Subject: [PATCH] Tweak Rococo Settings For Onboarding Testing (#2671) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Tweak Rococo Settings * rococo: use CurrentBlockRandomness wrapper in auctions Co-authored-by: André Silva Co-authored-by: Bastian Köcher --- polkadot/runtime/rococo/src/constants.rs | 2 +- polkadot/runtime/rococo/src/lib.rs | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/polkadot/runtime/rococo/src/constants.rs b/polkadot/runtime/rococo/src/constants.rs index 26fea2cac6..2422328ad9 100644 --- a/polkadot/runtime/rococo/src/constants.rs +++ b/polkadot/runtime/rococo/src/constants.rs @@ -34,7 +34,7 @@ pub mod time { pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; frame_support::parameter_types! { - pub storage EpochDurationInBlocks: BlockNumber = 1 * HOURS; + pub storage EpochDurationInBlocks: BlockNumber = 30 * MINUTES; } // These time units are defined in number of blocks. diff --git a/polkadot/runtime/rococo/src/lib.rs b/polkadot/runtime/rococo/src/lib.rs index 84a760cb72..3b78dc522c 100644 --- a/polkadot/runtime/rococo/src/lib.rs +++ b/polkadot/runtime/rococo/src/lib.rs @@ -616,11 +616,29 @@ parameter_types! { pub const EndingPeriod: BlockNumber = 15 * MINUTES; } +// A wrapper around `babe::CurrentBlockRandomness` that does not return `Option`. +pub struct CurrentBlockRandomness; + +impl Randomness for CurrentBlockRandomness { + fn random(subject: &[u8]) -> (Hash, BlockNumber) { + let (randomness, block_number) = + pallet_babe::CurrentBlockRandomness::::random(subject); + + let randomness = randomness.expect( + "only returns None when secondary VRF slots are not enabled; \ + secondary VRF slots are enbaled for rococo runtime; \ + qed.", + ); + + (randomness, block_number) + } +} + impl auctions::Config for Runtime { type Event = Event; type Leaser = Slots; type EndingPeriod = EndingPeriod; - type Randomness = pallet_babe::RandomnessFromOneEpochAgo; + type Randomness = CurrentBlockRandomness; type InitiateOrigin = EnsureRoot; type WeightInfo = auctions::TestWeightInfo; }