@@ -20,6 +20,7 @@ use frame_support::weights::{IdentityFee, Weight};
2020use frame_support:: { assert_err, assert_ok, derive_impl, parameter_types, PalletId } ;
2121use frame_system:: mocking:: MockUncheckedExtrinsic ;
2222use frame_system:: pallet_prelude:: * ;
23+ use pallet_subspace:: NormalEraChange ;
2324use parity_scale_codec:: { Decode , Encode , MaxEncodedLen } ;
2425use scale_info:: TypeInfo ;
2526use sp_core:: crypto:: Pair ;
@@ -34,14 +35,18 @@ use sp_domains::{
3435use sp_domains_fraud_proof:: fraud_proof:: FraudProof ;
3536use sp_runtime:: generic:: { Preamble , EXTRINSIC_FORMAT_VERSION } ;
3637use sp_runtime:: traits:: {
37- AccountIdConversion , BlakeTwo256 , BlockNumberProvider , Bounded , Hash as HashT , IdentityLookup ,
38- One , Zero ,
38+ AccountIdConversion , BlakeTwo256 , BlockNumberProvider , Bounded , ConstU16 , Hash as HashT ,
39+ IdentityLookup , One , Zero ,
3940} ;
4041use sp_runtime:: transaction_validity:: TransactionValidityError ;
4142use sp_runtime:: type_with_default:: TypeWithDefault ;
4243use sp_runtime:: { BuildStorage , OpaqueExtrinsic } ;
4344use sp_version:: RuntimeVersion ;
44- use subspace_core_primitives:: U256 as P256 ;
45+ use std:: num:: NonZeroU64 ;
46+ use subspace_core_primitives:: pieces:: Piece ;
47+ use subspace_core_primitives:: segments:: HistorySize ;
48+ use subspace_core_primitives:: solutions:: SolutionRange ;
49+ use subspace_core_primitives:: { SlotNumber , U256 as P256 } ;
4550use subspace_runtime_primitives:: {
4651 ConsensusEventSegmentSize , HoldIdentifier , Moment , Nonce , StorageFee , SSC ,
4752} ;
@@ -61,6 +66,7 @@ frame_support::construct_runtime!(
6166 System : frame_system,
6267 Timestamp : pallet_timestamp,
6368 Balances : pallet_balances,
69+ Subspace : pallet_subspace,
6470 Domains : pallet_domains,
6571 DomainExecutive : domain_pallet_executive,
6672 BlockFees : pallet_block_fees,
@@ -313,6 +319,54 @@ impl pallet_block_fees::Config for Test {
313319 type DomainChainByteFee = DomainChainByteFee ;
314320}
315321
322+ pub const INITIAL_SOLUTION_RANGE : SolutionRange =
323+ u64:: MAX / ( 1024 * 1024 * 1024 / Piece :: SIZE as u64 ) * 3 / 10 ;
324+
325+ parameter_types ! {
326+ pub const BlockAuthoringDelay : SlotNumber = 2 ;
327+ pub const PotEntropyInjectionInterval : BlockNumber = 5 ;
328+ pub const PotEntropyInjectionLookbackDepth : u8 = 2 ;
329+ pub const PotEntropyInjectionDelay : SlotNumber = 4 ;
330+ pub const EraDuration : u32 = 4 ;
331+ // 1GB
332+ pub const InitialSolutionRange : SolutionRange = INITIAL_SOLUTION_RANGE ;
333+ pub const RecentSegments : HistorySize = HistorySize :: new( NonZeroU64 :: new( 5 ) . unwrap( ) ) ;
334+ pub const RecentHistoryFraction : ( HistorySize , HistorySize ) = (
335+ HistorySize :: new( NonZeroU64 :: new( 1 ) . unwrap( ) ) ,
336+ HistorySize :: new( NonZeroU64 :: new( 10 ) . unwrap( ) ) ,
337+ ) ;
338+ pub const MinSectorLifetime : HistorySize = HistorySize :: new( NonZeroU64 :: new( 4 ) . unwrap( ) ) ;
339+ pub const RecordSize : u32 = 3840 ;
340+ pub const ExpectedVotesPerBlock : u32 = 9 ;
341+ pub const ReplicationFactor : u16 = 1 ;
342+ pub const ReportLongevity : u64 = 34 ;
343+ pub const ShouldAdjustSolutionRange : bool = false ;
344+ pub const BlockSlotCount : u32 = 6 ;
345+ }
346+
347+ impl pallet_subspace:: Config for Test {
348+ type RuntimeEvent = RuntimeEvent ;
349+ type SubspaceOrigin = pallet_subspace:: EnsureSubspaceOrigin ;
350+ type BlockAuthoringDelay = BlockAuthoringDelay ;
351+ type PotEntropyInjectionInterval = PotEntropyInjectionInterval ;
352+ type PotEntropyInjectionLookbackDepth = PotEntropyInjectionLookbackDepth ;
353+ type PotEntropyInjectionDelay = PotEntropyInjectionDelay ;
354+ type EraDuration = EraDuration ;
355+ type InitialSolutionRange = InitialSolutionRange ;
356+ type SlotProbability = SlotProbability ;
357+ type ConfirmationDepthK = ConfirmationDepthK ;
358+ type RecentSegments = RecentSegments ;
359+ type RecentHistoryFraction = RecentHistoryFraction ;
360+ type MinSectorLifetime = MinSectorLifetime ;
361+ type ExpectedVotesPerBlock = ExpectedVotesPerBlock ;
362+ type MaxPiecesInSector = ConstU16 < 1 > ;
363+ type ShouldAdjustSolutionRange = ShouldAdjustSolutionRange ;
364+ type EraChangeTrigger = NormalEraChange ;
365+ type WeightInfo = ( ) ;
366+ type BlockSlotCount = BlockSlotCount ;
367+ type ExtensionWeightInfo = pallet_subspace:: extensions:: weights:: SubstrateWeight < Self > ;
368+ }
369+
316370pub ( crate ) fn new_test_ext ( ) -> sp_io:: TestExternalities {
317371 let t = frame_system:: GenesisConfig :: < Test > :: default ( )
318372 . build_storage ( )
0 commit comments