Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
add runtime migration
Browse files Browse the repository at this point in the history
  • Loading branch information
alindima committed Aug 22, 2023
1 parent 5feadf4 commit eb864e0
Show file tree
Hide file tree
Showing 14 changed files with 583 additions and 123 deletions.
1 change: 1 addition & 0 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,7 @@ async fn construct_per_relay_parent_state<Context>(
try_runtime_api!(runtime_info.get_session_index_for_child(ctx.sender(), parent).await);
let minimum_backing_votes =
runtime_info.get_min_backing_votes(ctx.sender(), session_index, parent).await;
// TODO: if this does not exist, fall back to the hardcoded 2 value.

let (validators, groups, cores) = futures::try_join!(
request_validators(parent, ctx.sender()).await,
Expand Down
4 changes: 4 additions & 0 deletions node/core/runtime-api/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,10 @@ impl RuntimeApiSubsystemClient for MockSubsystemClient {
) -> Result<Option<vstaging::BackingState>, ApiError> {
todo!("Not required for tests")
}

async fn minimum_backing_votes(&self, _: Hash) -> Result<u32, ApiError> {
todo!("Not required for tests")
}
}

#[test]
Expand Down
1 change: 1 addition & 0 deletions primitives/src/runtime_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ sp_api::decl_runtime_apis! {
) -> Option<()>;

/// Get the minimum number of backing votes for a parachain candidate.
/// TODO: bump api version here?
fn minimum_backing_votes() -> u32;

/***** Asynchronous backing *****/
Expand Down
1 change: 1 addition & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,7 @@ pub mod migrations {
frame_support::migrations::RemovePallet<TechnicalMembershipPalletName, <Runtime as frame_system::Config>::DbWeight>,
frame_support::migrations::RemovePallet<TipsPalletName, <Runtime as frame_system::Config>::DbWeight>,

parachains_configuration::migration::v9::MigrateToV9<Runtime>,
);
}

Expand Down
17 changes: 15 additions & 2 deletions runtime/parachains/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
on_demand_fee_variability: Perbill::from_percent(3),
on_demand_target_queue_utilization: Perbill::from_percent(25),
on_demand_ttl: 5u32.into(),
minimum_backing_votes: Default::default(),
minimum_backing_votes: 2,
}
}
}
Expand Down Expand Up @@ -478,7 +478,8 @@ pub mod pallet {
/// v5-v6: <https://github.com/paritytech/polkadot/pull/6271> (remove UMP dispatch queue)
/// v6-v7: <https://github.com/paritytech/polkadot/pull/7396>
/// v7-v8: <https://github.com/paritytech/polkadot/pull/6969>
const STORAGE_VERSION: StorageVersion = StorageVersion::new(8);
/// v8-v9: <https://github.com/paritytech/polkadot/pull/7577>
const STORAGE_VERSION: StorageVersion = StorageVersion::new(9);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
Expand Down Expand Up @@ -1154,6 +1155,18 @@ pub mod pallet {
config.on_demand_ttl = new;
})
}
/// Set the minimum backing votes threshold.
#[pallet::call_index(52)]
#[pallet::weight((
T::WeightInfo::set_config_with_u32(),
DispatchClass::Operational
))]
pub fn set_minimum_backing_votes(origin: OriginFor<T>, new: u32) -> DispatchResult {
ensure_root(origin)?;
Self::schedule_config_update(|config| {
config.minimum_backing_votes = new;
})
}
}

#[pallet::hooks]
Expand Down
1 change: 1 addition & 0 deletions runtime/parachains/src/configuration/migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
pub mod v6;
pub mod v7;
pub mod v8;
pub mod v9;
105 changes: 102 additions & 3 deletions runtime/parachains/src/configuration/migration/v8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,114 @@ use frame_support::{
weights::Weight,
};
use frame_system::pallet_prelude::BlockNumberFor;
use primitives::SessionIndex;
use primitives::{
vstaging::AsyncBackingParams, Balance, ExecutorParams, SessionIndex,
ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
};
use sp_runtime::Perbill;
use sp_std::vec::Vec;

use frame_support::traits::OnRuntimeUpgrade;

