mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
Rococo to use BABE randomness, Westend & Rococo runtime synchronization in file format (#5082)
* * Rococo to use BABE randomness * Westend & Rococo runtime syncronization in file format (starting) * explicit frame_support::weights::Weight
This commit is contained in:
@@ -24,7 +24,7 @@ use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use beefy_primitives::{crypto::AuthorityId as BeefyId, mmr::MmrLeafVersion};
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{Contains, KeyOwnerProofSystem, Randomness},
|
||||
traits::{Contains, InstanceFilter, KeyOwnerProofSystem, OnRuntimeUpgrade},
|
||||
PalletId,
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
@@ -36,9 +36,9 @@ use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInf
|
||||
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
|
||||
use primitives::v2::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt,
|
||||
CoreState, GroupRotationInfo, Hash, Id, InboundDownwardMessage, InboundHrmpMessage, Moment,
|
||||
Nonce, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement, ScrapedOnChainVotes,
|
||||
SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId,
|
||||
CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage,
|
||||
Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement,
|
||||
ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId,
|
||||
ValidatorIndex, ValidatorSignature,
|
||||
};
|
||||
use runtime_common::{
|
||||
@@ -51,7 +51,7 @@ use sp_core::{OpaqueMetadata, RuntimeDebug};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
traits::{
|
||||
self, AccountIdLookup, BlakeTwo256, Block as BlockT, Extrinsic as ExtrinsicT, Keccak256,
|
||||
AccountIdLookup, BlakeTwo256, Block as BlockT, Extrinsic as ExtrinsicT, Keccak256,
|
||||
OpaqueKeys, SaturatedConversion, Verify,
|
||||
},
|
||||
transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
|
||||
@@ -75,15 +75,9 @@ use bridge_runtime_common::messages::{
|
||||
source::estimate_message_dispatch_and_delivery_fee, MessageBridge,
|
||||
};
|
||||
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
|
||||
use polkadot_parachain::primitives::Id as ParaId;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
use rococo_runtime_constants::{currency::*, fee::*, time::*};
|
||||
|
||||
use frame_support::traits::{InstanceFilter, OnRuntimeUpgrade};
|
||||
|
||||
mod bridge_messages;
|
||||
mod validator_manager;
|
||||
mod weights;
|
||||
@@ -715,11 +709,6 @@ impl paras_registrar::Config for Runtime {
|
||||
type WeightInfo = paras_registrar::TestWeightInfo;
|
||||
}
|
||||
|
||||
/// An insecure randomness beacon that uses the parent block hash as random material.
|
||||
///
|
||||
/// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES.
|
||||
pub struct ParentHashRandomness;
|
||||
|
||||
impl pallet_beefy::Config for Runtime {
|
||||
type BeefyId = BeefyId;
|
||||
}
|
||||
@@ -727,7 +716,7 @@ impl pallet_beefy::Config for Runtime {
|
||||
impl pallet_mmr::Config for Runtime {
|
||||
const INDEXING_PREFIX: &'static [u8] = b"mmr";
|
||||
type Hashing = Keccak256;
|
||||
type Hash = <Keccak256 as traits::Hash>::Output;
|
||||
type Hash = <Keccak256 as sp_runtime::traits::Hash>::Output;
|
||||
type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
|
||||
type WeightInfo = ();
|
||||
type LeafData = pallet_beefy_mmr::Pallet<Runtime>;
|
||||
@@ -913,17 +902,6 @@ impl pallet_bridge_messages::Config<AtRococoWithWococoMessagesInstance> for Runt
|
||||
type MessageDispatch = crate::bridge_messages::FromWococoMessageDispatch;
|
||||
}
|
||||
|
||||
impl Randomness<Hash, BlockNumber> for ParentHashRandomness {
|
||||
fn random(subject: &[u8]) -> (Hash, BlockNumber) {
|
||||
(
|
||||
(System::parent_hash(), subject)
|
||||
.using_encoded(sp_io::hashing::blake2_256)
|
||||
.into(),
|
||||
System::block_number(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const EndingPeriod: BlockNumber = 1 * HOURS;
|
||||
pub const SampleLength: BlockNumber = 1;
|
||||
@@ -935,7 +913,7 @@ impl auctions::Config for Runtime {
|
||||
type Registrar = Registrar;
|
||||
type EndingPeriod = EndingPeriod;
|
||||
type SampleLength = SampleLength;
|
||||
type Randomness = ParentHashRandomness;
|
||||
type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
|
||||
type InitiateOrigin = EnsureRoot<AccountId>;
|
||||
type WeightInfo = auctions::TestWeightInfo;
|
||||
}
|
||||
@@ -1201,7 +1179,7 @@ sp_api::impl_runtime_apis! {
|
||||
runtime_api_impl::availability_cores::<Runtime>()
|
||||
}
|
||||
|
||||
fn persisted_validation_data(para_id: Id, assumption: OccupiedCoreAssumption)
|
||||
fn persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
|
||||
-> Option<PersistedValidationData<Hash, BlockNumber>> {
|
||||
runtime_api_impl::persisted_validation_data::<Runtime>(para_id, assumption)
|
||||
}
|
||||
@@ -1217,7 +1195,7 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn check_validation_outputs(
|
||||
para_id: Id,
|
||||
para_id: ParaId,
|
||||
outputs: primitives::v2::CandidateCommitments,
|
||||
) -> bool {
|
||||
runtime_api_impl::check_validation_outputs::<Runtime>(para_id, outputs)
|
||||
@@ -1227,12 +1205,12 @@ sp_api::impl_runtime_apis! {
|
||||
runtime_api_impl::session_index_for_child::<Runtime>()
|
||||
}
|
||||
|
||||
fn validation_code(para_id: Id, assumption: OccupiedCoreAssumption)
|
||||
fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
|
||||
-> Option<ValidationCode> {
|
||||
runtime_api_impl::validation_code::<Runtime>(para_id, assumption)
|
||||
}
|
||||
|
||||
fn candidate_pending_availability(para_id: Id) -> Option<CommittedCandidateReceipt<Hash>> {
|
||||
fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
|
||||
runtime_api_impl::candidate_pending_availability::<Runtime>(para_id)
|
||||
}
|
||||
|
||||
@@ -1247,17 +1225,17 @@ sp_api::impl_runtime_apis! {
|
||||
})
|
||||
}
|
||||
|
||||
fn session_info(index: SessionIndex) -> Option<SessionInfoData> {
|
||||
fn session_info(index: SessionIndex) -> Option<SessionInfo> {
|
||||
runtime_api_impl::session_info::<Runtime>(index)
|
||||
}
|
||||
|
||||
fn dmq_contents(recipient: Id) -> Vec<InboundDownwardMessage<BlockNumber>> {
|
||||
fn dmq_contents(recipient: ParaId) -> Vec<InboundDownwardMessage<BlockNumber>> {
|
||||
runtime_api_impl::dmq_contents::<Runtime>(recipient)
|
||||
}
|
||||
|
||||
fn inbound_hrmp_channels_contents(
|
||||
recipient: Id
|
||||
) -> BTreeMap<Id, Vec<InboundHrmpMessage<BlockNumber>>> {
|
||||
recipient: ParaId
|
||||
) -> BTreeMap<ParaId, Vec<InboundHrmpMessage<BlockNumber>>> {
|
||||
runtime_api_impl::inbound_hrmp_channels_contents::<Runtime>(recipient)
|
||||
}
|
||||
|
||||
|
||||
@@ -14,26 +14,37 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! The Polkadot runtime. This can be compiled with `#[no_std]`, ready for Wasm.
|
||||
//! The Westend runtime. This can be compiled with `#[no_std]`, ready for Wasm.
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
use pallet_transaction_payment::CurrencyAdapter;
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use beefy_primitives::crypto::AuthorityId as BeefyId;
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{Contains, InstanceFilter, KeyOwnerProofSystem, OnRuntimeUpgrade},
|
||||
PalletId,
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use pallet_mmr_primitives as mmr;
|
||||
use pallet_session::historical as session_historical;
|
||||
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
|
||||
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
|
||||
use primitives::v2::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt,
|
||||
CoreState, GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage,
|
||||
Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
|
||||
SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
|
||||
Moment, Nonce, OccupiedCoreAssumption, PersistedValidationData, PvfCheckStatement,
|
||||
ScrapedOnChainVotes, SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId,
|
||||
ValidatorIndex, ValidatorSignature,
|
||||
};
|
||||
use runtime_common::{
|
||||
assigned_slots, auctions, crowdloan, impl_runtime_weights, impls::ToAuthor, paras_registrar,
|
||||
paras_sudo_wrapper, slots, BlockHashCount, BlockLength, CurrencyToVote, SlowAdjustingFeeUpdate,
|
||||
};
|
||||
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||
|
||||
use runtime_parachains::{
|
||||
configuration as parachains_configuration, disputes as parachains_disputes,
|
||||
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
|
||||
@@ -42,21 +53,8 @@ use runtime_parachains::{
|
||||
runtime_api_impl::v2 as parachains_runtime_api_impl, scheduler as parachains_scheduler,
|
||||
session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
|
||||
};
|
||||
|
||||
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
|
||||
use beefy_primitives::crypto::AuthorityId as BeefyId;
|
||||
use frame_support::{
|
||||
construct_runtime, parameter_types,
|
||||
traits::{Contains, InstanceFilter, KeyOwnerProofSystem, OnRuntimeUpgrade},
|
||||
PalletId, RuntimeDebug,
|
||||
};
|
||||
use frame_system::EnsureRoot;
|
||||
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use pallet_mmr_primitives as mmr;
|
||||
use pallet_session::historical as session_historical;
|
||||
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
|
||||
use sp_core::OpaqueMetadata;
|
||||
use scale_info::TypeInfo;
|
||||
use sp_core::{OpaqueMetadata, RuntimeDebug};
|
||||
use sp_runtime::{
|
||||
create_runtime_str,
|
||||
curve::PiecewiseLinear,
|
||||
@@ -69,11 +67,11 @@ use sp_runtime::{
|
||||
ApplyExtrinsicResult, KeyTypeId, Perbill,
|
||||
};
|
||||
use sp_staking::SessionIndex;
|
||||
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||
#[cfg(any(feature = "std", test))]
|
||||
use sp_version::NativeVersion;
|
||||
use sp_version::RuntimeVersion;
|
||||
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use pallet_election_provider_multi_phase::Call as EPMCall;
|
||||
#[cfg(feature = "std")]
|
||||
pub use pallet_staking::StakerStatus;
|
||||
@@ -84,13 +82,8 @@ pub use sp_runtime::BuildStorage;
|
||||
/// Constant values used within the runtime.
|
||||
use westend_runtime_constants::{currency::*, fee::*, time::*};
|
||||
|
||||
// Weights used in the runtime
|
||||
mod weights;
|
||||
|
||||
// Voter bag threshold definitions.
|
||||
mod bag_thresholds;
|
||||
|
||||
// XCM configurations.
|
||||
mod weights;
|
||||
pub mod xcm_config;
|
||||
|
||||
#[cfg(test)]
|
||||
@@ -171,7 +164,7 @@ impl frame_system::Config for Runtime {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) *
|
||||
pub MaximumSchedulerWeight: frame_support::weights::Weight = Perbill::from_percent(80) *
|
||||
BlockWeights::get().max_block;
|
||||
pub const MaxScheduledPerBlock: u32 = 50;
|
||||
pub const NoPreimagePostponement: Option<u32> = Some(10);
|
||||
@@ -704,7 +697,7 @@ parameter_types! {
|
||||
Decode,
|
||||
RuntimeDebug,
|
||||
MaxEncodedLen,
|
||||
scale_info::TypeInfo,
|
||||
TypeInfo,
|
||||
)]
|
||||
pub enum ProxyType {
|
||||
Any,
|
||||
@@ -1301,8 +1294,8 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
|
||||
fn submit_pvf_check_statement(
|
||||
stmt: primitives::v2::PvfCheckStatement,
|
||||
signature: primitives::v2::ValidatorSignature,
|
||||
stmt: PvfCheckStatement,
|
||||
signature: ValidatorSignature,
|
||||
) {
|
||||
parachains_runtime_api_impl::submit_pvf_check_statement::<Runtime>(stmt, signature)
|
||||
}
|
||||
@@ -1477,12 +1470,12 @@ sp_api::impl_runtime_apis! {
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
impl frame_try_runtime::TryRuntime<Block> for Runtime {
|
||||
fn on_runtime_upgrade() -> (Weight, Weight) {
|
||||
fn on_runtime_upgrade() -> (frame_support::weights::Weight, frame_support::weights::Weight) {
|
||||
log::info!("try-runtime::on_runtime_upgrade westend.");
|
||||
let weight = Executive::try_runtime_upgrade().unwrap();
|
||||
(weight, BlockWeights::get().max_block)
|
||||
}
|
||||
fn execute_block_no_check(block: Block) -> Weight {
|
||||
fn execute_block_no_check(block: Block) -> frame_support::weights::Weight {
|
||||
Executive::execute_block_no_check(block)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,8 @@ fn sample_size_is_sensible() {
|
||||
use runtime_common::auctions::WeightInfo;
|
||||
// Need to clean up all samples at the end of an auction.
|
||||
let samples: BlockNumber = EndingPeriod::get() / SampleLength::get();
|
||||
let max_weight: Weight = RocksDbWeight::get().reads_writes(samples.into(), samples.into());
|
||||
let max_weight: frame_support::weights::Weight =
|
||||
RocksDbWeight::get().reads_writes(samples.into(), samples.into());
|
||||
// Max sample cleanup should be no more than half the total block weight.
|
||||
assert!(max_weight * 2 < BlockWeights::get().max_block);
|
||||
assert!(
|
||||
|
||||
Reference in New Issue
Block a user