Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: remove ttl #5461

Merged
merged 195 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
195 commits
Select commit Hold shift + click to select a range
793142e
WIP primitives
sandreim Jul 17, 2024
3a29fdf
WIP
sandreim Aug 5, 2024
4a53577
Working version.
sandreim Aug 7, 2024
8285ae7
Better version
sandreim Aug 8, 2024
2831c5e
Add missing primitives and fix things
sandreim Aug 8, 2024
c767d60
Implement v2 receipts in polkadot-runtime-parachains
sandreim Aug 8, 2024
96999e3
add missing stuff
sandreim Aug 12, 2024
c5f2dc3
Switch parachains runtime to use new primitives
sandreim Aug 12, 2024
dbb0160
use vstaging primitives
sandreim Aug 12, 2024
5efab68
update rococo and westend
sandreim Aug 12, 2024
c2232e4
client keeps using the old primitives
sandreim Aug 12, 2024
87b079f
no unsafe pls
sandreim Aug 12, 2024
00e8c13
move async backing primtiives to own file
sandreim Aug 12, 2024
cd4d02f
fix
sandreim Aug 12, 2024
5509e33
fix test build
sandreim Aug 12, 2024
f8b86d2
fix test-runtime
sandreim Aug 12, 2024
fe2fbfb
self review feedback
sandreim Aug 13, 2024
975e13b
review feedback
sandreim Aug 13, 2024
1c7ac55
feedback
sandreim Aug 13, 2024
653873b
feedback
sandreim Aug 13, 2024
dc98149
clippy
sandreim Aug 13, 2024
0a6bce3
chores
sandreim Aug 13, 2024
5e4dac2
Filter v2 candidate descriptors
sandreim Aug 14, 2024
f12ca7a
fix
sandreim Aug 14, 2024
13734de
fix prospective parachains tests
sandreim Aug 14, 2024
effb1cc
fix fix
sandreim Aug 14, 2024
3f75cba
fmt
sandreim Aug 14, 2024
75a47bb
fix comment
sandreim Aug 14, 2024
12ed853
another one
sandreim Aug 14, 2024
f2c0882
fix build
sandreim Aug 15, 2024
768e034
.
sandreim Aug 15, 2024
4bf0706
improve test and add comment
sandreim Aug 15, 2024
0c83201
add log
sandreim Aug 15, 2024
4296942
simplify check()
sandreim Aug 19, 2024
e1a7509
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 20, 2024
6fb7790
impl<H>
sandreim Aug 20, 2024
e6add9c
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 20, 2024
d0b3961
comment
sandreim Aug 20, 2024
66f7a96
add some tests
sandreim Aug 20, 2024
5c0c919
update
sandreim Aug 20, 2024
38ce589
prdoc
sandreim Aug 21, 2024
9f1d611
can't be happy if CI is sad
sandreim Aug 21, 2024
a6a7329
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Aug 21, 2024
663817d
remove newlines
sandreim Aug 21, 2024
a1dacc1
match rfc 103 reserved field naming
sandreim Aug 21, 2024
33b80ea
remove default cq offset
sandreim Aug 21, 2024
d5b165f
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 21, 2024
29e4b47
Ignore UMP signals when checking and processing UMP queue
sandreim Aug 16, 2024
ab85fe3
wip
sandreim Aug 20, 2024
7d5636b
refactor a bit
sandreim Aug 20, 2024
2954bba
use descriptor core_index in `map_candidates_to_cores`
sandreim Aug 20, 2024
e7abe8b
nits
sandreim Aug 20, 2024
1db5eb0
Para Inherent: filter v2 candidate descriptors (#5362)
sandreim Aug 22, 2024
cdb49a6
increase test coverage
sandreim Aug 22, 2024
f6f714a
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 22, 2024
9cc8232
WIP
alindima Aug 22, 2024
6211c8e
first version that compiles
alindima Aug 23, 2024
aa925cd
Improve usability of primitives
sandreim Aug 23, 2024
00d7c71
use committed core index if available in v1 receipts
sandreim Aug 23, 2024
af9f561
typo
sandreim Aug 23, 2024
fb2cefb
fix check
sandreim Aug 23, 2024
b53787d
typo
sandreim Aug 23, 2024
e24afd4
first version that works well
alindima Aug 26, 2024
3e13ef9
remove ProcessedCandidates
alindima Aug 26, 2024
0df5886
start fixing tests
alindima Aug 26, 2024
e2ef46e
add test for mixed v1 v2 scenario
sandreim Aug 26, 2024
2dfc542
comment
sandreim Aug 26, 2024
a38a243
add ump test
sandreim Aug 26, 2024
da381da
avoid one storage read
sandreim Aug 26, 2024
ca5c618
store claim queue snapshot in allowed relay parent info
sandreim Aug 27, 2024
4266665
check v2 receipts using claim queue snapshots
sandreim Aug 27, 2024
e93b983
typo
sandreim Aug 27, 2024
2267e62
don't back anything if there's an upcoming session change
alindima Aug 28, 2024
e01bf53
it was a bad idea to process commitments of v1 receipts
sandreim Aug 28, 2024
fb9fbe6
fmt
sandreim Aug 28, 2024
c507488
remove unused
sandreim Aug 28, 2024
178e201
Validate session index
sandreim Aug 28, 2024
67f6382
avoid pushing back items to the assignment provider on session change
alindima Aug 28, 2024
984e8e1
add unknown version
sandreim Aug 29, 2024
fab215d
add check for unknown version and test
sandreim Aug 29, 2024
7300552
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Aug 29, 2024
9bbe2cc
typo
sandreim Aug 29, 2024
4dda9df
adjust comments
sandreim Aug 29, 2024
af6df0f
duplicate the first assignment if the claim queue used to be empty
alindima Aug 30, 2024
12c7ebd
temp: don't kill the pipelines if tests or clippy is failing
alindima Aug 30, 2024
e781da1
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Aug 30, 2024
cd3eb5f
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Aug 30, 2024
f8ef4ce
fix merge damage
sandreim Aug 30, 2024
04e31a1
unused
sandreim Aug 30, 2024
5fd1279
fix
sandreim Aug 30, 2024
19d6f32
fix benchmark build
sandreim Sep 2, 2024
552078a
Merge branch 'sandreim/rfc103-primitives' of github.com:paritytech/po…
sandreim Sep 2, 2024
4ec3fc8
typos
sandreim Sep 2, 2024
2ba0a27
fmt
sandreim Sep 2, 2024
e468d62
fix comment
sandreim Sep 2, 2024
3fe368f
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Sep 3, 2024
18a0496
mixed v1, v2, v2 without select core tests,
sandreim Sep 4, 2024
d320269
Add allowed relay parents storage migration
sandreim Sep 4, 2024
8490488
fix migration
sandreim Sep 5, 2024
db67486
fix
sandreim Sep 5, 2024
03cf8c1
clippy
sandreim Sep 5, 2024
43f6de7
feedback
sandreim Sep 5, 2024
70e48d2
sir, make it faster
sandreim Sep 5, 2024
1e26c73
fix
sandreim Sep 5, 2024
f4e3fb5
one last fix
sandreim Sep 5, 2024
2e87ad3
fixes
sandreim Sep 5, 2024
54432be
remove println
sandreim Sep 5, 2024
cfbecb0
add prdoc
sandreim Sep 6, 2024
3a518f2
fix comment
sandreim Sep 6, 2024
54106e2
refactor map_candidates_to_cores
sandreim Sep 6, 2024
b44a604
doc updates
sandreim Sep 9, 2024
4c5c707
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Sep 9, 2024
caff543
feedback
sandreim Sep 13, 2024
218f530
refactor
sandreim Sep 13, 2024
216937a
fix try-runtime
sandreim Sep 13, 2024
c0aee8c
check ump signal count and test
sandreim Sep 16, 2024
d0a42c8
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Sep 17, 2024
d31e0a0
remove fields from configuration
alindima Sep 17, 2024
fce03b3
fix storage version
alindima Sep 17, 2024
f07b6f4
add scheduler migration
alindima Sep 18, 2024
1ef7952
remove unused
sandreim Sep 18, 2024
5790b8e
fix prdoc
sandreim Sep 19, 2024
ba9d3ff
more tests cases
sandreim Sep 19, 2024
9c4e2ae
stricter UMP signal checks and tests
sandreim Sep 23, 2024
5b157a2
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Sep 24, 2024
8d7b59b
fix todo with a slight hack
alindima Sep 24, 2024
d9f0b52
fix core count on session change
alindima Sep 24, 2024
43bbb9d
type alias
sandreim Sep 24, 2024
d7e57fd
Merge branch 'master' into sandreim/runtime_v2_descriptor_support
sandreim Sep 24, 2024
e64216a
Merge remote-tracking branch 'origin/sandreim/runtime_v2_descriptor_s…
alindima Sep 24, 2024
eb1de77
add workaround for #64 for claim queue
alindima Sep 24, 2024
5437b4c
Revert "remove fields from configuration"
alindima Sep 24, 2024
415a938
remove config extrinsics and outdated error
alindima Sep 24, 2024
8985f60
complete fix for #64
alindima Sep 24, 2024
e7cf960
fix paras_inherent tests
alindima Sep 24, 2024
4488c11
don't add empty entries to cq
alindima Sep 25, 2024
d0c4ea8
fix tests and remove superfluous ones
alindima Sep 25, 2024
a48548c
remove yml hacks
alindima Sep 25, 2024
9bec454
fix config storage version
alindima Sep 25, 2024
4a316d0
bugfixes
alindima Sep 25, 2024
d745915
tests
alindima Sep 25, 2024
bac4b9e
clippy
alindima Sep 26, 2024
658da59
bugfixes
alindima Sep 26, 2024
8f65358
finish scheduler tests
alindima Sep 27, 2024
37fd8cf
extract back_candidates function
alindima Sep 27, 2024
5967f78
testing cleanups
alindima Sep 30, 2024
ae9b1ac
add session change test
alindima Sep 30, 2024
b9596ba
address comment
alindima Sep 30, 2024
fb599e7
prdoc
alindima Sep 30, 2024
b5f7bda
revert
alindima Sep 30, 2024
7a1f382
missing feedback
sandreim Oct 2, 2024
4757dab
Merge remote-tracking branch 'origin' into sandreim/runtime_v2_descri…
sandreim Oct 2, 2024
a2a0795
Merge branch 'sandreim/runtime_v2_descriptor_support' of github.com:p…
sandreim Oct 2, 2024
01ce087
:facepalm:
sandreim Oct 2, 2024
c0b36b1
Merge branch 'master' of github.com:paritytech/polkadot-sdk into sand…
sandreim Oct 2, 2024
45b4690
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Oct 2, 2024
28e4309
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Oct 2, 2024
6c81b4c
Merge remote-tracking branch 'origin/sandreim/runtime_v2_descriptor_s…
alindima Oct 7, 2024
a5d4dc0
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Oct 7, 2024
ccb1176
clippy
alindima Oct 7, 2024
9e411f8
address some review comments
alindima Oct 8, 2024
7ea37ad
clippy
alindima Oct 8, 2024
25b1c23
some more polishing
alindima Oct 8, 2024
9767e1b
move eligible_paras
alindima Oct 8, 2024
ce092e5
do report_processed when backing/dropping claim
alindima Oct 8, 2024
b369153
clippy
alindima Oct 8, 2024
345c956
Merge branch 'master' into alindima/remove-ttl
alindima Oct 9, 2024
4daf2ff
Merge branch 'master' into alindima/remove-ttl
alindima Oct 9, 2024
e61646a
nits
alindima Oct 9, 2024
75f1390
some more review feedback
alindima Oct 15, 2024
6e8f479
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Oct 15, 2024
8942c57
some fixes
alindima Oct 15, 2024
eff59c9
fix hyperlink
alindima Oct 15, 2024
e03d00d
add sync backing zombienet test
alindima Oct 15, 2024
de0fb25
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Oct 15, 2024
4e89e25
add zombienet test for core sharing when one parachain is not produci…
alindima Oct 15, 2024
053fe9c
try fixing zombienet
alindima Oct 16, 2024
9ea0e26
fix benchmarks
alindima Oct 16, 2024
8b3f248
update prdoc
alindima Oct 16, 2024
5b7bad1
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Oct 16, 2024
f022674
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Oct 16, 2024
468a28c
fix bench
alindima Oct 17, 2024
66d5abf
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Oct 17, 2024
a99309b
Merge remote-tracking branch 'origin/alindima/remove-ttl' into alindi…
alindima Oct 17, 2024
04a541b
fix benchmarks one last time
alindima Oct 17, 2024
1bfb31b
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Oct 17, 2024
10f7c72
switch test runtime to coretime
alindima Oct 21, 2024
acf109d
fix prdoc
alindima Oct 21, 2024
ec5c45f
Merge remote-tracking branch 'origin/master' into alindima/remove-ttl
alindima Oct 21, 2024
527a80c
Merge remote-tracking branch 'origin/alindima/remove-ttl' into alindi…
alindima Oct 21, 2024
e93a05f
try fixing prdoc
alindima Oct 21, 2024
14c1641
fix prdoc
alindima Oct 21, 2024
0680a2c
review feedback
alindima Oct 21, 2024
dea739c
fix clippy
alindima Oct 21, 2024
2c7b6ca
".git/.scripts/commands/bench/bench.sh" --subcommand=pallet --runtime…
Oct 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .gitlab/pipeline/zombienet/polkadot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,25 @@ zombienet-polkadot-functional-0016-approval-voting-parallel:
--local-dir="${LOCAL_DIR}/functional"
--test="0016-approval-voting-parallel.zndsl"

zombienet-polkadot-functional-0017-sync-backing:
extends:
- .zombienet-polkadot-common
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}/functional"
--test="0017-sync-backing.zndsl"

