From f57daeb16c588e03eda3c0dc7479413af9c008c5 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Mon, 23 Aug 2021 14:53:01 -0400
Subject: [PATCH 01/14] prune nimbus-primitives

---
 Cargo.toml | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index eb4ee77..a510b24 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -20,7 +20,6 @@ pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "p
 pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
 frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false, optional = true }
 cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
-nimbus-primitives = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
 cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
 cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
 ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_backend", "alloc"], optional = true }
@@ -46,7 +45,6 @@ std = [
     "sp-io/std",
     "cumulus-pallet-parachain-system/std",
     "cumulus-primitives-core/std",
-    "nimbus-primitives/std",
     "cumulus-primitives-parachain-inherent/std",
 ]
 runtime-benchmarks = [

From 5fead18a42af602d491129e51e534281424b1f8e Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Mon, 23 Aug 2021 15:53:19 -0400
Subject: [PATCH 02/14] update branches and toolchain

---
 Cargo.toml     | 28 ++++++++++++++--------------
 rust-toolchain |  2 +-
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index a510b24..7e397bc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,23 +10,23 @@ parity-scale-codec = { version = "2.1.1", default-features = false}
 serde = { version = "1.0.101", optional = true, features = ["derive"], default-features = false }
 log = { version = "0.4", default-features = false }
 
-frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
-frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
-sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
-sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
-sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
-sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8" }
-pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
-pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false }
-frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.8", default-features = false, optional = true }
-cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
-cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
-cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
+frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9" }
+frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9" }
+sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9" }
+sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9" }
+sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9" }
+sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9" }
+pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
+pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
+frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false, optional = true }
+cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9" }
+cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9" }
+cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9" }
 ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_backend", "alloc"], optional = true }
-sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8", optional = true }
+sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9", optional = true }
 
 [dev-dependencies]
-cumulus-test-relay-sproof-builder = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" }
+cumulus-test-relay-sproof-builder = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9" }
 
 [features]
 default = ["std"]
diff --git a/rust-toolchain b/rust-toolchain
index d52cfca..15ea0d2 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1,5 +1,5 @@
 [toolchain]
-channel = "nightly-2021-02-21"
+channel = "nightly-2021-08-01"
 components = [ "rustfmt", "clippy" ]
 targets = [ "wasm32-unknown-unknown" ]
 profile = "minimal"

From 6238fc7d67327b62a650f913c3abfd855b7d4f35 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Mon, 23 Aug 2021 15:54:12 -0400
Subject: [PATCH 03/14] reflect new events from
 https://github.com/paritytech/substrate/pull/9462

---
 src/tests.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/tests.rs b/src/tests.rs
