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

* import rococo into chain-spec

* make a few stabs at moving forward

* wip: rococo readme

* remove /service crate

- Move the chain-spec files to node-service
- update sufficient cargo files that polkadot-service-new builds
- not everything else builds yet

* wip: chase down some build errors in polkadot-cli

There's a lot more to go, but some progress has happened.

* make more progress getting polkadot-cli to build

* don't ignore polkadot.json within the res directory

* don't recreate pathbufs

* Prepare Polkadot to be used by Cumulus

This begins to make Polkadot usable from Cumulus.

* Remove old test

* migrate new_chain_ops fix from /service

* partially remove node/test-service

* Reset some changes

* Revert "partially remove node/test-service"

This reverts commit 7b8f9ba5bfc286a309df89853ae11facf3277ffb.

* WIP: replace v0 ParachainHost impl with v1 for test runtime

This is necessary because one of the current errors when building
the test service boils down to:

the trait bound `polkadot_test_runtime::RuntimeApiImpl<...>`:
  `polkadot_primitives::v1::ParachainHost<...>` is not satisfied

This is WIP because it appears to be causing some std leakage into
the wasm environment, or something; the compiler is currently
complaining about duplicate definitions of `panic_handler` and `oom`.
Presumably I have to identify all std types (Vec etc) and replace
them with sp_std equivalents.

* fix test runtime build

it wasn't std leakage, after all

* bump westend spec version

* use service-new as service within cli

* to revert: demo that forwarding the test runtime to the real impl blows up

* Revert "to revert: demo that forwarding the test runtime to the real impl blows up"

This reverts commit 68d2f385f378721c7433e3e39133434610cd2a51.

* Revert "Revert "to revert: demo that forwarding the test runtime to the real impl blows up""

This reverts commit 04cb1cbf8873b4429cb9c9fdccb7f4bb137dc720.

Might have just forgotten to disable default features

* More reverts

* MOARE

* plug in the runtime as the generic instantiation

This feels closer to a solution, but it still has problems: in particular,
it's assumed that Runtime implements all appropriate Trait traits,
which this one apparently does not.

* implement necessary traits to get the test runtime compiling

This is almost certainly not correct in some way; it really
looks like I need to mess with the construct_runtime! macro
somehow, to inject the inclusion trait's event type as a Event
variant. Still, better lock down this changeset while it all
compiles.

* add inclusion::Event as variant into Event enum

* implement unimplemented bits in kusama

* implement unimplemented bits in polkadot runtime

* implement unimplemented bits in westend runtime

* migrate client upgrades from master

* update test service with new node changes

* package metadata--that wasn't intended to be removed

* add parachains v1 modules to each runtime

It's not clear what precisely this does, but it's probably the right
thing to do.

* enable cli to opt out of full node features

* adjust rococo chainspec per example

https://github.com/paritytech/polkadot/blob/26f1fa47f7836ab4bee5d4aad127ebce748320dd/service/src/chain_spec.rs#L362

* try to fix Cargo.lock

Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
Peter Goodspeed-Niklaus
2020-09-18 10:27:54 +02:00
committed by GitHub
parent 23c1760b48
commit d531ba561c
31 changed files with 1293 additions and 3145 deletions
+70 -47
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,
@@ -51,7 +61,7 @@ use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use frame_support::{
parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, Randomness},
traits::{KeyOwnerProofSystem, Randomness, TestRandomness},
weights::Weight,
};
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
@@ -416,6 +426,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 = TestRandomness;
}
impl paras::Trait for Runtime {}
impl router::Trait for Runtime {}
impl scheduler::Trait for Runtime {}
construct_runtime! {
pub enum Runtime where
Block = Block,
@@ -449,6 +475,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>},
}
@@ -553,55 +586,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())
}
}