From f3c2db1a28a16bb5de16bb1ceab75fa105c6defe Mon Sep 17 00:00:00 2001
From: Peter Goodspeed-Niklaus <coriolinus@users.noreply.github.com>
Date: Tue, 7 Jul 2020 10:01:15 +0200
Subject: [PATCH] convert SignedAvailabilityBitfields from newtype to typedef
 (#1342)

Closes #1339.
---
 polkadot/node/subsystem/src/messages.rs      |  4 ++--
 polkadot/primitives/src/parachain.rs         |  9 +--------
 polkadot/runtime/parachains/src/inclusion.rs | 18 +++++++++---------
 3 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/polkadot/node/subsystem/src/messages.rs b/polkadot/node/subsystem/src/messages.rs
index fb4300f561c..1ff4986b067 100644
--- a/polkadot/node/subsystem/src/messages.rs
+++ b/polkadot/node/subsystem/src/messages.rs
@@ -27,7 +27,7 @@ use futures::channel::{mpsc, oneshot};
 use polkadot_primitives::{BlockNumber, Hash, Signature};
 use polkadot_primitives::parachain::{
 	AbridgedCandidateReceipt, PoVBlock, ErasureChunk, BackedCandidate, Id as ParaId,
-	SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, ValidatorId, ValidationCode, ValidatorIndex,
+	SignedAvailabilityBitfield, SigningContext, ValidatorId, ValidationCode, ValidatorIndex,
 };
 use polkadot_node_primitives::{
 	MisbehaviorReport, SignedFullStatement, View, ProtocolId,
@@ -194,7 +194,7 @@ pub enum ProvisionableData {
 /// This data needs to make its way from the provisioner into the InherentData.
 ///
 /// There, it is used to construct the InclusionInherent.
-pub type ProvisionerInherentData = (SignedAvailabilityBitfields, Vec<BackedCandidate>);
+pub type ProvisionerInherentData = (Vec<SignedAvailabilityBitfield>, Vec<BackedCandidate>);
 
 /// Message to the Provisioner.
 ///
diff --git a/polkadot/primitives/src/parachain.rs b/polkadot/primitives/src/parachain.rs
index 4a10fea6991..b187d488e19 100644
--- a/polkadot/primitives/src/parachain.rs
+++ b/polkadot/primitives/src/parachain.rs
@@ -736,14 +736,7 @@ impl From<BitVec<bitvec::order::Lsb0, u8>> for AvailabilityBitfield {
 pub type SignedAvailabilityBitfield = Signed<AvailabilityBitfield>;
 
 /// A set of signed availability bitfields. Should be sorted by validator index, ascending.
-#[derive(Encode, Decode, Clone, PartialEq, Eq, RuntimeDebug, Default)]
-pub struct SignedAvailabilityBitfields(pub Vec<SignedAvailabilityBitfield>);
-
-impl From<Vec<SignedAvailabilityBitfield>> for SignedAvailabilityBitfields {
-	fn from(fields: Vec<SignedAvailabilityBitfield>) -> SignedAvailabilityBitfields {
-		SignedAvailabilityBitfields(fields)
-	}
-}
+pub type SignedAvailabilityBitfields = Vec<SignedAvailabilityBitfield>;
 
 /// A backed (or backable, depending on context) candidate.
 // TODO: yes, this is roughly the same as AttestedCandidate.
diff --git a/polkadot/runtime/parachains/src/inclusion.rs b/polkadot/runtime/parachains/src/inclusion.rs
index c31c4a62e6e..f9696bb33cd 100644
--- a/polkadot/runtime/parachains/src/inclusion.rs
+++ b/polkadot/runtime/parachains/src/inclusion.rs
@@ -190,7 +190,7 @@ impl<T: Trait> Module<T> {
 				session_index,
 			};
 
-			for signed_bitfield in &signed_bitfields.0 {
+			for signed_bitfield in &signed_bitfields {
 				ensure!(
 					signed_bitfield.payload().0.len() == n_bits,
 					Error::<T>::WrongBitfieldSize,
@@ -220,7 +220,7 @@ impl<T: Trait> Module<T> {
 		}
 
 		let now = <system::Module<T>>::block_number();
-		for signed_bitfield in signed_bitfields.0 {
+		for signed_bitfield in signed_bitfields {
 			for (bit_idx, _)
 				in signed_bitfield.payload().0.iter().enumerate().filter(|(_, is_av)| **is_av)
 			{
@@ -755,7 +755,7 @@ mod tests {
 				);
 
 				assert!(Inclusion::process_bitfields(
-					SignedAvailabilityBitfields(vec![signed]),
+					vec![signed],
 					&core_lookup,
 				).is_err());
 			}
@@ -771,7 +771,7 @@ mod tests {
 				);
 
 				assert!(Inclusion::process_bitfields(
-					SignedAvailabilityBitfields(vec![signed.clone(), signed]),
+					vec![signed.clone(), signed],
 					&core_lookup,
 				).is_err());
 			}
@@ -794,7 +794,7 @@ mod tests {
 				);
 
 				assert!(Inclusion::process_bitfields(
-					SignedAvailabilityBitfields(vec![signed_1, signed_0]),
+					vec![signed_1, signed_0],
 					&core_lookup,
 				).is_err());
 			}
@@ -811,7 +811,7 @@ mod tests {
 				);
 
 				assert!(Inclusion::process_bitfields(
-					SignedAvailabilityBitfields(vec![signed]),
+					vec![signed],
 					&core_lookup,
 				).is_err());
 			}
@@ -827,7 +827,7 @@ mod tests {
 				);
 
 				assert!(Inclusion::process_bitfields(
-					SignedAvailabilityBitfields(vec![signed]),
+					vec![signed],
 					&core_lookup,
 				).is_ok());
 			}
@@ -855,7 +855,7 @@ mod tests {
 				);
 
 				assert!(Inclusion::process_bitfields(
-					SignedAvailabilityBitfields(vec![signed]),
+					vec![signed],
 					&core_lookup,
 				).is_ok());
 			}
@@ -959,7 +959,7 @@ mod tests {
 			}).collect();
 
 			assert!(Inclusion::process_bitfields(
-				SignedAvailabilityBitfields(signed_bitfields),
+				signed_bitfields,
 				&core_lookup,
 			).is_ok());
 
-- 
GitLab