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

Feature Flagging Consensus Hook Type Parameter #2911

Merged
merged 6 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions client/consensus/common/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ fn build_and_import_block_ext<I: BlockImport<Block>>(

fn build_and_import_block(mut client: Arc<Client>, import_as_best: bool) -> Block {
build_and_import_block_ext(
&*client.clone(),
&client.clone(),
BlockOrigin::Own,
import_as_best,
&mut client,
Expand Down Expand Up @@ -458,7 +458,7 @@ fn follow_finalized_does_not_stop_on_unknown_block() {
let block = build_and_import_block(client.clone(), false);

let unknown_block = {
let sproof = sproof_with_parent_by_hash(&*client, block.hash());
let sproof = sproof_with_parent_by_hash(&client, block.hash());
let block_builder = client.init_block_builder_at(block.hash(), None, sproof);
block_builder.build().unwrap().block
};
Expand Down Expand Up @@ -508,7 +508,7 @@ fn follow_new_best_sets_best_after_it_is_imported() {
let block = build_and_import_block(client.clone(), false);

let unknown_block = {
let sproof = sproof_with_parent_by_hash(&*client, block.hash());
let sproof = sproof_with_parent_by_hash(&client, block.hash());
let block_builder = client.init_block_builder_at(block.hash(), None, sproof);
block_builder.build().unwrap().block
};
Expand Down Expand Up @@ -632,7 +632,7 @@ fn prune_blocks_on_level_overflow() {
);

let block0 = build_and_import_block_ext(
&*client,
&client,
BlockOrigin::NetworkInitialSync,
true,
&mut para_import,
Expand All @@ -644,7 +644,7 @@ fn prune_blocks_on_level_overflow() {
let blocks1 = (0..LEVEL_LIMIT)
.map(|i| {
build_and_import_block_ext(
&*client,
&client,
if i == 1 { BlockOrigin::NetworkInitialSync } else { BlockOrigin::Own },
i == 1,
&mut para_import,
Expand All @@ -658,7 +658,7 @@ fn prune_blocks_on_level_overflow() {
let blocks2 = (0..2)
.map(|i| {
build_and_import_block_ext(
&*client,
&client,
BlockOrigin::Own,
false,
&mut para_import,
Expand Down Expand Up @@ -686,7 +686,7 @@ fn prune_blocks_on_level_overflow() {
assert_eq!(best, blocks1[1].header.hash());

let block13 = build_and_import_block_ext(
&*client,
&client,
BlockOrigin::Own,
false,
&mut para_import,
Expand All @@ -705,7 +705,7 @@ fn prune_blocks_on_level_overflow() {
assert_eq!(leaves, expected);

let block14 = build_and_import_block_ext(
&*client,
&client,
BlockOrigin::Own,
false,
&mut para_import,
Expand Down Expand Up @@ -743,7 +743,7 @@ fn restore_limit_monitor() {
);

let block00 = build_and_import_block_ext(
&*client,
&client,
BlockOrigin::NetworkInitialSync,
true,
&mut para_import,
Expand All @@ -755,7 +755,7 @@ fn restore_limit_monitor() {
let blocks1 = (0..LEVEL_LIMIT + 1)
.map(|i| {
build_and_import_block_ext(
&*client,
&client,
if i == 1 { BlockOrigin::NetworkInitialSync } else { BlockOrigin::Own },
i == 1,
&mut para_import,
Expand All @@ -769,7 +769,7 @@ fn restore_limit_monitor() {
let _ = (0..LEVEL_LIMIT)
.map(|i| {
build_and_import_block_ext(
&*client,
&client,
BlockOrigin::Own,
false,
&mut para_import,
Expand Down Expand Up @@ -803,7 +803,7 @@ fn restore_limit_monitor() {
std::mem::drop(monitor);

let block13 = build_and_import_block_ext(
&*client,
&client,
BlockOrigin::Own,
false,
&mut para_import,
Expand Down
2 changes: 2 additions & 0 deletions pallets/parachain-system/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,5 @@ runtime-benchmarks = [
]

try-runtime = ["frame-support/try-runtime"]

parameterized-consensus-hook = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing endlines though

11 changes: 8 additions & 3 deletions pallets/parachain-system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ use unincluded_segment::{
UsedBandwidth,
};

pub use consensus_hook::ConsensusHook;
pub use consensus_hook::{ConsensusHook, ExpectParentIncluded};
/// Register the `validate_block` function that is used by parachains to validate blocks on a
/// validator.
///
Expand Down Expand Up @@ -212,6 +212,9 @@ pub mod pallet {
/// [`consensus_hook::ExpectParentIncluded`] here. This is only necessary in the case
/// that collators aren't expected to have node versions that supply the included block
/// in the relay-chain state proof.
///
/// This config type is only available when the `parameterized-consensus-hook` crate feature is activated.
#[cfg(feature = "parameterized-consensus-hook")]
BradleyOlson64 marked this conversation as resolved.
Show resolved Hide resolved
type ConsensusHook: ConsensusHook;
}

Expand Down Expand Up @@ -490,8 +493,10 @@ pub mod pallet {
.expect("Invalid relay chain state proof");

// Update the desired maximum capacity according to the consensus hook.
let (consensus_hook_weight, capacity) =
T::ConsensusHook::on_state_proof(&relay_state_proof);
#[cfg(feature = "parameterized-consensus-hook")]
let (consensus_hook_weight, capacity) = T::ConsensusHook::on_state_proof(&relay_state_proof);
#[cfg(not(feature = "parameterized-consensus-hook"))]
let (consensus_hook_weight, capacity) = ExpectParentIncluded::on_state_proof(&relay_state_proof);
total_weight += consensus_hook_weight;
total_weight += Self::maybe_drop_included_ancestors(&relay_state_proof, capacity);
// Deposit a log indicating the relay-parent storage root.
Expand Down
8 changes: 5 additions & 3 deletions pallets/parachain-system/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ use frame_support::{
traits::{OnFinalize, OnInitialize},
weights::Weight,
};
use frame_system::{pallet_prelude::{BlockNumberFor, HeaderFor}, RawOrigin};
use frame_system::{
pallet_prelude::{BlockNumberFor, HeaderFor},
RawOrigin,
};
use hex_literal::hex;
use relay_chain::HrmpChannelId;
use sp_core::{blake2_256, H256};
Expand Down Expand Up @@ -238,8 +241,7 @@ struct BlockTests {
inherent_data_hook:
Option<Box<dyn Fn(&BlockTests, RelayChainBlockNumber, &mut ParachainInherentData)>>,
inclusion_delay: Option<usize>,
relay_block_number:
Option<Box<dyn Fn(&BlockNumberFor<Test>) -> RelayChainBlockNumber>>,
relay_block_number: Option<Box<dyn Fn(&BlockNumberFor<Test>) -> RelayChainBlockNumber>>,

included_para_head: Option<relay_chain::HeadData>,
pending_blocks: VecDeque<relay_chain::HeadData>,
Expand Down
4 changes: 2 additions & 2 deletions parachain-template/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = {path = "../../pallets/session-benchmarking", default-features = false, version = "3.0.0"}
cumulus-pallet-xcm = { path = "../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../pallets/xcmp-queue", default-features = false }
Expand Down Expand Up @@ -161,4 +161,4 @@ try-runtime = [
"pallet-transaction-payment/try-runtime",
"pallet-xcm/try-runtime",
"parachain-info/try-runtime",
]
]
6 changes: 4 additions & 2 deletions parachains/runtimes/assets/asset-hub-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = {path = "../../../../pallets/session-benchmarking", default-features = false, version = "3.0.0"}
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
Expand All @@ -82,7 +82,9 @@ asset-test-utils = { path = "../test-utils"}
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
default = [
"std",
]
# When enabled the `state_version` is set to `1`.
# This means that the chain will start using the new state format. The migration is lazy, so
# it requires to write a storage value to use the new state format. To migrate all the other
Expand Down
6 changes: 4 additions & 2 deletions parachains/runtimes/assets/asset-hub-polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", default-features = false, version = "3.0.0" }
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
Expand All @@ -81,7 +81,9 @@ asset-test-utils = { path = "../test-utils"}
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
default = [
"std",
]
runtime-benchmarks = [
"hex-literal",
"frame-benchmarking/runtime-benchmarks",
Expand Down
6 changes: 4 additions & 2 deletions parachains/runtimes/assets/asset-hub-westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = {path = "../../../../pallets/session-benchmarking", default-features = false, version = "3.0.0"}
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
Expand All @@ -84,7 +84,9 @@ asset-test-utils = { path = "../test-utils"}
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
default = [
"std",
]
runtime-benchmarks = [
"hex-literal",
"frame-benchmarking/runtime-benchmarks",
Expand Down
2 changes: 1 addition & 1 deletion parachains/runtimes/assets/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sp-std = { git = "https://github.com/paritytech/substrate", default-features = f
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }

# Cumulus
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = {path = "../../../../pallets/session-benchmarking", default-features = false, version = "3.0.0"}
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = {path = "../../../../pallets/session-benchmarking", default-features = false, version = "3.0.0"}
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = {path = "../../../../pallets/session-benchmarking", default-features = false, version = "3.0.0"}
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
Expand Down
2 changes: 1 addition & 1 deletion parachains/runtimes/bridge-hubs/test-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pallet-session = { git = "https://github.com/paritytech/substrate", default-feat
# Cumulus
asset-test-utils = { path = "../../assets/test-utils"}
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
pallet-collator-selection = { path = "../../../../pallets/collator-selection", default-features = false }
parachain-info = { path = "../../../../parachains/pallets/parachain-info", default-features = false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", default-features = false, version = "3.0.0" }
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
Expand All @@ -81,7 +81,9 @@ substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", bran
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }

[features]
default = [ "std" ]
default = [
"std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
Expand Down
2 changes: 1 addition & 1 deletion parachains/runtimes/contracts/contracts-rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature
# Cumulus
cumulus-pallet-aura-ext = { path = "../../../../pallets/aura-ext", default-features = false }
cumulus-pallet-dmp-queue = { path = "../../../../pallets/dmp-queue", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-session-benchmarking = { path = "../../../../pallets/session-benchmarking", default-features = false }
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-pallet-xcmp-queue = { path = "../../../../pallets/xcmp-queue", default-features = false }
Expand Down
6 changes: 4 additions & 2 deletions parachains/runtimes/glutton/glutton-kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "rh-async-backing-feature" }

# Cumulus
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
Expand All @@ -45,7 +45,9 @@ parachains-common = { path = "../../../common", default-features = false }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }

[features]
default = [ "std" ]
default = [
"std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
Expand Down
6 changes: 4 additions & 2 deletions parachains/runtimes/starters/seedling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ sp-transaction-pool = { git = "https://github.com/paritytech/substrate", default
sp-version = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }

# Cumulus
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-solo-to-para = { path = "../../../../pallets/solo-to-para", default-features = false }
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
parachains-common = { path = "../../../common", default-features = false }
Expand All @@ -36,7 +36,9 @@ cumulus-primitives-core = { path = "../../../../primitives/core", default-featur
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
default = [
"std",
]
std = [
"codec/std",
"scale-info/std",
Expand Down
8 changes: 5 additions & 3 deletions parachains/runtimes/starters/shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ xcm-builder = { git = "https://github.com/paritytech/polkadot", default-features
xcm-executor = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "rh-async-backing-feature" }

# Cumulus
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false }
cumulus-pallet-parachain-system = { path = "../../../../pallets/parachain-system", default-features = false, features = ["parameterized-consensus-hook",] }
cumulus-pallet-xcm = { path = "../../../../pallets/xcm", default-features = false }
cumulus-primitives-core = { path = "../../../../primitives/core", default-features = false }
parachain-info = { path = "../../../pallets/parachain-info", default-features = false }
Expand All @@ -40,7 +40,9 @@ parachains-common = { path = "../../../common", default-features = false }
substrate-wasm-builder = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }

[features]
default = [ "std" ]
default = [
"std",
]
std = [
"codec/std",
"scale-info/std",
Expand Down Expand Up @@ -70,4 +72,4 @@ std = [
try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime/try-runtime",
]
]
Loading
Loading