zombienet-polkadot-functional-0018-shared-core-idle-parachain:
extends:
- .zombienet-polkadot-common
before_script:
- !reference [ .zombienet-polkadot-common, before_script ]
- cp --remove-destination ${LOCAL_DIR}/assign-core.js ${LOCAL_DIR}/functional
script:
- /home/nonroot/zombie-net/scripts/ci/run-test-local-env-manager.sh
--local-dir="${LOCAL_DIR}/functional"
--test="0018-shared-core-idle-parachain.zndsl"

zombienet-polkadot-smoke-0001-parachains-smoke-test:
extends:
- .zombienet-polkadot-common
Expand Down
11 changes: 7 additions & 4 deletions polkadot/primitives/src/v8/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,9 @@ pub struct SchedulerParams<BlockNumber> {
pub lookahead: u32,
/// How many cores are managed by the coretime chain.
pub num_cores: u32,
/// The max number of times a claim can time out in availability.
/// Deprecated and no longer used by the runtime.
/// Removal is tracked by <https://github.com/paritytech/polkadot-sdk/issues/6067>.
#[deprecated]
pub max_availability_timeouts: u32,
/// The maximum queue size of the pay as you go module.
pub on_demand_queue_max_size: u32,
Expand All @@ -2104,13 +2106,14 @@ pub struct SchedulerParams<BlockNumber> {
pub on_demand_fee_variability: Perbill,
/// The minimum amount needed to claim a slot in the spot pricing queue.
pub on_demand_base_fee: Balance,
/// The number of blocks a claim stays in the scheduler's claim queue before getting cleared.
/// This number should go reasonably higher than the number of blocks in the async backing
/// lookahead.
/// Deprecated and no longer used by the runtime.
/// Removal is tracked by <https://github.com/paritytech/polkadot-sdk/issues/6067>.
#[deprecated]
pub ttl: BlockNumber,
}

impl<BlockNumber: Default + From<u32>> Default for SchedulerParams<BlockNumber> {
#[allow(deprecated)]
fn default() -> Self {
Self {
group_rotation_frequency: 1u32.into(),
Expand Down
9 changes: 6 additions & 3 deletions polkadot/runtime/parachains/src/assigner_coretime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,12 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pallet<T> {
Assignment::Bulk(para_id)
}

fn session_core_count() -> u32 {
let config = configuration::ActiveConfig::<T>::get();
config.scheduler_params.num_cores
fn assignment_duplicated(assignment: &Assignment) {
eskimor marked this conversation as resolved.
Show resolved Hide resolved
match assignment {
Assignment::Pool { para_id, core_index } =>
on_demand::Pallet::<T>::assignment_duplicated(*para_id, *core_index),
Assignment::Bulk(_) => {},
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions polkadot/runtime/parachains/src/assigner_coretime/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use crate::{
paras::{ParaGenesisArgs, ParaKind},
scheduler::common::Assignment,
};
use alloc::collections::btree_map::BTreeMap;
use frame_support::{assert_noop, assert_ok, pallet_prelude::*, traits::Currency};
use pallet_broker::TaskId;
use polkadot_primitives::{BlockNumber, Id as ParaId, SessionIndex, ValidationCode};
Expand Down Expand Up @@ -78,7 +77,7 @@ fn run_to_block(
OnDemand::on_initialize(b + 1);

// In the real runtime this is expected to be called by the `InclusionInherent` pallet.
Scheduler::free_cores_and_fill_claim_queue(BTreeMap::new(), b + 1);
Scheduler::advance_claim_queue(&Default::default());
}
}

Expand Down
4 changes: 1 addition & 3 deletions polkadot/runtime/parachains/src/assigner_parachains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,5 @@ impl<T: Config> AssignmentProvider<BlockNumberFor<T>> for Pallet<T> {
Assignment::Bulk(para_id)
}

fn session_core_count() -> u32 {
paras::Parachains::<T>::decode_len().unwrap_or(0) as u32
}
fn assignment_duplicated(_: &Assignment) {}
}
3 changes: 1 addition & 2 deletions polkadot/runtime/parachains/src/assigner_parachains/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use crate::{
},
paras::{ParaGenesisArgs, ParaKind},
};
use alloc::collections::btree_map::BTreeMap;
use frame_support::{assert_ok, pallet_prelude::*};
use polkadot_primitives::{BlockNumber, Id as ParaId, SessionIndex, ValidationCode};

Expand Down Expand Up @@ -71,7 +70,7 @@ fn run_to_block(
Scheduler::initializer_initialize(b + 1);

// In the real runtime this is expected to be called by the `InclusionInherent` pallet.
Scheduler::free_cores_and_fill_claim_queue(BTreeMap::new(), b + 1);
Scheduler::advance_claim_queue(&Default::default());
}
}

Expand Down
131 changes: 59 additions & 72 deletions polkadot/runtime/parachains/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use crate::{
configuration, inclusion, initializer, paras,
paras::ParaKind,
paras_inherent,
scheduler::{self, common::AssignmentProvider, CoreOccupied, ParasEntry},
scheduler::{
self,
common::{Assignment, AssignmentProvider},
},
session_info, shared,
};
use alloc::{
Expand Down Expand Up @@ -138,8 +141,6 @@ pub(crate) struct BenchBuilder<T: paras_inherent::Config> {
/// Make every candidate include a code upgrade by setting this to `Some` where the interior
/// value is the byte length of the new code.
code_upgrade: Option<u32>,
/// Specifies whether the claimqueue should be filled.
fill_claimqueue: bool,
/// Cores which should not be available when being populated with pending candidates.
unavailable_cores: Vec<u32>,
/// Use v2 candidate descriptor.
Expand Down Expand Up @@ -178,7 +179,6 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
backed_in_inherent_paras: Default::default(),
elastic_paras: Default::default(),
code_upgrade: None,
fill_claimqueue: true,
unavailable_cores: vec![],
candidate_descriptor_v2: false,
candidate_modifier: None,
Expand Down Expand Up @@ -322,13 +322,6 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
self.max_validators() / self.max_validators_per_core()
}

/// Set whether the claim queue should be filled.
#[cfg(not(feature = "runtime-benchmarks"))]
pub(crate) fn set_fill_claimqueue(mut self, f: bool) -> Self {
self.fill_claimqueue = f;
self
}

/// Get the minimum number of validity votes in order for a backed candidate to be included.
#[cfg(feature = "runtime-benchmarks")]
pub(crate) fn fallback_min_backing_votes() -> u32 {
Expand All @@ -340,10 +333,13 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
HeadData(vec![0xFF; max_head_size as usize])
}

fn candidate_descriptor_mock(candidate_descriptor_v2: bool) -> CandidateDescriptorV2<T::Hash> {
fn candidate_descriptor_mock(
para_id: ParaId,
candidate_descriptor_v2: bool,
) -> CandidateDescriptorV2<T::Hash> {
if candidate_descriptor_v2 {
CandidateDescriptorV2::new(
0.into(),
para_id,
Default::default(),
CoreIndex(200),
2,
Expand All @@ -356,7 +352,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
} else {
// Convert v1 to v2.
CandidateDescriptor::<T::Hash> {
para_id: 0.into(),
para_id,
relay_parent: Default::default(),
collator: junk_collator(),
persisted_validation_data_hash: Default::default(),
Expand All @@ -373,6 +369,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {

/// Create a mock of `CandidatePendingAvailability`.
fn candidate_availability_mock(
para_id: ParaId,
group_idx: GroupIndex,
core_idx: CoreIndex,
candidate_hash: CandidateHash,
Expand All @@ -381,15 +378,16 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
candidate_descriptor_v2: bool,
) -> inclusion::CandidatePendingAvailability<T::Hash, BlockNumberFor<T>> {
inclusion::CandidatePendingAvailability::<T::Hash, BlockNumberFor<T>>::new(
core_idx, // core
candidate_hash, // hash
Self::candidate_descriptor_mock(candidate_descriptor_v2), // candidate descriptor
commitments, // commitments
availability_votes, // availability votes
Default::default(), // backers
Zero::zero(), // relay parent
One::one(), /* relay chain block this
* was backed in */
core_idx, // core
candidate_hash, // hash
Self::candidate_descriptor_mock(para_id, candidate_descriptor_v2), /* candidate descriptor */
commitments, // commitments
availability_votes, /* availability
* votes */
Default::default(), // backers
Zero::zero(), // relay parent
One::one(), /* relay chain block this
* was backed in */
group_idx, // backing group
)
}
Expand All @@ -416,6 +414,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
hrmp_watermark: 0u32.into(),
};
let candidate_availability = Self::candidate_availability_mock(
para_id,
group_idx,
core_idx,
candidate_hash,
Expand Down Expand Up @@ -886,14 +885,11 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
extra_cores;

assert!(used_cores <= max_cores);
let fill_claimqueue = self.fill_claimqueue;

// NOTE: there is an n+2 session delay for these actions to take effect.
// We are currently in Session 0, so these changes will take effect in Session 2.
Self::setup_para_ids(used_cores - extra_cores);
configuration::ActiveConfig::<T>::mutate(|c| {
c.scheduler_params.num_cores = used_cores as u32;
});
configuration::Pallet::<T>::set_coretime_cores_unchecked(used_cores as u32).unwrap();

let validator_ids = generate_validator_pairs::<T>(self.max_validators());
let target_session = SessionIndex::from(self.target_session);
Expand All @@ -902,7 +898,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
let bitfields = builder.create_availability_bitfields(
&builder.backed_and_concluding_paras,
&builder.elastic_paras,
used_cores,
scheduler::Pallet::<T>::num_availability_cores(),
);

let mut backed_in_inherent = BTreeMap::new();
Expand Down Expand Up @@ -930,66 +926,57 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {

assert_eq!(inclusion::PendingAvailability::<T>::iter().count(), used_cores - extra_cores);

// Mark all the used cores as occupied. We expect that there are
// `backed_and_concluding_paras` that are pending availability and that there are
// `used_cores - backed_and_concluding_paras ` which are about to be disputed.
let now = frame_system::Pallet::<T>::block_number() + One::one();

// Sanity check that the occupied cores reported by the inclusion module are what we expect
// to be.
let mut core_idx = 0u32;
let elastic_paras = &builder.elastic_paras;
// Assign potentially multiple cores to same parachains,
sandreim marked this conversation as resolved.
Show resolved Hide resolved
let cores = all_cores

let mut occupied_cores = inclusion::Pallet::<T>::get_occupied_cores()
.map(|(core, candidate)| (core, candidate.candidate_descriptor().para_id()))
.collect::<Vec<_>>();
occupied_cores.sort_by(|(core_a, _), (core_b, _)| core_a.0.cmp(&core_b.0));

let mut expected_cores = all_cores
.iter()
.flat_map(|(para_id, _)| {
(0..elastic_paras.get(&para_id).cloned().unwrap_or(1))
.map(|_para_local_core_idx| {
let ttl = configuration::ActiveConfig::<T>::get().scheduler_params.ttl;
// Load an assignment into provider so that one is present to pop
let assignment =
<T as scheduler::Config>::AssignmentProvider::get_mock_assignment(
CoreIndex(core_idx),
ParaId::from(*para_id),
);
let old_core_idx = core_idx;
core_idx += 1;
CoreOccupied::Paras(ParasEntry::new(assignment, now + ttl))
(CoreIndex(old_core_idx), ParaId::from(*para_id))
})
.collect::<Vec<CoreOccupied<_>>>()
.collect::<Vec<_>>()
})
.collect::<Vec<CoreOccupied<_>>>();
.collect::<Vec<_>>();

scheduler::AvailabilityCores::<T>::set(cores);
expected_cores.sort_by(|(core_a, _), (core_b, _)| core_a.0.cmp(&core_b.0));

core_idx = 0u32;
assert_eq!(expected_cores, occupied_cores);

// We need entries in the claim queue for those:
all_cores.append(&mut builder.backed_in_inherent_paras.clone());

if fill_claimqueue {
let cores = all_cores
.keys()
.flat_map(|para_id| {
(0..elastic_paras.get(&para_id).cloned().unwrap_or(1))
.map(|_para_local_core_idx| {
let ttl = configuration::ActiveConfig::<T>::get().scheduler_params.ttl;
// Load an assignment into provider so that one is present to pop
let assignment =
<T as scheduler::Config>::AssignmentProvider::get_mock_assignment(
CoreIndex(core_idx),
ParaId::from(*para_id),
);

core_idx += 1;
(
CoreIndex(core_idx - 1),
[ParasEntry::new(assignment, now + ttl)].into(),
)
})
.collect::<Vec<(CoreIndex, VecDeque<ParasEntry<_>>)>>()
})
.collect::<BTreeMap<CoreIndex, VecDeque<ParasEntry<_>>>>();
let mut core_idx = 0u32;
let cores = all_cores
.keys()
.flat_map(|para_id| {
(0..elastic_paras.get(&para_id).cloned().unwrap_or(1))
.map(|_para_local_core_idx| {
// Load an assignment into provider so that one is present to pop
let assignment =
<T as scheduler::Config>::AssignmentProvider::get_mock_assignment(
CoreIndex(core_idx),
ParaId::from(*para_id),
);

scheduler::ClaimQueue::<T>::set(cores);
}
core_idx += 1;
(CoreIndex(core_idx - 1), [assignment].into())
})
.collect::<Vec<(CoreIndex, VecDeque<Assignment>)>>()
})
.collect::<BTreeMap<CoreIndex, VecDeque<Assignment>>>();

scheduler::ClaimQueue::<T>::set(cores);

Bench::<T> {
data: ParachainsInherentData {
Expand Down
Loading
Loading