Skip to content

Commit

Permalink
Merge branch 'master' into sync-status-refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-markin committed Aug 26, 2024
2 parents cc8ec77 + 178e699 commit c775ae4
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
25 changes: 25 additions & 0 deletions .github/workflows/checks-quick.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,28 @@ jobs:
git diff
exit 1
fi
check-fail-ci:
runs-on: ubuntu-latest
container:
# there's no "rg" in ci-unified, and tools is a smaller image anyway
image: "paritytech/tools:latest"
# paritytech/tools uses "nonroot" user by default, which doesn't have enough
# permissions to create GHA context
options: --user root
steps:
- name: Fetch latest code
uses: actions/checkout@v4
- name: Check
run: |
set +e
rg --line-number --hidden --type rust --glob '!{.git,target}' "$ASSERT_REGEX" .; exit_status=$?
if [ $exit_status -eq 0 ]; then
echo "$ASSERT_REGEX was found, exiting with 1";
exit 1;
else
echo "No $ASSERT_REGEX was found, exiting with 0";
exit 0;
fi
env:
ASSERT_REGEX: "FAIL-CI"
GIT_DEPTH: 1
20 changes: 0 additions & 20 deletions .gitlab/pipeline/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,6 @@ check-runtime-migration-rococo:
URI: "wss://rococo-try-runtime-node.parity-chains.parity.io:443"
SUBCOMMAND_EXTRA_ARGS: "--no-weight-warnings"

find-fail-ci-phrase:
stage: check
variables:
CI_IMAGE: "paritytech/tools:latest"
ASSERT_REGEX: "FAIL-CI"
GIT_DEPTH: 1
extends:
- .kubernetes-env
- .test-pr-refs
script:
- set +e
- rg --line-number --hidden --type rust --glob '!{.git,target}' "$ASSERT_REGEX" .; exit_status=$?
- if [ $exit_status -eq 0 ]; then
echo "$ASSERT_REGEX was found, exiting with 1";
exit 1;
else
echo "No $ASSERT_REGEX was found, exiting with 0";
exit 0;
fi

