mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 18:41:03 +00:00
Enable changing executor params through governance (#6934)
* Add a pallet call to change executor params * Use `OptionQuery`; Avoid runtime panic * Move pending executor params to `configuration` * Move `ExecutorParams` to `HostConfiguration` structure * Add executor params to the v5 migration * Add an `ExecutorParams` benchmark * ".git/.scripts/commands/bench/bench.sh" runtime polkadot runtime_parachains::configuration * Add to `WeightInfo` * Add dummy weights to other networks * ".git/.scripts/commands/bench/bench.sh" runtime kusama runtime_parachains::configuration * ".git/.scripts/commands/bench/bench.sh" runtime rococo runtime_parachains::configuration * ".git/.scripts/commands/bench/bench.sh" runtime westend runtime_parachains::configuration * Use real weight * Fix comment --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -24,8 +24,8 @@ use frame_system::pallet_prelude::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_parachain::primitives::{MAX_HORIZONTAL_MESSAGE_NUM, MAX_UPWARD_MESSAGE_NUM};
|
||||
use primitives::{
|
||||
vstaging::AsyncBackingParams, Balance, SessionIndex, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE,
|
||||
MAX_POV_SIZE,
|
||||
vstaging::AsyncBackingParams, Balance, ExecutorParams, SessionIndex, MAX_CODE_SIZE,
|
||||
MAX_HEAD_DATA_SIZE, MAX_POV_SIZE,
|
||||
};
|
||||
use sp_runtime::traits::Zero;
|
||||
use sp_std::prelude::*;
|
||||
@@ -157,6 +157,8 @@ pub struct HostConfiguration<BlockNumber> {
|
||||
///
|
||||
/// This parameter affects the upper bound of size of `CandidateCommitments`.
|
||||
pub hrmp_channel_max_message_size: u32,
|
||||
/// The executor environment parameters
|
||||
pub executor_params: ExecutorParams,
|
||||
|
||||
/**
|
||||
* Parameters that will unlikely be needed by parachains.
|
||||
@@ -296,6 +298,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
|
||||
pvf_checking_enabled: false,
|
||||
pvf_voting_ttl: 2u32.into(),
|
||||
minimum_validation_upgrade_delay: 2.into(),
|
||||
executor_params: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,6 +453,7 @@ pub trait WeightInfo {
|
||||
fn set_config_with_weight() -> Weight;
|
||||
fn set_config_with_balance() -> Weight;
|
||||
fn set_hrmp_open_request_ttl() -> Weight;
|
||||
fn set_config_with_executor_params() -> Weight;
|
||||
}
|
||||
|
||||
pub struct TestWeightInfo;
|
||||
@@ -472,6 +476,9 @@ impl WeightInfo for TestWeightInfo {
|
||||
fn set_hrmp_open_request_ttl() -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
fn set_config_with_executor_params() -> Weight {
|
||||
Weight::MAX
|
||||
}
|
||||
}
|
||||
|
||||
#[frame_support::pallet]
|
||||
@@ -1163,6 +1170,19 @@ pub mod pallet {
|
||||
config.async_backing_params = new;
|
||||
})
|
||||
}
|
||||
|
||||
/// Set PVF executor parameters.
|
||||
#[pallet::call_index(46)]
|
||||
#[pallet::weight((
|
||||
T::WeightInfo::set_config_with_executor_params(),
|
||||
DispatchClass::Operational,
|
||||
))]
|
||||
pub fn set_executor_params(origin: OriginFor<T>, new: ExecutorParams) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
Self::schedule_config_update(|config| {
|
||||
config.executor_params = new;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
use crate::configuration::*;
|
||||
use frame_benchmarking::{benchmarks, BenchmarkError, BenchmarkResult};
|
||||
use frame_system::RawOrigin;
|
||||
use primitives::{ExecutorParam, ExecutorParams, PvfExecTimeoutKind, PvfPrepTimeoutKind};
|
||||
use sp_runtime::traits::One;
|
||||
|
||||
benchmarks! {
|
||||
@@ -36,6 +37,18 @@ benchmarks! {
|
||||
|
||||
set_config_with_balance {}: set_hrmp_sender_deposit(RawOrigin::Root, 100_000_000_000)
|
||||
|
||||
set_config_with_executor_params {}: set_executor_params(RawOrigin::Root, ExecutorParams::from(&[
|
||||
ExecutorParam::MaxMemoryPages(2080),
|
||||
ExecutorParam::StackLogicalMax(65536),
|
||||
ExecutorParam::StackNativeMax(256 * 1024 * 1024),
|
||||
ExecutorParam::WasmExtBulkMemory,
|
||||
ExecutorParam::PrecheckingMaxMemory(2 * 1024 * 1024 * 1024),
|
||||
ExecutorParam::PvfPrepTimeout(PvfPrepTimeoutKind::Precheck, 60_000),
|
||||
ExecutorParam::PvfPrepTimeout(PvfPrepTimeoutKind::Lenient, 360_000),
|
||||
ExecutorParam::PvfExecTimeout(PvfExecTimeoutKind::Backing, 2_000),
|
||||
ExecutorParam::PvfExecTimeout(PvfExecTimeoutKind::Approval, 12_000),
|
||||
][..]))
|
||||
|
||||
impl_benchmark_test_suite!(
|
||||
Pallet,
|
||||
crate::mock::new_test_ext(Default::default()),
|
||||
|
||||
@@ -28,7 +28,9 @@ use sp_std::vec::Vec;
|
||||
/// v1-v2: <https://github.com/paritytech/polkadot/pull/4420>
|
||||
/// v2-v3: <https://github.com/paritytech/polkadot/pull/6091>
|
||||
/// v3-v4: <https://github.com/paritytech/polkadot/pull/6345>
|
||||
/// v4-v5: <https://github.com/paritytech/polkadot/pull/6937> + <https://github.com/paritytech/polkadot/pull/6961>
|
||||
/// v4-v5: <https://github.com/paritytech/polkadot/pull/6937>
|
||||
/// + <https://github.com/paritytech/polkadot/pull/6961>
|
||||
/// + <https://github.com/paritytech/polkadot/pull/6934>
|
||||
pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(5);
|
||||
|
||||
pub mod v5 {
|
||||
@@ -230,6 +232,9 @@ minimum_validation_upgrade_delay : pre.minimum_validation_upgrade_delay,
|
||||
|
||||
// Default values are zeroes, thus it's ensured allowed ancestry never crosses the upgrade block.
|
||||
async_backing_params : AsyncBackingParams { max_candidate_depth: 0, allowed_ancestry_len: 0 },
|
||||
|
||||
// Default executor parameters set is empty
|
||||
executor_params : Default::default(),
|
||||
}
|
||||
};
|
||||
|
||||
@@ -268,6 +273,7 @@ async_backing_params : AsyncBackingParams { max_candidate_de
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::mock::{new_test_ext, Test};
|
||||
use primitives::ExecutorParams;
|
||||
|
||||
#[test]
|
||||
fn v4_deserialized_from_actual_data() {
|
||||
@@ -391,6 +397,7 @@ mod tests {
|
||||
// additional checks for async backing.
|
||||
assert_eq!(v5.async_backing_params.allowed_ancestry_len, 0);
|
||||
assert_eq!(v5.async_backing_params.max_candidate_depth, 0);
|
||||
assert_eq!(v5.executor_params, ExecutorParams::new());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -326,6 +326,7 @@ fn setting_pending_config_members() {
|
||||
pvf_checking_enabled: true,
|
||||
pvf_voting_ttl: 3,
|
||||
minimum_validation_upgrade_delay: 20,
|
||||
executor_params: Default::default(),
|
||||
};
|
||||
|
||||
Configuration::set_validation_upgrade_cooldown(
|
||||
|
||||
@@ -27,9 +27,7 @@ use frame_support::{
|
||||
pallet_prelude::*,
|
||||
traits::{OneSessionHandler, ValidatorSet, ValidatorSetWithIdentification},
|
||||
};
|
||||
use primitives::{
|
||||
AssignmentId, AuthorityDiscoveryId, ExecutorParam, ExecutorParams, SessionIndex, SessionInfo,
|
||||
};
|
||||
use primitives::{AssignmentId, AuthorityDiscoveryId, ExecutorParams, SessionIndex, SessionInfo};
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
pub use pallet::*;
|
||||
@@ -39,10 +37,6 @@ pub mod migration;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
||||
// The order of parameters should be deterministic, that is, one should not reorder them when
|
||||
// changing the array contents to avoid creating excessive pressure to PVF execution subsys.
|
||||
const EXECUTOR_PARAMS: [ExecutorParam; 0] = [];
|
||||
|
||||
/// A type for representing the validator account id in a session.
|
||||
pub type AccountId<T> = <<T as Config>::ValidatorSet as ValidatorSet<
|
||||
<T as frame_system::Config>::AccountId,
|
||||
@@ -196,10 +190,8 @@ impl<T: Config> Pallet<T> {
|
||||
dispute_period,
|
||||
};
|
||||
Sessions::<T>::insert(&new_session_index, &new_session_info);
|
||||
SessionExecutorParams::<T>::insert(
|
||||
&new_session_index,
|
||||
ExecutorParams::from(&EXECUTOR_PARAMS[..]),
|
||||
);
|
||||
|
||||
SessionExecutorParams::<T>::insert(&new_session_index, config.executor_params);
|
||||
}
|
||||
|
||||
/// Called by the initializer to initialize the session info pallet.
|
||||
|
||||
Reference in New Issue
Block a user