Unverified Commit 96af6ead authored by asynchronous rob's avatar asynchronous rob Committed by GitHub
Browse files

Refactor primitives (#1383)

* create a v1 primitives module

* Improve guide on availability types

* punctuate

* new parachains runtime uses new primitives

* tests of new runtime now use new primitives

* add ErasureChunk to guide

* export erasure chunk from v1 primitives

* subsystem crate uses v1 primitives

* node-primitives uses new v1 primitives

* port overseer to new primitives

* new-proposer uses v1 primitives (no ParachainHost anymore)

* fix no-std compilation for primitives

* service-new uses v1 primitives

* network-bridge uses new primitives

* statement distribution uses v1 primitives

* PoV distribution uses v1 primitives; add PoV::hash fn

* move parachain to v0

* remove inclusion_inherent module and place into v1

* remove everything from primitives crate root

* remove some unused old types from v0 primitives

* point everything else at primitives::v0

* squanch some warns up

* add RuntimeDebug import to no-std as well

* port over statement-table and validation

* fix final errors in validation and node-primitives

* add dummy Ord impl to committed candidate receipt

* guide: update CandidateValidationMessage

* add primitive for validationoutputs

* expand CandidateValidationMessage further

* bikeshed

* add some impls to omitted-validation-data and available-data

* expand CandidateValidationMessage

* make erasure-coding generic over v1/v0

* update usages of erasure-coding

* implement commitments.hash()

* use Arc<Pov> for CandidateValidation

* improve new erasure-coding method names

* fix up candidate backing

* update docs a bit

* fix most tests and add short-circuiting to make_pov_available

* fix remainder of candidate backing tests

* squanching warns

* squanch it up

* some fallout

* overseer fallout

* free from polkadot-test-service hell
parent 8845df22
Pipeline #100069 passed with stages
in 25 minutes and 41 seconds
...@@ -79,7 +79,7 @@ use sp_runtime::{ModuleId, ...@@ -79,7 +79,7 @@ use sp_runtime::{ModuleId,
use crate::slots; use crate::slots;
use codec::{Encode, Decode}; use codec::{Encode, Decode};
use sp_std::vec::Vec; use sp_std::vec::Vec;
use primitives::parachain::{Id as ParaId, HeadData}; use primitives::v0::{Id as ParaId, HeadData};
pub type BalanceOf<T> = pub type BalanceOf<T> =
<<T as slots::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance; <<T as slots::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
...@@ -568,7 +568,7 @@ mod tests { ...@@ -568,7 +568,7 @@ mod tests {
}; };
use frame_support::traits::{Contains, ContainsLengthBound}; use frame_support::traits::{Contains, ContainsLengthBound};
use sp_core::H256; use sp_core::H256;
use primitives::parachain::{Info as ParaInfo, Id as ParaId, Scheduling, ValidationCode}; use primitives::v0::{Info as ParaInfo, Id as ParaId, Scheduling, ValidationCode};
// The testing primitives are very useful for avoiding having to work with signatures // The testing primitives are very useful for avoiding having to work with signatures
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried. // or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
use sp_runtime::{ use sp_runtime::{
......
...@@ -26,8 +26,8 @@ pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>); ...@@ -26,8 +26,8 @@ pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>);
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R> impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R>
where where
R: balances::Trait + authorship::Trait, R: balances::Trait + authorship::Trait,
<R as system::Trait>::AccountId: From<primitives::AccountId>, <R as system::Trait>::AccountId: From<primitives::v0::AccountId>,
<R as system::Trait>::AccountId: Into<primitives::AccountId>, <R as system::Trait>::AccountId: Into<primitives::v0::AccountId>,
<R as system::Trait>::Event: From<balances::RawEvent< <R as system::Trait>::Event: From<balances::RawEvent<
<R as system::Trait>::AccountId, <R as system::Trait>::AccountId,
<R as balances::Trait>::Balance, <R as balances::Trait>::Balance,
......
...@@ -27,7 +27,7 @@ pub mod slots; ...@@ -27,7 +27,7 @@ pub mod slots;
pub mod crowdfund; pub mod crowdfund;
pub mod impls; pub mod impls;
use primitives::BlockNumber; use primitives::v0::BlockNumber;
use sp_runtime::{Perquintill, Perbill, FixedPointNumber, traits::Saturating}; use sp_runtime::{Perquintill, Perbill, FixedPointNumber, traits::Saturating};
use frame_support::{ use frame_support::{
parameter_types, traits::{Currency}, parameter_types, traits::{Currency},
......
...@@ -37,16 +37,13 @@ use frame_support::{ ...@@ -37,16 +37,13 @@ use frame_support::{
dispatch::IsSubType, dispatch::IsSubType,
weights::{DispatchClass, Weight}, weights::{DispatchClass, Weight},
}; };
use primitives::{ use primitives::v0::{
Balance, Balance, BlockNumber,
BlockNumber, Id as ParaId, Chain, DutyRoster, AttestedCandidate, CompactStatement as Statement, ParachainDispatchOrigin,
parachain::{ UpwardMessage, ValidatorId, ActiveParas, CollatorId, Retriable, OmittedValidationData,
Id as ParaId, Chain, DutyRoster, AttestedCandidate, CompactStatement as Statement, ParachainDispatchOrigin, CandidateReceipt, GlobalValidationSchedule, AbridgedCandidateReceipt,
UpwardMessage, ValidatorId, ActiveParas, CollatorId, Retriable, OmittedValidationData, LocalValidationData, Scheduling, ValidityAttestation, NEW_HEADS_IDENTIFIER, PARACHAIN_KEY_TYPE_ID,
CandidateReceipt, GlobalValidationSchedule, AbridgedCandidateReceipt, ValidatorSignature, SigningContext, HeadData, ValidationCode,
LocalValidationData, Scheduling, ValidityAttestation, NEW_HEADS_IDENTIFIER, PARACHAIN_KEY_TYPE_ID,
ValidatorSignature, SigningContext, HeadData, ValidationCode,
},
Remark, DownwardMessage Remark, DownwardMessage
}; };
use frame_support::{ use frame_support::{
...@@ -329,7 +326,7 @@ pub trait Trait: CreateSignedTransaction<Call<Self>> + attestations::Trait + ses ...@@ -329,7 +326,7 @@ pub trait Trait: CreateSignedTransaction<Call<Self>> + attestations::Trait + ses
>; >;
/// A type that converts the opaque hash type to exact one. /// A type that converts the opaque hash type to exact one.
type BlockHashConversion: Convert<Self::Hash, primitives::Hash>; type BlockHashConversion: Convert<Self::Hash, primitives::v0::Hash>;
} }
/// Origin for the parachains module. /// Origin for the parachains module.
...@@ -1681,13 +1678,10 @@ mod tests { ...@@ -1681,13 +1678,10 @@ mod tests {
}, },
testing::TestXt, testing::TestXt,
}; };
use primitives::{ use primitives::v0::{
parachain::{ CandidateReceipt, ValidityAttestation, ValidatorId, Info as ParaInfo,
CandidateReceipt, ValidityAttestation, ValidatorId, Info as ParaInfo, Scheduling, CandidateCommitments,
Scheduling, CandidateCommitments, BlockNumber, Header,
},
BlockNumber,
Header,
}; };
use keyring::Sr25519Keyring; use keyring::Sr25519Keyring;
use frame_support::{ use frame_support::{
...@@ -1819,7 +1813,7 @@ mod tests { ...@@ -1819,7 +1813,7 @@ mod tests {
} }
mod time { mod time {
use primitives::{Moment, BlockNumber}; use primitives::v0::{Moment, BlockNumber};
pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const MILLISECS_PER_BLOCK: Moment = 6000;
pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 1 * HOURS; pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 1 * HOURS;
// These time units are defined in number of blocks. // These time units are defined in number of blocks.
...@@ -2246,7 +2240,7 @@ mod tests { ...@@ -2246,7 +2240,7 @@ mod tests {
println!("session index {}", i); println!("session index {}", i);
Staking::on_finalize(System::block_number()); Staking::on_finalize(System::block_number());
System::set_block_number((i + 1).into()); System::set_block_number((i + 1).into());
Timestamp::set_timestamp(System::block_number() as primitives::Moment * 6000); Timestamp::set_timestamp(System::block_number() as primitives::v0::Moment * 6000);
// In order to be able to use `System::parent_hash()` in the tests // In order to be able to use `System::parent_hash()` in the tests
// we need to first get it via `System::finalize` and then set it // we need to first get it via `System::finalize` and then set it
......
...@@ -34,7 +34,7 @@ use frame_support::{ ...@@ -34,7 +34,7 @@ use frame_support::{
weights::{DispatchClass, Weight}, weights::{DispatchClass, Weight},
}; };
use system::{self, ensure_root, ensure_signed}; use system::{self, ensure_root, ensure_signed};
use primitives::parachain::{ use primitives::v0::{
Id as ParaId, CollatorId, Scheduling, LOWEST_USER_ID, SwapAux, Info as ParaInfo, ActiveParas, Id as ParaId, CollatorId, Scheduling, LOWEST_USER_ID, SwapAux, Info as ParaInfo, ActiveParas,
Retriable, ValidationCode, HeadData, Retriable, ValidationCode, HeadData,
}; };
...@@ -213,7 +213,7 @@ fn build<T: Trait>(config: &GenesisConfig<T>) { ...@@ -213,7 +213,7 @@ fn build<T: Trait>(config: &GenesisConfig<T>) {
Parachains::put(&only_ids); Parachains::put(&only_ids);
for (id, code, genesis) in p { for (id, code, genesis) in p {
Paras::insert(id, &primitives::parachain::PARACHAIN_INFO); Paras::insert(id, &primitives::v0::PARACHAIN_INFO);
// no ingress -- a chain cannot be routed to until it is live. // no ingress -- a chain cannot be routed to until it is live.
<parachains::Code>::insert(&id, &code); <parachains::Code>::insert(&id, &code);
<parachains::Heads>::insert(&id, &genesis); <parachains::Heads>::insert(&id, &genesis);
...@@ -670,12 +670,10 @@ mod tests { ...@@ -670,12 +670,10 @@ mod tests {
AccountIdConversion, Extrinsic as ExtrinsicT, AccountIdConversion, Extrinsic as ExtrinsicT,
}, testing::{UintAuthorityId, TestXt}, KeyTypeId, Perbill, curve::PiecewiseLinear, }, testing::{UintAuthorityId, TestXt}, KeyTypeId, Perbill, curve::PiecewiseLinear,
}; };
use primitives::{ use primitives::v0::{
parachain::{ ValidatorId, Info as ParaInfo, Scheduling, LOWEST_USER_ID, AttestedCandidate,
ValidatorId, Info as ParaInfo, Scheduling, LOWEST_USER_ID, AttestedCandidate, CandidateReceipt, HeadData, ValidityAttestation, CompactStatement as Statement, Chain,
CandidateReceipt, HeadData, ValidityAttestation, CompactStatement as Statement, Chain, CollatorPair, CandidateCommitments,
CollatorPair, CandidateCommitments,
},
Balance, BlockNumber, Header, Signature, Balance, BlockNumber, Header, Signature,
}; };
use frame_support::{ use frame_support::{
...@@ -869,7 +867,7 @@ mod tests { ...@@ -869,7 +867,7 @@ mod tests {
// This is needed for a custom `AccountId` type which is `u64` in testing here. // This is needed for a custom `AccountId` type which is `u64` in testing here.
pub mod test_keys { pub mod test_keys {
use sp_core::{crypto::KeyTypeId, sr25519}; use sp_core::{crypto::KeyTypeId, sr25519};
use primitives::Signature; use primitives::v0::Signature;
pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test"); pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test");
......
...@@ -28,7 +28,7 @@ use frame_support::{ ...@@ -28,7 +28,7 @@ use frame_support::{
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness}, traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
weights::{DispatchClass, Weight}, weights::{DispatchClass, Weight},
}; };
use primitives::parachain::{ use primitives::v0::{
SwapAux, PARACHAIN_INFO, Id as ParaId, ValidationCode, HeadData, SwapAux, PARACHAIN_INFO, Id as ParaId, ValidationCode, HeadData,
}; };
use system::{ensure_signed, ensure_root}; use system::{ensure_signed, ensure_root};
...@@ -890,8 +890,7 @@ mod tests { ...@@ -890,8 +890,7 @@ mod tests {
traits::{OnInitialize, OnFinalize} traits::{OnInitialize, OnFinalize}
}; };
use balances; use balances;
use primitives::{BlockNumber, Header}; use primitives::v0::{BlockNumber, Header, Id as ParaId, Info as ParaInfo, Scheduling};
use primitives::parachain::{Id as ParaId, Info as ParaInfo, Scheduling};
impl_outer_origin! { impl_outer_origin! {
pub enum Origin for Test {} pub enum Origin for Test {}
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
/// Money matters. /// Money matters.
pub mod currency { pub mod currency {
use primitives::Balance; use primitives::v0::Balance;
pub const DOTS: Balance = 1_000_000_000_000; pub const DOTS: Balance = 1_000_000_000_000;
pub const DOLLARS: Balance = DOTS / 6; pub const DOLLARS: Balance = DOTS / 6;
...@@ -30,7 +30,7 @@ pub mod currency { ...@@ -30,7 +30,7 @@ pub mod currency {
/// Time and blocks. /// Time and blocks.
pub mod time { pub mod time {
use primitives::{Moment, BlockNumber}; use primitives::v0::{Moment, BlockNumber};
// Kusama & mainnet // Kusama & mainnet
pub const MILLISECS_PER_BLOCK: Moment = 6000; pub const MILLISECS_PER_BLOCK: Moment = 6000;
// Testnet // Testnet
...@@ -55,7 +55,7 @@ pub mod time { ...@@ -55,7 +55,7 @@ pub mod time {
/// Fee-related. /// Fee-related.
pub mod fee { pub mod fee {
pub use sp_runtime::Perbill; pub use sp_runtime::Perbill;
use primitives::Balance; use primitives::v0::Balance;
use runtime_common::ExtrinsicBaseWeight; use runtime_common::ExtrinsicBaseWeight;
use frame_support::weights::{ use frame_support::weights::{
WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,
......
...@@ -23,9 +23,10 @@ ...@@ -23,9 +23,10 @@
use sp_std::prelude::*; use sp_std::prelude::*;
use sp_core::u32_trait::{_1, _2, _3, _4, _5}; use sp_core::u32_trait::{_1, _2, _3, _4, _5};
use codec::{Encode, Decode}; use codec::{Encode, Decode};
use primitives::{ use primitives::v0::{
self as parachain,
AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment, AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
parachain::{self, ActiveParas, AbridgedCandidateReceipt, SigningContext}, ActiveParas, AbridgedCandidateReceipt, SigningContext,
}; };
use runtime_common::{ use runtime_common::{
attestations, claims, parachains, registrar, slots, SlowAdjustingFeeUpdate, attestations, claims, parachains, registrar, slots, SlowAdjustingFeeUpdate,
...@@ -560,7 +561,7 @@ impl grandpa::Trait for Runtime { ...@@ -560,7 +561,7 @@ impl grandpa::Trait for Runtime {
type HandleEquivocation = grandpa::EquivocationHandler< type HandleEquivocation = grandpa::EquivocationHandler<
Self::KeyOwnerIdentification, Self::KeyOwnerIdentification,
primitives::fisherman::FishermanAppCrypto, primitives::v0::fisherman::FishermanAppCrypto,
Runtime, Runtime,
Offences, Offences,
>; >;
...@@ -596,7 +597,7 @@ parameter_types! { ...@@ -596,7 +597,7 @@ parameter_types! {
} }
impl parachains::Trait for Runtime { impl parachains::Trait for Runtime {
type AuthorityId = primitives::fisherman::FishermanAppCrypto; type AuthorityId = primitives::v0::fisherman::FishermanAppCrypto;
type Origin = Origin; type Origin = Origin;
type Call = Call; type Call = Call;
type ParachainCurrency = Balances; type ParachainCurrency = Balances;
...@@ -939,7 +940,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade { ...@@ -939,7 +940,7 @@ impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
construct_runtime! { construct_runtime! {
pub enum Runtime where pub enum Runtime where
Block = Block, Block = Block,
NodeBlock = primitives::Block, NodeBlock = primitives::v0::Block,
UncheckedExtrinsic = UncheckedExtrinsic UncheckedExtrinsic = UncheckedExtrinsic
{ {
// Basic stuff; balances is uncallable initially. // Basic stuff; balances is uncallable initially.
...@@ -1147,7 +1148,7 @@ sp_api::impl_runtime_apis! { ...@@ -1147,7 +1148,7 @@ sp_api::impl_runtime_apis! {
fn signing_context() -> SigningContext { fn signing_context() -> SigningContext {
Parachains::signing_context() Parachains::signing_context()
} }
fn downward_messages(id: parachain::Id) -> Vec<primitives::DownwardMessage> { fn downward_messages(id: parachain::Id) -> Vec<primitives::v0::DownwardMessage> {
Parachains::downward_messages(id) Parachains::downward_messages(id)
} }
} }
......
...@@ -19,9 +19,7 @@ ...@@ -19,9 +19,7 @@
//! Configuration can change only at session boundaries and is buffered until then. //! Configuration can change only at session boundaries and is buffered until then.
use sp_std::prelude::*; use sp_std::prelude::*;
use primitives::{ use primitives::v1::ValidatorId;
parachain::{ValidatorId},
};
use frame_support::{ use frame_support::{
decl_storage, decl_module, decl_error, decl_storage, decl_module, decl_error,
dispatch::DispatchResult, dispatch::DispatchResult,
......
...@@ -21,12 +21,10 @@ ...@@ -21,12 +21,10 @@
//! to included. //! to included.
use sp_std::prelude::*; use sp_std::prelude::*;
use primitives::{ use primitives::v1::{
parachain::{ ValidatorId, CommittedCandidateReceipt, ValidatorIndex, Id as ParaId,
ValidatorId, AbridgedCandidateReceipt, ValidatorIndex, Id as ParaId, AvailabilityBitfield as AvailabilityBitfield, SignedAvailabilityBitfields, SigningContext,
AvailabilityBitfield as AvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, BackedCandidate, CoreIndex, GroupIndex, CoreAssignment,
BackedCandidate, CoreIndex, GroupIndex, CoreAssignment,
},
}; };
use frame_support::{ use frame_support::{
decl_storage, decl_module, decl_error, ensure, dispatch::DispatchResult, IterableStorageMap, decl_storage, decl_module, decl_error, ensure, dispatch::DispatchResult, IterableStorageMap,
...@@ -53,13 +51,15 @@ pub struct AvailabilityBitfieldRecord<N> { ...@@ -53,13 +51,15 @@ pub struct AvailabilityBitfieldRecord<N> {
} }
/// A backed candidate pending availability. /// A backed candidate pending availability.
// TODO: split this type and change this to hold a plain `CandidateReceipt`.
// https://github.com/paritytech/polkadot/issues/1357
#[derive(Encode, Decode, PartialEq)] #[derive(Encode, Decode, PartialEq)]
#[cfg_attr(test, derive(Debug))] #[cfg_attr(test, derive(Debug))]
pub struct CandidatePendingAvailability<H, N> { pub struct CandidatePendingAvailability<H, N> {
/// The availability core this is assigned to. /// The availability core this is assigned to.
core: CoreIndex, core: CoreIndex,
/// The candidate receipt itself. /// The candidate receipt itself.
receipt: AbridgedCandidateReceipt<H>, receipt: CommittedCandidateReceipt<H>,
/// The received availability votes. One bit per validator. /// The received availability votes. One bit per validator.
availability_votes: BitVec<BitOrderLsb0, u8>, availability_votes: BitVec<BitOrderLsb0, u8>,
/// The block number of the relay-parent of the receipt. /// The block number of the relay-parent of the receipt.
...@@ -213,7 +213,10 @@ impl<T: Trait> Module<T> { ...@@ -213,7 +213,10 @@ impl<T: Trait> Module<T> {
let validator_public = &validators[signed_bitfield.validator_index() as usize]; let validator_public = &validators[signed_bitfield.validator_index() as usize];
signed_bitfield.check_signature(&signing_context, validator_public).map_err(|_| Error::<T>::InvalidBitfieldSignature)?; signed_bitfield.check_signature(
&signing_context,
validator_public,
).map_err(|_| Error::<T>::InvalidBitfieldSignature)?;
last_index = Some(signed_bitfield.validator_index()); last_index = Some(signed_bitfield.validator_index());
} }
...@@ -331,11 +334,11 @@ impl<T: Trait> Module<T> { ...@@ -331,11 +334,11 @@ impl<T: Trait> Module<T> {
// list. // list.
'a: 'a:
for candidate in &candidates { for candidate in &candidates {
let para_id = candidate.candidate.parachain_index; let para_id = candidate.descriptor().para_id;
// we require that the candidate is in the context of the parent block. // we require that the candidate is in the context of the parent block.
ensure!( ensure!(
candidate.candidate.relay_parent == parent_hash, candidate.descriptor().relay_parent == parent_hash,
Error::<T>::CandidateNotInParentContext, Error::<T>::CandidateNotInParentContext,
); );
...@@ -348,17 +351,17 @@ impl<T: Trait> Module<T> { ...@@ -348,17 +351,17 @@ impl<T: Trait> Module<T> {
ensure!(code_upgrade_allowed, Error::<T>::PrematureCodeUpgrade); ensure!(code_upgrade_allowed, Error::<T>::PrematureCodeUpgrade);
ensure!( ensure!(
candidate.candidate.check_signature().is_ok(), candidate.descriptor().check_collator_signature().is_ok(),
Error::<T>::NotCollatorSigned, Error::<T>::NotCollatorSigned,
); );
for (i, assignment) in scheduled[skip..].iter().enumerate() { for (i, assignment) in scheduled[skip..].iter().enumerate() {
check_assignment_in_order(assignment)?; check_assignment_in_order(assignment)?;
if candidate.candidate.parachain_index == assignment.para_id { if candidate.descriptor().para_id == assignment.para_id {
if let Some(required_collator) = assignment.required_collator() { if let Some(required_collator) = assignment.required_collator() {
ensure!( ensure!(
required_collator == &candidate.candidate.collator, required_collator == &candidate.descriptor().collator,
Error::<T>::WrongCollator, Error::<T>::WrongCollator,
); );
} }
...@@ -377,7 +380,7 @@ impl<T: Trait> Module<T> { ...@@ -377,7 +380,7 @@ impl<T: Trait> Module<T> {
// check the signatures in the backing and that it is a majority. // check the signatures in the backing and that it is a majority.
{ {
let maybe_amount_validated let maybe_amount_validated
= primitives::parachain::check_candidate_backing( = primitives::v1::check_candidate_backing(
&candidate, &candidate,
&signing_context, &signing_context,
group_vals.len(), group_vals.len(),
...@@ -419,7 +422,7 @@ impl<T: Trait> Module<T> { ...@@ -419,7 +422,7 @@ impl<T: Trait> Module<T> {
// one more sweep for actually writing to storage. // one more sweep for actually writing to storage.
for (candidate, core) in candidates.into_iter().zip(core_indices.iter().cloned()) { for (candidate, core) in candidates.into_iter().zip(core_indices.iter().cloned()) {
let para_id = candidate.candidate.parachain_index; let para_id = candidate.descriptor().para_id;
// initialize all availability votes to 0. // initialize all availability votes to 0.
let availability_votes: BitVec<BitOrderLsb0, u8> let availability_votes: BitVec<BitOrderLsb0, u8>
...@@ -438,7 +441,7 @@ impl<T: Trait> Module<T> { ...@@ -438,7 +441,7 @@ impl<T: Trait> Module<T> {
fn enact_candidate( fn enact_candidate(
relay_parent_number: T::BlockNumber, relay_parent_number: T::BlockNumber,
receipt: AbridgedCandidateReceipt<T::Hash>, receipt: CommittedCandidateReceipt<T::Hash>,
) -> Weight { ) -> Weight {
let commitments = receipt.commitments; let commitments = receipt.commitments;
let config = <configuration::Module<T>>::config(); let config = <configuration::Module<T>>::config();
...@@ -447,15 +450,15 @@ impl<T: Trait> Module<T> { ...@@ -447,15 +450,15 @@ impl<T: Trait> Module<T> {
let mut weight = T::DbWeight::get().reads_writes(1, 0); let mut weight = T::DbWeight::get().reads_writes(1, 0);
if let Some(new_code) = commitments.new_validation_code { if let Some(new_code) = commitments.new_validation_code {
weight += <paras::Module<T>>::schedule_code_upgrade( weight += <paras::Module<T>>::schedule_code_upgrade(
receipt.parachain_index, receipt.descriptor.para_id,
new_code, new_code,
relay_parent_number + config.validation_upgrade_delay, relay_parent_number + config.validation_upgrade_delay,
); );
} }
weight + <paras::Module<T>>::note_new_head( weight + <paras::Module<T>>::note_new_head(
receipt.parachain_index, receipt.descriptor.para_id,
receipt.head_data, commitments.head_data,
relay_parent_number, relay_parent_number,
) )
} }
...@@ -495,10 +498,11 @@ const fn availability_threshold(n_validators: usize) -> usize { ...@@ -495,10 +498,11 @@ const fn availability_threshold(n_validators: usize) -> usize {
mod tests { mod tests {
use super::*; use super::*;
use primitives::{BlockNumber, Hash}; use primitives::v1::{BlockNumber, Hash};
use primitives::parachain::{ use primitives::v1::{
SignedAvailabilityBitfield, CompactStatement as Statement, ValidityAttestation, CollatorId, SignedAvailabilityBitfield, CompactStatement as Statement, ValidityAttestation, CollatorId,
CandidateCommitments, SignedStatement, AssignmentKind, CandidateCommitments, SignedStatement, CandidateDescriptor, HeadData, ValidationCode,
AssignmentKind,
}; };
use frame_support::traits::{OnFinalize, OnInitialize}; use frame_support::traits::{OnFinalize, OnInitialize};
use keyring::Sr25519Keyring; use keyring::Sr25519Keyring;
...@@ -545,22 +549,22 @@ mod tests { ...@@ -545,22 +549,22 @@ mod tests {
fn collator_sign_candidate( fn collator_sign_candidate(
collator: Sr25519Keyring, collator: Sr25519Keyring,
candidate: &mut AbridgedCandidateReceipt, candidate: &mut CommittedCandidateReceipt,
) { ) {
candidate.collator = collator.public().into(); candidate.descriptor.collator = collator.public().into();
let payload = primitives::parachain::collator_signature_payload( let payload = primitives::v1::collator_signature_payload(
&candidate.relay_parent, &candidate.descriptor.relay_parent,
&candidate.parachain_index, &candidate.descriptor.para_id,
&candidate.pov_block_hash, &candidate.descriptor.pov_hash,
); );
candidate.signature = collator.sign(&payload[..]).into(); candidate.descriptor.signature = collator.sign(&payload[..]).into();