mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
paras: dismiss pvf_checking_enabled configuration (#7138)
* paras: unconditionally precheck pvfs * Update integration tests * paras_registrar tests * runtime benchmark tests * fix bench * bypass prechecking in test node * adjust bench * ".git/.scripts/commands/bench/bench.sh" runtime polkadot runtime_parachains::paras * ".git/.scripts/commands/bench/bench.sh" runtime kusama runtime_parachains::paras * ".git/.scripts/commands/bench/bench.sh" runtime rococo runtime_parachains::paras * ".git/.scripts/commands/bench/bench.sh" runtime westend runtime_parachains::paras * use test helper * fix new test --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -55,6 +55,22 @@ fn sign_and_include_pvf_check_statement(stmt: PvfCheckStatement) {
|
||||
Paras::include_pvf_check_statement(None.into(), stmt, signature.into()).unwrap();
|
||||
}
|
||||
|
||||
fn submit_super_majority_pvf_votes(
|
||||
validation_code: &ValidationCode,
|
||||
session_index: SessionIndex,
|
||||
accept: bool,
|
||||
) {
|
||||
[0, 1, 2, 3]
|
||||
.into_iter()
|
||||
.map(|i| PvfCheckStatement {
|
||||
accept,
|
||||
subject: validation_code.hash(),
|
||||
session_index,
|
||||
validator_index: i.into(),
|
||||
})
|
||||
.for_each(sign_and_include_pvf_check_statement);
|
||||
}
|
||||
|
||||
fn run_to_block(to: BlockNumber, new_session: Option<Vec<BlockNumber>>) {
|
||||
let keystore: KeystorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
for validator in VALIDATORS.iter() {
|
||||
@@ -420,7 +436,9 @@ fn code_upgrade_applied_after_delay() {
|
||||
let para_id = ParaId::from(0);
|
||||
let new_code = ValidationCode(vec![4, 5, 6]);
|
||||
|
||||
run_to_block(2, None);
|
||||
// Wait for at least one session change to set active validators.
|
||||
const EXPECTED_SESSION: SessionIndex = 1;
|
||||
run_to_block(2, Some(vec![1]));
|
||||
assert_eq!(Paras::current_code(¶_id), Some(original_code.clone()));
|
||||
|
||||
let expected_at = {
|
||||
@@ -428,6 +446,9 @@ fn code_upgrade_applied_after_delay() {
|
||||
let expected_at = 1 + validation_upgrade_delay;
|
||||
let next_possible_upgrade_at = 1 + validation_upgrade_cooldown;
|
||||
Paras::schedule_code_upgrade(para_id, new_code.clone(), 1, &Configuration::config());
|
||||
// Include votes for super-majority.
|
||||
submit_super_majority_pvf_votes(&new_code, EXPECTED_SESSION, true);
|
||||
|
||||
Paras::note_new_head(para_id, Default::default(), 1);
|
||||
|
||||
assert!(Paras::past_code_meta(¶_id).most_recent_change().is_none());
|
||||
@@ -515,7 +536,9 @@ fn code_upgrade_applied_after_delay_even_when_late() {
|
||||
let para_id = ParaId::from(0);
|
||||
let new_code = ValidationCode(vec![4, 5, 6]);
|
||||
|
||||
run_to_block(2, None);
|
||||
// Wait for at least one session change to set active validators.
|
||||
const EXPECTED_SESSION: SessionIndex = 1;
|
||||
run_to_block(2, Some(vec![1]));
|
||||
assert_eq!(Paras::current_code(¶_id), Some(original_code.clone()));
|
||||
|
||||
let expected_at = {
|
||||
@@ -523,6 +546,9 @@ fn code_upgrade_applied_after_delay_even_when_late() {
|
||||
let expected_at = 1 + validation_upgrade_delay;
|
||||
let next_possible_upgrade_at = 1 + validation_upgrade_cooldown;
|
||||
Paras::schedule_code_upgrade(para_id, new_code.clone(), 1, &Configuration::config());
|
||||
// Include votes for super-majority.
|
||||
submit_super_majority_pvf_votes(&new_code, EXPECTED_SESSION, true);
|
||||
|
||||
Paras::note_new_head(para_id, Default::default(), 1);
|
||||
|
||||
assert!(Paras::past_code_meta(¶_id).most_recent_change().is_none());
|
||||
@@ -595,8 +621,14 @@ fn submit_code_change_when_not_allowed_is_err() {
|
||||
let new_code = ValidationCode(vec![4, 5, 6]);
|
||||
let newer_code = ValidationCode(vec![4, 5, 6, 7]);
|
||||
|
||||
run_to_block(1, None);
|
||||
// Wait for at least one session change to set active validators.
|
||||
const EXPECTED_SESSION: SessionIndex = 1;
|
||||
run_to_block(1, Some(vec![1]));
|
||||
|
||||
Paras::schedule_code_upgrade(para_id, new_code.clone(), 1, &Configuration::config());
|
||||
// Include votes for super-majority.
|
||||
submit_super_majority_pvf_votes(&new_code, EXPECTED_SESSION, true);
|
||||
|
||||
assert_eq!(FutureCodeUpgrades::<Test>::get(¶_id), Some(1 + validation_upgrade_delay));
|
||||
assert_eq!(FutureCodeHash::<Test>::get(¶_id), Some(new_code.hash()));
|
||||
check_code_is_stored(&new_code);
|
||||
@@ -625,7 +657,7 @@ fn upgrade_restriction_elapsed_doesnt_mean_can_upgrade() {
|
||||
// rather an artifact of the current implementation and not necessarily something we want
|
||||
// to keep in the future.
|
||||
//
|
||||
// This test exists that this is not accidentially changed.
|
||||
// This test exists that this is not accidentally changed.
|
||||
|
||||
let code_retention_period = 10;
|
||||
let validation_upgrade_delay = 7;
|
||||
@@ -660,8 +692,14 @@ fn upgrade_restriction_elapsed_doesnt_mean_can_upgrade() {
|
||||
let new_code = ValidationCode(vec![4, 5, 6]);
|
||||
let newer_code = ValidationCode(vec![4, 5, 6, 7]);
|
||||
|
||||
run_to_block(1, None);
|
||||
// Wait for at least one session change to set active validators.
|
||||
const EXPECTED_SESSION: SessionIndex = 1;
|
||||
run_to_block(1, Some(vec![1]));
|
||||
|
||||
Paras::schedule_code_upgrade(para_id, new_code.clone(), 0, &Configuration::config());
|
||||
// Include votes for super-majority.
|
||||
submit_super_majority_pvf_votes(&new_code, EXPECTED_SESSION, true);
|
||||
|
||||
Paras::note_new_head(para_id, dummy_head_data(), 0);
|
||||
assert_eq!(
|
||||
UpgradeRestrictionSignal::<Test>::get(¶_id),
|
||||
@@ -722,7 +760,10 @@ fn full_parachain_cleanup_storage() {
|
||||
let para_id = ParaId::from(0);
|
||||
let new_code = ValidationCode(vec![4, 5, 6]);
|
||||
|
||||
run_to_block(2, None);
|
||||
// Wait for at least one session change to set active validators.
|
||||
const EXPECTED_SESSION: SessionIndex = 1;
|
||||
run_to_block(2, Some(vec![1]));
|
||||
|
||||
assert_eq!(Paras::current_code(¶_id), Some(original_code.clone()));
|
||||
check_code_is_stored(&original_code);
|
||||
|
||||
@@ -730,6 +771,9 @@ fn full_parachain_cleanup_storage() {
|
||||
// this parablock is in the context of block 1.
|
||||
let expected_at = 1 + validation_upgrade_delay;
|
||||
Paras::schedule_code_upgrade(para_id, new_code.clone(), 1, &Configuration::config());
|
||||
// Include votes for super-majority.
|
||||
submit_super_majority_pvf_votes(&new_code, EXPECTED_SESSION, true);
|
||||
|
||||
Paras::note_new_head(para_id, Default::default(), 1);
|
||||
|
||||
assert!(Paras::past_code_meta(¶_id).most_recent_change().is_none());
|
||||
@@ -832,14 +876,7 @@ fn cannot_offboard_ongoing_pvf_check() {
|
||||
assert_err!(Paras::schedule_para_cleanup(para_id), Error::<Test>::CannotOffboard);
|
||||
|
||||
// Include votes for super-majority.
|
||||
IntoIterator::into_iter([0, 1, 2, 3])
|
||||
.map(|i| PvfCheckStatement {
|
||||
accept: true,
|
||||
subject: new_code.hash(),
|
||||
session_index: EXPECTED_SESSION,
|
||||
validator_index: i.into(),
|
||||
})
|
||||
.for_each(sign_and_include_pvf_check_statement);
|
||||
submit_super_majority_pvf_votes(&new_code, EXPECTED_SESSION, true);
|
||||
|
||||
// Voting concluded, can offboard even though an upgrade is in progress.
|
||||
assert_ok!(Paras::schedule_para_cleanup(para_id));
|
||||
@@ -985,10 +1022,16 @@ fn code_hash_at_returns_up_to_end_of_code_retention_period() {
|
||||
};
|
||||
|
||||
new_test_ext(genesis_config).execute_with(|| {
|
||||
// Wait for at least one session change to set active validators.
|
||||
run_to_block(2, Some(vec![1]));
|
||||
const EXPECTED_SESSION: SessionIndex = 1;
|
||||
|
||||
let para_id = ParaId::from(0);
|
||||
let old_code: ValidationCode = vec![1, 2, 3].into();
|
||||
let new_code: ValidationCode = vec![4, 5, 6].into();
|
||||
Paras::schedule_code_upgrade(para_id, new_code.clone(), 0, &Configuration::config());
|
||||
// Include votes for super-majority.
|
||||
submit_super_majority_pvf_votes(&new_code, EXPECTED_SESSION, true);
|
||||
|
||||
// The new validation code can be applied but a new parablock hasn't gotten in yet,
|
||||
// so the old code should still be current.
|
||||
@@ -998,7 +1041,7 @@ fn code_hash_at_returns_up_to_end_of_code_retention_period() {
|
||||
run_to_block(10, None);
|
||||
Paras::note_new_head(para_id, Default::default(), 7);
|
||||
|
||||
assert_eq!(Paras::past_code_meta(¶_id).upgrade_times, vec![upgrade_at(2, 10)]);
|
||||
assert_eq!(Paras::past_code_meta(¶_id).upgrade_times, vec![upgrade_at(4, 10)]);
|
||||
assert_eq!(Paras::current_code(¶_id), Some(new_code.clone()));
|
||||
|
||||
// Make sure that the old code is available **before** the code retion period passes.
|
||||
@@ -1103,14 +1146,7 @@ fn pvf_check_coalescing_onboarding_and_upgrade() {
|
||||
assert!(!Paras::pvfs_require_precheck().is_empty());
|
||||
|
||||
// Supermajority of validators vote for `validation_code`. It should be approved.
|
||||
IntoIterator::into_iter([0, 1, 2, 3])
|
||||
.map(|i| PvfCheckStatement {
|
||||
accept: true,
|
||||
subject: validation_code.hash(),
|
||||
session_index: EXPECTED_SESSION,
|
||||
validator_index: i.into(),
|
||||
})
|
||||
.for_each(sign_and_include_pvf_check_statement);
|
||||
submit_super_majority_pvf_votes(&validation_code, EXPECTED_SESSION, true);
|
||||
|
||||
// Check that `b` actually onboards.
|
||||
assert_eq!(ActionsQueue::<Test>::get(EXPECTED_SESSION + 2), vec![b]);
|
||||
@@ -1253,47 +1289,6 @@ fn pvf_check_upgrade_reject() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pvf_check_submit_vote_while_disabled() {
|
||||
let genesis_config = MockGenesisConfig {
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration { pvf_checking_enabled: false, ..Default::default() },
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
new_test_ext(genesis_config).execute_with(|| {
|
||||
// This will set the session index to 1 and seed the validators.
|
||||
run_to_block(1, Some(vec![1]));
|
||||
|
||||
let stmt = PvfCheckStatement {
|
||||
accept: false,
|
||||
subject: ValidationCode(vec![1, 2, 3]).hash(),
|
||||
session_index: 1,
|
||||
validator_index: 1.into(),
|
||||
};
|
||||
|
||||
let signature: ValidatorSignature =
|
||||
Sr25519Keyring::Alice.sign(&stmt.signing_payload()).into();
|
||||
|
||||
let call =
|
||||
Call::include_pvf_check_statement { stmt: stmt.clone(), signature: signature.clone() };
|
||||
|
||||
let validate_unsigned =
|
||||
<Paras as ValidateUnsigned>::validate_unsigned(TransactionSource::InBlock, &call);
|
||||
assert_eq!(
|
||||
validate_unsigned,
|
||||
InvalidTransaction::Custom(INVALID_TX_PVF_CHECK_DISABLED).into()
|
||||
);
|
||||
|
||||
assert_err!(
|
||||
Paras::include_pvf_check_statement(None.into(), stmt.clone(), signature.clone()),
|
||||
Error::<Test>::PvfCheckDisabled
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pvf_check_submit_vote() {
|
||||
let code_a: ValidationCode = vec![3, 2, 1].into();
|
||||
|
||||
Reference in New Issue
Block a user