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

Commit 9534c2b

Browse files
committed
Merge branch 'master' into ao-validator-discovery-api
* master: Companion for 7155 (WeightInfo for Babe and Grandpa) (#1736) Companion PR for #7136 (WeightInfo for Session / Offences) (#1735) 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)
2 parents 7585d6e + 6c169ca commit 9534c2b

File tree

20 files changed

+723
-358
lines changed

20 files changed

+723
-358
lines changed

Cargo.lock

Lines changed: 175 additions & 171 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/service/src/lib.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration) -> Result<
134134
grandpa::LinkHalf<Block, FullClient<RuntimeApi, Executor>, FullSelectChain>,
135135
babe::BabeLink<Block>
136136
),
137-
grandpa::SharedVoterState,
137+
(
138+
grandpa::SharedVoterState,
139+
Arc<GrandpaFinalityProofProvider<FullBackend, Block>>,
140+
),
138141
)
139142
>,
140143
Error
@@ -200,9 +203,11 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration) -> Result<
200203
let justification_stream = grandpa_link.justification_stream();
201204
let shared_authority_set = grandpa_link.shared_authority_set().clone();
202205
let shared_voter_state = grandpa::SharedVoterState::empty();
206+
let finality_proof_provider =
207+
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
203208

204209
let import_setup = (block_import.clone(), grandpa_link, babe_link.clone());
205-
let rpc_setup = shared_voter_state.clone();
210+
let rpc_setup = (shared_voter_state.clone(), finality_proof_provider.clone());
206211

207212
let babe_config = babe_link.config().clone();
208213
let shared_epoch_changes = babe_link.epoch_changes().clone();
@@ -229,6 +234,7 @@ fn new_partial<RuntimeApi, Executor>(config: &mut Configuration) -> Result<
229234
shared_authority_set: shared_authority_set.clone(),
230235
justification_stream: justification_stream.clone(),
231236
subscription_executor,
237+
finality_provider: finality_proof_provider.clone(),
232238
},
233239
};
234240

