mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 20:21:03 +00:00
Approve multiple candidates with a single signature (#1191)
Initial implementation for the plan discussed here: https://github.com/paritytech/polkadot-sdk/issues/701 Built on top of https://github.com/paritytech/polkadot-sdk/pull/1178 v0: https://github.com/paritytech/polkadot/pull/7554, ## Overall idea When approval-voting checks a candidate and is ready to advertise the approval, defer it in a per-relay chain block until we either have MAX_APPROVAL_COALESCE_COUNT candidates to sign or a candidate has stayed MAX_APPROVALS_COALESCE_TICKS in the queue, in both cases we sign what candidates we have available. This should allow us to reduce the number of approvals messages we have to create/send/verify. The parameters are configurable, so we should find some values that balance: - Security of the network: Delaying broadcasting of an approval shouldn't but the finality at risk and to make sure that never happens we won't delay sending a vote if we are past 2/3 from the no-show time. - Scalability of the network: MAX_APPROVAL_COALESCE_COUNT = 1 & MAX_APPROVALS_COALESCE_TICKS =0, is what we have now and we know from the measurements we did on versi, it bottlenecks approval-distribution/approval-voting when increase significantly the number of validators and parachains - Block storage: In case of disputes we have to import this votes on chain and that increase the necessary storage with MAX_APPROVAL_COALESCE_COUNT * CandidateHash per vote. Given that disputes are not the normal way of the network functioning and we will limit MAX_APPROVAL_COALESCE_COUNT in the single digits numbers, this should be good enough. Alternatively, we could try to create a better way to store this on-chain through indirection, if that's needed. ## Other fixes: - Fixed the fact that we were sending random assignments to non-validators, that was wrong because those won't do anything with it and they won't gossip it either because they do not have a grid topology set, so we would waste the random assignments. - Added metrics to be able to debug potential no-shows and mis-processing of approvals/assignments. ## TODO: - [x] Get feedback, that this is moving in the right direction. @ordian @sandreim @eskimor @burdges, let me know what you think. - [x] More and more testing. - [x] Test in versi. - [x] Make MAX_APPROVAL_COALESCE_COUNT & MAX_APPROVAL_COALESCE_WAIT_MILLIS a parachain host configuration. - [x] Make sure the backwards compatibility works correctly - [x] Make sure this direction is compatible with other streams of work: https://github.com/paritytech/polkadot-sdk/issues/635 & https://github.com/paritytech/polkadot-sdk/issues/742 - [x] Final versi burn-in before merging --------- Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
This commit is contained in:
committed by
GitHub
parent
d18a682bf7
commit
a84dd0dba5
@@ -636,7 +636,7 @@ impl<T: paras_inherent::Config> BenchBuilder<T> {
|
||||
} else {
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::Explicit)
|
||||
};
|
||||
let data = dispute_statement.payload_data(candidate_hash, session);
|
||||
let data = dispute_statement.payload_data(candidate_hash, session).unwrap();
|
||||
let statement_sig = validator_public.sign(&data).unwrap();
|
||||
|
||||
(dispute_statement, ValidatorIndex(validator_index), statement_sig)
|
||||
|
||||
@@ -26,8 +26,9 @@ use polkadot_parachain_primitives::primitives::{
|
||||
MAX_HORIZONTAL_MESSAGE_NUM, MAX_UPWARD_MESSAGE_NUM,
|
||||
};
|
||||
use primitives::{
|
||||
vstaging::NodeFeatures, AsyncBackingParams, Balance, ExecutorParamError, ExecutorParams,
|
||||
SessionIndex, LEGACY_MIN_BACKING_VOTES, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE,
|
||||
vstaging::{ApprovalVotingParams, NodeFeatures},
|
||||
AsyncBackingParams, Balance, ExecutorParamError, ExecutorParams, SessionIndex,
|
||||
LEGACY_MIN_BACKING_VOTES, MAX_CODE_SIZE, MAX_HEAD_DATA_SIZE, MAX_POV_SIZE,
|
||||
ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
|
||||
};
|
||||
use sp_runtime::{traits::Zero, Perbill};
|
||||
@@ -263,6 +264,8 @@ pub struct HostConfiguration<BlockNumber> {
|
||||
pub minimum_backing_votes: u32,
|
||||
/// Node features enablement.
|
||||
pub node_features: NodeFeatures,
|
||||
/// Params used by approval-voting
|
||||
pub approval_voting_params: ApprovalVotingParams,
|
||||
}
|
||||
|
||||
impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber> {
|
||||
@@ -308,6 +311,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
|
||||
pvf_voting_ttl: 2u32.into(),
|
||||
minimum_validation_upgrade_delay: 2.into(),
|
||||
executor_params: Default::default(),
|
||||
approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 },
|
||||
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),
|
||||
@@ -515,7 +519,8 @@ pub mod pallet {
|
||||
/// v7-v8: <https://github.com/paritytech/polkadot/pull/6969>
|
||||
/// v8-v9: <https://github.com/paritytech/polkadot/pull/7577>
|
||||
/// v9-v10: <https://github.com/paritytech/polkadot-sdk/pull/2177>
|
||||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(10);
|
||||
/// v10-11: <https://github.com/paritytech/polkadot-sdk/pull/1191>
|
||||
const STORAGE_VERSION: StorageVersion = StorageVersion::new(11);
|
||||
|
||||
#[pallet::pallet]
|
||||
#[pallet::storage_version(STORAGE_VERSION)]
|
||||
@@ -1191,6 +1196,7 @@ pub mod pallet {
|
||||
config.on_demand_ttl = new;
|
||||
})
|
||||
}
|
||||
|
||||
/// Set the minimum backing votes threshold.
|
||||
#[pallet::call_index(52)]
|
||||
#[pallet::weight((
|
||||
@@ -1203,6 +1209,7 @@ pub mod pallet {
|
||||
config.minimum_backing_votes = new;
|
||||
})
|
||||
}
|
||||
|
||||
/// Set/Unset a node feature.
|
||||
#[pallet::call_index(53)]
|
||||
#[pallet::weight((
|
||||
@@ -1220,6 +1227,22 @@ pub mod pallet {
|
||||
config.node_features.set(index, value);
|
||||
})
|
||||
}
|
||||
|
||||
/// Set approval-voting-params.
|
||||
#[pallet::call_index(54)]
|
||||
#[pallet::weight((
|
||||
T::WeightInfo::set_config_with_executor_params(),
|
||||
DispatchClass::Operational,
|
||||
))]
|
||||
pub fn set_approval_voting_params(
|
||||
origin: OriginFor<T>,
|
||||
new: ApprovalVotingParams,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
Self::schedule_config_update(|config| {
|
||||
config.approval_voting_params = new;
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[pallet::hooks]
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
//! A module that is responsible for migration of storage.
|
||||
|
||||
pub mod v10;
|
||||
pub mod v11;
|
||||
pub mod v6;
|
||||
pub mod v7;
|
||||
pub mod v8;
|
||||
|
||||
@@ -16,17 +16,121 @@
|
||||
|
||||
//! A module that is responsible for migration of storage.
|
||||
|
||||
use crate::configuration::{self, Config, Pallet};
|
||||
use crate::configuration::{Config, Pallet};
|
||||
use frame_support::{pallet_prelude::*, traits::Defensive, weights::Weight};
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use primitives::{vstaging::NodeFeatures, SessionIndex};
|
||||
use primitives::{
|
||||
vstaging::NodeFeatures, AsyncBackingParams, Balance, ExecutorParams, SessionIndex,
|
||||
LEGACY_MIN_BACKING_VOTES, ON_DEMAND_DEFAULT_QUEUE_MAX_SIZE,
|
||||
};
|
||||
use sp_runtime::Perbill;
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
use frame_support::traits::OnRuntimeUpgrade;
|
||||
|
||||
use super::v9::V9HostConfiguration;
|
||||
// All configuration of the runtime with respect to paras.
|
||||
#[derive(Clone, Encode, PartialEq, Decode, Debug)]
|
||||
pub struct V10HostConfiguration<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,
|
||||
pub minimum_backing_votes: u32,
|
||||
pub node_features: NodeFeatures,
|
||||
}
|
||||
|
||||
type V10HostConfiguration<BlockNumber> = configuration::HostConfiguration<BlockNumber>;
|
||||
impl<BlockNumber: Default + From<u32>> Default for V10HostConfiguration<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(),
|
||||
minimum_backing_votes: LEGACY_MIN_BACKING_VOTES,
|
||||
node_features: NodeFeatures::EMPTY,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod v9 {
|
||||
use super::*;
|
||||
|
||||
@@ -0,0 +1,329 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Polkadot.
|
||||
|
||||
// Polkadot is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Polkadot is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
//! A module that is responsible for migration of storage.
|
||||
|
||||
use crate::configuration::{self, Config, Pallet};
|
||||
use frame_support::{
|
||||
migrations::VersionedMigration, pallet_prelude::*, traits::Defensive, weights::Weight,
|
||||
};
|
||||
use frame_system::pallet_prelude::BlockNumberFor;
|
||||
use primitives::{vstaging::ApprovalVotingParams, SessionIndex};
|
||||
use sp_std::vec::Vec;
|
||||
|
||||
use frame_support::traits::OnRuntimeUpgrade;
|
||||
|
||||
use super::v10::V10HostConfiguration;
|
||||
type V11HostConfiguration<BlockNumber> = configuration::HostConfiguration<BlockNumber>;
|
||||
|
||||
mod v10 {
|
||||
use super::*;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type ActiveConfig<T: Config> =
|
||||
StorageValue<Pallet<T>, V10HostConfiguration<BlockNumberFor<T>>, OptionQuery>;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type PendingConfigs<T: Config> = StorageValue<
|
||||
Pallet<T>,
|
||||
Vec<(SessionIndex, V10HostConfiguration<BlockNumberFor<T>>)>,
|
||||
OptionQuery,
|
||||
>;
|
||||
}
|
||||
|
||||
mod v11 {
|
||||
use super::*;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type ActiveConfig<T: Config> =
|
||||
StorageValue<Pallet<T>, V11HostConfiguration<BlockNumberFor<T>>, OptionQuery>;
|
||||
|
||||
#[frame_support::storage_alias]
|
||||
pub(crate) type PendingConfigs<T: Config> = StorageValue<
|
||||
Pallet<T>,
|
||||
Vec<(SessionIndex, V11HostConfiguration<BlockNumberFor<T>>)>,
|
||||
OptionQuery,
|
||||
>;
|
||||
}
|
||||
|
||||
pub type MigrateToV11<T> = VersionedMigration<
|
||||
10,
|
||||
11,
|
||||
UncheckedMigrateToV11<T>,
|
||||
Pallet<T>,
|
||||
<T as frame_system::Config>::DbWeight,
|
||||
>;
|
||||
|
||||
pub struct UncheckedMigrateToV11<T>(sp_std::marker::PhantomData<T>);
|
||||
impl<T: Config> OnRuntimeUpgrade for UncheckedMigrateToV11<T> {
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn pre_upgrade() -> Result<Vec<u8>, sp_runtime::TryRuntimeError> {
|
||||
log::trace!(target: crate::configuration::LOG_TARGET, "Running pre_upgrade() for HostConfiguration MigrateToV11");
|
||||
Ok(Vec::new())
|
||||
}
|
||||
|
||||
fn on_runtime_upgrade() -> Weight {
|
||||
log::info!(target: configuration::LOG_TARGET, "HostConfiguration MigrateToV11 started");
|
||||
let weight_consumed = migrate_to_v11::<T>();
|
||||
|
||||
log::info!(target: configuration::LOG_TARGET, "HostConfiguration MigrateToV11 executed successfully");
|
||||
|
||||
weight_consumed
|
||||
}
|
||||
|
||||
#[cfg(feature = "try-runtime")]
|
||||
fn post_upgrade(_state: Vec<u8>) -> Result<(), sp_runtime::TryRuntimeError> {
|
||||
log::trace!(target: crate::configuration::LOG_TARGET, "Running post_upgrade() for HostConfiguration MigrateToV11");
|
||||
ensure!(
|
||||
StorageVersion::get::<Pallet<T>>() >= 11,
|
||||
"Storage version should be >= 11 after the migration"
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn migrate_to_v11<T: Config>() -> Weight {
|
||||
// Unusual formatting is justified:
|
||||
// - make it easier to verify that fields assign what they supposed to assign.
|
||||
// - this code is transient and will be removed after all migrations are done.
|
||||
// - this code is important enough to optimize for legibility sacrificing consistency.
|
||||
#[rustfmt::skip]
|
||||
let translate =
|
||||
|pre: V10HostConfiguration<BlockNumberFor<T>>| ->
|
||||
V11HostConfiguration<BlockNumberFor<T>>
|
||||
{
|
||||
V11HostConfiguration {
|
||||
max_code_size : pre.max_code_size,
|
||||
max_head_data_size : pre.max_head_data_size,
|
||||
max_upward_queue_count : pre.max_upward_queue_count,
|
||||
max_upward_queue_size : pre.max_upward_queue_size,
|
||||
max_upward_message_size : pre.max_upward_message_size,
|
||||
max_upward_message_num_per_candidate : pre.max_upward_message_num_per_candidate,
|
||||
hrmp_max_message_num_per_candidate : pre.hrmp_max_message_num_per_candidate,
|
||||
validation_upgrade_cooldown : pre.validation_upgrade_cooldown,
|
||||
validation_upgrade_delay : pre.validation_upgrade_delay,
|
||||
max_pov_size : pre.max_pov_size,
|
||||
max_downward_message_size : pre.max_downward_message_size,
|
||||
hrmp_sender_deposit : pre.hrmp_sender_deposit,
|
||||
hrmp_recipient_deposit : pre.hrmp_recipient_deposit,
|
||||
hrmp_channel_max_capacity : pre.hrmp_channel_max_capacity,
|
||||
hrmp_channel_max_total_size : pre.hrmp_channel_max_total_size,
|
||||
hrmp_max_parachain_inbound_channels : pre.hrmp_max_parachain_inbound_channels,
|
||||
hrmp_max_parachain_outbound_channels : pre.hrmp_max_parachain_outbound_channels,
|
||||
hrmp_channel_max_message_size : pre.hrmp_channel_max_message_size,
|
||||
code_retention_period : pre.code_retention_period,
|
||||
on_demand_cores : pre.on_demand_cores,
|
||||
on_demand_retries : pre.on_demand_retries,
|
||||
group_rotation_frequency : pre.group_rotation_frequency,
|
||||
paras_availability_period : pre.paras_availability_period,
|
||||
scheduling_lookahead : pre.scheduling_lookahead,
|
||||
max_validators_per_core : pre.max_validators_per_core,
|
||||
max_validators : pre.max_validators,
|
||||
dispute_period : pre.dispute_period,
|
||||
dispute_post_conclusion_acceptance_period: pre.dispute_post_conclusion_acceptance_period,
|
||||
no_show_slots : pre.no_show_slots,
|
||||
n_delay_tranches : pre.n_delay_tranches,
|
||||
zeroth_delay_tranche_width : pre.zeroth_delay_tranche_width,
|
||||
needed_approvals : pre.needed_approvals,
|
||||
relay_vrf_modulo_samples : pre.relay_vrf_modulo_samples,
|
||||
pvf_voting_ttl : pre.pvf_voting_ttl,
|
||||
minimum_validation_upgrade_delay : pre.minimum_validation_upgrade_delay,
|
||||
async_backing_params : pre.async_backing_params,
|
||||
executor_params : pre.executor_params,
|
||||
on_demand_queue_max_size : pre.on_demand_queue_max_size,
|
||||
on_demand_base_fee : pre.on_demand_base_fee,
|
||||
on_demand_fee_variability : pre.on_demand_fee_variability,
|
||||
on_demand_target_queue_utilization : pre.on_demand_target_queue_utilization,
|
||||
on_demand_ttl : pre.on_demand_ttl,
|
||||
minimum_backing_votes : pre.minimum_backing_votes,
|
||||
node_features : pre.node_features,
|
||||
approval_voting_params : ApprovalVotingParams {
|
||||
max_approval_coalesce_count: 1,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let v10 = v10::ActiveConfig::<T>::get()
|
||||
.defensive_proof("Could not decode old config")
|
||||
.unwrap_or_default();
|
||||
let v11 = translate(v10);
|
||||
v11::ActiveConfig::<T>::set(Some(v11));
|
||||
|
||||
// Allowed to be empty.
|
||||
let pending_v9 = v10::PendingConfigs::<T>::get().unwrap_or_default();
|
||||
let mut pending_v10 = Vec::new();
|
||||
|
||||
for (session, v10) in pending_v9.into_iter() {
|
||||
let v11 = translate(v10);
|
||||
pending_v10.push((session, v11));
|
||||
}
|
||||
v11::PendingConfigs::<T>::set(Some(pending_v10.clone()));
|
||||
|
||||
let num_configs = (pending_v10.len() + 1) as u64;
|
||||
T::DbWeight::get().reads_writes(num_configs, num_configs)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use primitives::LEGACY_MIN_BACKING_VOTES;
|
||||
|
||||
use super::*;
|
||||
use crate::mock::{new_test_ext, Test};
|
||||
|
||||
#[test]
|
||||
fn v11_deserialized_from_actual_data() {
|
||||
// Example how to get new `raw_config`:
|
||||
// We'll obtain the raw_config at a specified a block
|
||||
// Steps:
|
||||
// 1. Go to Polkadot.js -> Developer -> Chain state -> Storage: https://polkadot.js.org/apps/#/chainstate
|
||||
// 2. Set these parameters:
|
||||
// 2.1. selected state query: configuration; activeConfig():
|
||||
// PolkadotRuntimeParachainsConfigurationHostConfiguration
|
||||
// 2.2. blockhash to query at:
|
||||
// 0xf89d3ab5312c5f70d396dc59612f0aa65806c798346f9db4b35278baed2e0e53 (the hash of
|
||||
// the block)
|
||||
// 2.3. Note the value of encoded storage key ->
|
||||
// 0x06de3d8a54d27e44a9d5ce189618f22db4b49d95320d9021994c850f25b8e385 for the
|
||||
// referenced block.
|
||||
// 2.4. You'll also need the decoded values to update the test.
|
||||
// 3. Go to Polkadot.js -> Developer -> Chain state -> Raw storage
|
||||
// 3.1 Enter the encoded storage key and you get the raw config.
|
||||
|
||||
// This exceeds the maximal line width length, but that's fine, since this is not code and
|
||||
// doesn't need to be read and also leaving it as one line allows to easily copy it.
|
||||
let raw_config =
|
||||
hex_literal::hex!["
|
||||
0000300000800000080000000000100000c8000005000000050000000200000002000000000000000000000000005000000010000400000000000000000000000000000000000000000000000000000000000000000000000800000000200000040000000000100000b004000000000000000000001027000080b2e60e80c3c9018096980000000000000000000000000005000000140000000400000001000000010100000000060000006400000002000000190000000000000002000000020000000200000005000000020000000001000000"
|
||||
];
|
||||
|
||||
let v11 =
|
||||
V11HostConfiguration::<primitives::BlockNumber>::decode(&mut &raw_config[..]).unwrap();
|
||||
|
||||
// We check only a sample of the values here. If we missed any fields or messed up data
|
||||
// types that would skew all the fields coming after.
|
||||
assert_eq!(v11.max_code_size, 3_145_728);
|
||||
assert_eq!(v11.validation_upgrade_cooldown, 2);
|
||||
assert_eq!(v11.max_pov_size, 5_242_880);
|
||||
assert_eq!(v11.hrmp_channel_max_message_size, 1_048_576);
|
||||
assert_eq!(v11.n_delay_tranches, 25);
|
||||
assert_eq!(v11.minimum_validation_upgrade_delay, 5);
|
||||
assert_eq!(v11.group_rotation_frequency, 20);
|
||||
assert_eq!(v11.on_demand_cores, 0);
|
||||
assert_eq!(v11.on_demand_base_fee, 10_000_000);
|
||||
assert_eq!(v11.minimum_backing_votes, LEGACY_MIN_BACKING_VOTES);
|
||||
assert_eq!(v11.approval_voting_params.max_approval_coalesce_count, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_migrate_to_v11() {
|
||||
// Host configuration has lots of fields. However, in this migration we only add one
|
||||
// field. The most important part to check are a couple of the last fields. We also pick
|
||||
// extra fields to check arbitrarily, e.g. depending on their position (i.e. the middle) and
|
||||
// also their type.
|
||||
//
|
||||
// We specify only the picked fields and the rest should be provided by the `Default`
|
||||
// implementation. That implementation is copied over between the two types and should work
|
||||
// fine.
|
||||
let v10 = V10HostConfiguration::<primitives::BlockNumber> {
|
||||
needed_approvals: 69,
|
||||
paras_availability_period: 55,
|
||||
hrmp_recipient_deposit: 1337,
|
||||
max_pov_size: 1111,
|
||||
minimum_validation_upgrade_delay: 20,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mut pending_configs = Vec::new();
|
||||
pending_configs.push((100, v10.clone()));
|
||||
pending_configs.push((300, v10.clone()));
|
||||
|
||||
new_test_ext(Default::default()).execute_with(|| {
|
||||
// Implant the v10 version in the state.
|
||||
v10::ActiveConfig::<Test>::set(Some(v10));
|
||||
v10::PendingConfigs::<Test>::set(Some(pending_configs));
|
||||
|
||||
migrate_to_v11::<Test>();
|
||||
|
||||
let v11 = v11::ActiveConfig::<Test>::get().unwrap();
|
||||
assert_eq!(v11.approval_voting_params.max_approval_coalesce_count, 1);
|
||||
|
||||
let mut configs_to_check = v11::PendingConfigs::<Test>::get().unwrap();
|
||||
configs_to_check.push((0, v11.clone()));
|
||||
|
||||
for (_, v10) in configs_to_check {
|
||||
#[rustfmt::skip]
|
||||
{
|
||||
assert_eq!(v10.max_code_size , v11.max_code_size);
|
||||
assert_eq!(v10.max_head_data_size , v11.max_head_data_size);
|
||||
assert_eq!(v10.max_upward_queue_count , v11.max_upward_queue_count);
|
||||
assert_eq!(v10.max_upward_queue_size , v11.max_upward_queue_size);
|
||||
assert_eq!(v10.max_upward_message_size , v11.max_upward_message_size);
|
||||
assert_eq!(v10.max_upward_message_num_per_candidate , v11.max_upward_message_num_per_candidate);
|
||||
assert_eq!(v10.hrmp_max_message_num_per_candidate , v11.hrmp_max_message_num_per_candidate);
|
||||
assert_eq!(v10.validation_upgrade_cooldown , v11.validation_upgrade_cooldown);
|
||||
assert_eq!(v10.validation_upgrade_delay , v11.validation_upgrade_delay);
|
||||
assert_eq!(v10.max_pov_size , v11.max_pov_size);
|
||||
assert_eq!(v10.max_downward_message_size , v11.max_downward_message_size);
|
||||
assert_eq!(v10.hrmp_max_parachain_outbound_channels , v11.hrmp_max_parachain_outbound_channels);
|
||||
assert_eq!(v10.hrmp_sender_deposit , v11.hrmp_sender_deposit);
|
||||
assert_eq!(v10.hrmp_recipient_deposit , v11.hrmp_recipient_deposit);
|
||||
assert_eq!(v10.hrmp_channel_max_capacity , v11.hrmp_channel_max_capacity);
|
||||
assert_eq!(v10.hrmp_channel_max_total_size , v11.hrmp_channel_max_total_size);
|
||||
assert_eq!(v10.hrmp_max_parachain_inbound_channels , v11.hrmp_max_parachain_inbound_channels);
|
||||
assert_eq!(v10.hrmp_channel_max_message_size , v11.hrmp_channel_max_message_size);
|
||||
assert_eq!(v10.code_retention_period , v11.code_retention_period);
|
||||
assert_eq!(v10.on_demand_cores , v11.on_demand_cores);
|
||||
assert_eq!(v10.on_demand_retries , v11.on_demand_retries);
|
||||
assert_eq!(v10.group_rotation_frequency , v11.group_rotation_frequency);
|
||||
assert_eq!(v10.paras_availability_period , v11.paras_availability_period);
|
||||
assert_eq!(v10.scheduling_lookahead , v11.scheduling_lookahead);
|
||||
assert_eq!(v10.max_validators_per_core , v11.max_validators_per_core);
|
||||
assert_eq!(v10.max_validators , v11.max_validators);
|
||||
assert_eq!(v10.dispute_period , v11.dispute_period);
|
||||
assert_eq!(v10.no_show_slots , v11.no_show_slots);
|
||||
assert_eq!(v10.n_delay_tranches , v11.n_delay_tranches);
|
||||
assert_eq!(v10.zeroth_delay_tranche_width , v11.zeroth_delay_tranche_width);
|
||||
assert_eq!(v10.needed_approvals , v11.needed_approvals);
|
||||
assert_eq!(v10.relay_vrf_modulo_samples , v11.relay_vrf_modulo_samples);
|
||||
assert_eq!(v10.pvf_voting_ttl , v11.pvf_voting_ttl);
|
||||
assert_eq!(v10.minimum_validation_upgrade_delay , v11.minimum_validation_upgrade_delay);
|
||||
assert_eq!(v10.async_backing_params.allowed_ancestry_len, v11.async_backing_params.allowed_ancestry_len);
|
||||
assert_eq!(v10.async_backing_params.max_candidate_depth , v11.async_backing_params.max_candidate_depth);
|
||||
assert_eq!(v10.executor_params , v11.executor_params);
|
||||
assert_eq!(v10.minimum_backing_votes , v11.minimum_backing_votes);
|
||||
}; // ; makes this a statement. `rustfmt::skip` cannot be put on an expression.
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Test that migration doesn't panic in case there're no pending configurations upgrades in
|
||||
// pallet's storage.
|
||||
#[test]
|
||||
fn test_migrate_to_v11_no_pending() {
|
||||
let v10 = V10HostConfiguration::<primitives::BlockNumber>::default();
|
||||
|
||||
new_test_ext(Default::default()).execute_with(|| {
|
||||
// Implant the v10 version in the state.
|
||||
v10::ActiveConfig::<Test>::set(Some(v10));
|
||||
// Ensure there're no pending configs.
|
||||
v11::PendingConfigs::<Test>::set(None);
|
||||
|
||||
// Shouldn't fail.
|
||||
migrate_to_v11::<Test>();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -250,7 +250,7 @@ on_demand_fee_variability : Perbill::from_percent(3),
|
||||
on_demand_target_queue_utilization : Perbill::from_percent(25),
|
||||
on_demand_ttl : 5u32.into(),
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
let v7 = v7::ActiveConfig::<T>::get()
|
||||
.defensive_proof("Could not decode old config")
|
||||
|
||||
@@ -313,6 +313,7 @@ fn setting_pending_config_members() {
|
||||
pvf_voting_ttl: 3,
|
||||
minimum_validation_upgrade_delay: 20,
|
||||
executor_params: Default::default(),
|
||||
approval_voting_params: ApprovalVotingParams { max_approval_coalesce_count: 1 },
|
||||
on_demand_queue_max_size: 10_000u32,
|
||||
on_demand_base_fee: 10_000_000u128,
|
||||
on_demand_fee_variability: Perbill::from_percent(3),
|
||||
|
||||
@@ -25,11 +25,11 @@ use frame_system::pallet_prelude::*;
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
use polkadot_runtime_metrics::get_current_time;
|
||||
use primitives::{
|
||||
byzantine_threshold, supermajority_threshold, ApprovalVote, CandidateHash,
|
||||
CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet, CompactStatement, ConsensusLog,
|
||||
DisputeState, DisputeStatement, DisputeStatementSet, ExplicitDisputeStatement,
|
||||
InvalidDisputeStatementKind, MultiDisputeStatementSet, SessionIndex, SigningContext,
|
||||
ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorSignature,
|
||||
byzantine_threshold, supermajority_threshold, vstaging::ApprovalVoteMultipleCandidates,
|
||||
ApprovalVote, CandidateHash, CheckedDisputeStatementSet, CheckedMultiDisputeStatementSet,
|
||||
CompactStatement, ConsensusLog, DisputeState, DisputeStatement, DisputeStatementSet,
|
||||
ExplicitDisputeStatement, InvalidDisputeStatementKind, MultiDisputeStatementSet, SessionIndex,
|
||||
SigningContext, ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorSignature,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
@@ -952,6 +952,8 @@ impl<T: Config> Pallet<T> {
|
||||
None => return StatementSetFilter::RemoveAll,
|
||||
};
|
||||
|
||||
let config = <configuration::Pallet<T>>::config();
|
||||
|
||||
let n_validators = session_info.validators.len();
|
||||
|
||||
// Check for ancient.
|
||||
@@ -1015,7 +1017,14 @@ impl<T: Config> Pallet<T> {
|
||||
set.session,
|
||||
statement,
|
||||
signature,
|
||||
// This is here to prevent malicious nodes of generating
|
||||
// `ValidDisputeStatementKind::ApprovalCheckingMultipleCandidates` before that
|
||||
// is enabled, via setting `max_approval_coalesce_count` in the parachain host
|
||||
// config.
|
||||
config.approval_voting_params.max_approval_coalesce_count > 1,
|
||||
) {
|
||||
log::warn!("Failed to check dispute signature");
|
||||
|
||||
importer.undo(undo);
|
||||
filter.remove_index(i);
|
||||
continue
|
||||
@@ -1260,22 +1269,31 @@ fn check_signature(
|
||||
session: SessionIndex,
|
||||
statement: &DisputeStatement,
|
||||
validator_signature: &ValidatorSignature,
|
||||
approval_multiple_candidates_enabled: bool,
|
||||
) -> Result<(), ()> {
|
||||
let payload = match *statement {
|
||||
let payload = match statement {
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::Explicit) =>
|
||||
ExplicitDisputeStatement { valid: true, candidate_hash, session }.signing_payload(),
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::BackingSeconded(inclusion_parent)) =>
|
||||
CompactStatement::Seconded(candidate_hash).signing_payload(&SigningContext {
|
||||
session_index: session,
|
||||
parent_hash: inclusion_parent,
|
||||
parent_hash: *inclusion_parent,
|
||||
}),
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::BackingValid(inclusion_parent)) =>
|
||||
CompactStatement::Valid(candidate_hash).signing_payload(&SigningContext {
|
||||
session_index: session,
|
||||
parent_hash: inclusion_parent,
|
||||
parent_hash: *inclusion_parent,
|
||||
}),
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::ApprovalChecking) =>
|
||||
ApprovalVote(candidate_hash).signing_payload(session),
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::ApprovalCheckingMultipleCandidates(
|
||||
candidates,
|
||||
)) =>
|
||||
if approval_multiple_candidates_enabled && candidates.contains(&candidate_hash) {
|
||||
ApprovalVoteMultipleCandidates(candidates).signing_payload(session)
|
||||
} else {
|
||||
return Err(())
|
||||
},
|
||||
DisputeStatement::Invalid(InvalidDisputeStatementKind::Explicit) =>
|
||||
ExplicitDisputeStatement { valid: false, candidate_hash, session }.signing_payload(),
|
||||
};
|
||||
|
||||
@@ -1500,7 +1500,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_1,
|
||||
&signed_1
|
||||
&signed_1,
|
||||
true,
|
||||
)
|
||||
.is_ok());
|
||||
assert!(check_signature(
|
||||
@@ -1508,7 +1509,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_1,
|
||||
&signed_1
|
||||
&signed_1,
|
||||
true
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1516,7 +1518,8 @@ fn test_check_signature() {
|
||||
wrong_candidate_hash,
|
||||
session,
|
||||
&statement_1,
|
||||
&signed_1
|
||||
&signed_1,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1524,7 +1527,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
wrong_session,
|
||||
&statement_1,
|
||||
&signed_1
|
||||
&signed_1,
|
||||
true
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1532,7 +1536,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_2,
|
||||
&signed_1
|
||||
&signed_1,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1540,7 +1545,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_3,
|
||||
&signed_1
|
||||
&signed_1,
|
||||
true
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1548,7 +1554,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_4,
|
||||
&signed_1
|
||||
&signed_1,
|
||||
true
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1556,7 +1563,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_5,
|
||||
&signed_1
|
||||
&signed_1,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
|
||||
@@ -1565,7 +1573,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_2,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true,
|
||||
)
|
||||
.is_ok());
|
||||
assert!(check_signature(
|
||||
@@ -1573,7 +1582,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_2,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1581,7 +1591,8 @@ fn test_check_signature() {
|
||||
wrong_candidate_hash,
|
||||
session,
|
||||
&statement_2,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1589,7 +1600,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
wrong_session,
|
||||
&statement_2,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1597,7 +1609,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&wrong_statement_2,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1605,7 +1618,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_1,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1613,7 +1627,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_3,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1621,7 +1636,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_4,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1629,7 +1645,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_5,
|
||||
&signed_2
|
||||
&signed_2,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
|
||||
@@ -1638,7 +1655,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_3,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true,
|
||||
)
|
||||
.is_ok());
|
||||
assert!(check_signature(
|
||||
@@ -1646,7 +1664,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_3,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1654,7 +1673,8 @@ fn test_check_signature() {
|
||||
wrong_candidate_hash,
|
||||
session,
|
||||
&statement_3,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1662,7 +1682,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
wrong_session,
|
||||
&statement_3,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1670,7 +1691,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&wrong_statement_3,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1678,7 +1700,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_1,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1686,7 +1709,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_2,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1694,7 +1718,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_4,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1702,7 +1727,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_5,
|
||||
&signed_3
|
||||
&signed_3,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
|
||||
@@ -1711,7 +1737,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_4,
|
||||
&signed_4
|
||||
&signed_4,
|
||||
true,
|
||||
)
|
||||
.is_ok());
|
||||
assert!(check_signature(
|
||||
@@ -1719,7 +1746,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_4,
|
||||
&signed_4
|
||||
&signed_4,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1727,7 +1755,8 @@ fn test_check_signature() {
|
||||
wrong_candidate_hash,
|
||||
session,
|
||||
&statement_4,
|
||||
&signed_4
|
||||
&signed_4,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1735,7 +1764,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
wrong_session,
|
||||
&statement_4,
|
||||
&signed_4
|
||||
&signed_4,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1743,7 +1773,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_1,
|
||||
&signed_4
|
||||
&signed_4,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1751,7 +1782,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_2,
|
||||
&signed_4
|
||||
&signed_4,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1759,7 +1791,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_3,
|
||||
&signed_4
|
||||
&signed_4,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1767,7 +1800,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_5,
|
||||
&signed_4
|
||||
&signed_4,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
|
||||
@@ -1776,7 +1810,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_5,
|
||||
&signed_5
|
||||
&signed_5,
|
||||
true,
|
||||
)
|
||||
.is_ok());
|
||||
assert!(check_signature(
|
||||
@@ -1784,7 +1819,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_5,
|
||||
&signed_5
|
||||
&signed_5,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1792,7 +1828,8 @@ fn test_check_signature() {
|
||||
wrong_candidate_hash,
|
||||
session,
|
||||
&statement_5,
|
||||
&signed_5
|
||||
&signed_5,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1800,7 +1837,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
wrong_session,
|
||||
&statement_5,
|
||||
&signed_5
|
||||
&signed_5,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1808,7 +1846,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_1,
|
||||
&signed_5
|
||||
&signed_5,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1816,7 +1855,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_2,
|
||||
&signed_5
|
||||
&signed_5,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1824,7 +1864,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_3,
|
||||
&signed_5
|
||||
&signed_5,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
assert!(check_signature(
|
||||
@@ -1832,7 +1873,8 @@ fn test_check_signature() {
|
||||
candidate_hash,
|
||||
session,
|
||||
&statement_4,
|
||||
&signed_5
|
||||
&signed_5,
|
||||
true,
|
||||
)
|
||||
.is_err());
|
||||
}
|
||||
|
||||
@@ -17,7 +17,10 @@
|
||||
//! Put implementations of functions from staging APIs here.
|
||||
|
||||
use crate::{configuration, initializer, shared};
|
||||
use primitives::{vstaging::NodeFeatures, ValidatorIndex};
|
||||
use primitives::{
|
||||
vstaging::{ApprovalVotingParams, NodeFeatures},
|
||||
ValidatorIndex,
|
||||
};
|
||||
use sp_std::{collections::btree_map::BTreeMap, prelude::Vec};
|
||||
|
||||
/// Implementation for `DisabledValidators`
|
||||
@@ -47,3 +50,9 @@ where
|
||||
pub fn node_features<T: initializer::Config>() -> NodeFeatures {
|
||||
<configuration::Pallet<T>>::config().node_features
|
||||
}
|
||||
|
||||
/// Approval voting subsystem configuration parameteres
|
||||
pub fn approval_voting_params<T: initializer::Config>() -> ApprovalVotingParams {
|
||||
let config = <configuration::Pallet<T>>::config();
|
||||
config.approval_voting_params
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user