From 0ae721970909efc3b2a049632c9c904d9fa4fed1 Mon Sep 17 00:00:00 2001
From: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
Date: Fri, 31 May 2024 09:34:43 +0300
Subject: [PATCH] collator-protocol: remove `elastic-scaling-experimental`
 feature (#4595)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Validators already have been upgraded so they could already receive the
new `CollationWithParentHeadData` response when fetching collation.
However this is only sent by collators when the parachain has more than
1 core is assigned.

TODO:
- [x] PRDoc

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
---
 cumulus/polkadot-parachain/Cargo.toml         |  1 -
 .../node/network/collator-protocol/Cargo.toml |  1 -
 .../src/collator_side/mod.rs                  |  8 ------
 .../src/collator_side/tests/mod.rs            |  1 -
 .../tests/prospective_parachains.rs           |  1 -
 polkadot/node/service/Cargo.toml              |  4 ---
 .../test-parachains/adder/collator/Cargo.toml |  2 +-
 .../undying/collator/Cargo.toml               |  2 +-
 prdoc/pr_4595.prdoc                           | 25 +++++++++++++++++++
 9 files changed, 27 insertions(+), 18 deletions(-)
 create mode 100644 prdoc/pr_4595.prdoc

diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml
index a22606edb6c..def7d95fd56 100644
--- a/cumulus/polkadot-parachain/Cargo.toml
+++ b/cumulus/polkadot-parachain/Cargo.toml
@@ -172,4 +172,3 @@ try-runtime = [
 	"sp-runtime/try-runtime",
 ]
 fast-runtime = ["bridge-hub-rococo-runtime/fast-runtime"]
-elastic-scaling-experimental = ["polkadot-service/elastic-scaling-experimental"]
diff --git a/polkadot/node/network/collator-protocol/Cargo.toml b/polkadot/node/network/collator-protocol/Cargo.toml
index c02999a59b5..d7291552738 100644
--- a/polkadot/node/network/collator-protocol/Cargo.toml
+++ b/polkadot/node/network/collator-protocol/Cargo.toml
@@ -45,4 +45,3 @@ polkadot-primitives-test-helpers = { path = "../../../primitives/test-helpers" }
 
 [features]
 default = []
-elastic-scaling-experimental = []
diff --git a/polkadot/node/network/collator-protocol/src/collator_side/mod.rs b/polkadot/node/network/collator-protocol/src/collator_side/mod.rs
index 88375d58309..80a85420b39 100644
--- a/polkadot/node/network/collator-protocol/src/collator_side/mod.rs
+++ b/polkadot/node/network/collator-protocol/src/collator_side/mod.rs
@@ -924,7 +924,6 @@ async fn send_collation(
 	let peer_id = request.peer_id();
 	let candidate_hash = receipt.hash();
 
-	#[cfg(feature = "elastic-scaling-experimental")]
 	let result = match parent_head_data {
 		ParentHeadData::WithData { head_data, .. } =>
 			Ok(request_v2::CollationFetchingResponse::CollationWithParentHeadData {
@@ -935,13 +934,6 @@ async fn send_collation(
 		ParentHeadData::OnlyHash(_) =>
 			Ok(request_v1::CollationFetchingResponse::Collation(receipt, pov)),
 	};
-	#[cfg(not(feature = "elastic-scaling-experimental"))]
-	let result = {
-		// suppress unused warning
-		let _parent_head_data = parent_head_data;
-
-		Ok(request_v1::CollationFetchingResponse::Collation(receipt, pov))
-	};
 
 	let response =
 		OutgoingResponse { result, reputation_changes: Vec::new(), sent_feedback: Some(tx) };
diff --git a/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs b/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs
index 689e03ce473..412792bbecf 100644
--- a/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs
+++ b/polkadot/node/network/collator-protocol/src/collator_side/tests/mod.rs
@@ -144,7 +144,6 @@ impl Default for TestState {
 impl TestState {
 	/// Adds a few more scheduled cores to the state for the same para id
 	/// compared to the default.
-	#[cfg(feature = "elastic-scaling-experimental")]
 	pub fn with_elastic_scaling() -> Self {
 		let mut state = Self::default();
 		let para_id = state.para_id;
diff --git a/polkadot/node/network/collator-protocol/src/collator_side/tests/prospective_parachains.rs b/polkadot/node/network/collator-protocol/src/collator_side/tests/prospective_parachains.rs
index 2a147aef69e..0a0a85fb1f2 100644
--- a/polkadot/node/network/collator-protocol/src/collator_side/tests/prospective_parachains.rs
+++ b/polkadot/node/network/collator-protocol/src/collator_side/tests/prospective_parachains.rs
@@ -443,7 +443,6 @@ fn distribute_collation_up_to_limit() {
 /// Tests that collator send the parent head data in
 /// case the para is assigned to multiple cores (elastic scaling).
 #[test]
-#[cfg(feature = "elastic-scaling-experimental")]
 fn send_parent_head_data_for_elastic_scaling() {
 	let test_state = TestState::with_elastic_scaling();
 
diff --git a/polkadot/node/service/Cargo.toml b/polkadot/node/service/Cargo.toml
index 37836f134bd..0dfdf926b1b 100644
--- a/polkadot/node/service/Cargo.toml
+++ b/polkadot/node/service/Cargo.toml
@@ -238,7 +238,3 @@ runtime-metrics = [
 	"rococo-runtime?/runtime-metrics",
 	"westend-runtime?/runtime-metrics",
 ]
-
-elastic-scaling-experimental = [
-	"polkadot-collator-protocol?/elastic-scaling-experimental",
-]
diff --git a/polkadot/parachain/test-parachains/adder/collator/Cargo.toml b/polkadot/parachain/test-parachains/adder/collator/Cargo.toml
index dbc8507d599..f9aaab74deb 100644
--- a/polkadot/parachain/test-parachains/adder/collator/Cargo.toml
+++ b/polkadot/parachain/test-parachains/adder/collator/Cargo.toml
@@ -24,7 +24,7 @@ log = { workspace = true, default-features = true }
 test-parachain-adder = { path = ".." }
 polkadot-primitives = { path = "../../../../primitives" }
 polkadot-cli = { path = "../../../../cli" }
-polkadot-service = { path = "../../../../node/service", features = ["elastic-scaling-experimental", "rococo-native"] }
+polkadot-service = { path = "../../../../node/service", features = ["rococo-native"] }
 polkadot-node-primitives = { path = "../../../../node/primitives" }
 polkadot-node-subsystem = { path = "../../../../node/subsystem" }
 
diff --git a/polkadot/parachain/test-parachains/undying/collator/Cargo.toml b/polkadot/parachain/test-parachains/undying/collator/Cargo.toml
index 28efdbbf242..08d1e74d879 100644
--- a/polkadot/parachain/test-parachains/undying/collator/Cargo.toml
+++ b/polkadot/parachain/test-parachains/undying/collator/Cargo.toml
@@ -24,7 +24,7 @@ log = { workspace = true, default-features = true }
 test-parachain-undying = { path = ".." }
 polkadot-primitives = { path = "../../../../primitives" }
 polkadot-cli = { path = "../../../../cli" }
-polkadot-service = { path = "../../../../node/service", features = ["elastic-scaling-experimental", "rococo-native"] }
+polkadot-service = { path = "../../../../node/service", features = ["rococo-native"] }
 polkadot-node-primitives = { path = "../../../../node/primitives" }
 polkadot-node-subsystem = { path = "../../../../node/subsystem" }
 
diff --git a/prdoc/pr_4595.prdoc b/prdoc/pr_4595.prdoc
new file mode 100644
index 00000000000..8baa6e8a91f
--- /dev/null
+++ b/prdoc/pr_4595.prdoc
@@ -0,0 +1,25 @@
+title: "Remove `elastic-scaling-experimental` feature flag"
+
+doc:
+  - audience: Node Dev
+    description: |
+      The feature was masking the ability of collators to respond with `CollationWithParentHeadData`
+      to validator collation fetch requests, a requirement for elastic scaling. 
+      Please note that `CollationWithParentHeadData` is only sent by collators of parachains with 
+      multiple cores assigned, otherwise collators must respond with `CollationFetchingResponse::Collation`
+  - audience: Node Operator
+    description: |
+      This change enables elastic scaling support in collators. Please upgrade to latest version, 
+      otherwise validator nodes will not be able to back elastic parachain blocks leading to 
+      missed rewards. 
+
+crates:
+  - name: polkadot-collator-protocol
+    bump: major
+    validate: false
+  - name: polkadot-service
+    bump: major
+    validate: false
+  - name: polkadot-parachain-bin
+    bump: minor
+    validate: false
-- 
GitLab