mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-20 05:51:02 +00:00
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
This commit is contained in:
committed by
GitHub
parent
6957847b6b
commit
3b13cd9a85
@@ -28,7 +28,7 @@ use frame_support::{
|
||||
weights::DispatchClass,
|
||||
};
|
||||
|
||||
use primitives::{Hash, parachain::{AttestedCandidate, AbridgedCandidateReceipt, Id as ParaId}};
|
||||
use primitives::v0::{Hash, AttestedCandidate, AbridgedCandidateReceipt, Id as ParaId};
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_staking::SessionIndex;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ use sp_runtime::{
|
||||
TransactionSource, TransactionValidityError,
|
||||
},
|
||||
};
|
||||
use primitives::ValidityError;
|
||||
use primitives::v0::ValidityError;
|
||||
|
||||
type CurrencyOf<T> = <<T as Trait>::VestingSchedule as VestingSchedule<<T as system::Trait>::AccountId>>::Currency;
|
||||
type BalanceOf<T> = <CurrencyOf<T> as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
|
||||
@@ -79,7 +79,7 @@ use sp_runtime::{ModuleId,
|
||||
use crate::slots;
|
||||
use codec::{Encode, Decode};
|
||||
use sp_std::vec::Vec;
|
||||
use primitives::parachain::{Id as ParaId, HeadData};
|
||||
use primitives::v0::{Id as ParaId, HeadData};
|
||||
|
||||
pub type BalanceOf<T> =
|
||||
<<T as slots::Trait>::Currency as Currency<<T as system::Trait>::AccountId>>::Balance;
|
||||
@@ -568,7 +568,7 @@ mod tests {
|
||||
};
|
||||
use frame_support::traits::{Contains, ContainsLengthBound};
|
||||
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
|
||||
// or public keys. `u64` is used as the `AccountId` and no `Signature`s are requried.
|
||||
use sp_runtime::{
|
||||
|
||||
@@ -26,8 +26,8 @@ pub struct ToAuthor<R>(sp_std::marker::PhantomData<R>);
|
||||
impl<R> OnUnbalanced<NegativeImbalance<R>> for ToAuthor<R>
|
||||
where
|
||||
R: balances::Trait + authorship::Trait,
|
||||
<R as system::Trait>::AccountId: From<primitives::AccountId>,
|
||||
<R as system::Trait>::AccountId: Into<primitives::AccountId>,
|
||||
<R as system::Trait>::AccountId: From<primitives::v0::AccountId>,
|
||||
<R as system::Trait>::AccountId: Into<primitives::v0::AccountId>,
|
||||
<R as system::Trait>::Event: From<balances::RawEvent<
|
||||
<R as system::Trait>::AccountId,
|
||||
<R as balances::Trait>::Balance,
|
||||
|
||||
@@ -27,7 +27,7 @@ pub mod slots;
|
||||
pub mod crowdfund;
|
||||
pub mod impls;
|
||||
|
||||
use primitives::BlockNumber;
|
||||
use primitives::v0::BlockNumber;
|
||||
use sp_runtime::{Perquintill, Perbill, FixedPointNumber, traits::Saturating};
|
||||
use frame_support::{
|
||||
parameter_types, traits::{Currency},
|
||||
|
||||
@@ -37,16 +37,13 @@ use frame_support::{
|
||||
dispatch::IsSubType,
|
||||
weights::{DispatchClass, Weight},
|
||||
};
|
||||
use primitives::{
|
||||
Balance,
|
||||
BlockNumber,
|
||||
parachain::{
|
||||
Id as ParaId, Chain, DutyRoster, AttestedCandidate, CompactStatement as Statement, ParachainDispatchOrigin,
|
||||
UpwardMessage, ValidatorId, ActiveParas, CollatorId, Retriable, OmittedValidationData,
|
||||
CandidateReceipt, GlobalValidationSchedule, AbridgedCandidateReceipt,
|
||||
LocalValidationData, Scheduling, ValidityAttestation, NEW_HEADS_IDENTIFIER, PARACHAIN_KEY_TYPE_ID,
|
||||
ValidatorSignature, SigningContext, HeadData, ValidationCode,
|
||||
},
|
||||
use primitives::v0::{
|
||||
Balance, BlockNumber,
|
||||
Id as ParaId, Chain, DutyRoster, AttestedCandidate, CompactStatement as Statement, ParachainDispatchOrigin,
|
||||
UpwardMessage, ValidatorId, ActiveParas, CollatorId, Retriable, OmittedValidationData,
|
||||
CandidateReceipt, GlobalValidationSchedule, AbridgedCandidateReceipt,
|
||||
LocalValidationData, Scheduling, ValidityAttestation, NEW_HEADS_IDENTIFIER, PARACHAIN_KEY_TYPE_ID,
|
||||
ValidatorSignature, SigningContext, HeadData, ValidationCode,
|
||||
Remark, DownwardMessage
|
||||
};
|
||||
use frame_support::{
|
||||
@@ -329,7 +326,7 @@ pub trait Trait: CreateSignedTransaction<Call<Self>> + attestations::Trait + ses
|
||||
>;
|
||||
|
||||
/// 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.
|
||||
@@ -1681,13 +1678,10 @@ mod tests {
|
||||
},
|
||||
testing::TestXt,
|
||||
};
|
||||
use primitives::{
|
||||
parachain::{
|
||||
CandidateReceipt, ValidityAttestation, ValidatorId, Info as ParaInfo,
|
||||
Scheduling, CandidateCommitments,
|
||||
},
|
||||
BlockNumber,
|
||||
Header,
|
||||
use primitives::v0::{
|
||||
CandidateReceipt, ValidityAttestation, ValidatorId, Info as ParaInfo,
|
||||
Scheduling, CandidateCommitments,
|
||||
BlockNumber, Header,
|
||||
};
|
||||
use keyring::Sr25519Keyring;
|
||||
use frame_support::{
|
||||
@@ -1819,7 +1813,7 @@ mod tests {
|
||||
}
|
||||
|
||||
mod time {
|
||||
use primitives::{Moment, BlockNumber};
|
||||
use primitives::v0::{Moment, BlockNumber};
|
||||
pub const MILLISECS_PER_BLOCK: Moment = 6000;
|
||||
pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 1 * HOURS;
|
||||
// These time units are defined in number of blocks.
|
||||
@@ -2246,7 +2240,7 @@ mod tests {
|
||||
println!("session index {}", i);
|
||||
Staking::on_finalize(System::block_number());
|
||||
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
|
||||
// we need to first get it via `System::finalize` and then set it
|
||||
|
||||
@@ -34,7 +34,7 @@ use frame_support::{
|
||||
weights::{DispatchClass, Weight},
|
||||
};
|
||||
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,
|
||||
Retriable, ValidationCode, HeadData,
|
||||
};
|
||||
@@ -213,7 +213,7 @@ fn build<T: Trait>(config: &GenesisConfig<T>) {
|
||||
Parachains::put(&only_ids);
|
||||
|
||||
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.
|
||||
<parachains::Code>::insert(&id, &code);
|
||||
<parachains::Heads>::insert(&id, &genesis);
|
||||
@@ -670,12 +670,10 @@ mod tests {
|
||||
AccountIdConversion, Extrinsic as ExtrinsicT,
|
||||
}, testing::{UintAuthorityId, TestXt}, KeyTypeId, Perbill, curve::PiecewiseLinear,
|
||||
};
|
||||
use primitives::{
|
||||
parachain::{
|
||||
ValidatorId, Info as ParaInfo, Scheduling, LOWEST_USER_ID, AttestedCandidate,
|
||||
CandidateReceipt, HeadData, ValidityAttestation, CompactStatement as Statement, Chain,
|
||||
CollatorPair, CandidateCommitments,
|
||||
},
|
||||
use primitives::v0::{
|
||||
ValidatorId, Info as ParaInfo, Scheduling, LOWEST_USER_ID, AttestedCandidate,
|
||||
CandidateReceipt, HeadData, ValidityAttestation, CompactStatement as Statement, Chain,
|
||||
CollatorPair, CandidateCommitments,
|
||||
Balance, BlockNumber, Header, Signature,
|
||||
};
|
||||
use frame_support::{
|
||||
@@ -869,7 +867,7 @@ mod tests {
|
||||
// This is needed for a custom `AccountId` type which is `u64` in testing here.
|
||||
pub mod test_keys {
|
||||
use sp_core::{crypto::KeyTypeId, sr25519};
|
||||
use primitives::Signature;
|
||||
use primitives::v0::Signature;
|
||||
|
||||
pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"test");
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ use frame_support::{
|
||||
traits::{Currency, ReservableCurrency, WithdrawReason, ExistenceRequirement, Get, Randomness},
|
||||
weights::{DispatchClass, Weight},
|
||||
};
|
||||
use primitives::parachain::{
|
||||
use primitives::v0::{
|
||||
SwapAux, PARACHAIN_INFO, Id as ParaId, ValidationCode, HeadData,
|
||||
};
|
||||
use system::{ensure_signed, ensure_root};
|
||||
@@ -890,8 +890,7 @@ mod tests {
|
||||
traits::{OnInitialize, OnFinalize}
|
||||
};
|
||||
use balances;
|
||||
use primitives::{BlockNumber, Header};
|
||||
use primitives::parachain::{Id as ParaId, Info as ParaInfo, Scheduling};
|
||||
use primitives::v0::{BlockNumber, Header, Id as ParaId, Info as ParaInfo, Scheduling};
|
||||
|
||||
impl_outer_origin! {
|
||||
pub enum Origin for Test {}
|
||||
|
||||
Reference in New Issue
Block a user