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

Activate 10 Mb PoVs #553

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Kusama Treasury: remove funding to the Kappa Sigma Mu Society and disable burn ([polkadot-fellows/runtimes#507](https://github.com/polkadot-fellows/runtimes/pull/507))
- Kusama Treasury: allow burn parameters to be set via OpenGov ([polkadot-fellows/runtimes#511](https://github.com/polkadot-fellows/runtimes/pull/511))
- Remove Snowbridge create agent and channel extrinsics. ([polkadot-fellows/runtimes#506](https://github.com/polkadot-fellows/runtimes/pull/506))
- Activate 10 Mb PoVs on Kusama ([polkadot-fellows/runtimes#553](https://github.com/polkadot-fellows/runtimes/pull/553))
s0me0ne-unkn0wn marked this conversation as resolved.
Show resolved Hide resolved

#### From [#490](https://github.com/polkadot-fellows/runtimes/pull/490)

Expand Down
63 changes: 56 additions & 7 deletions relay/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@

extern crate alloc;

use core::marker::PhantomData;

use codec::{Decode, Encode, MaxEncodedLen};
use frame_support::{
dynamic_params::{dynamic_pallet_params, dynamic_params},
traits::{EnsureOrigin, EnsureOriginWithArg},
traits::{EnsureOrigin, EnsureOriginWithArg, OnRuntimeUpgrade},
weights::constants::{WEIGHT_PROOF_SIZE_PER_KB, WEIGHT_REF_TIME_PER_MICROS},
};
use kusama_runtime_constants::system_parachain::coretime::TIMESLICE_PERIOD;
Expand Down Expand Up @@ -57,12 +59,14 @@ use sp_std::{
};

use runtime_parachains::{
assigner_coretime as parachains_assigner_coretime, configuration as parachains_configuration,
configuration::ActiveConfigHrmpChannelSizeAndCapacityRatio,
coretime, disputes as parachains_disputes,
disputes::slashing as parachains_slashing,
dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
inclusion::{AggregateMessageOrigin, UmpQueueId},
assigner_coretime as parachains_assigner_coretime,
configuration::{
self as parachains_configuration, ActiveConfigHrmpChannelSizeAndCapacityRatio, WeightInfo,
},
coretime,
disputes::{self as parachains_disputes, slashing as parachains_slashing},
dmp as parachains_dmp, hrmp as parachains_hrmp,
inclusion::{self as parachains_inclusion, AggregateMessageOrigin, UmpQueueId},
initializer as parachains_initializer, on_demand as parachains_on_demand,
origin as parachains_origin, paras as parachains_paras,
paras_inherent as parachains_paras_inherent, reward_points as parachains_reward_points,
Expand Down Expand Up @@ -1902,6 +1906,50 @@ parameter_types! {
pub const MaxPoolsToMigrate: u32 = 500;
}

const NEW_MAX_POV: u32 = 10 * 1024 * 1024;

pub struct Activate10MbPovs<T>(PhantomData<T>);
impl<T> OnRuntimeUpgrade for Activate10MbPovs<T>
where
T: parachains_configuration::Config,
{
#[cfg(feature = "try-runtime")]
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
// The pre-upgrade state doesn't matter
Ok(vec![])
}

fn on_runtime_upgrade() -> Weight {
match parachains_configuration::Pallet::<T>::set_max_pov_size(
s0me0ne-unkn0wn marked this conversation as resolved.
Show resolved Hide resolved
frame_system::RawOrigin::Root.into(),
NEW_MAX_POV,
) {
Ok(()) =>
weights::runtime_parachains_configuration::WeightInfo::<T>::set_config_with_u32(),
Err(e) => {
log::warn!(
target: LOG_TARGET,
"Failed to set max PoV size. Error: {e:?}"
);
Weight::zero()
},
}
}

#[cfg(feature = "try-runtime")]
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
let pending = parachains_configuration::PendingConfigs::<T>::get();
let Some((_, last_pending)) = pending.last() else {
return Err(sp_runtime::TryRuntimeError::CannotLookup);
};
frame_support::ensure!(
last_pending.max_pov_size == NEW_MAX_POV,
"Setting max PoV size to 10 Mb should be pending"
);
Ok(())
}
}

/// All migrations that will run on the next runtime upgrade.
///
/// This contains the combined migrations of the last 10 releases. It allows to skip runtime
Expand All @@ -1925,6 +1973,7 @@ pub mod migrations {
Runtime,
MaxPoolsToMigrate,
>,
Activate10MbPovs<Runtime>,
);

/// Migrations/checks that do not need to be versioned and can run on every update.
Expand Down
Loading