diff --git a/polkadot/runtime/parachains/src/builder.rs b/polkadot/runtime/parachains/src/builder.rs index 87a085fc84554bf2142fcfcbd9d4ef661378c6fa..d153d864b4e2484cf601e9d0fd67aa272159b63e 100644 --- a/polkadot/runtime/parachains/src/builder.rs +++ b/polkadot/runtime/parachains/src/builder.rs @@ -710,7 +710,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> { let cores = (0..used_cores) .into_iter() .map(|i| { - let ttl = configuration::Pallet::<T>::config().on_demand_ttl; + let ttl = configuration::Pallet::<T>::config().coretime_ttl; // Load an assignment into provider so that one is present to pop let assignment = <T as scheduler::Config>::AssignmentProvider::get_mock_assignment( CoreIndex(i), @@ -725,7 +725,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> { let cores = (0..used_cores) .into_iter() .map(|i| { - let ttl = configuration::Pallet::<T>::config().on_demand_ttl; + let ttl = configuration::Pallet::<T>::config().coretime_ttl; // Load an assignment into provider so that one is present to pop let assignment = <T as scheduler::Config>::AssignmentProvider::get_mock_assignment( diff --git a/polkadot/runtime/parachains/src/configuration.rs b/polkadot/runtime/parachains/src/configuration.rs index 4619313590ebc2d5d92dfc85a4e845c381c61607..93faced80538c2e6839fdd4d6938d7f0f7ec80ce 100644 --- a/polkadot/runtime/parachains/src/configuration.rs +++ b/polkadot/runtime/parachains/src/configuration.rs @@ -174,8 +174,8 @@ pub struct HostConfiguration<BlockNumber> { pub code_retention_period: BlockNumber, /// How many cores are managed by the coretime chain. pub coretime_cores: u32, - /// The number of retries that a on demand author has to submit their block. - pub on_demand_retries: u32, + /// The max number of times a claim can time out in availability + pub coretime_max_availability_timeouts: u32, /// The maximum queue size of the pay as you go module. pub on_demand_queue_max_size: u32, /// The target utilization of the spot price queue in percentages. @@ -185,10 +185,10 @@ pub struct HostConfiguration<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 an on demand claim stays in the scheduler's claimqueue before getting - /// cleared. This number should go reasonably higher than the number of blocks in the async - /// backing lookahead. - pub on_demand_ttl: BlockNumber, + /// The number of blocks a claim stays in the scheduler's claimqueue before getting cleared. + /// This number should go reasonably higher than the number of blocks in the async backing + /// lookahead. + pub coretime_ttl: BlockNumber, /// How often parachain groups should be rotated across parachains. /// /// Must be non-zero. @@ -285,7 +285,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber max_pov_size: Default::default(), max_head_data_size: Default::default(), coretime_cores: Default::default(), - on_demand_retries: Default::default(), + coretime_max_availability_timeouts: Default::default(), scheduling_lookahead: 1, max_validators_per_core: Default::default(), max_validators: None, @@ -316,7 +316,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber on_demand_base_fee: 10_000_000u128, on_demand_fee_variability: Perbill::from_percent(3), on_demand_target_queue_utilization: Perbill::from_percent(25), - on_demand_ttl: 5u32.into(), + coretime_ttl: 5u32.into(), minimum_backing_votes: LEGACY_MIN_BACKING_VOTES, node_features: NodeFeatures::EMPTY, } @@ -688,7 +688,7 @@ pub mod pallet { pub fn set_on_demand_retries(origin: OriginFor<T>, new: u32) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { - config.on_demand_retries = new; + config.coretime_max_availability_timeouts = new; }) } @@ -1194,7 +1194,7 @@ pub mod pallet { pub fn set_on_demand_ttl(origin: OriginFor<T>, new: BlockNumberFor<T>) -> DispatchResult { ensure_root(origin)?; Self::schedule_config_update(|config| { - config.on_demand_ttl = new; + config.coretime_ttl = new; }) } diff --git a/polkadot/runtime/parachains/src/configuration/tests.rs b/polkadot/runtime/parachains/src/configuration/tests.rs index c915eb12a0ca1712a1d923d126daac959a40cd09..0a6cfa395a921196ff9222d8c4bae36fad6f3554 100644 --- a/polkadot/runtime/parachains/src/configuration/tests.rs +++ b/polkadot/runtime/parachains/src/configuration/tests.rs @@ -284,7 +284,7 @@ fn setting_pending_config_members() { max_pov_size: 1024, max_head_data_size: 1_000, coretime_cores: 2, - on_demand_retries: 5, + coretime_max_availability_timeouts: 5, group_rotation_frequency: 20, paras_availability_period: 10, scheduling_lookahead: 3, @@ -318,7 +318,7 @@ fn setting_pending_config_members() { on_demand_base_fee: 10_000_000u128, on_demand_fee_variability: Perbill::from_percent(3), on_demand_target_queue_utilization: Perbill::from_percent(25), - on_demand_ttl: 5u32, + coretime_ttl: 5u32, minimum_backing_votes: 5, node_features: bitvec![u8, Lsb0; 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1], }; @@ -344,8 +344,11 @@ fn setting_pending_config_members() { .unwrap(); Configuration::set_coretime_cores(RuntimeOrigin::root(), new_config.coretime_cores) .unwrap(); - Configuration::set_on_demand_retries(RuntimeOrigin::root(), new_config.on_demand_retries) - .unwrap(); + Configuration::set_on_demand_retries( + RuntimeOrigin::root(), + new_config.coretime_max_availability_timeouts, + ) + .unwrap(); Configuration::set_group_rotation_frequency( RuntimeOrigin::root(), new_config.group_rotation_frequency, diff --git a/polkadot/runtime/parachains/src/scheduler.rs b/polkadot/runtime/parachains/src/scheduler.rs index 747a05f24b95ef5b41cac1283fd739e0699f0b5b..8fc84b40f0cc2d9e12521f55c48075f4344ad5f5 100644 --- a/polkadot/runtime/parachains/src/scheduler.rs +++ b/polkadot/runtime/parachains/src/scheduler.rs @@ -352,7 +352,7 @@ impl<T: Config> Pallet<T> { fn drop_expired_claims_from_claimqueue() { let now = <frame_system::Pallet<T>>::block_number(); let availability_cores = AvailabilityCores::<T>::get(); - let ttl = <configuration::Pallet<T>>::config().on_demand_ttl; + let ttl = <configuration::Pallet<T>>::config().coretime_ttl; ClaimQueue::<T>::mutate(|cq| { for (idx, _) in (0u32..).zip(availability_cores) { @@ -509,7 +509,8 @@ impl<T: Config> Pallet<T> { /// Return the next thing that will be scheduled on this core assuming it is currently /// occupied and the candidate occupying it times out. pub(crate) fn next_up_on_time_out(core: CoreIndex) -> Option<ScheduledCore> { - let max_availability_timeouts = <configuration::Pallet<T>>::config().on_demand_retries; + let max_availability_timeouts = + <configuration::Pallet<T>>::config().coretime_max_availability_timeouts; Self::next_up_on_available(core).or_else(|| { // Or, if none, the claim currently occupying the core, // as it would be put back on the queue after timing out if number of retries is not at @@ -584,8 +585,8 @@ impl<T: Config> Pallet<T> { let n_session_cores = T::AssignmentProvider::session_core_count(); let cq = ClaimQueue::<T>::get(); let config = <configuration::Pallet<T>>::config(); - let max_availability_timeouts = config.on_demand_retries; - let ttl = config.on_demand_ttl; + let max_availability_timeouts = config.coretime_max_availability_timeouts; + let ttl = config.coretime_ttl; for core_idx in 0..n_session_cores { let core_idx = CoreIndex::from(core_idx); diff --git a/polkadot/runtime/parachains/src/scheduler/tests.rs b/polkadot/runtime/parachains/src/scheduler/tests.rs index abe57efcc3befe8b80af874779347e1d8a3009d4..d963d77a8ec03f9740510113fd2463b49eb9e49d 100644 --- a/polkadot/runtime/parachains/src/scheduler/tests.rs +++ b/polkadot/runtime/parachains/src/scheduler/tests.rs @@ -112,7 +112,7 @@ fn default_config() -> HostConfiguration<BlockNumber> { // `minimum_validation_upgrade_delay` is greater than `chain_availability_period` and // `thread_availability_period`. minimum_validation_upgrade_delay: 6, - on_demand_retries: 1, + coretime_max_availability_timeouts: 1, ..Default::default() } } @@ -164,8 +164,7 @@ fn claimqueue_ttl_drop_fn_works() { let mut now = 10; new_test_ext(genesis_config).execute_with(|| { - let assignment_provider_ttl = config.on_demand_ttl; - assert!(assignment_provider_ttl == 5); + assert!(config.coretime_ttl == 5); // Register and run to a blockheight where the para is in a valid state. schedule_blank_para(para_id); run_to_block(now, |n| if n == now { Some(Default::default()) } else { None }); @@ -344,7 +343,7 @@ fn fill_claimqueue_fills() { new_test_ext(genesis_config).execute_with(|| { MockAssigner::set_core_count(2); - let config_ttl = config.on_demand_ttl; + let coretime_ttl = config.coretime_ttl; // Add 3 paras schedule_blank_para(para_a); @@ -382,7 +381,7 @@ fn fill_claimqueue_fills() { &ParasEntry { assignment: assignment_a.clone(), availability_timeouts: 0, - ttl: 2 + config_ttl + ttl: 2 + coretime_ttl }, ); // Sits on the same core as `para_a` @@ -391,7 +390,7 @@ fn fill_claimqueue_fills() { ParasEntry { assignment: assignment_b.clone(), availability_timeouts: 0, - ttl: 2 + config_ttl + ttl: 2 + coretime_ttl } ); assert_eq!( @@ -399,7 +398,7 @@ fn fill_claimqueue_fills() { &ParasEntry { assignment: assignment_c.clone(), availability_timeouts: 0, - ttl: 2 + config_ttl + ttl: 2 + coretime_ttl }, ); } @@ -747,8 +746,8 @@ fn on_demand_claims_are_pruned_after_timing_out() { let mut config = default_config(); config.scheduling_lookahead = 1; // Need more timeouts for this test - config.on_demand_retries = max_retries; - config.on_demand_ttl = BlockNumber::from(5u32); + config.coretime_max_availability_timeouts = max_retries; + config.coretime_ttl = BlockNumber::from(5u32); let genesis_config = genesis_config(&config); let para_a = ParaId::from(1_u32); @@ -1055,7 +1054,7 @@ fn session_change_requires_reschedule_dropping_removed_paras() { new_test_ext(genesis_config).execute_with(|| { // Setting explicit core count MockAssigner::set_core_count(5); - let assignment_provider_ttl = <configuration::Pallet<Test>>::config().on_demand_ttl; + let coretime_ttl = <configuration::Pallet<Test>>::config().coretime_ttl; schedule_blank_para(para_a); schedule_blank_para(para_b); @@ -1119,7 +1118,7 @@ fn session_change_requires_reschedule_dropping_removed_paras() { vec![ParasEntry::new( Assignment::Bulk(para_a), // At end of block 2 - assignment_provider_ttl + 2 + coretime_ttl + 2 )] .into_iter() .collect() @@ -1168,7 +1167,7 @@ fn session_change_requires_reschedule_dropping_removed_paras() { vec![ParasEntry::new( Assignment::Bulk(para_a), // At block 3 - assignment_provider_ttl + 3 + coretime_ttl + 3 )] .into_iter() .collect() @@ -1178,7 +1177,7 @@ fn session_change_requires_reschedule_dropping_removed_paras() { vec![ParasEntry::new( Assignment::Bulk(para_b), // At block 3 - assignment_provider_ttl + 3 + coretime_ttl + 3 )] .into_iter() .collect()