mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
paras: do not allow PVF vote submission if disabled (#4684)
if the PVF pre-checking is disabled the runtime dispatchable will reject any attempts of submission. This is also concern the unsigned tx validation. Right now, the `include_pvf_check_statement` dispatchable is effectively uncallable because of the weight set to the maximum value. If we were to benchmark it, it would become includable in a block, but since there will be no active votes, the dispatchable won't do anything. However, it will execute some code, like signature validation and querying some storage entries. To be completely safe, we can bail out early if the `pvf_checking_enabled` config is disabled. That's what this PR does.
This commit is contained in:
@@ -1214,6 +1214,47 @@ 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