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

Commit

Permalink
merge master once again
Browse files Browse the repository at this point in the history
* master:
  [Companion] Metadata delete on dissolve_pool (#5955)
  Companion for: `try-runtime`::`follow-chain` - keep connection (#5968)
  Companion - Read babe config parameters from runtime (#5842)
  Double approval checking timeout. (#5951)
  Doc comments for metrics in provisioner (#5967)
  • Loading branch information
ordian committed Sep 6, 2022
2 parents cd9aeb8 + d100210 commit 3fe81e9
Show file tree
Hide file tree
Showing 17 changed files with 242 additions and 236 deletions.
340 changes: 170 additions & 170 deletions Cargo.lock

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions node/core/provisioner/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ use polkadot_node_subsystem_util::metrics::{self, prometheus};

#[derive(Clone)]
struct MetricsInner {
/// Tracks successful/unsuccessful inherent data requests
inherent_data_requests: prometheus::CounterVec<prometheus::U64>,
request_inherent_data: prometheus::Histogram,
provisionable_data: prometheus::Histogram,
/// How much time the `RequestInherentData` processing takes
request_inherent_data_duration: prometheus::Histogram,
/// How much time `ProvisionableData` processing takes
provisionable_data_duration: prometheus::Histogram,
/// Bitfields array length in `ProvisionerInherentData` (the result for `RequestInherentData`)
inherent_data_response_bitfields: prometheus::Histogram,

/// The following metrics track how many disputes/votes the runtime will have to process. These will count
Expand Down Expand Up @@ -54,14 +58,16 @@ impl Metrics {
pub(crate) fn time_request_inherent_data(
&self,
) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
self.0.as_ref().map(|metrics| metrics.request_inherent_data.start_timer())
self.0
.as_ref()
.map(|metrics| metrics.request_inherent_data_duration.start_timer())
}

/// Provide a timer for `provisionable_data` which observes on drop.
pub(crate) fn time_provisionable_data(
&self,
) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
self.0.as_ref().map(|metrics| metrics.provisionable_data.start_timer())
self.0.as_ref().map(|metrics| metrics.provisionable_data_duration.start_timer())
}

pub(crate) fn observe_inherent_data_bitfields_count(&self, bitfields_count: usize) {
Expand Down Expand Up @@ -110,14 +116,14 @@ impl metrics::Metrics for Metrics {
)?,
registry,
)?,
request_inherent_data: prometheus::register(
request_inherent_data_duration: prometheus::register(
prometheus::Histogram::with_opts(prometheus::HistogramOpts::new(
"polkadot_parachain_provisioner_request_inherent_data_time",
"Time spent within `provisioner::request_inherent_data`",
))?,
registry,
)?,
provisionable_data: prometheus::register(
provisionable_data_duration: prometheus::register(
prometheus::Histogram::with_opts(prometheus::HistogramOpts::new(
"polkadot_parachain_provisioner_provisionable_data_time",
"Time spent within `provisioner::provisionable_data`",
Expand Down
2 changes: 1 addition & 1 deletion node/core/runtime-api/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ sp_api::mock_impl_runtime_apis! {
}

impl BabeApi<Block> for MockRuntimeApi {
fn configuration(&self) -> sp_consensus_babe::BabeGenesisConfiguration {
fn configuration(&self) -> sp_consensus_babe::BabeConfiguration {
unimplemented!()
}

Expand Down
2 changes: 1 addition & 1 deletion node/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pub const BACKING_EXECUTION_TIMEOUT: Duration = Duration::from_secs(2);
/// ensure that in the absence of extremely large disparities between hardware,
/// blocks that pass backing are considerd executable by approval checkers or
/// dispute participants.
pub const APPROVAL_EXECUTION_TIMEOUT: Duration = Duration::from_secs(6);
pub const APPROVAL_EXECUTION_TIMEOUT: Duration = Duration::from_secs(12);

/// Linked to `MAX_FINALITY_LAG` in relay chain selection,
/// `MAX_HEADS_LOOK_BACK` in `approval-voting` and
Expand Down
2 changes: 1 addition & 1 deletion node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ where
client.clone(),
);

let babe_config = babe::Config::get(&*client)?;
let babe_config = babe::configuration(&*client)?;
let (block_import, babe_link) =
babe::block_import(babe_config.clone(), beefy_block_import, client.clone())?;

Expand Down
4 changes: 2 additions & 2 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::sync::Arc;
use jsonrpsee::RpcModule;
use polkadot_primitives::v2::{AccountId, Balance, Block, BlockNumber, Hash, Nonce};
use sc_client_api::AuxStore;
use sc_consensus_babe::Epoch;
use sc_consensus_babe::{BabeConfiguration, Epoch};
use sc_finality_grandpa::FinalityProofProvider;
pub use sc_rpc::{DenyUnsafe, SubscriptionTaskExecutor};
use sp_api::ProvideRuntimeApi;
Expand All @@ -40,7 +40,7 @@ pub type RpcExtension = RpcModule<()>;
/// Extra dependencies for BABE.
pub struct BabeDeps {
/// BABE protocol config.
pub babe_config: sc_consensus_babe::Config,
pub babe_config: BabeConfiguration,
/// BABE pending epoch changes.
pub shared_epoch_changes: sc_consensus_epochs::SharedEpochChanges<Block, Epoch>,
/// The keystore that manages the keys of the node.
Expand Down
3 changes: 3 additions & 0 deletions runtime/kusama/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub mod time {
pub const WEEKS: BlockNumber = DAYS * 7;

// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
// The choice of is done in accordance to the slot duration and expected target
// block time, for safely resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
}

Expand Down
18 changes: 7 additions & 11 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(),
pallet_nomination_pools::migration::v3::MigrateToV3<Runtime>,
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
Expand Down Expand Up @@ -1766,19 +1766,15 @@ sp_api::impl_runtime_apis! {
}

impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeGenesisConfiguration {
// The choice of `c` parameter (where `1 - c` represents the
// probability of a slot being empty), is done in accordance to the
// slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
babe_primitives::BabeGenesisConfiguration {
fn configuration() -> babe_primitives::BabeConfiguration {
let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
babe_primitives::BabeConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities().to_vec(),
c: epoch_config.c,
authorities: Babe::authorities().to_vec(),
randomness: Babe::randomness(),
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
allowed_slots: epoch_config.allowed_slots,
}
}

Expand Down
3 changes: 3 additions & 0 deletions runtime/polkadot/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ pub mod time {
pub const WEEKS: BlockNumber = DAYS * 7;

// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
// The choice of is done in accordance to the slot duration and expected target
// block time, for safely resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
}

Expand Down
18 changes: 7 additions & 11 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
InitiateNominationPools,
(InitiateNominationPools, pallet_nomination_pools::migration::v3::MigrateToV3<Runtime>),
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
Expand Down Expand Up @@ -1895,19 +1895,15 @@ sp_api::impl_runtime_apis! {
}

impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeGenesisConfiguration {
// The choice of `c` parameter (where `1 - c` represents the
// probability of a slot being empty), is done in accordance to the
// slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
babe_primitives::BabeGenesisConfiguration {
fn configuration() -> babe_primitives::BabeConfiguration {
let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
babe_primitives::BabeConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities().to_vec(),
c: epoch_config.c,
authorities: Babe::authorities().to_vec(),
randomness: Babe::randomness(),
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
allowed_slots: epoch_config.allowed_slots,
}
}

Expand Down
3 changes: 3 additions & 0 deletions runtime/rococo/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub mod time {
pub const DAYS: BlockNumber = HOURS * 24;

// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
// The choice of is done in accordance to the slot duration and expected target
// block time, for safely resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
}

Expand Down
16 changes: 6 additions & 10 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,19 +1160,15 @@ sp_api::impl_runtime_apis! {
}

impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeGenesisConfiguration {
// The choice of `c` parameter (where `1 - c` represents the
// probability of a slot being empty), is done in accordance to the
// slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
babe_primitives::BabeGenesisConfiguration {
fn configuration() -> babe_primitives::BabeConfiguration {
let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
babe_primitives::BabeConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDurationInBlocks::get().into(),
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities().to_vec(),
c: epoch_config.c,
authorities: Babe::authorities().to_vec(),
randomness: Babe::randomness(),
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
allowed_slots: epoch_config.allowed_slots,
}
}

Expand Down
3 changes: 3 additions & 0 deletions runtime/test-runtime/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub mod time {
pub const DAYS: BlockNumber = HOURS * 24;

// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
// The choice of is done in accordance to the slot duration and expected target
// block time, for safely resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
}

Expand Down
16 changes: 6 additions & 10 deletions runtime/test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -992,19 +992,15 @@ sp_api::impl_runtime_apis! {
}

impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeGenesisConfiguration {
// The choice of `c` parameter (where `1 - c` represents the
// probability of a slot being empty), is done in accordance to the
// slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
babe_primitives::BabeGenesisConfiguration {
fn configuration() -> babe_primitives::BabeConfiguration {
let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
babe_primitives::BabeConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities().to_vec(),
c: epoch_config.c,
authorities: Babe::authorities().to_vec(),
randomness: Babe::randomness(),
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
allowed_slots: epoch_config.allowed_slots,
}
}

Expand Down
3 changes: 3 additions & 0 deletions runtime/westend/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ pub mod time {
pub const DAYS: BlockNumber = HOURS * 24;

// 1 in 4 blocks (on average, not counting collisions) will be primary babe blocks.
// The choice of is done in accordance to the slot duration and expected target
// block time, for safely resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4);
}

Expand Down
18 changes: 7 additions & 11 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(),
pallet_nomination_pools::migration::v3::MigrateToV3<Runtime>,
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
Expand Down Expand Up @@ -1496,19 +1496,15 @@ sp_api::impl_runtime_apis! {
}

impl babe_primitives::BabeApi<Block> for Runtime {
fn configuration() -> babe_primitives::BabeGenesisConfiguration {
// The choice of `c` parameter (where `1 - c` represents the
// probability of a slot being empty), is done in accordance to the
// slot duration and expected target block time, for safely
// resisting network delays of maximum two seconds.
// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
babe_primitives::BabeGenesisConfiguration {
fn configuration() -> babe_primitives::BabeConfiguration {
let epoch_config = Babe::epoch_config().unwrap_or(BABE_GENESIS_EPOCH_CONFIG);
babe_primitives::BabeConfiguration {
slot_duration: Babe::slot_duration(),
epoch_length: EpochDuration::get(),
c: BABE_GENESIS_EPOCH_CONFIG.c,
genesis_authorities: Babe::authorities().to_vec(),
c: epoch_config.c,
authorities: Babe::authorities().to_vec(),
randomness: Babe::randomness(),
allowed_slots: BABE_GENESIS_EPOCH_CONFIG.allowed_slots,
allowed_slots: epoch_config.allowed_slots,
}
}

Expand Down
9 changes: 7 additions & 2 deletions tests/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.

use polkadot_core_primitives::Block;
use remote_externalities::rpc_api::get_finalized_head;
use remote_externalities::rpc_api::RpcService;
use std::{
io::{BufRead, BufReader, Read},
process::{Child, ExitStatus},
Expand Down Expand Up @@ -56,7 +56,12 @@ async fn wait_n_finalized_blocks_from(n: usize, url: &str) {
let mut interval = tokio::time::interval(Duration::from_secs(6));

loop {
if let Ok(block) = get_finalized_head::<Block, _>(url).await {
let rpc_service = match RpcService::new(url, false).await {
Ok(rpc_service) => rpc_service,
Err(_) => continue,
};

if let Ok(block) = rpc_service.get_finalized_head::<Block>().await {
built_blocks.insert(block);
if built_blocks.len() > n {
break
Expand Down

0 comments on commit 3fe81e9

Please sign in to comment.