Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into mku-txpool-register…
Browse files Browse the repository at this point in the history
…-listeners
  • Loading branch information
michalkucharczyk committed Feb 4, 2025
2 parents e907960 + d6aa157 commit c15f33a
Show file tree
Hide file tree
Showing 83 changed files with 1,783 additions and 4,849 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/misc-sync-templates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,20 @@ jobs:
- name: Build runtime and generate chain spec
run: |
# Prepare directories
sudo mkdir -p ${{ matrix.template.runtime_path }}/target
sudo chmod -R 777 ${{ matrix.template.runtime_path }}/target
sudo mkdir -p ${{ matrix.runtime_path }}/target
sudo chmod -R 777 ${{ matrix.runtime_path }}/target
# Build runtime
srtool build --package ${{ matrix.template.package_name }} --runtime-dir ${{ matrix.template.runtime_path }} --root
srtool build --package ${{ matrix.package_name }} --runtime-dir ${{ matrix.runtime_path }} --root
# Generate chain spec
# Note that para-id is set to 1000 for both minimal/parachain templates.
# `parachain-runtime` is hardcoded to use this parachain id.
# `minimal` template isn't using it, but when started with Omni Node, this para id is required (any number can do it, so setting it to 1000 for convenience).
chain-spec-builder -c dev_chain_spec.json create \
--relay-chain "${{ matrix.template.relay_chain }}" \
--relay-chain "${{ matrix.relay_chain }}" \
--para-id 1000 \
--runtime "${{ matrix.template.runtime_path }}/target/srtool/release/wbuild/${{ matrix.template.runtime_wasm_path }}" \
--runtime "${{ matrix.runtime_path }}/target/srtool/release/wbuild/${{ matrix.runtime_wasm_path }}" \
named-preset development
- name: Prepare upload directory
Expand Down Expand Up @@ -149,6 +149,10 @@ jobs:
working-directory: polkadot-sdk/templates/${{ matrix.template }}/
- name: Create a new workspace Cargo.toml
run: |
# This replaces the existing Cargo.toml for parachain-template,
# corresponding to the `parachain-template-docs` crate, so no need
# to delete that `Cargo.toml` after copying the `polkadot-sdk/templates/parachain/*`
# to the `polkadot-sdk-parachain-template` repo.
cat << EOF > Cargo.toml
[workspace.package]
license = "MIT-0"
Expand Down Expand Up @@ -204,7 +208,6 @@ jobs:
if: ${{ matrix.template == 'parachain' }}
run: |
rm -f "${{ env.template-path }}/README.docify.md"
rm -f "${{ env.template-path }}/Cargo.toml"
rm -f "${{ env.template-path }}/src/lib.rs"
- name: Run psvm on monorepo workspace dependencies
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/release-10_branchoff-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,11 @@ jobs:
. ./.github/scripts/release/release_lib.sh
NODE_VERSION="${{ needs.prepare-tooling.outputs.node_version }}"
set_version "\(NODE_VERSION[^=]*= \)\".*\"" $NODE_VERSION "polkadot/node/primitives/src/lib.rs"
NODE_VERSION_PATTERN="\(NODE_VERSION[^=]*= \)\".*\""
set_version $NODE_VERSION_PATTERN $NODE_VERSION "polkadot/node/primitives/src/lib.rs"
commit_with_message "Bump node version to $NODE_VERSION in polkadot-cli"
set_version $NODE_VERSION_PATTERN $NODE_VERSION "cumulus/polkadot-omni-node/lib/src/nodes/mod.rs"
commit_with_message "Bump node version to $NODE_VERSION in polkadot-omni-node-lib"
SPEC_VERSION=$(get_spec_version $NODE_VERSION)
runtimes_list=$(get_filtered_runtimes_list)
Expand Down
57 changes: 37 additions & 20 deletions cumulus/client/consensus/aura/src/collators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@
use crate::collator::SlotClaim;
use codec::Codec;
use cumulus_client_consensus_common::{
self as consensus_common, load_abridged_host_configuration, ParentSearchParams,
};
use cumulus_client_consensus_common::{self as consensus_common, ParentSearchParams};
use cumulus_primitives_aura::{AuraUnincludedSegmentApi, Slot};
use cumulus_primitives_core::{relay_chain::Hash as ParaHash, BlockT, ClaimQueueOffset};
use cumulus_relay_chain_interface::RelayChainInterface;
use polkadot_node_subsystem::messages::RuntimeApiRequest;
use polkadot_node_subsystem_util::runtime::ClaimQueueSnapshot;
use polkadot_primitives::{
AsyncBackingParams, CoreIndex, Hash as RelayHash, Id as ParaId, OccupiedCoreAssumption,
ValidationCodeHash,
CoreIndex, Hash as RelayHash, Id as ParaId, OccupiedCoreAssumption, ValidationCodeHash,
DEFAULT_SCHEDULING_LOOKAHEAD,
};
use sc_consensus_aura::{standalone as aura_internal, AuraApi};
use sp_api::{ApiExt, ProvideRuntimeApi};
use sp_api::{ApiExt, ProvideRuntimeApi, RuntimeApiInfo};
use sp_core::Pair;
use sp_keystore::KeystorePtr;
use sp_timestamp::Timestamp;
Expand Down Expand Up @@ -102,26 +101,43 @@ async fn check_validation_code_or_log(
}
}