use super::v7::V7HostConfiguration;
type V8HostConfiguration<BlockNumber> = configuration::HostConfiguration<BlockNumber>;
/// All configuration of the runtime with respect to paras.
#[derive(Clone, Encode, Decode, Debug)]
pub struct V8HostConfiguration<BlockNumber> {
pub max_code_size: u32,
pub max_head_data_size: u32,
pub max_upward_queue_count: u32,
pub max_upward_queue_size: u32,
pub max_upward_message_size: u32,
pub max_upward_message_num_per_candidate: u32,
pub hrmp_max_message_num_per_candidate: u32,
pub validation_upgrade_cooldown: BlockNumber,
pub validation_upgrade_delay: BlockNumber,
pub async_backing_params: AsyncBackingParams,
pub max_pov_size: u32,
pub max_downward_message_size: u32,
pub hrmp_max_parachain_outbound_channels: u32,
pub hrmp_sender_deposit: Balance,
pub hrmp_recipient_deposit: Balance,
pub hrmp_channel_max_capacity: u32,
pub hrmp_channel_max_total_size: u32,
pub hrmp_max_parachain_inbound_channels: u32,
pub hrmp_channel_max_message_size: u32,
pub executor_params: ExecutorParams,
pub code_retention_period: BlockNumber,
pub on_demand_cores: u32,
pub on_demand_retries: u32,
pub on_demand_queue_max_size: u32,
pub on_demand_target_queue_utilization: Perbill,
pub on_demand_fee_variability: Perbill,
pub on_demand_base_fee: Balance,
pub on_demand_ttl: BlockNumber,
pub group_rotation_frequency: BlockNumber,
pub paras_availability_period: BlockNumber,
pub scheduling_lookahead: u32,
pub max_validators_per_core: Option<u32>,
pub max_validators: Option<u32>,
pub dispute_period: SessionIndex,
pub dispute_post_conclusion_acceptance_period: BlockNumber,
pub no_show_slots: u32,
pub n_delay_tranches: u32,
pub zeroth_delay_tranche_width: u32,
pub needed_approvals: u32,
pub relay_vrf_modulo_samples: u32,
pub pvf_voting_ttl: SessionIndex,
pub minimum_validation_upgrade_delay: BlockNumber,
}

impl<BlockNumber: Default + From<u32>> Default for V8HostConfiguration<BlockNumber> {
fn default() -> Self {
Self {
async_backing_params: AsyncBackingParams {
max_candidate_depth: 0,
allowed_ancestry_len: 0,
},
group_rotation_frequency: 1u32.into(),
paras_availability_period: 1u32.into(),
no_show_slots: 1u32.into(),
validation_upgrade_cooldown: Default::default(),
validation_upgrade_delay: 2u32.into(),
code_retention_period: Default::default(),
max_code_size: Default::default(),
max_pov_size: Default::default(),
max_head_data_size: Default::default(),
on_demand_cores: Default::default(),
on_demand_retries: Default::default(),
scheduling_lookahead: 1,
max_validators_per_core: Default::default(),
max_validators: None,
dispute_period: 6,
dispute_post_conclusion_acceptance_period: 100.into(),
n_delay_tranches: Default::default(),
zeroth_delay_tranche_width: Default::default(),
needed_approvals: Default::default(),
relay_vrf_modulo_samples: Default::default(),
max_upward_queue_count: Default::default(),
max_upward_queue_size: Default::default(),
max_downward_message_size: Default::default(),
max_upward_message_size: Default::default(),
max_upward_message_num_per_candidate: Default::default(),
hrmp_sender_deposit: Default::default(),
hrmp_recipient_deposit: Default::default(),
hrmp_channel_max_capacity: Default::default(),
hrmp_channel_max_total_size: Default::default(),
hrmp_max_parachain_inbound_channels: Default::default(),
hrmp_channel_max_message_size: Default::default(),
hrmp_max_parachain_outbound_channels: Default::default(),
hrmp_max_message_num_per_candidate: Default::default(),
pvf_voting_ttl: 2u32.into(),
minimum_validation_upgrade_delay: 2.into(),
executor_params: Default::default(),
on_demand_queue_max_size: ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
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(),
}
}
}

mod v7 {
use super::*;
Expand Down Expand Up @@ -150,7 +250,6 @@ 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(),
minimum_backing_votes : 2
}
};

Expand Down
Loading

0 comments on commit eb864e0

Please sign in to comment.