Skip to content

Commit

Permalink
Merge branch 'master' into cl/return-data-api
Browse files Browse the repository at this point in the history
  • Loading branch information
xermicus committed Sep 23, 2024
2 parents fcacb89 + b9eb68b commit 5878734
Show file tree
Hide file tree
Showing 96 changed files with 2,163 additions and 1,757 deletions.
21 changes: 21 additions & 0 deletions .gitlab/pipeline/short-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ short-benchmark-westend: &short-bench
script:
- ./artifacts/polkadot benchmark pallet --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1

short-benchmark-rococo: &short-bench
stage: short-benchmarks
extends:
- .docker-env
- .common-refs
needs:
- job: build-short-benchmark
artifacts: true
variables:
RUNTIME: rococo
# Enable debug assertions since we are running optimized builds for testing
# but still want to have debug assertions.
RUSTFLAGS: "-C debug-assertions -D warnings"
RUST_BACKTRACE: "full"
WASM_BUILD_NO_COLOR: 1
WASM_BUILD_RUSTFLAGS: "-C debug-assertions -D warnings"
tags:
- benchmark
script:
- ./artifacts/polkadot benchmark pallet --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1

# run short-benchmarks for system parachain runtimes from cumulus

.short-benchmark-cumulus: &short-bench-cumulus
Expand Down
27 changes: 10 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/paritytec
* [Introduction](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/index.html)
to each component of the Polkadot SDK: Substrate, FRAME, Cumulus, and XCM
* [Guides](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/guides/index.html),
namely how to build your first FRAME pallet.
namely how to build your first FRAME pallet
* [Templates](https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/polkadot_sdk/templates/index.html)
for starting a new project.
* Other Resources:
for starting a new project
* Other resources:
* [Polkadot Wiki -> Build](https://wiki.polkadot.network/docs/build-guide)

## 🚀 Releases

<!-- markdownlint-disable-next-line MD013 -->
![Current Stable Release](https://raw.githubusercontent.com/paritytech/release-registry/main/badges/polkadot-sdk-latest.svg)&nbsp;&nbsp;![Next Stable Release](https://raw.githubusercontent.com/paritytech/release-registry/main/badges/polkadot-sdk-next.svg)

The Polkadot-SDK is released every three months as a `stableYYMMDD` release. They are supported for
The Polkadot SDK is released every three months as a `stableYYMMDD` release. They are supported for
one year with patches. See the next upcoming versions in the [Release
Registry](https://github.com/paritytech/release-registry/).

Expand Down
1 change: 1 addition & 0 deletions cumulus/client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ cumulus-client-collator = { workspace = true, default-features = true }
polkadot-primitives = { workspace = true, default-features = true }
polkadot-node-primitives = { workspace = true, default-features = true }
polkadot-node-subsystem = { workspace = true, default-features = true }
polkadot-node-subsystem-util = { workspace = true, default-features = true }
polkadot-overseer = { workspace = true, default-features = true }

[features]
Expand Down
4 changes: 3 additions & 1 deletion cumulus/client/consensus/aura/src/collators/lookahead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use cumulus_client_collator::service::ServiceInterface as CollatorServiceInterfa
use cumulus_client_consensus_common::{self as consensus_common, ParachainBlockImportMarker};
use cumulus_client_consensus_proposer::ProposerInterface;
use cumulus_primitives_aura::AuraUnincludedSegmentApi;
use cumulus_primitives_core::{CollectCollationInfo, PersistedValidationData};
use cumulus_primitives_core::{ClaimQueueOffset, CollectCollationInfo, PersistedValidationData};
use cumulus_relay_chain_interface::RelayChainInterface;

use polkadot_node_primitives::{PoV, SubmitCollationParams};
Expand Down Expand Up @@ -260,6 +260,8 @@ where
relay_parent,
params.para_id,
&mut params.relay_client,
// Use depth 0, to preserve behaviour.
ClaimQueueOffset(0),
)
.await
.get(0)
Expand Down
48 changes: 16 additions & 32 deletions cumulus/client/consensus/aura/src/collators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ use cumulus_client_consensus_common::{
self as consensus_common, load_abridged_host_configuration, ParentSearchParams,
};
use cumulus_primitives_aura::{AuraUnincludedSegmentApi, Slot};
use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT};
use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT, ClaimQueueOffset};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_node_subsystem_util::runtime::ClaimQueueSnapshot;
use polkadot_primitives::{
AsyncBackingParams, CoreIndex, CoreState, Hash as RelayHash, Id as ParaId,
OccupiedCoreAssumption, ValidationCodeHash,
AsyncBackingParams, CoreIndex, Hash as RelayHash, Id as ParaId, OccupiedCoreAssumption,
ValidationCodeHash,
};
use sc_consensus_aura::{standalone as aura_internal, AuraApi};
use sp_api::ProvideRuntimeApi;
Expand Down Expand Up @@ -126,50 +127,33 @@ async fn async_backing_params(
}
}

// Return all the cores assigned to the para at the provided relay parent.
// Return all the cores assigned to the para at the provided relay parent, using the claim queue
// offset.
// Will return an empty vec if the provided offset is higher than the claim queue length (which
// corresponds to the scheduling_lookahead on the relay chain).
async fn cores_scheduled_for_para(
relay_parent: RelayHash,
para_id: ParaId,
relay_client: &impl RelayChainInterface,
claim_queue_offset: ClaimQueueOffset,
) -> Vec<CoreIndex> {
// Get `AvailabilityCores` from runtime
let cores = match relay_client.availability_cores(relay_parent).await {
Ok(cores) => cores,
// Get `ClaimQueue` from runtime
let claim_queue: ClaimQueueSnapshot = match relay_client.claim_queue(relay_parent).await {
Ok(claim_queue) => claim_queue.into(),
Err(error) => {
tracing::error!(
target: crate::LOG_TARGET,
?error,
?relay_parent,
"Failed to query availability cores runtime API",
"Failed to query claim queue runtime API",
);
return Vec::new()
},
};

let max_candidate_depth = async_backing_params(relay_parent, relay_client)
.await
.map(|c| c.max_candidate_depth)
.unwrap_or(0);

cores
.iter()
.enumerate()
.filter_map(|(index, core)| {
let core_para_id = match core {
CoreState::Scheduled(scheduled_core) => Some(scheduled_core.para_id),
CoreState::Occupied(occupied_core) if max_candidate_depth > 0 => occupied_core
.next_up_on_available
.as_ref()
.map(|scheduled_core| scheduled_core.para_id),
CoreState::Free | CoreState::Occupied(_) => None,
};

if core_para_id == Some(para_id) {
Some(CoreIndex(index as u32))
} else {
None
}
})
claim_queue
.iter_claims_at_depth(claim_queue_offset.0 as usize)
.filter_map(|(core_index, core_para_id)| (core_para_id == para_id).then_some(core_index))
.collect()
}

Expand Down
Loading

0 comments on commit 5878734

Please sign in to comment.