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

Commit

Permalink
Merge branch 'master' into prgn-remove-old-service-second-try
Browse files Browse the repository at this point in the history
* master:
  Bump jsonrpc-core to v15 (#1737)
  Companion PR for #6215 (#1654)
  Companion PR for #7138 (WeightInfo for Scheduler) (#1734)
  Companion PR for Bounties #5715 (#1336)
  • Loading branch information
ordian committed Sep 21, 2020
2 parents 944b745 + 01778f2 commit 036080b
Show file tree
Hide file tree
Showing 17 changed files with 693 additions and 320 deletions.
346 changes: 175 additions & 171 deletions Cargo.lock

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration) -> Result<
grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
babe::BabeLink<Block>
),
grandpa::SharedVoterState,
(
grandpa::SharedVoterState,
Arc<GrandpaFinalityProofProvider<FullBackend, Block>>,
),
)
>,
Error
Expand Down Expand Up @@ -217,9 +220,11 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration) -> Result<
let justification_stream = grandpa_link.justification_stream();
let shared_authority_set = grandpa_link.shared_authority_set().clone();
let shared_voter_state = grandpa::SharedVoterState::empty();
let finality_proof_provider =
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());

let import_setup = (block_import.clone(), grandpa_link, babe_link.clone());
let rpc_setup = shared_voter_state.clone();
let rpc_setup = (shared_voter_state.clone(), finality_proof_provider.clone());

let babe_config = babe_link.config().clone();
let shared_epoch_changes = babe_link.epoch_changes().clone();
Expand All @@ -246,6 +251,7 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration) -> Result<
shared_authority_set: shared_authority_set.clone(),
justification_stream: justification_stream.clone(),
subscription_executor,
finality_provider: finality_proof_provider.clone(),
},
};