@@ -316,8 +322,7 @@ fn new_full<RuntimeApi, Executor>(
316322

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

319-
let finality_proof_provider =
320-
GrandpaFinalityProofProvider::new_for_service(backend.clone(), client.clone());
325+
let (shared_voter_state, finality_proof_provider) = rpc_setup;
321326

322327
let (network, network_status_sinks, system_rpc_tx, network_starter) =
323328
service::build_network(service::BuildNetworkParams {
@@ -357,8 +362,6 @@ fn new_full<RuntimeApi, Executor>(
357362

358363
let (block_import, link_half, babe_link) = import_setup;
359364

360-
let shared_voter_state = rpc_setup;
361-
362365
let overseer_client = client.clone();
363366
let spawner = task_manager.spawn_handle();
364367
let leaves: Vec<_> = select_chain.clone()

rpc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
55
edition = "2018"
66

77
[dependencies]
8-
jsonrpc-core = "14.0.3"
8+
jsonrpc-core = "15.0.0"
99
polkadot-primitives = { path = "../primitives" }
1010
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
1111
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }

rpc/src/lib.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ use std::sync::Arc;
2323
use polkadot_primitives::v0::{Block, BlockNumber, AccountId, Nonce, Balance, Hash};
2424
use sp_api::ProvideRuntimeApi;
2525
use txpool_api::TransactionPool;
26+
use sp_block_builder::BlockBuilder;
2627
use sp_blockchain::{HeaderBackend, HeaderMetadata, Error as BlockChainError};
2728
use sp_consensus::SelectChain;
2829
use sp_consensus_babe::BabeApi;
2930
use sc_client_api::light::{Fetcher, RemoteBlockchain};
3031
use sc_consensus_babe::Epoch;
31-
use sp_block_builder::BlockBuilder;
32+
use sc_finality_grandpa::FinalityProofProvider;
3233
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
3334

3435
/// A type representing all RPC extensions.
@@ -57,19 +58,21 @@ pub struct BabeDeps {
5758
}
5859

5960
/// Dependencies for GRANDPA
60-
pub struct GrandpaDeps {
61+
pub struct GrandpaDeps<B> {
6162
/// Voting round info.
6263
pub shared_voter_state: sc_finality_grandpa::SharedVoterState,
6364
/// Authority set info.
6465
pub shared_authority_set: sc_finality_grandpa::SharedAuthoritySet<Hash, BlockNumber>,
6566
/// Receives notifications about justification events from Grandpa.
6667
pub justification_stream: sc_finality_grandpa::GrandpaJustificationStream<Block>,
67-
/// Subscription manager to keep track of pubsub subscribers.
68+
/// Executor to drive the subscription manager in the Grandpa RPC handler.
6869
pub subscription_executor: sc_rpc::SubscriptionTaskExecutor,
70+
/// Finality proof provider.
71+
pub finality_provider: Arc<FinalityProofProvider<B, Block>>,
6972
}
7073

7174
/// Full client dependencies
72-
pub struct FullDeps<C, P, SC> {
75+
pub struct FullDeps<C, P, SC, B> {
7376
/// The client instance to use.
7477
pub client: Arc<C>,
7578
/// Transaction pool instance.
@@ -81,11 +84,11 @@ pub struct FullDeps<C, P, SC> {
8184
/// BABE specific dependencies.
8285
pub babe: BabeDeps,
8386
/// GRANDPA specific dependencies.
84-
pub grandpa: GrandpaDeps,
87+
pub grandpa: GrandpaDeps<B>,
8588
}
8689

8790
/// Instantiate all RPC extensions.
88-
pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
91+
pub fn create_full<C, P, SC, B>(deps: FullDeps<C, P, SC, B>) -> RpcExtension where
8992
C: ProvideRuntimeApi<Block>,
9093
C: HeaderBackend<Block> + HeaderMetadata<Block, Error=BlockChainError>,
9194
C: Send + Sync + 'static,
@@ -95,6 +98,8 @@ pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
9598
C::Api: BlockBuilder<Block>,
9699
P: TransactionPool + Sync + Send + 'static,
97100
SC: SelectChain<Block> + 'static,
101+
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
102+
B::State: sc_client_api::StateBackend<sp_runtime::traits::HashFor<Block>>,
98103
{
99104
use frame_rpc_system::{FullSystem, SystemApi};
100105
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApi};
@@ -120,6 +125,7 @@ pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
120125
shared_authority_set,
121126
justification_stream,
122127
subscription_executor,
128+
finality_provider,
123129
} = grandpa;
124130

125131
io.extend_with(
@@ -146,6 +152,7 @@ pub fn create_full<C, P, SC>(deps: FullDeps<C, P, SC>) -> RpcExtension where
146152
shared_voter_state,
147153
justification_stream,
148154
subscription_executor,
155+
finality_provider,
149156
))
150157
);
151158
io

runtime/common/src/crowdfund.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,14 @@ mod tests {
647647
pub const TipCountdown: u64 = 1;
648648
pub const TipFindersFee: Percent = Percent::from_percent(20);
649649
pub const TipReportDepositBase: u64 = 1;
650-
pub const TipReportDepositPerByte: u64 = 1;
651650
pub const TreasuryModuleId: ModuleId = ModuleId(*b"py/trsry");
651+
pub const DataDepositPerByte: u64 = 1;
652+
pub const BountyDepositBase: u64 = 1;
653+
pub const BountyDepositPayoutDelay: u64 = 1;
654+
pub const BountyUpdatePeriod: u64 = 1;
655+
pub const MaximumReasonLength: u32 = 16384;
656+
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
657+
pub const BountyValueMinimum: u64 = 1;
652658
}
653659
pub struct Nobody;
654660
impl Contains<u64> for Nobody {
@@ -666,7 +672,7 @@ mod tests {
666672
type ApproveOrigin = frame_system::EnsureRoot<u64>;
667673
type RejectOrigin = frame_system::EnsureRoot<u64>;
668674
type Event = ();
669-
type ProposalRejection = ();
675+
type OnSlash = ();
670676
type ProposalBond = ProposalBond;
671677
type ProposalBondMinimum = ProposalBondMinimum;
672678
type SpendPeriod = SpendPeriod;
@@ -676,7 +682,13 @@ mod tests {
676682
type TipCountdown = TipCountdown;
677683
type TipFindersFee = TipFindersFee;
678684
type TipReportDepositBase = TipReportDepositBase;
679-
type TipReportDepositPerByte = TipReportDepositPerByte;
685+
type DataDepositPerByte = DataDepositPerByte;
686+
type BountyDepositBase = BountyDepositBase;
687+
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
688+
type BountyUpdatePeriod = BountyUpdatePeriod;
689+
type MaximumReasonLength = MaximumReasonLength;
690+
type BountyCuratorDeposit = BountyCuratorDeposit;
691+
type BountyValueMinimum = BountyValueMinimum;
680692
type ModuleId = TreasuryModuleId;
681693
type WeightInfo = ();
682694
}

runtime/kusama/src/lib.rs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,19 @@ impl frame_system::Trait for Runtime {
152152
type SystemWeightInfo = weights::frame_system::WeightInfo;
153153
}
154154

155+
parameter_types! {
156+
pub const MaxScheduledPerBlock: u32 = 50;
157+
}
158+
155159
impl pallet_scheduler::Trait for Runtime {
156160
type Event = Event;
157161
type Origin = Origin;
158162
type PalletsOrigin = OriginCaller;
159163
type Call = Call;
160164
type MaximumWeight = MaximumBlockWeight;
161165
type ScheduleOrigin = EnsureRoot<AccountId>;
162-
type WeightInfo = ();
166+
type MaxScheduledPerBlock = MaxScheduledPerBlock;
167+
type WeightInfo = weights::pallet_scheduler::WeightInfo;
163168
}
164169

165170
parameter_types! {
@@ -188,6 +193,8 @@ impl pallet_babe::Trait for Runtime {
188193

189194
type HandleEquivocation =
190195
pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
196+
197+
type WeightInfo = ();
191198
}
192199

193200
parameter_types! {
@@ -494,7 +501,13 @@ parameter_types! {
494501
pub const TipCountdown: BlockNumber = 1 * DAYS;
495502
pub const TipFindersFee: Percent = Percent::from_percent(20);
496503
pub const TipReportDepositBase: Balance = 1 * DOLLARS;
497-
pub const TipReportDepositPerByte: Balance = 1 * CENTS;
504+
pub const DataDepositPerByte: Balance = 1 * CENTS;
505+
pub const BountyDepositBase: Balance = 1 * DOLLARS;
506+
pub const BountyDepositPayoutDelay: BlockNumber = 4 * DAYS;
507+
pub const BountyUpdatePeriod: BlockNumber = 90 * DAYS;
508+
pub const MaximumReasonLength: u32 = 16384;
509+
pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);
510+
pub const BountyValueMinimum: Balance = 2 * DOLLARS;
498511
}
499512

500513
type ApproveOrigin = EnsureOneOf<
@@ -504,23 +517,29 @@ type ApproveOrigin = EnsureOneOf<
504517
>;
505518

506519
impl pallet_treasury::Trait for Runtime {
520+
type ModuleId = TreasuryModuleId;
507521
type Currency = Balances;
508522
type ApproveOrigin = ApproveOrigin;
509523
type RejectOrigin = MoreThanHalfCouncil;
510524
type Tippers = ElectionsPhragmen;
511525
type TipCountdown = TipCountdown;
512526
type TipFindersFee = TipFindersFee;
513527
type TipReportDepositBase = TipReportDepositBase;
514-
type TipReportDepositPerByte = TipReportDepositPerByte;
528+
type DataDepositPerByte = DataDepositPerByte;
515529
type Event = Event;
516-
type ProposalRejection = Treasury;
530+
type OnSlash = Treasury;
517531
type ProposalBond = ProposalBond;
518532
type ProposalBondMinimum = ProposalBondMinimum;
519533
type SpendPeriod = SpendPeriod;
520534
type Burn = Burn;
535+
type BountyDepositBase = BountyDepositBase;
536+
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
537+
type BountyUpdatePeriod = BountyUpdatePeriod;
538+
type MaximumReasonLength = MaximumReasonLength;
539+
type BountyCuratorDeposit = BountyCuratorDeposit;
540+
type BountyValueMinimum = BountyValueMinimum;
521541
type BurnDestination = Society;
522-
type ModuleId = TreasuryModuleId;
523-
type WeightInfo = ();
542+
type WeightInfo = weights::pallet_treasury::WeightInfo;
524543
}
525544

526545
parameter_types! {
@@ -532,7 +551,6 @@ impl pallet_offences::Trait for Runtime {
532551
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
533552
type OnOffenceHandler = Staking;
534553
type WeightSoftLimit = OffencesWeightSoftLimit;
535-
type WeightInfo = ();
536554
}
537555

538556
impl pallet_authority_discovery::Trait for Runtime {}
@@ -570,6 +588,8 @@ impl pallet_grandpa::Trait for Runtime {
570588
)>>::IdentificationTuple;
571589

572590
type HandleEquivocation = pallet_grandpa::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
591+
592+
type WeightInfo = ();
573593
}
574594

575595
parameter_types! {

runtime/kusama/src/weights/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ pub mod pallet_balances;
2121
pub mod pallet_collective;
2222
pub mod pallet_democracy;
2323
pub mod pallet_proxy;
24+
pub mod pallet_scheduler;
2425
pub mod pallet_staking;
2526
pub mod pallet_timestamp;
27+
pub mod pallet_treasury;
2628
pub mod pallet_utility;
2729
pub mod pallet_vesting;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (C) 2020 Parity Technologies (UK) Ltd.
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 2.0.0-rc6
17+
18+
#![allow(unused_parens)]
19+
#![allow(unused_imports)]
20+
21+
use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
22+
23+
pub struct WeightInfo;
24+
impl pallet_scheduler::WeightInfo for WeightInfo {
25+
fn schedule(s: u32, ) -> Weight {
26+
(37_835_000 as Weight)
27+
.saturating_add((81_000 as Weight).saturating_mul(s as Weight))
28+
.saturating_add(DbWeight::get().reads(1 as Weight))
29+
.saturating_add(DbWeight::get().writes(1 as Weight))
30+
}
31+
fn cancel(s: u32, ) -> Weight {
32+
(34_707_000 as Weight)
33+
.saturating_add((3_125_000 as Weight).saturating_mul(s as Weight))
34+
.saturating_add(DbWeight::get().reads(1 as Weight))
35+
.saturating_add(DbWeight::get().writes(2 as Weight))
36+
}
37+
fn schedule_named(s: u32, ) -> Weight {
38+
(48_065_000 as Weight)
39+
.saturating_add((110_000 as Weight).saturating_mul(s as Weight))
40+
.saturating_add(DbWeight::get().reads(2 as Weight))
41+
.saturating_add(DbWeight::get().writes(2 as Weight))
42+
}
43+
fn cancel_named(s: u32, ) -> Weight {
44+
(38_776_000 as Weight)
45+
.saturating_add((3_138_000 as Weight).saturating_mul(s as Weight))
46+
.saturating_add(DbWeight::get().reads(2 as Weight))
47+
.saturating_add(DbWeight::get().writes(2 as Weight))
48+
}
49+
}

0 commit comments

Comments
 (0)