/// Reads async backing parameters from the relay chain storage at the given relay parent.
async fn async_backing_params(
/// Fetch scheduling lookahead at given relay parent.
async fn scheduling_lookahead(
relay_parent: RelayHash,
relay_client: &impl RelayChainInterface,
) -> Option<AsyncBackingParams> {
match load_abridged_host_configuration(relay_parent, relay_client).await {
Ok(Some(config)) => Some(config.async_backing_params),
Ok(None) => {
) -> Option<u32> {
let runtime_api_version = relay_client
.version(relay_parent)
.await
.map_err(|e| {
tracing::error!(
target: crate::LOG_TARGET,
"Active config is missing in relay chain storage",
);
None
},
target: super::LOG_TARGET,
error = ?e,
"Failed to fetch relay chain runtime version.",
)
})
.ok()?;

let parachain_host_runtime_api_version = runtime_api_version
.api_version(
&<dyn polkadot_primitives::runtime_api::ParachainHost<polkadot_primitives::Block>>::ID,
)
.unwrap_or_default();

if parachain_host_runtime_api_version <
RuntimeApiRequest::SCHEDULING_LOOKAHEAD_RUNTIME_REQUIREMENT
{
return None
}

match relay_client.scheduling_lookahead(relay_parent).await {
Ok(scheduling_lookahead) => Some(scheduling_lookahead),
Err(err) => {
tracing::error!(
target: crate::LOG_TARGET,
?err,
?relay_parent,
"Failed to read active config from relay chain client",
"Failed to fetch scheduling lookahead from relay chain",
);
None
},
Expand Down Expand Up @@ -217,9 +233,10 @@ where
let parent_search_params = ParentSearchParams {
relay_parent,
para_id,
ancestry_lookback: crate::collators::async_backing_params(relay_parent, relay_client)
ancestry_lookback: scheduling_lookahead(relay_parent, relay_client)
.await
.map_or(0, |params| params.allowed_ancestry_len as usize),
.unwrap_or(DEFAULT_SCHEDULING_LOOKAHEAD)
.saturating_sub(1) as usize,
max_depth: PARENT_SEARCH_DEPTH,
ignore_alternative_branches: true,
};
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/consensus/common/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ impl RelayChainInterface for Relaychain {
) -> RelayChainResult<Vec<u8>> {
unimplemented!("Not needed for test")
}

async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
unimplemented!("Not needed for test")
}
}

fn sproof_with_best_parent(client: &Client) -> RelayStateSproofBuilder {
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ impl RelayChainInterface for DummyRelayChainInterface {
) -> RelayChainResult<Vec<u8>> {
unimplemented!("Not needed for test")
}

async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
unimplemented!("Not needed for test")
}
}

fn make_validator_and_api() -> (
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/pov-recovery/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,10 @@ impl RelayChainInterface for Relaychain {
) -> RelayChainResult<Vec<u8>> {
unimplemented!("Not needed for test")
}

async fn scheduling_lookahead(&self, _: PHash) -> RelayChainResult<u32> {
unimplemented!("Not needed for test")
}
}

fn make_candidate_chain(candidate_number_range: Range<u32>) -> Vec<CommittedCandidateReceipt> {
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/relay-chain-inprocess-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ impl RelayChainInterface for RelayChainInProcessInterface {
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>> {
Ok(self.full_client.runtime_api().claim_queue(hash)?)
}

async fn scheduling_lookahead(&self, hash: PHash) -> RelayChainResult<u32> {
Ok(self.full_client.runtime_api().scheduling_lookahead(hash)?)
}
}

pub enum BlockCheckStatus {
Expand Down
7 changes: 7 additions & 0 deletions cumulus/client/relay-chain-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ pub trait RelayChainInterface: Send + Sync {
&self,
relay_parent: PHash,
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>>;

/// Fetch the scheduling lookahead value.
async fn scheduling_lookahead(&self, relay_parent: PHash) -> RelayChainResult<u32>;
}

#[async_trait]
Expand Down Expand Up @@ -398,6 +401,10 @@ where
) -> RelayChainResult<BTreeMap<CoreIndex, VecDeque<ParaId>>> {
(**self).claim_queue(relay_parent).await
}

async fn scheduling_lookahead(&self, relay_parent: PHash) -> RelayChainResult<u32> {
(**self).scheduling_lookahead(relay_parent).await
}
}

