mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 04:41:03 +00:00
add disputes members to HostConfiguration (#2806)
* add disputes members to `HostConfiguration` * revert bad rename
This commit is contained in:
committed by
GitHub
parent
beca01f118
commit
c54f8848d1
@@ -118,9 +118,9 @@ pub struct HostConfiguration<BlockNumber> {
|
||||
* Parameters that will unlikely be needed by parachains.
|
||||
*/
|
||||
|
||||
/// The acceptance period, in blocks. This is the amount of blocks after availability that validators
|
||||
/// and fishermen have to perform secondary checks or issue reports.
|
||||
pub acceptance_period: BlockNumber,
|
||||
/// How long to keep code on-chain, in blocks. This should be sufficiently long that disputes
|
||||
/// have concluded.
|
||||
pub code_retention_period: BlockNumber,
|
||||
/// The amount of execution cores to dedicate to parathread execution.
|
||||
pub parathread_cores: u32,
|
||||
/// The number of retries that a parathread author has to submit their block.
|
||||
@@ -152,6 +152,12 @@ pub struct HostConfiguration<BlockNumber> {
|
||||
pub max_validators: Option<u32>,
|
||||
/// The amount of sessions to keep for disputes.
|
||||
pub dispute_period: SessionIndex,
|
||||
/// How long after dispute conclusion to accept statements.
|
||||
pub dispute_post_conclusion_acceptance_period: BlockNumber,
|
||||
/// The maximum number of dispute spam slots
|
||||
pub dispute_max_spam_slots: u32,
|
||||
/// How long it takes for a dispute to conclude by time-out, if no supermajority is reached.
|
||||
pub dispute_conclusion_by_time_out_period: BlockNumber,
|
||||
/// The amount of consensus slots that must pass between submitting an assignment and
|
||||
/// submitting an approval vote before a validator is considered a no-show.
|
||||
///
|
||||
@@ -177,7 +183,7 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
|
||||
no_show_slots: 1u32.into(),
|
||||
validation_upgrade_frequency: Default::default(),
|
||||
validation_upgrade_delay: Default::default(),
|
||||
acceptance_period: Default::default(),
|
||||
code_retention_period: Default::default(),
|
||||
max_code_size: Default::default(),
|
||||
max_pov_size: Default::default(),
|
||||
max_head_data_size: Default::default(),
|
||||
@@ -186,7 +192,10 @@ impl<BlockNumber: Default + From<u32>> Default for HostConfiguration<BlockNumber
|
||||
scheduling_lookahead: Default::default(),
|
||||
max_validators_per_core: Default::default(),
|
||||
max_validators: None,
|
||||
dispute_period: Default::default(),
|
||||
dispute_period: 6,
|
||||
dispute_post_conclusion_acceptance_period: 100.into(),
|
||||
dispute_max_spam_slots: 2,
|
||||
dispute_conclusion_by_time_out_period: 200.into(),
|
||||
n_delay_tranches: Default::default(),
|
||||
zeroth_delay_tranche_width: Default::default(),
|
||||
needed_approvals: Default::default(),
|
||||
@@ -287,10 +296,10 @@ decl_module! {
|
||||
|
||||
/// Set the acceptance period for an included candidate.
|
||||
#[weight = (1_000, DispatchClass::Operational)]
|
||||
pub fn set_acceptance_period(origin, new: T::BlockNumber) -> DispatchResult {
|
||||
pub fn set_code_retention_period(origin, new: T::BlockNumber) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
Self::update_config_member(|config| {
|
||||
sp_std::mem::replace(&mut config.acceptance_period, new) != new
|
||||
sp_std::mem::replace(&mut config.code_retention_period, new) != new
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
@@ -425,6 +434,41 @@ decl_module! {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the dispute post conclusion acceptance period.
|
||||
#[weight = (1_000, DispatchClass::Operational)]
|
||||
pub fn set_dispute_post_conclusion_acceptance_period(
|
||||
origin,
|
||||
new: T::BlockNumber,
|
||||
) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
Self::update_config_member(|config| {
|
||||
sp_std::mem::replace(&mut config.dispute_post_conclusion_acceptance_period, new) != new
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the maximum number of dispute spam slots.
|
||||
#[weight = (1_000, DispatchClass::Operational)]
|
||||
pub fn set_dispute_max_spam_slots(origin, new: u32) -> DispatchResult {
|
||||
ensure_root(origin)?;
|
||||
Self::update_config_member(|config| {
|
||||
sp_std::mem::replace(&mut config.dispute_max_spam_slots, new) != new
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the dispute conclusion by time out period.
|
||||
#[weight = (1_000, DispatchClass::Operational)]
|
||||
pub fn set_dispute_conclusion_by_time_out_period(origin, new: T::BlockNumber)
|
||||
-> DispatchResult
|
||||
{
|
||||
ensure_root(origin)?;
|
||||
Self::update_config_member(|config| {
|
||||
sp_std::mem::replace(&mut config.dispute_conclusion_by_time_out_period, new) != new
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the no show slots, in number of number of consensus slots.
|
||||
/// Must be at least 1.
|
||||
#[weight = (1_000, DispatchClass::Operational)]
|
||||
@@ -731,7 +775,7 @@ mod tests {
|
||||
let new_config = HostConfiguration {
|
||||
validation_upgrade_frequency: 100,
|
||||
validation_upgrade_delay: 10,
|
||||
acceptance_period: 5,
|
||||
code_retention_period: 5,
|
||||
max_code_size: 100_000,
|
||||
max_pov_size: 1024,
|
||||
max_head_data_size: 1_000,
|
||||
@@ -744,6 +788,9 @@ mod tests {
|
||||
max_validators_per_core: None,
|
||||
max_validators: None,
|
||||
dispute_period: 239,
|
||||
dispute_post_conclusion_acceptance_period: 10,
|
||||
dispute_max_spam_slots: 2,
|
||||
dispute_conclusion_by_time_out_period: 512,
|
||||
no_show_slots: 240,
|
||||
n_delay_tranches: 241,
|
||||
zeroth_delay_tranche_width: 242,
|
||||
@@ -776,8 +823,8 @@ mod tests {
|
||||
Configuration::set_validation_upgrade_delay(
|
||||
Origin::root(), new_config.validation_upgrade_delay,
|
||||
).unwrap();
|
||||
Configuration::set_acceptance_period(
|
||||
Origin::root(), new_config.acceptance_period,
|
||||
Configuration::set_code_retention_period(
|
||||
Origin::root(), new_config.code_retention_period,
|
||||
).unwrap();
|
||||
Configuration::set_max_code_size(
|
||||
Origin::root(), new_config.max_code_size,
|
||||
@@ -815,6 +862,15 @@ mod tests {
|
||||
Configuration::set_dispute_period(
|
||||
Origin::root(), new_config.dispute_period,
|
||||
).unwrap();
|
||||
Configuration::set_dispute_post_conclusion_acceptance_period(
|
||||
Origin::root(), new_config.dispute_post_conclusion_acceptance_period,
|
||||
).unwrap();
|
||||
Configuration::set_dispute_max_spam_slots(
|
||||
Origin::root(), new_config.dispute_max_spam_slots,
|
||||
).unwrap();
|
||||
Configuration::set_dispute_conclusion_by_time_out_period(
|
||||
Origin::root(), new_config.dispute_conclusion_by_time_out_period,
|
||||
).unwrap();
|
||||
Configuration::set_no_show_slots(
|
||||
Origin::root(), new_config.no_show_slots,
|
||||
).unwrap();
|
||||
|
||||
@@ -575,14 +575,14 @@ impl<T: Config> Module<T> {
|
||||
// that are too old.
|
||||
fn prune_old_code(now: T::BlockNumber) -> Weight {
|
||||
let config = configuration::Module::<T>::config();
|
||||
let acceptance_period = config.acceptance_period;
|
||||
if now <= acceptance_period {
|
||||
let code_retention_period = config.code_retention_period;
|
||||
if now <= code_retention_period {
|
||||
let weight = T::DbWeight::get().reads_writes(1, 0);
|
||||
return weight;
|
||||
}
|
||||
|
||||
// The height of any changes we no longer should keep around.
|
||||
let pruning_height = now - (acceptance_period + One::one());
|
||||
let pruning_height = now - (code_retention_period + One::one());
|
||||
|
||||
let pruning_tasks_done =
|
||||
<Self as Store>::PastCodePruning::mutate(|pruning_tasks: &mut Vec<(_, T::BlockNumber)>| {
|
||||
@@ -1071,7 +1071,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn para_past_code_pruning_in_initialize() {
|
||||
let acceptance_period = 10;
|
||||
let code_retention_period = 10;
|
||||
let paras = vec![
|
||||
(0u32.into(), ParaGenesisArgs {
|
||||
parachain: true,
|
||||
@@ -1089,7 +1089,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -1113,7 +1113,7 @@ mod tests {
|
||||
<Paras as Store>::PastCodeMeta::insert(&id, &code_meta);
|
||||
}
|
||||
|
||||
let pruned_at: BlockNumber = included_block + acceptance_period + 1;
|
||||
let pruned_at: BlockNumber = included_block + code_retention_period + 1;
|
||||
assert_eq!(<Paras as Store>::PastCodeHash::get(&(id, at_block)), Some(validation_code.hash()));
|
||||
check_code_is_stored(&validation_code);
|
||||
|
||||
@@ -1131,7 +1131,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn note_new_head_sets_head() {
|
||||
let acceptance_period = 10;
|
||||
let code_retention_period = 10;
|
||||
let paras = vec![
|
||||
(0u32.into(), ParaGenesisArgs {
|
||||
parachain: true,
|
||||
@@ -1144,7 +1144,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -1165,7 +1165,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn note_past_code_sets_up_pruning_correctly() {
|
||||
let acceptance_period = 10;
|
||||
let code_retention_period = 10;
|
||||
let paras = vec![
|
||||
(0u32.into(), ParaGenesisArgs {
|
||||
parachain: true,
|
||||
@@ -1183,7 +1183,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -1218,7 +1218,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn code_upgrade_applied_after_delay() {
|
||||
let acceptance_period = 10;
|
||||
let code_retention_period = 10;
|
||||
let validation_upgrade_delay = 5;
|
||||
|
||||
let original_code = ValidationCode(vec![1, 2, 3]);
|
||||
@@ -1234,7 +1234,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
validation_upgrade_delay,
|
||||
..Default::default()
|
||||
},
|
||||
@@ -1309,7 +1309,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn code_upgrade_applied_after_delay_even_when_late() {
|
||||
let acceptance_period = 10;
|
||||
let code_retention_period = 10;
|
||||
let validation_upgrade_delay = 5;
|
||||
|
||||
let original_code = ValidationCode(vec![1, 2, 3]);
|
||||
@@ -1325,7 +1325,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
validation_upgrade_delay,
|
||||
..Default::default()
|
||||
},
|
||||
@@ -1379,7 +1379,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn submit_code_change_when_not_allowed_is_err() {
|
||||
let acceptance_period = 10;
|
||||
let code_retention_period = 10;
|
||||
|
||||
let paras = vec![
|
||||
(0u32.into(), ParaGenesisArgs {
|
||||
@@ -1393,7 +1393,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -1422,7 +1422,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn full_parachain_cleanup_storage() {
|
||||
let acceptance_period = 10;
|
||||
let code_retention_period = 10;
|
||||
|
||||
let original_code = ValidationCode(vec![1, 2, 3]);
|
||||
let paras = vec![
|
||||
@@ -1437,7 +1437,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -1509,7 +1509,7 @@ mod tests {
|
||||
check_code_is_not_stored(&new_code);
|
||||
|
||||
// run to do the final cleanup
|
||||
let cleaned_up_at = 3 + acceptance_period + 1;
|
||||
let cleaned_up_at = 3 + code_retention_period + 1;
|
||||
run_to_block(cleaned_up_at, None);
|
||||
|
||||
// now the final cleanup: last past code cleaned up, and this triggers meta cleanup.
|
||||
@@ -1600,7 +1600,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn code_at_with_intermediate() {
|
||||
let acceptance_period = 10;
|
||||
let code_retention_period = 10;
|
||||
|
||||
let paras = vec![
|
||||
(0u32.into(), ParaGenesisArgs {
|
||||
@@ -1614,7 +1614,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -1642,7 +1642,7 @@ mod tests {
|
||||
assert_eq!(Paras::validation_code_at(para_id, 11, Some(10)), Some(new_code.clone()));
|
||||
assert_eq!(Paras::validation_code_at(para_id, 100, Some(11)), Some(new_code.clone()));
|
||||
|
||||
run_to_block(acceptance_period + 5, None);
|
||||
run_to_block(code_retention_period + 5, None);
|
||||
|
||||
// at <= intermediate not allowed
|
||||
assert_eq!(Paras::validation_code_at(para_id, 10, Some(10)), None);
|
||||
@@ -1651,8 +1651,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn code_at_returns_up_to_end_of_acceptance_period() {
|
||||
let acceptance_period = 10;
|
||||
fn code_at_returns_up_to_end_of_code_retention_period() {
|
||||
let code_retention_period = 10;
|
||||
|
||||
let paras = vec![
|
||||
(0u32.into(), ParaGenesisArgs {
|
||||
@@ -1666,7 +1666,7 @@ mod tests {
|
||||
paras: GenesisConfig { paras, ..Default::default() },
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
acceptance_period,
|
||||
code_retention_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
@@ -1691,12 +1691,12 @@ mod tests {
|
||||
assert_eq!(Paras::validation_code_at(para_id, 2, None), Some(old_code.clone()));
|
||||
assert_eq!(Paras::validation_code_at(para_id, 3, None), Some(new_code.clone()));
|
||||
|
||||
run_to_block(10 + acceptance_period, None);
|
||||
run_to_block(10 + code_retention_period, None);
|
||||
|
||||
assert_eq!(Paras::validation_code_at(para_id, 2, None), Some(old_code.clone()));
|
||||
assert_eq!(Paras::validation_code_at(para_id, 3, None), Some(new_code.clone()));
|
||||
|
||||
run_to_block(10 + acceptance_period + 1, None);
|
||||
run_to_block(10 + code_retention_period + 1, None);
|
||||
|
||||
// code entry should be pruned now.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user