check-core-crypto-features:
stage: check
extends:
Expand Down
1 change: 1 addition & 0 deletions CODE_OF_CONDUCT.md
1 change: 1 addition & 0 deletions CONTRIBUTING.md
2 changes: 1 addition & 1 deletion cumulus/pallets/collator-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ pub mod pallet {
let result = Self::assemble_collators();

frame_system::Pallet::<T>::register_extra_weight_unchecked(
T::WeightInfo::new_session(candidates_len_before, removed),
T::WeightInfo::new_session(removed, candidates_len_before),
DispatchClass::Mandatory,
);
Some(result)
Expand Down
5 changes: 1 addition & 4 deletions polkadot/statement-table/src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,7 @@ impl<Ctx: Context> Table<Ctx> {
if !context.is_member_of(&from, &votes.group_id) {
let sig = match vote {
ValidityVote::Valid(s) => s,
ValidityVote::Issued(_) => panic!(
"implicit issuance vote only cast from `import_candidate` after \
checking group membership of issuer; qed"
),
ValidityVote::Issued(s) => s,
};

return Err(Misbehavior::UnauthorizedStatement(UnauthorizedStatement {
Expand Down
10 changes: 10 additions & 0 deletions prdoc/pr_5344.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Fix storage weight reclaim bug.

doc:
- audience: Node Dev
description: |
Improvement in slot worker loop that will not call create inherent data providers if the major sync is in progress. Before it was called every slot and the results were discarded during major sync.

crates:
- name: sc-consensus-slots
bump: minor
13 changes: 13 additions & 0 deletions prdoc/pr_5430.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: "pallet-collator-selection: correctly register weight in `new_session`"

doc:
- audience: Runtime Dev
description: |
- Fixes an incorrect usage of the `WeightInfo` trait for `new_session`.

crates:
- name: pallet-collator-selection
bump: patch
10 changes: 10 additions & 0 deletions prdoc/pr_5442.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: Derive `Clone` on `EncodableOpaqueLeaf`

doc:
- audience: Runtime Dev
description: |
`Clone` was derived on `EncodableOpaqueLeaf` for convenience of downstream users

crates:
- name: sp-mmr-primitives
bump: patch
13 changes: 6 additions & 7 deletions substrate/client/consensus/slots/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,16 +517,15 @@ pub async fn start_slot_worker<B, C, W, SO, CIDP, Proof>(
CIDP: CreateInherentDataProviders<B, ()> + Send + 'static,
CIDP::InherentDataProviders: InherentDataProviderExt + Send,
{
let mut slots = Slots::new(slot_duration.as_duration(), create_inherent_data_providers, client);
let mut slots = Slots::new(
slot_duration.as_duration(),
create_inherent_data_providers,
client,
sync_oracle,
);

loop {
let slot_info = slots.next_slot().await;

if sync_oracle.is_major_syncing() {
debug!(target: LOG_TARGET, "Skipping proposal slot due to sync.");
continue
}

let _ = worker.on_slot(slot_info).await;
}
}
Expand Down
17 changes: 13 additions & 4 deletions substrate/client/consensus/slots/src/slots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
//! This is used instead of `futures_timer::Interval` because it was unreliable.

use super::{InherentDataProviderExt, Slot, LOG_TARGET};
use sp_consensus::SelectChain;
use sp_consensus::{SelectChain, SyncOracle};
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
use sp_runtime::traits::{Block as BlockT, Header as HeaderT};

Expand Down Expand Up @@ -87,39 +87,43 @@ impl<B: BlockT> SlotInfo<B> {
}

/// A stream that returns every time there is a new slot.
pub(crate) struct Slots<Block, SC, IDP> {
pub(crate) struct Slots<Block, SC, IDP, SO> {
last_slot: Slot,
slot_duration: Duration,
until_next_slot: Option<Delay>,
create_inherent_data_providers: IDP,
select_chain: SC,
sync_oracle: SO,
_phantom: std::marker::PhantomData<Block>,
}

impl<Block, SC, IDP> Slots<Block, SC, IDP> {
impl<Block, SC, IDP, SO> Slots<Block, SC, IDP, SO> {
/// Create a new `Slots` stream.
pub fn new(
slot_duration: Duration,
create_inherent_data_providers: IDP,
select_chain: SC,
sync_oracle: SO,
) -> Self {
Slots {
last_slot: 0.into(),
slot_duration,
until_next_slot: None,
create_inherent_data_providers,
select_chain,
sync_oracle,
_phantom: Default::default(),
}
}
}

impl<Block, SC, IDP> Slots<Block, SC, IDP>
impl<Block, SC, IDP, SO> Slots<Block, SC, IDP, SO>
where
Block: BlockT,
SC: SelectChain<Block>,
IDP: CreateInherentDataProviders<Block, ()> + 'static,
IDP::InherentDataProviders: crate::InherentDataProviderExt,
SO: SyncOracle,
{
/// Returns a future that fires when the next slot starts.
pub async fn next_slot(&mut self) -> SlotInfo<Block> {
Expand All @@ -138,6 +142,11 @@ where
let wait_dur = time_until_next_slot(self.slot_duration);
self.until_next_slot = Some(Delay::new(wait_dur));

if self.sync_oracle.is_major_syncing() {
log::debug!(target: LOG_TARGET, "Skipping slot: major sync is in progress.");
continue;
}

let chain_head = match self.select_chain.best_chain().await {
Ok(x) => x,
Err(e) => {
Expand Down
2 changes: 1 addition & 1 deletion substrate/primitives/merkle-mountain-range/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl FullLeaf for OpaqueLeaf {
///
/// It is different from [`OpaqueLeaf`], because it does implement `Codec`
/// and the encoding has to match raw `Vec<u8>` encoding.
#[derive(codec::Encode, codec::Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)]
#[derive(codec::Encode, codec::Decode, RuntimeDebug, Clone, PartialEq, Eq, TypeInfo)]
pub struct EncodableOpaqueLeaf(pub Vec<u8>);

impl EncodableOpaqueLeaf {
Expand Down

0 comments on commit c775ae4

Please sign in to comment.