/// Helper function to call an arbitrary runtime API using a `RelayChainInterface` client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,10 @@ impl RuntimeApiSubsystemClient for BlockChainRpcClient {
) -> Result<Option<Constraints>, ApiError> {
Ok(self.rpc_client.parachain_host_backing_constraints(at, para_id).await?)
}

async fn scheduling_lookahead(&self, at: Hash) -> Result<u32, sp_api::ApiError> {
Ok(self.rpc_client.parachain_host_scheduling_lookahead(at).await?)
}
}

#[async_trait::async_trait]
Expand Down
4 changes: 4 additions & 0 deletions cumulus/client/relay-chain-rpc-interface/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,8 @@ impl RelayChainInterface for RelayChainRpcInterface {
> {
self.rpc_client.parachain_host_claim_queue(relay_parent).await
}

async fn scheduling_lookahead(&self, relay_parent: RelayHash) -> RelayChainResult<u32> {
self.rpc_client.parachain_host_scheduling_lookahead(relay_parent).await
}
}
8 changes: 8 additions & 0 deletions cumulus/client/relay-chain-rpc-interface/src/rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,14 @@ impl RelayChainRpcClient {
.await
}

pub async fn parachain_host_scheduling_lookahead(
&self,
at: RelayHash,
) -> Result<u32, RelayChainError> {
self.call_remote_runtime_function("ParachainHost_scheduling_lookahead", at, None::<()>)
.await
}

pub async fn validation_code_hash(
&self,
at: RelayHash,
Expand Down
1 change: 1 addition & 0 deletions cumulus/polkadot-omni-node/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ mod nodes;
pub use cli::CliConfig;
pub use command::{run, RunConfig};
pub use common::{chain_spec, runtime};
pub use nodes::NODE_VERSION;
5 changes: 5 additions & 0 deletions cumulus/polkadot-omni-node/lib/src/nodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ use cumulus_primitives_core::ParaId;
use manual_seal::ManualSealNode;
use sc_service::{Configuration, TaskManager};

/// The current node version for cumulus official binaries, which takes the basic
/// SemVer form `<major>.<minor>.<patch>`. It should correspond to the latest
/// `polkadot` version of a stable release.
pub const NODE_VERSION: &'static str = "1.17.1";

/// Trait that extends the `DynNodeSpec` trait with manual seal related logic.
///
/// We need it in order to be able to access both the `DynNodeSpec` and the manual seal logic
Expand Down
5 changes: 3 additions & 2 deletions cumulus/polkadot-omni-node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@

use polkadot_omni_node_lib::{
chain_spec::DiskChainSpecLoader, run, runtime::DefaultRuntimeResolver, CliConfig as CliConfigT,
RunConfig,
RunConfig, NODE_VERSION,
};

struct CliConfig;

impl CliConfigT for CliConfig {
fn impl_version() -> String {
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
let commit_hash = env!("SUBSTRATE_CLI_COMMIT_HASH");
format!("{}-{commit_hash}", NODE_VERSION)
}

fn author() -> String {
Expand Down
5 changes: 3 additions & 2 deletions cumulus/polkadot-parachain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@

mod chain_spec;

use polkadot_omni_node_lib::{run, CliConfig as CliConfigT, RunConfig};
use polkadot_omni_node_lib::{run, CliConfig as CliConfigT, RunConfig, NODE_VERSION};

struct CliConfig;

impl CliConfigT for CliConfig {
fn impl_version() -> String {
env!("SUBSTRATE_CLI_IMPL_VERSION").into()
let commit_hash = env!("SUBSTRATE_CLI_COMMIT_HASH");
format!("{}-{commit_hash}", NODE_VERSION)
}

fn author() -> String {
Expand Down
4 changes: 0 additions & 4 deletions cumulus/zombienet/tests/0008-elastic_authoring.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
[settings]
timeout = 1000

[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params]
max_candidate_depth = 6
allowed_ancestry_len = 3

[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
num_cores = 4
Expand Down
4 changes: 0 additions & 4 deletions cumulus/zombienet/tests/0009-elastic_pov_recovery.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ requests = { memory = "2G", cpu = "1" }
limits = { memory = "4G", cpu = "2" }
requests = { memory = "2G", cpu = "1" }

[relaychain.genesis.runtimeGenesis.patch.configuration.config.async_backing_params]
max_candidate_depth = 6
allowed_ancestry_len = 3

[relaychain.genesis.runtimeGenesis.patch.configuration.config.scheduler_params]
max_validators_per_core = 1
num_cores = 4
Expand Down
Loading

0 comments on commit c15f33a

Please sign in to comment.