Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Reduce Westend deposit requirements (#1341)
Browse files Browse the repository at this point in the history
* Switch branch

* Return chain ops parts in new_chain_ops

* Remove where param from new_chain_ops

* Add task manager to new_chain_ops return

* Revert branch switch

* Revert "Revert branch switch"

This reverts commit 7c7900c.

* network/test/src/lib: Adjust network worker polling

Companion for paritytech/substrate#6552.

* Fix adder parachain

* Fix collator tests

* Revert branch switch

* Bump everything

- Remove old migration code
- Reduce deposit requried for westend

* Reapply fixes

* Bump locl

* Fix for #6550

* Fix message

Co-authored-by: Ashley Ruglys <ashley.ruglys@gmail.com>
Co-authored-by: Max Inden <mail@max-inden.de>
  • Loading branch information
3 people authored Jul 3, 2020
1 parent aeb79d4 commit 0a7d04d
Show file tree
Hide file tree
Showing 34 changed files with 299 additions and 222 deletions.
327 changes: 171 additions & 156 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ path = "src/main.rs"

[package]
name = "polkadot"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion availability-store/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "polkadot-availability-store"
description = "Persistent database for parachain data"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-cli"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot Relay-chain Client Node"
edition = "2018"
Expand Down
12 changes: 6 additions & 6 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ fn get_exec_name() -> Option<String> {
}

impl SubstrateCli for Cli {
fn impl_name() -> &'static str { "Parity Polkadot" }
fn impl_name() -> String { "Parity Polkadot".into() }

fn impl_version() -> &'static str { env!("SUBSTRATE_CLI_IMPL_VERSION") }
fn impl_version() -> String { env!("SUBSTRATE_CLI_IMPL_VERSION").into() }

fn description() -> &'static str { env!("CARGO_PKG_DESCRIPTION") }
fn description() -> String { env!("CARGO_PKG_DESCRIPTION").into() }

fn author() -> &'static str { env!("CARGO_PKG_AUTHORS") }
fn author() -> String { env!("CARGO_PKG_AUTHORS").into() }

fn support_url() -> &'static str { "https://github.com/paritytech/polkadot/issues/new" }
fn support_url() -> String { "https://github.com/paritytech/polkadot/issues/new".into() }

fn copyright_start_year() -> i32 { 2017 }

fn executable_name() -> &'static str { "polkadot" }
fn executable_name() -> String { "polkadot".into() }

fn load_spec(&self, id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {
let id = if id == "" {
Expand Down
2 changes: 1 addition & 1 deletion collator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-collator"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Collator node implementation"
edition = "2018"
Expand Down
28 changes: 16 additions & 12 deletions collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,12 +373,15 @@ fn build_collator_service<P, C, R, Extrinsic>(

/// Async function that will run the collator node with the given `RelayChainContext` and `ParachainContext`
/// built by the given `BuildParachainContext` and arguments to the underlying polkadot node.
pub async fn start_collator<P>(
pub fn start_collator<P>(
build_parachain_context: P,
para_id: ParaId,
key: Arc<CollatorPair>,
config: Configuration,
) -> Result<(), polkadot_service::Error>
) -> Result<
(Pin<Box<dyn Future<Output = ()> + Send>>, sc_service::TaskManager),
polkadot_service::Error
>
where
P: 'static + BuildParachainContext,
P::ParachainContext: Send + 'static,
Expand All @@ -400,14 +403,15 @@ where
None,
)?;
let spawn_handle = task_manager.spawn_handle();
build_collator_service(
let future = build_collator_service(
spawn_handle,
handlers,
client,
para_id,
key,
build_parachain_context
)?.await;
)?;
Ok((future.boxed(), task_manager))
} else if config.chain_spec.is_westend() {
let (task_manager, client, handlers) = service::westend_new_full(
config,
Expand All @@ -418,14 +422,15 @@ where
None,
)?;
let spawn_handle = task_manager.spawn_handle();
build_collator_service(
let future = build_collator_service(
spawn_handle,
handlers,
client,
para_id,
key,
build_parachain_context
)?.await;
)?;
Ok((future.boxed(), task_manager))
} else {
let (task_manager, client, handles) = service::polkadot_new_full(
config,
Expand All @@ -436,17 +441,16 @@ where
None,
)?;
let spawn_handle = task_manager.spawn_handle();
build_collator_service(
let future = build_collator_service(
spawn_handle,
handles,
client,
para_id,
key,
build_parachain_context,
)?.await;
build_parachain_context
)?;
Ok((future.boxed(), task_manager))
}

Ok(())
}

#[cfg(not(feature = "service-rewr"))]
Expand Down Expand Up @@ -506,7 +510,7 @@ mod tests {
fn check_send<T: Send>(_: T) {}

let cli = Cli::from_iter(&["-dev"]);
let task_executor = |_, _| unimplemented!();
let task_executor = |_, _| {};
let config = cli.create_configuration(&cli.run.base, task_executor.into()).unwrap();

check_send(start_collator(
Expand Down
2 changes: 1 addition & 1 deletion erasure-coding/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-erasure-coding"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion network/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-network"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Polkadot-specific networking protocol"
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion network/test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-network-test"
version = "0.8.13"
version = "0.8.14"
license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
Expand Down
6 changes: 3 additions & 3 deletions network/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,13 +758,13 @@ pub trait TestNetFactory: Sized {
futures::executor::block_on(futures::future::poll_fn::<(), _>(|cx| self.poll_until_idle(cx)));
}

/// Polls the testnet. Processes all the pending actions and returns `NotReady`.
/// Polls the testnet. Processes all the pending actions.
fn poll(&mut self, cx: &mut FutureContext) {
self.mut_peers(|peers| {
for peer in peers {
trace!(target: "sync", "-- Polling {}", peer.id());
if let Poll::Ready(res) = Pin::new(&mut peer.network).poll(cx) {
res.unwrap();
if let Poll::Ready(()) = peer.network.poll_unpin(cx) {
panic!("NetworkWorker has terminated unexpectedly.")
}
trace!(target: "sync", "-- Polling complete {}", peer.id());

Expand Down
1 change: 1 addition & 0 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sc-chain-spec = { git = "https://github.com/paritytech/substrate", branch = "mas
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-trie = { git = "https://github.com/paritytech/substrate", branch = "master" }
consensus_common = { package = "sp-consensus", git = "https://github.com/paritytech/substrate", branch = "master" }
grandpa = { package = "sc-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
grandpa_primitives = { package = "sp-finality-grandpa", git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
18 changes: 13 additions & 5 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ use polkadot_subsystem::{
Subsystem, SubsystemContext, SpawnedSubsystem,
messages::{CandidateValidationMessage, CandidateBackingMessage},
};
use sp_trie::PrefixedMemoryDB;
pub use service::{
Role, PruningMode, TransactionPoolOptions, Error, RuntimeGenesis,
TFullClient, TLightClient, TFullBackend, TLightBackend, TFullCallExecutor, TLightCallExecutor,
Configuration, ChainSpec, ServiceBuilderCommand, ServiceComponents, TaskManager,
Configuration, ChainSpec, ServiceComponents, TaskManager,
};
pub use service::config::{DatabaseConfig, PrometheusConfig};
pub use sc_executor::NativeExecutionDispatch;
Expand Down Expand Up @@ -576,18 +577,25 @@ macro_rules! new_light {
}

/// Builds a new object suitable for chain operations.
pub fn new_chain_ops<Runtime, Dispatch, Extrinsic>(mut config: Configuration)
-> Result<impl ServiceBuilderCommand<Block=Block>, ServiceError>
pub fn new_chain_ops<Runtime, Dispatch, Extrinsic>(mut config: Configuration) -> Result<
(
Arc<service::TFullClient<Block, Runtime, Dispatch>>,
Arc<TFullBackend<Block>>,
consensus_common::import_queue::BasicQueue<Block, PrefixedMemoryDB<BlakeTwo256>>,
TaskManager,
),
ServiceError
>
where
Runtime: ConstructRuntimeApi<Block, service::TFullClient<Block, Runtime, Dispatch>> + Send + Sync + 'static,
Runtime::RuntimeApi:
RuntimeApiCollection<Extrinsic, StateBackend = sc_client_api::StateBackendFor<TFullBackend<Block>, Block>>,
Dispatch: NativeExecutionDispatch + 'static,
Extrinsic: RuntimeExtrinsic,
<Runtime::RuntimeApi as sp_api::ApiExt<Block>>::StateBackend: sp_api::StateBackend<BlakeTwo256>,
{
config.keystore = service::config::KeystoreConfig::InMemory;
Ok(new_full_start!(config, Runtime, Dispatch).0)
let (builder, _, _, _) = new_full_start!(config, Runtime, Dispatch);
Ok(builder.to_chain_ops_parts())
}

/// Create a new Polkadot service for a full node.
Expand Down
2 changes: 1 addition & 1 deletion parachain/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-parachain"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Types and utilities for creating and working with parachains"
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/adder/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "test-parachain-adder"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which adds to a number as its state transition"
edition = "2018"
Expand Down
8 changes: 5 additions & 3 deletions parachain/test-parachains/adder/collator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use primitives::{
};
use collator::{ParachainContext, Network, BuildParachainContext, Cli, SubstrateCli};
use parking_lot::Mutex;
use futures::future::{Ready, ready, TryFutureExt};
use futures::future::{Ready, ready, FutureExt};

const GENESIS: AdderHead = AdderHead {
number: 0,
Expand Down Expand Up @@ -135,12 +135,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::from_iter(&["-dev"]);
let runner = cli.create_runner(&cli.run.base)?;
runner.async_run(|config| {
collator::start_collator(
let (future, task_manager) = collator::start_collator(
context,
id,
key,
config,
).map_err(|e| e.into())
)?;

Ok((future.map(Ok), task_manager))
})?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion parachain/test-parachains/halt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "test-parachain-halt"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
description = "Test parachain which executes forever"
edition = "2018"
Expand Down
2 changes: 1 addition & 1 deletion primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-primitives"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-rpc"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion runtime/common/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-runtime-common"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ pub trait Trait: CreateSignedTransaction<Call<Self>> + attestations::Trait + ses
}

/// Origin for the parachains module.
#[derive(PartialEq, Eq, Clone)]
#[derive(PartialEq, Eq, Clone, Encode, Decode)]
#[cfg_attr(feature = "std", derive(Debug))]
pub enum Origin {
/// It comes from a parachain.
Expand Down
2 changes: 1 addition & 1 deletion runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "kusama-runtime"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
Expand Down
10 changes: 8 additions & 2 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ impl system::Trait for Runtime {
impl scheduler::Trait for Runtime {
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumBlockWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
}

parameter_types! {
Expand Down Expand Up @@ -373,6 +375,7 @@ impl democracy::Trait for Runtime {
type PreimageByteDeposit = PreimageByteDeposit;
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type OperationalPreimageOrigin = collective::EnsureMember<AccountId, CouncilCollective>;
}
Expand Down Expand Up @@ -891,8 +894,11 @@ impl proxy::Trait for Runtime {
pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
fn on_runtime_upgrade() -> frame_support::weights::Weight {
treasury::Module::<Runtime>::migrate_retract_tip_for_tip_new();
500_000_000
if scheduler::Module::<Runtime>::migrate_v1_to_t2() {
<Runtime as system::Trait>::MaximumBlockWeight::get()
} else {
<Runtime as system::Trait>::DbWeight::get().reads(1) + 500_000_000
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion runtime/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "polkadot-runtime"
version = "0.8.13"
version = "0.8.14"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"
build = "build.rs"
Expand Down
Loading

0 comments on commit 0a7d04d

Please sign in to comment.