Remove Old Service, 2nd try (#1732)

* Restore "Remove service, migrate all to service-new (#1630)"

i.e.
Revert "Revert "Remove service, migrate all to service-new (#1630)" (#1731)"

This reverts commit b4457f555b.

This allows us to get the changeset from #1630 into a new branch
which can be merged sometime in the future after appropriate burnin
tests have completed.

* remove ',)' from codebase outside of macros

* restore bdfl-preferred formatting

* attempt to improve destructuring formatting

* rename polkadot-service-new -> polkadot-service

* Apply suggestions from code review

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

* remove unused import

* Update runtime/rococo-v1/README.md

Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>

Co-authored-by: Andronik Ordian <write@reusable.software>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
Peter Goodspeed-Niklaus
2020-09-28 10:23:02 +02:00
committed by GitHub
parent 796de5f3e3
commit 96f2615582
31 changed files with 1291 additions and 3145 deletions
+69 -46
View File
@@ -21,10 +21,20 @@
#![recursion_limit="256"]
use rstd::prelude::*;
use codec::{Encode, Decode};
use primitives::v0 as p_v0;
use codec::Encode;
use polkadot_runtime_parachains::{
configuration,
inclusion,
initializer,
paras,
router,
runtime_api_impl::v1 as runtime_impl,
scheduler,
};
use primitives::v1::{
AccountId, AccountIndex, Balance, BlockNumber, Hash as HashT, Nonce, Signature, Moment,
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt,
CoreState, GroupRotationInfo, Hash as HashT, Id as ParaId, Moment, Nonce, OccupiedCoreAssumption,
PersistedValidationData, Signature, ValidationCode, ValidationData, ValidatorId, ValidatorIndex,
};
use runtime_common::{
claims, SlowAdjustingFeeUpdate, impls::CurrencyToVoteHandler,
@@ -419,6 +429,22 @@ impl pallet_sudo::Trait for Runtime {
type Call = Call;
}
impl configuration::Trait for Runtime {}
impl inclusion::Trait for Runtime {
type Event = Event;
}
impl initializer::Trait for Runtime {
type Randomness = RandomnessCollectiveFlip;
}
impl paras::Trait for Runtime {}
impl router::Trait for Runtime {}
impl scheduler::Trait for Runtime {}
construct_runtime! {
pub enum Runtime where
Block = Block,
@@ -452,6 +478,13 @@ construct_runtime! {
// Vesting. Usable initially, but removed once all vesting is finished.
Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>},
// Parachains runtime modules
Configuration: configuration::{Module, Call, Storage},
Inclusion: inclusion::{Module, Call, Storage, Event<T>},
Initializer: initializer::{Module, Call, Storage},
Paras: paras::{Module, Call, Storage},
Scheduler: scheduler::{Module, Call, Storage},
// Sudo. Last module.
Sudo: pallet_sudo::{Module, Call, Storage, Config<T>, Event<T>},
}
@@ -556,55 +589,45 @@ sp_api::impl_runtime_apis! {
}
}
// 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>;
impl primitives::v1::ParachainHost<Block, Hash, BlockNumber> for Runtime {
fn validators() -> Vec<ValidatorId> {
runtime_impl::validators::<Runtime>()
}
// 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()
.map(|k| k.using_encoded(|s| Decode::decode(&mut &s[..]))
.expect("correct size and raw-bytes; qed"))
.collect()
fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
runtime_impl::validator_groups::<Runtime>()
}
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 availability_cores() -> Vec<CoreState<BlockNumber>> {
runtime_impl::availability_cores::<Runtime>()
}
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 full_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
-> Option<ValidationData<BlockNumber>> {
runtime_impl::full_validation_data::<Runtime>(para_id, assumption)
}
}
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 persisted_validation_data(para_id: ParaId, assumption: OccupiedCoreAssumption)
-> Option<PersistedValidationData<BlockNumber>> {
runtime_impl::persisted_validation_data::<Runtime>(para_id, assumption)
}
fn session_index_for_child() -> SessionIndex {
runtime_impl::session_index_for_child::<Runtime>()
}
fn downward_messages(_id: p_v0::Id) -> Vec<p_v0::DownwardMessage> {
Vec::new()
fn validation_code(para_id: ParaId, assumption: OccupiedCoreAssumption)
-> Option<ValidationCode> {
runtime_impl::validation_code::<Runtime>(para_id, assumption)
}
fn candidate_pending_availability(para_id: ParaId) -> Option<CommittedCandidateReceipt<Hash>> {
runtime_impl::candidate_pending_availability::<Runtime>(para_id)
}
fn candidate_events() -> Vec<CandidateEvent<Hash>> {
use core::convert::TryInto;
runtime_impl::candidate_events::<Runtime, _>(|trait_event| trait_event.try_into().ok())
}
}