mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 22:05:42 +00:00
Remove v0 parachains runtime (#1501)
* remove v0 parachains modules and switch to v1 primitives * get tests compiling for runtime-common * remove registrar module * Add a dummy module * remove runtime-parachains * mostly remove old parachains code from polkadot-runtime * remove slots::Trait implementation * remove sp_std prelude import * add a ZeroSizedTypeDifferentiator to dummy * finish porting over polkadot runtime * ZeroSizedTypeDifferentiator was actually unnecessary * westend * kusama * test-runtime (no dummy modules) * fix warning * fix chain-specs * fix test-service * test-client * remove dead import * remove unused needed_extrinsics parameter * runtimes compile * remove rococo-v0 * remove remaining references to Rococo * bump versions
This commit is contained in:
committed by
GitHub
parent
e6688620b5
commit
57aef8eef5
@@ -22,16 +22,16 @@
|
||||
|
||||
use sp_std::prelude::*;
|
||||
use codec::{Encode, Decode};
|
||||
use primitives::v0::{
|
||||
self as parachain,
|
||||
use primitives::v1::{
|
||||
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
|
||||
ActiveParas, AbridgedCandidateReceipt, SigningContext,
|
||||
};
|
||||
use primitives::v0 as p_v0;
|
||||
use runtime_common::{
|
||||
attestations, parachains, registrar, purchase, SlowAdjustingFeeUpdate,
|
||||
dummy, purchase, SlowAdjustingFeeUpdate,
|
||||
impls::{CurrencyToVoteHandler, ToAuthor},
|
||||
BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength,
|
||||
BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumExtrinsicWeight,
|
||||
ParachainSessionKeyPlaceholder,
|
||||
};
|
||||
use sp_runtime::{
|
||||
create_runtime_str, generic, impl_opaque_keys,
|
||||
@@ -67,8 +67,6 @@ pub use pallet_staking::StakerStatus;
|
||||
pub use sp_runtime::BuildStorage;
|
||||
pub use pallet_timestamp::Call as TimestampCall;
|
||||
pub use pallet_balances::Call as BalancesCall;
|
||||
pub use attestations::{Call as AttestationsCall, MORE_ATTESTATIONS_IDENTIFIER};
|
||||
pub use parachains::Call as ParachainsCall;
|
||||
|
||||
/// Constant values used within the runtime.
|
||||
pub mod constants;
|
||||
@@ -86,7 +84,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("westend"),
|
||||
impl_name: create_runtime_str!("parity-westend"),
|
||||
authoring_version: 2,
|
||||
spec_version: 42,
|
||||
spec_version: 43,
|
||||
impl_version: 0,
|
||||
#[cfg(not(feature = "disable-runtime-api"))]
|
||||
apis: RUNTIME_API_VERSIONS,
|
||||
@@ -104,11 +102,11 @@ pub fn native_version() -> NativeVersion {
|
||||
}
|
||||
}
|
||||
|
||||
/// Avoid processing transactions from slots and parachain registrar.
|
||||
/// Accept all transactions.
|
||||
pub struct BaseFilter;
|
||||
impl Filter<Call> for BaseFilter {
|
||||
fn filter(call: &Call) -> bool {
|
||||
!matches!(call, Call::Registrar(_))
|
||||
fn filter(_: &Call) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,7 +249,7 @@ impl_opaque_keys! {
|
||||
pub grandpa: Grandpa,
|
||||
pub babe: Babe,
|
||||
pub im_online: ImOnline,
|
||||
pub parachain_validator: Parachains,
|
||||
pub parachain_validator: ParachainSessionKeyPlaceholder<Runtime>,
|
||||
pub authority_discovery: AuthorityDiscovery,
|
||||
}
|
||||
}
|
||||
@@ -401,47 +399,6 @@ impl pallet_finality_tracker::Trait for Runtime {
|
||||
type ReportLatency = ReportLatency;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const AttestationPeriod: BlockNumber = 50;
|
||||
}
|
||||
|
||||
impl attestations::Trait for Runtime {
|
||||
type AttestationPeriod = AttestationPeriod;
|
||||
type ValidatorIdentities = parachains::ValidatorIdentities<Runtime>;
|
||||
type RewardAttestation = Staking;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const MaxCodeSize: u32 = 10 * 1024 * 1024; // 10 MB
|
||||
pub const MaxHeadDataSize: u32 = 20 * 1024; // 20 KB
|
||||
pub const ValidationUpgradeFrequency: BlockNumber = 2 * DAYS;
|
||||
pub const ValidationUpgradeDelay: BlockNumber = 8 * HOURS;
|
||||
pub const SlashPeriod: BlockNumber = 7 * DAYS;
|
||||
}
|
||||
|
||||
impl parachains::Trait for Runtime {
|
||||
type AuthorityId = primitives::v0::fisherman::FishermanAppCrypto;
|
||||
type Origin = Origin;
|
||||
type Call = Call;
|
||||
type ParachainCurrency = Balances;
|
||||
type BlockNumberConversion = sp_runtime::traits::Identity;
|
||||
type Randomness = RandomnessCollectiveFlip;
|
||||
type ActiveParachains = Registrar;
|
||||
type Registrar = Registrar;
|
||||
type MaxCodeSize = MaxCodeSize;
|
||||
type MaxHeadDataSize = MaxHeadDataSize;
|
||||
|
||||
type ValidationUpgradeFrequency = ValidationUpgradeFrequency;
|
||||
type ValidationUpgradeDelay = ValidationUpgradeDelay;
|
||||
type SlashPeriod = SlashPeriod;
|
||||
|
||||
type Proof = sp_session::MembershipProof;
|
||||
type KeyOwnerProofSystem = pallet_session::historical::Module<Self>;
|
||||
type IdentificationTuple = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, Vec<u8>)>>::IdentificationTuple;
|
||||
type ReportOffence = Offences;
|
||||
type BlockHashConversion = sp_runtime::traits::Identity;
|
||||
}
|
||||
|
||||
/// Submits a transaction with the node's public and signature type. Adheres to the signed extension
|
||||
/// format of the chain.
|
||||
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
|
||||
@@ -473,8 +430,6 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
|
||||
frame_system::CheckNonce::<Runtime>::from(nonce),
|
||||
frame_system::CheckWeight::<Runtime>::new(),
|
||||
pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
|
||||
registrar::LimitParathreadCommits::<Runtime>::new(),
|
||||
parachains::ValidateDoubleVoteReports::<Runtime>::new(),
|
||||
);
|
||||
let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
|
||||
debug::warn!("Unable to create signed payload: {:?}", e);
|
||||
@@ -499,22 +454,6 @@ impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
|
||||
type Extrinsic = UncheckedExtrinsic;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub const ParathreadDeposit: Balance = 5 * DOLLARS;
|
||||
pub const QueueSize: usize = 2;
|
||||
pub const MaxRetries: u32 = 3;
|
||||
}
|
||||
|
||||
impl registrar::Trait for Runtime {
|
||||
type Event = Event;
|
||||
type Origin = Origin;
|
||||
type Currency = Balances;
|
||||
type ParathreadDeposit = ParathreadDeposit;
|
||||
type SwapAux = ();
|
||||
type QueueSize = QueueSize;
|
||||
type MaxRetries = MaxRetries;
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
// Minimum 100 bytes/KSM deposited (1 CENT/byte)
|
||||
pub const BasicDeposit: Balance = 10 * DOLLARS; // 258 bytes on-chain
|
||||
@@ -637,9 +576,9 @@ impl InstanceFilter<Call> for ProxyType {
|
||||
Call::Grandpa(..) |
|
||||
Call::ImOnline(..) |
|
||||
Call::AuthorityDiscovery(..) |
|
||||
Call::Parachains(..) |
|
||||
Call::Attestations(..) |
|
||||
Call::Registrar(..) |
|
||||
Call::DummyParachains(..) |
|
||||
Call::DummyAttestations(..) |
|
||||
Call::DummyRegistrar(..) |
|
||||
Call::Utility(..) |
|
||||
Call::Identity(..) |
|
||||
Call::Recovery(pallet_recovery::Call::as_recovered(..)) |
|
||||
@@ -733,10 +672,12 @@ impl purchase::Trait for Runtime {
|
||||
type MaxUnlocked = MaxUnlocked;
|
||||
}
|
||||
|
||||
impl<I: frame_support::traits::Instance> dummy::Trait<I> for Runtime { }
|
||||
|
||||
construct_runtime! {
|
||||
pub enum Runtime where
|
||||
Block = Block,
|
||||
NodeBlock = primitives::v0::Block,
|
||||
NodeBlock = primitives::v1::Block,
|
||||
UncheckedExtrinsic = UncheckedExtrinsic
|
||||
{
|
||||
// Basic stuff; balances is uncallable initially.
|
||||
@@ -762,11 +703,10 @@ construct_runtime! {
|
||||
ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
|
||||
AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config},
|
||||
|
||||
// Parachains stuff; slots are disabled (no auctions initially). The rest are safe as they
|
||||
// have no public dispatchables.
|
||||
Parachains: parachains::{Module, Call, Storage, Config, Inherent, Origin},
|
||||
Attestations: attestations::{Module, Call, Storage},
|
||||
Registrar: registrar::{Module, Call, Storage, Event, Config<T>},
|
||||
// Old Parachains stuff. All dummies to avoid messing up the transaction indices.
|
||||
DummyParachains: dummy::<Instance0>::{Module, Call},
|
||||
DummyAttestations: dummy::<Instance1>::{Module, Call},
|
||||
DummyRegistrar: dummy::<Instance2>::{Module, Call},
|
||||
|
||||
// Utility module.
|
||||
Utility: pallet_utility::{Module, Call, Event},
|
||||
@@ -816,8 +756,6 @@ pub type SignedExtra = (
|
||||
frame_system::CheckNonce<Runtime>,
|
||||
frame_system::CheckWeight<Runtime>,
|
||||
pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
|
||||
registrar::LimitParathreadCommits<Runtime>,
|
||||
parachains::ValidateDoubleVoteReports<Runtime>,
|
||||
);
|
||||
/// Unchecked extrinsic type as expected by this runtime.
|
||||
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
|
||||
@@ -890,45 +828,55 @@ sp_api::impl_runtime_apis! {
|
||||
}
|
||||
}
|
||||
|
||||
impl parachain::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<parachain::ValidatorId> {
|
||||
Parachains::authorities()
|
||||
}
|
||||
fn duty_roster() -> parachain::DutyRoster {
|
||||
Parachains::calculate_duty_roster().0
|
||||
}
|
||||
fn active_parachains() -> Vec<(parachain::Id, Option<(parachain::CollatorId, parachain::Retriable)>)> {
|
||||
Registrar::active_paras()
|
||||
}
|
||||
fn global_validation_data() -> parachain::GlobalValidationData {
|
||||
Parachains::global_validation_data()
|
||||
}
|
||||
fn local_validation_data(id: parachain::Id) -> Option<parachain::LocalValidationData> {
|
||||
Parachains::current_local_validation_data(&id)
|
||||
}
|
||||
fn parachain_code(id: parachain::Id) -> Option<parachain::ValidationCode> {
|
||||
Parachains::parachain_code(&id)
|
||||
}
|
||||
fn get_heads(extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<AbridgedCandidateReceipt>>
|
||||
{
|
||||
extrinsics
|
||||
// Dummy implementation to continue supporting old parachains runtime temporarily.
|
||||
impl p_v0::ParachainHost<Block> for Runtime {
|
||||
fn validators() -> Vec<p_v0::ValidatorId> {
|
||||
// this is a compile-time check of size equality. note that we don't invoke
|
||||
// the function and nothing here is unsafe.
|
||||
let _ = core::mem::transmute::<p_v0::ValidatorId, AccountId>;
|
||||
|
||||
// Yes, these aren't actually the parachain session keys.
|
||||
// It doesn't matter, but we shouldn't return a zero-sized vector here.
|
||||
// As there are no parachains
|
||||
Session::validators()
|
||||
.into_iter()
|
||||
.find_map(|ex| match UncheckedExtrinsic::decode(&mut ex.encode().as_slice()) {
|
||||
Ok(ex) => match ex.function {
|
||||
Call::Parachains(ParachainsCall::set_heads(heads)) => {
|
||||
Some(heads.into_iter().map(|c| c.candidate).collect())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
Err(_) => None,
|
||||
})
|
||||
.map(|k| k.using_encoded(|s| Decode::decode(&mut &s[..]))
|
||||
.expect("correct size and raw-bytes; qed"))
|
||||
.collect()
|
||||
}
|
||||
fn signing_context() -> SigningContext {
|
||||
Parachains::signing_context()
|
||||
fn duty_roster() -> p_v0::DutyRoster {
|
||||
let v = Session::validators();
|
||||
p_v0::DutyRoster { validator_duty: (0..v.len()).map(|_| p_v0::Chain::Relay).collect() }
|
||||
}
|
||||
fn downward_messages(id: parachain::Id) -> Vec<primitives::v0::DownwardMessage> {
|
||||
Parachains::downward_messages(id)
|
||||
fn active_parachains() -> Vec<(p_v0::Id, Option<(p_v0::CollatorId, p_v0::Retriable)>)> {
|
||||
Vec::new()
|
||||
}
|
||||
fn global_validation_data() -> p_v0::GlobalValidationData {
|
||||
p_v0::GlobalValidationData {
|
||||
max_code_size: 1,
|
||||
max_head_data_size: 1,
|
||||
block_number: System::block_number().saturating_sub(1),
|
||||
}
|
||||
}
|
||||
fn local_validation_data(_id: p_v0::Id) -> Option<p_v0::LocalValidationData> {
|
||||
None
|
||||
}
|
||||
fn parachain_code(_id: p_v0::Id) -> Option<p_v0::ValidationCode> {
|
||||
None
|
||||
}
|
||||
fn get_heads(_extrinsics: Vec<<Block as BlockT>::Extrinsic>)
|
||||
-> Option<Vec<p_v0::AbridgedCandidateReceipt>>
|
||||
{
|
||||
None
|
||||
}
|
||||
fn signing_context() -> p_v0::SigningContext {
|
||||
p_v0::SigningContext {
|
||||
parent_hash: System::parent_hash(),
|
||||
session_index: Session::current_index(),
|
||||
}
|
||||
}
|
||||
fn downward_messages(_id: p_v0::Id) -> Vec<p_v0::DownwardMessage> {
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user