Expand Down Expand Up @@ -355,8 +361,7 @@ pub fn new_full<RuntimeApi, Executor>(

let prometheus_registry = config.prometheus_registry().cloned();

let finality_proof_provider =
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
let (shared_voter_state, finality_proof_provider) = rpc_setup;

let (network, network_status_sinks, system_rpc_tx, network_starter) =
service::build_network(service::BuildNetworkParams {
Expand Down Expand Up @@ -397,8 +402,6 @@ pub fn new_full<RuntimeApi, Executor>(

let (block_import, link_half, babe_link) = import_setup;

let shared_voter_state = rpc_setup;

let overseer_client = client.clone();
let spawner = task_manager.spawn_handle();
let leaves: Vec<_> = select_chain.clone()
Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
jsonrpc-core = "14.0.3"
jsonrpc-core = "15.0.0"
polkadot-primitives = { path = "../primitives" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
19 changes: 13 additions & 6 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ use std::sync::Arc;
use polkadot_primitives::v0::{Block, BlockNumber, AccountId, Nonce, Balance, Hash};
use sp_api::ProvideRuntimeApi;
use txpool_api::TransactionPool;
use sp_block_builder::BlockBuilder;
use sp_blockchain::{HeaderBackend, HeaderMetadata, Error as BlockChainError};
use sp_consensus::SelectChain;
use sp_consensus_babe::BabeApi;
use sc_client_api::light::{Fetcher, RemoteBlockchain};
use sc_consensus_babe::Epoch;
use sp_block_builder::BlockBuilder;
use sc_finality_grandpa::FinalityProofProvider;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};

/// A type representing all RPC extensions.
Expand Down Expand Up @@ -57,19 +58,21 @@ pub struct BabeDeps {
}

/// Dependencies for GRANDPA
pub struct GrandpaDeps {
pub struct GrandpaDeps<B> {
/// Voting round info.
pub shared_voter_state: sc_finality_grandpa::SharedVoterState,
/// Authority set info.
pub shared_authority_set: sc_finality_grandpa::SharedAuthoritySet<Hash, BlockNumber>,
/// Receives notifications about justification events from Grandpa.
pub justification_stream: sc_finality_grandpa::GrandpaJustificationStream<Block>,
/// Subscription manager to keep track of pubsub subscribers.
/// Executor to drive the subscription manager in the Grandpa RPC handler.
pub subscription_executor: sc_rpc::SubscriptionTaskExecutor,
/// Finality proof provider.
pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
}

/// Full client dependencies
pub struct FullDeps<C, P, SC> {
pub struct FullDeps<C, P, SC, B> {
/// The client instance to use.
pub client: Arc<C>,
/// Transaction pool instance.
Expand All @@ -81,11 +84,11 @@ pub struct FullDeps<C, P, SC> {
/// BABE specific dependencies.
pub babe: BabeDeps,
/// GRANDPA specific dependencies.
pub grandpa: GrandpaDeps,
pub grandpa: GrandpaDeps<B>,
}

/// Instantiate all RPC extensions.
pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension where
C: ProvideRuntimeApi<Block>,
C: HeaderBackend<Block> + HeaderMetadata<Block, Error=BlockChainError>,
C: Send + Sync + 'static,
Expand All @@ -95,6 +98,8 @@ pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
SC: SelectChain<Block> + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::StateBackend<sp_runtime::traits::HashFor<Block>>,
{
use frame_rpc_system::{FullSystem, SystemApi};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
Expand All @@ -120,6 +125,7 @@ pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
shared_authority_set,
justification_stream,
subscription_executor,
finality_provider,
} = grandpa;

io.extend_with(
Expand All @@ -146,6 +152,7 @@ pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
shared_voter_state,
justification_stream,
subscription_executor,
finality_provider,
))
);
io
Expand Down
18 changes: 15 additions & 3 deletions runtime/common/src/crowdfund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,14 @@ mod tests {
pub const TipCountdown: u64 = 1;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: u64 = 1;
pub const TipReportDepositPerByte: u64 = 1;
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
pub const DataDepositPerByte: u64 = 1;
pub const BountyDepositBase: u64 = 1;
pub const BountyDepositPayoutDelay: u64 = 1;
pub const BountyUpdatePeriod: u64 = 1;
pub const MaximumReasonLength: u32 = 16384;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: u64 = 1;
}
pub struct Nobody;
impl Contains<u64> for Nobody {
Expand All @@ -666,7 +672,7 @@ mod tests {
type ApproveOrigin = frame_system::EnsureRoot<u64>;
type RejectOrigin = frame_system::EnsureRoot<u64>;
type Event = ();
type ProposalRejection = ();
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
Expand All @@ -676,7 +682,13 @@ mod tests {
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type TipReportDepositPerByte = TipReportDepositPerByte;
type DataDepositPerByte = DataDepositPerByte;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type MaximumReasonLength = MaximumReasonLength;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type ModuleId = TreasuryModuleId;
type WeightInfo = ();
}
Expand Down
29 changes: 23 additions & 6 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,19 @@ impl frame_system::Trait for Runtime {
type SystemWeightInfo = weights::frame_system::WeightInfo;
}

parameter_types! {
pub const MaxScheduledPerBlock: u32 = 50;
}

impl pallet_scheduler::Trait for Runtime {
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumBlockWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type WeightInfo = ();
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = weights::pallet_scheduler::WeightInfo;
}

parameter_types! {
Expand Down Expand Up @@ -494,7 +499,13 @@ parameter_types! {
pub const TipCountdown: BlockNumber = 1 * DAYS;
pub const TipFindersFee: Percent = Percent::from_percent(20);
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
pub const TipReportDepositPerByte: Balance = 1 * CENTS;
pub const DataDepositPerByte: Balance = 1 * CENTS;
pub const BountyDepositBase: Balance = 1 * DOLLARS;
pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS;
pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
pub const MaximumReasonLength: u32 = 16384;
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
pub const BountyValueMinimum: Balance = 2 * DOLLARS;
}

type ApproveOrigin = EnsureOneOf<
Expand All @@ -504,23 +515,29 @@ type ApproveOrigin = EnsureOneOf<
>;

impl pallet_treasury::Trait for Runtime {
type ModuleId = TreasuryModuleId;
type Currency = Balances;
type ApproveOrigin = ApproveOrigin;
type RejectOrigin = MoreThanHalfCouncil;
type Tippers = ElectionsPhragmen;
type TipCountdown = TipCountdown;
type TipFindersFee = TipFindersFee;
type TipReportDepositBase = TipReportDepositBase;
type TipReportDepositPerByte = TipReportDepositPerByte;
type DataDepositPerByte = DataDepositPerByte;
type Event = Event;
type ProposalRejection = Treasury;
type OnSlash = Treasury;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type MaximumReasonLength = MaximumReasonLength;
type BountyCuratorDeposit = BountyCuratorDeposit;
type BountyValueMinimum = BountyValueMinimum;
type BurnDestination = Society;
type ModuleId = TreasuryModuleId;
type WeightInfo = ();
type WeightInfo = weights::pallet_treasury::WeightInfo;
}

parameter_types! {
Expand Down
2 changes: 2 additions & 0 deletions runtime/kusama/src/weights/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ pub mod pallet_balances;
pub mod pallet_collective;
pub mod pallet_democracy;
pub mod pallet_proxy;
pub mod pallet_scheduler;
pub mod pallet_staking;
pub mod pallet_timestamp;
pub mod pallet_treasury;
pub mod pallet_utility;
pub mod pallet_vesting;
49 changes: 49 additions & 0 deletions runtime/kusama/src/weights/pallet_scheduler.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (C) 2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc6
#![allow(unused_parens)]
#![allow(unused_imports)]

use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};

pub struct WeightInfo;
impl pallet_scheduler::WeightInfo for WeightInfo {
fn schedule(s: u32, ) -> Weight {
(37_835_000 as Weight)
.saturating_add((81_000 as Weight).saturating_mul(s as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(1 as Weight))
}
fn cancel(s: u32, ) -> Weight {
(34_707_000 as Weight)
.saturating_add((3_125_000 as Weight).saturating_mul(s as Weight))
.saturating_add(DbWeight::get().reads(1 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn schedule_named(s: u32, ) -> Weight {
(48_065_000 as Weight)
.saturating_add((110_000 as Weight).saturating_mul(s as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
fn cancel_named(s: u32, ) -> Weight {
(38_776_000 as Weight)
.saturating_add((3_138_000 as Weight).saturating_mul(s as Weight))
.saturating_add(DbWeight::get().reads(2 as Weight))
.saturating_add(DbWeight::get().writes(2 as Weight))
}
}
Loading

0 comments on commit 036080b

Please sign in to comment.