index be087a4..1d7557c 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -632,6 +632,8 @@ fn initialize_new_addresses_with_batch() {
 		);
 
 		let expected = vec![
+			pallet_utility::Event::ItemCompleted,
+			pallet_utility::Event::ItemCompleted,
 			pallet_utility::Event::BatchCompleted,
 			pallet_utility::Event::BatchInterrupted(
 				0,

From bc276342f5c594c2c086c5134a58411f65f12eb4 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Mon, 23 Aug 2021 16:26:28 -0400
Subject: [PATCH 04/14] core change. pallet compiles.

---
 src/lib.rs | 46 +++++++++++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 19 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index 9158878..1a8dc6a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -74,7 +74,6 @@ pub mod weights;
 pub mod pallet {
 
 	use crate::weights::WeightInfo;
-	use cumulus_primitives_core::relay_chain;
 	use frame_support::traits::WithdrawReasons;
 	use frame_support::{
 		dispatch::fmt::Debug,
@@ -84,7 +83,7 @@ pub mod pallet {
 	};
 	use frame_system::pallet_prelude::*;
 	use sp_core::crypto::AccountId32;
-	use sp_runtime::traits::{AccountIdConversion, Saturating, Verify};
+	use sp_runtime::traits::{AccountIdConversion, BlockNumberProvider, Saturating, Verify};
 	use sp_runtime::{MultiSignature, Perbill};
 	use sp_std::vec::Vec;
 	use sp_std::vec;
@@ -99,7 +98,7 @@ pub mod pallet {
 
 	/// Configuration trait of this pallet.
 	#[pallet::config]
-	pub trait Config: cumulus_pallet_parachain_system::Config + frame_system::Config {
+	pub trait Config: frame_system::Config {
 		/// The overarching event type
 		type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
 		/// Checker for the reward vec, is it initalized already?
@@ -125,6 +124,20 @@ pub mod pallet {
 			+ Debug
 			+ Into<AccountId32>
 			+ From<AccountId32>;
+		
+		//TODO do we need at least 32 bit unsigned
+		/// The type that will be used to track vesting progress
+		type VestingBlockNumber: sp_runtime::traits::AtLeast32BitUnsigned + Parameter
+		+ Member
+		+ MaybeSerializeDeserialize
+		+ Ord
+		+ Default
+		+ Debug
+		+ Into<BalanceOf<Self>>;
+
+		/// The notion of time that will be used for vesting. Probably
+		/// either the relay chain or sovereign chain block number.
+		type VestingBlockProvider: BlockNumberProvider<BlockNumber = Self::VestingBlockNumber>;
 
 		type WeightInfo: WeightInfo;
 	}
@@ -149,10 +162,7 @@ pub mod pallet {
 		fn on_finalize(n: <T as frame_system::Config>::BlockNumber) {
 			// In the first block of the parachain we need to introduce the relay block related info
 			if n == 1u32.into() {
-				let slot = cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
-					.expect("validation data was set in parachain system inherent")
-					.relay_parent_number;
-				<InitRelayBlock<T>>::put(slot);
+				<InitVestingBlock<T>>::put(T::VestingBlockProvider::current_block_number());
 			}
 		}
 	}
@@ -259,21 +269,19 @@ pub mod pallet {
 				Error::<T>::RewardsAlreadyClaimed
 			);
 
-			// Vesting is done in relation with the relay chain slot
-			let now = cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
-				.expect("validation data was set in parachain system inherent")
-				.relay_parent_number;
+			// Get the current block used for vesting purposes
+			let now = T::VestingBlockProvider::current_block_number();
 
 			// Substract the first payment from the vested amount
 			let first_paid = T::InitializationPayment::get() * info.total_reward;
 
 			// To calculate how much could the user have claimed already
-			let payable_period = now.saturating_sub(<InitRelayBlock<T>>::get());
+			let payable_period = now.saturating_sub(<InitVestingBlock<T>>::get());
 
 			// How much should the contributor have already claimed by this block?
 			// By multiplying first we allow the conversion to integer done with the biggest number
-			let period = EndRelayBlock::<T>::get() - InitRelayBlock::<T>::get();
-			let should_have_claimed = if period == 0 {
+			let period = EndVestingBlock::<T>::get() - InitVestingBlock::<T>::get();
+			let should_have_claimed = if period == 0u32.into() {
 				// Pallet is configured with a zero vesting period.
 				info.total_reward - first_paid
 			} else {
@@ -343,7 +351,7 @@ pub mod pallet {
 		#[pallet::weight(T::WeightInfo::complete_initialization())]
 		pub fn complete_initialization(
 			origin: OriginFor<T>,
-			lease_ending_block: relay_chain::BlockNumber,
+			lease_ending_block: T::VestingBlockNumber,
 		) -> DispatchResultWithPostInfo {
 			ensure_root(origin)?;
 
@@ -357,7 +365,7 @@ pub mod pallet {
 
 			// This ensures the lease ending block is bigger than the init relay block
 			ensure!(
-				lease_ending_block > InitRelayBlock::<T>::get(),
+				lease_ending_block > InitVestingBlock::<T>::get(),
 				Error::<T>::VestingPeriodNonValid
 			);
 
@@ -381,7 +389,7 @@ pub mod pallet {
 			.expect("Shouldnt fail, as the fund should be enough to burn and nothing is locked");
 			drop(imbalance);
 
-			EndRelayBlock::<T>::put(lease_ending_block);
+			EndVestingBlock::<T>::put(lease_ending_block);
 
 			<Initialized<T>>::put(true);
 
@@ -602,12 +610,12 @@ pub mod pallet {
 	#[pallet::storage]
 	#[pallet::getter(fn init_relay_block)]
 	/// Relay block height at the initialization of the pallet
-	type InitRelayBlock<T: Config> = StorageValue<_, relay_chain::BlockNumber, ValueQuery>;
+	type InitVestingBlock<T: Config> = StorageValue<_, T::VestingBlockNumber, ValueQuery>;
 
 	#[pallet::storage]
 	#[pallet::getter(fn end_relay_block)]
 	/// Relay block height at the initialization of the pallet
-	type EndRelayBlock<T: Config> = StorageValue<_, relay_chain::BlockNumber, ValueQuery>;
+	type EndVestingBlock<T: Config> = StorageValue<_, T::VestingBlockNumber, ValueQuery>;
 
 	#[pallet::storage]
 	#[pallet::getter(fn init_reward_amount)]

From 15f1f93c9a2d0c3dbc7add23bd13d852d13538b5 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Mon, 23 Aug 2021 16:31:48 -0400
Subject: [PATCH 05/14] remove some seemingly-unnecessary trait bounds

---
 src/lib.rs | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index 1a8dc6a..418b0b5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -76,14 +76,13 @@ pub mod pallet {
 	use crate::weights::WeightInfo;
 	use frame_support::traits::WithdrawReasons;
 	use frame_support::{
-		dispatch::fmt::Debug,
 		pallet_prelude::*,
 		traits::{Currency, ExistenceRequirement::AllowDeath},
 		PalletId,
 	};
 	use frame_system::pallet_prelude::*;
 	use sp_core::crypto::AccountId32;
-	use sp_runtime::traits::{AccountIdConversion, BlockNumberProvider, Saturating, Verify};
+	use sp_runtime::traits::{AccountIdConversion, AtLeast32BitUnsigned, BlockNumberProvider, Saturating, Verify};
 	use sp_runtime::{MultiSignature, Perbill};
 	use sp_std::vec::Vec;
 	use sp_std::vec;
@@ -113,26 +112,16 @@ pub mod pallet {
 		type MinimumReward: Get<BalanceOf<Self>>;
 		/// The currency in which the rewards will be paid (probably the parachain native currency)
 		type RewardCurrency: Currency<Self::AccountId>;
-		// TODO What trait bounds do I need here? I think concretely we would
-		// be using MultiSigner? Or maybe MultiAccount? I copied these from frame_system
 		/// The AccountId type contributors used on the relay chain.
 		type RelayChainAccountId: Parameter
-			+ Member
-			+ MaybeSerializeDeserialize
-			+ Ord
-			+ Default
-			+ Debug
+			//TODO these AccountId32 bounds feel a little extraneous. I wonder if we can remove them.
 			+ Into<AccountId32>
 			+ From<AccountId32>;
 		
-		//TODO do we need at least 32 bit unsigned
 		/// The type that will be used to track vesting progress
-		type VestingBlockNumber: sp_runtime::traits::AtLeast32BitUnsigned + Parameter
-		+ Member
-		+ MaybeSerializeDeserialize
-		+ Ord
+		type VestingBlockNumber: AtLeast32BitUnsigned
+		+ Parameter
 		+ Default
-		+ Debug
 		+ Into<BalanceOf<Self>>;
 
 		/// The notion of time that will be used for vesting. Probably

From c88c9da4840932b296b7f4b0ace4b4a38ed9e0bd Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Mon, 23 Aug 2021 16:36:23 -0400
Subject: [PATCH 06/14] fix test mock

---
 src/mock.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/mock.rs b/src/mock.rs
index 2934bcd..b1e870c 100644
--- a/src/mock.rs
+++ b/src/mock.rs
@@ -134,6 +134,8 @@ impl Config for Test {
 	type MinimumReward = TestMinimumReward;
 	type RewardCurrency = Balances;
 	type RelayChainAccountId = [u8; 32];
+	type VestingBlockNumber = RelayChainBlockNumber;
+	type VestingBlockProvider = cumulus_pallet_parachain_system::RelaychainBlockNumberProvider<Self>;
 	type WeightInfo = ();
 }
 

From f6b10a85ea777b7d020d17401c441b8b889413d8 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Mon, 23 Aug 2021 16:40:14 -0400
Subject: [PATCH 07/14] make cumulus stuff dev-dependencies

---
 Cargo.toml | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 7e397bc..154357b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -19,14 +19,14 @@ sp-io = { git = "https://github.com/paritytech/substrate", default-features = fa
 pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
 pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false }
 frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.9", default-features = false, optional = true }
-cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9" }
-cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9" }
-cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9" }
 ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_backend", "alloc"], optional = true }
 sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9", optional = true }
 
 [dev-dependencies]
-cumulus-test-relay-sproof-builder = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9" }
+cumulus-test-relay-sproof-builder = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
+cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
+cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
+cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
 
 [features]
 default = ["std"]
@@ -43,9 +43,6 @@ std = [
     "log/std",
     "sp-std/std",
     "sp-io/std",
-    "cumulus-pallet-parachain-system/std",
-    "cumulus-primitives-core/std",
-    "cumulus-primitives-parachain-inherent/std",
 ]
 runtime-benchmarks = [
     "frame-benchmarking",

From 2b348a032898b6c137e5032d9c8d1a7023bc6ab3 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Thu, 2 Sep 2021 04:57:45 -0400
Subject: [PATCH 08/14] use old storage location so we don't need a migration

---
 src/lib.rs | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/lib.rs b/src/lib.rs
index 418b0b5..0c5e226 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -597,11 +597,13 @@ pub mod pallet {
 	pub type Initialized<T: Config> = StorageValue<_, bool, ValueQuery, T::Initialized>;
 
 	#[pallet::storage]
+	#[pallet::storage_prefix = "InitRelayBlock"]
 	#[pallet::getter(fn init_relay_block)]
 	/// Relay block height at the initialization of the pallet
 	type InitVestingBlock<T: Config> = StorageValue<_, T::VestingBlockNumber, ValueQuery>;
 
 	#[pallet::storage]
+	#[pallet::storage_prefix = "EndRelayBlock"]
 	#[pallet::getter(fn end_relay_block)]
 	/// Relay block height at the initialization of the pallet
 	type EndVestingBlock<T: Config> = StorageValue<_, T::VestingBlockNumber, ValueQuery>;

From d04a12124f26a59d7b1b62796c783ae9a6adb84a Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Thu, 2 Sep 2021 05:07:37 -0400
Subject: [PATCH 09/14] update accessor names and coments

---
 src/lib.rs   | 23 +++++++++++------------
 src/tests.rs | 34 +++++++++++++++++-----------------
 2 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/src/lib.rs b/src/lib.rs
index 0c5e226..4cc4807 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -93,8 +93,6 @@ pub mod pallet {
 
 	pub const PALLET_ID: PalletId = PalletId(*b"Crowdloa");
 
-	pub struct RelayChainBeacon<T>(PhantomData<T>);
-
 	/// Configuration trait of this pallet.
 	#[pallet::config]
 	pub trait Config: frame_system::Config {
@@ -145,11 +143,11 @@ pub mod pallet {
 		pub contributed_relay_addresses: Vec<T::RelayChainAccountId>,
 	}
 
-	// This hook is in charge of initializing the relay chain height at the first block of the parachain
+	// This hook is in charge of initializing the vesting height at the first block of the parachain
 	#[pallet::hooks]
 	impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
 		fn on_finalize(n: <T as frame_system::Config>::BlockNumber) {
-			// In the first block of the parachain we need to introduce the relay block related info
+			// In the first block of the parachain we need to introduce the vesting block related info
 			if n == 1u32.into() {
 				<InitVestingBlock<T>>::put(T::VestingBlockProvider::current_block_number());
 			}
@@ -335,7 +333,7 @@ pub mod pallet {
 
 		/// This extrinsic completes the initialization if some checks are fullfiled. These checks are:
 		///  -The reward contribution money matches the crowdloan pot
-		///  -The end relay block is higher than the init relay block
+		///  -The end vesting block is higher than the init vesting block
 		///  -The initialization has not complete yet
 		#[pallet::weight(T::WeightInfo::complete_initialization())]
 		pub fn complete_initialization(
@@ -352,7 +350,8 @@ pub mod pallet {
 				Error::<T>::RewardVecAlreadyInitialized
 			);
 
-			// This ensures the lease ending block is bigger than the init relay block
+			// This ensures the end vesting block (when all funds are fully vested)
+			// is bigger than the init vesting block
 			ensure!(
 				lease_ending_block > InitVestingBlock::<T>::get(),
 				Error::<T>::VestingPeriodNonValid
@@ -438,7 +437,7 @@ pub mod pallet {
 				}
 
 				if *reward < T::MinimumReward::get() {
-					// Dont fail as this is supposed to be called with batch calls and we
+					// Don't fail as this is supposed to be called with batch calls and we
 					// dont want to stall the rest of the contributions
 					Self::deposit_event(Event::InitializedAccountWithNotEnoughContribution(
 						relay_account.clone(),
@@ -466,7 +465,7 @@ pub mod pallet {
 					0u32.into()
 				};
 
-				// We need to calculate the vesting based on the relay block number
+				// Calculate the reward info to store after the initial payment has been made.
 				let mut reward_info = RewardInfo {
 					total_reward: *reward,
 					claimed_reward: initial_payment,
@@ -598,14 +597,14 @@ pub mod pallet {
 
 	#[pallet::storage]
 	#[pallet::storage_prefix = "InitRelayBlock"]
-	#[pallet::getter(fn init_relay_block)]
-	/// Relay block height at the initialization of the pallet
+	#[pallet::getter(fn init_vesting_block)]
+	/// Vesting block height at the initialization of the pallet
 	type InitVestingBlock<T: Config> = StorageValue<_, T::VestingBlockNumber, ValueQuery>;
 
 	#[pallet::storage]
 	#[pallet::storage_prefix = "EndRelayBlock"]
-	#[pallet::getter(fn end_relay_block)]
-	/// Relay block height at the initialization of the pallet
+	#[pallet::getter(fn end_vesting_block)]
+	/// Vesting block height at the initialization of the pallet
 	type EndVestingBlock<T: Config> = StorageValue<_, T::VestingBlockNumber, ValueQuery>;
 
 	#[pallet::storage]
diff --git a/src/tests.rs b/src/tests.rs
index 1d7557c..c43e3fd 100644
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -33,7 +33,7 @@ fn geneses() {
 		assert!(System::events().is_empty());
 		// Insert contributors
 		let pairs = get_ed25519_pairs(3);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -80,7 +80,7 @@ fn proving_assignation_works() {
 	empty().execute_with(|| {
 		// Insert contributors
 		let pairs = get_ed25519_pairs(3);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -162,7 +162,7 @@ fn initializing_multi_relay_to_single_native_address_works() {
 		let pairs = get_ed25519_pairs(3);
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -210,7 +210,7 @@ fn paying_works_step_by_step() {
 		let pairs = get_ed25519_pairs(3);
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -280,7 +280,7 @@ fn paying_works_after_unclaimed_period() {
 		let pairs = get_ed25519_pairs(3);
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -343,7 +343,7 @@ fn paying_late_joiner_works() {
 	empty().execute_with(|| {
 		// Insert contributors
 		let pairs = get_ed25519_pairs(3);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -386,7 +386,7 @@ fn update_address_works() {
 		let pairs = get_ed25519_pairs(3);
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -432,7 +432,7 @@ fn update_address_with_existing_address_fails() {
 		let pairs = get_ed25519_pairs(3);
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -465,7 +465,7 @@ fn update_address_with_existing_with_multi_address_works() {
 		let pairs = get_ed25519_pairs(3);
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -503,7 +503,7 @@ fn initialize_new_addresses() {
 		roll_to(2);
 		// Insert contributors
 		let pairs = get_ed25519_pairs(3);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -544,7 +544,7 @@ fn initialize_new_addresses_handle_dust() {
 		roll_to(2);
 		// Insert contributors
 		let pairs = get_ed25519_pairs(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
 			vec![
@@ -578,7 +578,7 @@ fn initialize_new_addresses_not_matching_funds() {
 		roll_to(2);
 		// Insert contributors
 		let pairs = get_ed25519_pairs(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		// Total supply is 2500.Lets ensure inserting 2495 is not working.
 		assert_ok!(Crowdloan::initialize_reward_vec(
 			Origin::root(),
@@ -601,7 +601,7 @@ fn initialize_new_addresses_with_batch() {
 	empty().execute_with(|| {
 		// This time should succeed trully
 		roll_to(10);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(mock::Call::Utility(UtilityCall::batch_all(vec![
 			mock::Call::Crowdloan(crate::Call::initialize_reward_vec(vec![(
 				[4u8; 32].into(),
@@ -621,7 +621,7 @@ fn initialize_new_addresses_with_batch() {
 		));
 		assert_eq!(Crowdloan::total_contributors(), 2);
 		// Verify that the second ending block provider had no effect
-		assert_eq!(Crowdloan::end_relay_block(), init_block + VESTING);
+		assert_eq!(Crowdloan::end_vesting_block(), init_block + VESTING);
 
 		// Batch calls always succeed. We just need to check the inner event
 		assert_ok!(
@@ -653,7 +653,7 @@ fn floating_point_arithmetic_works() {
 	empty().execute_with(|| {
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(mock::Call::Utility(UtilityCall::batch_all(vec![
 			mock::Call::Crowdloan(crate::Call::initialize_reward_vec(vec![(
 				[4u8; 32].into(),
@@ -729,7 +729,7 @@ fn reward_below_vesting_period_works() {
 	empty().execute_with(|| {
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 		assert_ok!(mock::Call::Utility(UtilityCall::batch_all(vec![
 			mock::Call::Crowdloan(crate::Call::initialize_reward_vec(vec![(
 				[4u8; 32].into(),
@@ -819,7 +819,7 @@ fn test_initialization_errors() {
 	empty().execute_with(|| {
 		// The init relay block gets inserted
 		roll_to(2);
-		let init_block = Crowdloan::init_relay_block();
+		let init_block = Crowdloan::init_vesting_block();
 
 		let pot = Crowdloan::pot();
 

From 214824f11542f1985c80e680f405cb35bde933ee Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Thu, 2 Sep 2021 05:27:40 -0400
Subject: [PATCH 10/14] make cumulus dependencies optional and use them when
 building benchmarks

---
 Cargo.toml        | 13 +++++++++----
 src/benchmarks.rs |  6 +++---
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 154357b..61b3a5d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,11 +22,13 @@ frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch =
 ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_backend", "alloc"], optional = true }
 sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9", optional = true }
 
+# These cumulus dependencies to be removed with https://github.com/PureStake/crowdloan-rewards/pull/44
+cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9", optional = true }
+cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9", optional = true }
+cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9", optional = true }
+
 [dev-dependencies]
 cumulus-test-relay-sproof-builder = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
-cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
-cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
-cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
 
 [features]
 default = ["std"]
@@ -47,5 +49,8 @@ std = [
 runtime-benchmarks = [
     "frame-benchmarking",
     "sp-trie",
-    "ed25519-dalek"
+    "ed25519-dalek",
+    "cumulus-primitives-core",
+    "cumulus-pallet-parachain-system",
+    "cumulus-primitives-parachain-inherent",
 ]
diff --git a/src/benchmarks.rs b/src/benchmarks.rs
index 761b05a..3031c6f 100644
--- a/src/benchmarks.rs
+++ b/src/benchmarks.rs
@@ -135,8 +135,8 @@ fn insert_contributors<T: Config>(
 }
 
 /// Create a Contributor.
-fn close_initialization<T: Config>(end_relay: RelayChainBlockNumber) -> Result<(), &'static str> {
-	Pallet::<T>::complete_initialization(RawOrigin::Root.into(), end_relay)?;
+fn close_initialization<T: Config>(end_vesting_block: T::VestingBlockNumber) -> Result<(), &'static str> {
+	Pallet::<T>::complete_initialization(RawOrigin::Root.into(), end_vesting_block)?;
 	Ok(())
 }
 
@@ -206,7 +206,7 @@ benchmarks! {
 		RelayPallet::<T>::on_finalize(T::BlockNumber::one());
 		Pallet::<T>::on_finalize(T::BlockNumber::one());
 
-	}:  _(RawOrigin::Root, 10u32)
+	}:  _(RawOrigin::Root, 10.into())
 	verify {
 	  assert!(Pallet::<T>::initialized());
 	}

From 87c6e882e192655d2f3535960932065cdf826788 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Thu, 2 Sep 2021 05:35:15 -0400
Subject: [PATCH 11/14] cargo fmt

---
 src/benchmarks.rs |  4 +++-
 src/lib.rs        | 11 +++++------
 src/mock.rs       |  3 ++-
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/benchmarks.rs b/src/benchmarks.rs
index 377bff3..25bd5ae 100644
--- a/src/benchmarks.rs
+++ b/src/benchmarks.rs
@@ -135,7 +135,9 @@ fn insert_contributors<T: Config>(
 }
 
 /// Create a Contributor.
-fn close_initialization<T: Config>(end_vesting_block: T::VestingBlockNumber) -> Result<(), &'static str> {
+fn close_initialization<T: Config>(
+	end_vesting_block: T::VestingBlockNumber,
+) -> Result<(), &'static str> {
 	Pallet::<T>::complete_initialization(RawOrigin::Root.into(), end_vesting_block)?;
 	Ok(())
 }
diff --git a/src/lib.rs b/src/lib.rs
index a3089fd..0a556dc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -82,7 +82,9 @@ pub mod pallet {
 	};
 	use frame_system::pallet_prelude::*;
 	use sp_core::crypto::AccountId32;
-	use sp_runtime::traits::{AccountIdConversion, AtLeast32BitUnsigned, BlockNumberProvider, Saturating, Verify};
+	use sp_runtime::traits::{
+		AccountIdConversion, AtLeast32BitUnsigned, BlockNumberProvider, Saturating, Verify,
+	};
 	use sp_runtime::{MultiSignature, Perbill};
 	use sp_std::vec;
 	use sp_std::vec::Vec;
@@ -115,12 +117,9 @@ pub mod pallet {
 			//TODO these AccountId32 bounds feel a little extraneous. I wonder if we can remove them.
 			+ Into<AccountId32>
 			+ From<AccountId32>;
-		
+
 		/// The type that will be used to track vesting progress
-		type VestingBlockNumber: AtLeast32BitUnsigned
-		+ Parameter
-		+ Default
-		+ Into<BalanceOf<Self>>;
+		type VestingBlockNumber: AtLeast32BitUnsigned + Parameter + Default + Into<BalanceOf<Self>>;
 
 		/// The notion of time that will be used for vesting. Probably
 		/// either the relay chain or sovereign chain block number.
diff --git a/src/mock.rs b/src/mock.rs
index b1e870c..ddfbe46 100644
--- a/src/mock.rs
+++ b/src/mock.rs
@@ -135,7 +135,8 @@ impl Config for Test {
 	type RewardCurrency = Balances;
 	type RelayChainAccountId = [u8; 32];
 	type VestingBlockNumber = RelayChainBlockNumber;
-	type VestingBlockProvider = cumulus_pallet_parachain_system::RelaychainBlockNumberProvider<Self>;
+	type VestingBlockProvider =
+		cumulus_pallet_parachain_system::RelaychainBlockNumberProvider<Self>;
 	type WeightInfo = ();
 }
 

From 15bf43c1962ec160fe93abe70f869bbf532ee8d4 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Tue, 7 Sep 2021 09:07:49 -0400
Subject: [PATCH 12/14] Make benchmarks build as long as parachan system is
 persent.

---
 src/benchmarks.rs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/benchmarks.rs b/src/benchmarks.rs
index 25bd5ae..a803328 100644
--- a/src/benchmarks.rs
+++ b/src/benchmarks.rs
@@ -1,6 +1,6 @@
 #![cfg(feature = "runtime-benchmarks")]
 
-use crate::{BalanceOf, Call, Config, Pallet};
+use crate::{BalanceOf, Call, Pallet};
 use cumulus_pallet_parachain_system::Pallet as RelayPallet;
 use cumulus_primitives_core::{
 	relay_chain::{v1::HeadData, BlockNumber as RelayChainBlockNumber},
@@ -39,9 +39,13 @@ const MOCK_PROOF_HASH: [u8; 32] = [
 	243, 146, 7, 202, 245, 129, 165, 70, 72, 184, 130, 141,
 ];
 
+// These benchmarks only work with a Runtime that uses cumulus's RelayChainBlockNumberProvider.
+// This will improve once https://github.com/PureStake/crowdloan-rewards/pull/44 lands
+pub trait Config: crate::Config + cumulus_pallet_parachain_system::Config {}
+
 /// Default balance amount is minimum contribution
 fn default_balance<T: Config>() -> BalanceOf<T> {
-	<<T as Config>::MinimumReward as Get<BalanceOf<T>>>::get()
+	T::MinimumReward::get()
 }
 
 /// Create a funded user.
@@ -156,7 +160,7 @@ fn create_sig<T: Config>(signed_account: T::AccountId) -> (AccountId32, MultiSig
 }
 
 fn max_batch_contributors<T: Config>() -> u32 {
-	<<T as Config>::MaxInitContributors as Get<u32>>::get()
+	T::MaxInitContributors::get()
 }
 
 // This is our current number of contributors
@@ -208,7 +212,7 @@ benchmarks! {
 		RelayPallet::<T>::on_finalize(T::BlockNumber::one());
 		Pallet::<T>::on_finalize(T::BlockNumber::one());
 
-	}:  _(RawOrigin::Root, 10.into())
+	}:  _(RawOrigin::Root, 10u32.into())
 	verify {
 	  assert!(Pallet::<T>::initialized());
 	}

From 7d694cce08918524a34190b5815dc2eb9461f113 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Thu, 9 Sep 2021 11:00:24 -0400
Subject: [PATCH 13/14] blanket impl should make it work

---
 src/benchmarks.rs | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/benchmarks.rs b/src/benchmarks.rs
index a803328..ef9135a 100644
--- a/src/benchmarks.rs
+++ b/src/benchmarks.rs
@@ -42,6 +42,7 @@ const MOCK_PROOF_HASH: [u8; 32] = [
 // These benchmarks only work with a Runtime that uses cumulus's RelayChainBlockNumberProvider.
 // This will improve once https://github.com/PureStake/crowdloan-rewards/pull/44 lands
 pub trait Config: crate::Config + cumulus_pallet_parachain_system::Config {}
+impl<T: crate::Config + cumulus_pallet_parachain_system::Config> Config for T {}
 
 /// Default balance amount is minimum contribution
 fn default_balance<T: Config>() -> BalanceOf<T> {

From 60003f9f4904b6122dc70b409df0c1ae5688de64 Mon Sep 17 00:00:00 2001
From: Joshy Orndorff <admin@joshyorndorff.com>
Date: Fri, 10 Sep 2021 11:36:57 -0400
Subject: [PATCH 14/14] fix no_std

---
 Cargo.toml | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Cargo.toml b/Cargo.toml
index 61b3a5d..44c9987 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -23,9 +23,9 @@ ed25519-dalek = { version = "1.0.1", default-features = false, features = ["u64_
 sp-trie = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.9", optional = true }
 
 # These cumulus dependencies to be removed with https://github.com/PureStake/crowdloan-rewards/pull/44
-cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9", optional = true }
-cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9", optional = true }
-cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9", optional = true }
+cumulus-primitives-core = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9", optional = true }
+cumulus-pallet-parachain-system = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9", optional = true }
+cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "nimbus-polkadot-v0.9.9", optional = true }
 
 [dev-dependencies]
 cumulus-test-relay-sproof-builder = { git = "https://github.com/purestake/cumulus", branch = "nimbus-polkadot-v0.9.9" }
@@ -45,6 +45,9 @@ std = [
     "log/std",
     "sp-std/std",
     "sp-io/std",
+    "cumulus-pallet-parachain-system/std",
+    "cumulus-primitives-core/std",
+    "cumulus-primitives-parachain-inherent/std",
 ]
 runtime-benchmarks = [
     "frame-benchmarking",