mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 11:01:01 +00:00
inherent disputes: remove per block initializer and disputes timeout event (#6937)
* Limit disputes weight and remove initializer code Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * const Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * remove timeout test Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * review feedback #1 Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Remove the new weight limiting for disputes Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * cargo lock Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Remove dispute_conclusion_by_time_out_period Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Enable migrations Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Update guide Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Fix comment Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * More guide fixes Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Also migrate pending configs Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix build Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix test Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -329,131 +329,6 @@ fn test_import_backing_votes() {
|
||||
);
|
||||
}
|
||||
|
||||
// Test that dispute timeout is handled correctly.
|
||||
#[test]
|
||||
fn test_dispute_timeout() {
|
||||
let dispute_conclusion_by_time_out_period = 3;
|
||||
let start = 10;
|
||||
|
||||
let mock_genesis_config = MockGenesisConfig {
|
||||
configuration: crate::configuration::GenesisConfig {
|
||||
config: HostConfiguration {
|
||||
dispute_conclusion_by_time_out_period,
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
new_test_ext(mock_genesis_config).execute_with(|| {
|
||||
// We need 7 validators for the byzantine threshold to be 2
|
||||
let v0 = <ValidatorId as CryptoType>::Pair::generate().0;
|
||||
let v1 = <ValidatorId as CryptoType>::Pair::generate().0;
|
||||
let v2 = <ValidatorId as CryptoType>::Pair::generate().0;
|
||||
let v3 = <ValidatorId as CryptoType>::Pair::generate().0;
|
||||
let v4 = <ValidatorId as CryptoType>::Pair::generate().0;
|
||||
let v5 = <ValidatorId as CryptoType>::Pair::generate().0;
|
||||
let v6 = <ValidatorId as CryptoType>::Pair::generate().0;
|
||||
|
||||
run_to_block(start, |b| {
|
||||
// a new session at each block
|
||||
Some((
|
||||
true,
|
||||
b,
|
||||
vec![
|
||||
(&0, v0.public()),
|
||||
(&1, v1.public()),
|
||||
(&2, v2.public()),
|
||||
(&3, v3.public()),
|
||||
(&4, v4.public()),
|
||||
(&5, v5.public()),
|
||||
(&6, v6.public()),
|
||||
],
|
||||
Some(vec![
|
||||
(&0, v0.public()),
|
||||
(&1, v1.public()),
|
||||
(&2, v2.public()),
|
||||
(&3, v3.public()),
|
||||
(&4, v4.public()),
|
||||
(&5, v5.public()),
|
||||
(&6, v6.public()),
|
||||
]),
|
||||
))
|
||||
});
|
||||
|
||||
let candidate_hash = CandidateHash(sp_core::H256::repeat_byte(1));
|
||||
let inclusion_parent = sp_core::H256::repeat_byte(0xff);
|
||||
|
||||
// v0 and v1 vote for 3, v2 against. We need f+1 votes (3) so that the dispute is
|
||||
// confirmed. Otherwise It will be filtered out.
|
||||
let session = start - 1;
|
||||
let stmts = vec![DisputeStatementSet {
|
||||
candidate_hash: candidate_hash.clone(),
|
||||
session,
|
||||
statements: vec![
|
||||
(
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::BackingValid(
|
||||
inclusion_parent,
|
||||
)),
|
||||
ValidatorIndex(0),
|
||||
v0.sign(&CompactStatement::Valid(candidate_hash).signing_payload(
|
||||
&SigningContext { session_index: start - 1, parent_hash: inclusion_parent },
|
||||
)),
|
||||
),
|
||||
(
|
||||
DisputeStatement::Valid(ValidDisputeStatementKind::Explicit),
|
||||
ValidatorIndex(1),
|
||||
v1.sign(
|
||||
&ExplicitDisputeStatement {
|
||||
valid: true,
|
||||
candidate_hash: candidate_hash.clone(),
|
||||
session: start - 1,
|
||||
}
|
||||
.signing_payload(),
|
||||
),
|
||||
),
|
||||
(
|
||||
DisputeStatement::Invalid(InvalidDisputeStatementKind::Explicit),
|
||||
ValidatorIndex(6),
|
||||
v2.sign(
|
||||
&ExplicitDisputeStatement {
|
||||
valid: false,
|
||||
candidate_hash: candidate_hash.clone(),
|
||||
session: start - 1,
|
||||
}
|
||||
.signing_payload(),
|
||||
),
|
||||
),
|
||||
],
|
||||
}];
|
||||
|
||||
let stmts = filter_dispute_set(stmts);
|
||||
|
||||
assert_ok!(
|
||||
Pallet::<Test>::process_checked_multi_dispute_data(&stmts),
|
||||
vec![(9, candidate_hash.clone())],
|
||||
);
|
||||
|
||||
// Run to timeout period
|
||||
run_to_block(start + dispute_conclusion_by_time_out_period, |_| None);
|
||||
assert!(<Disputes<Test>>::get(&session, &candidate_hash)
|
||||
.expect("dispute should exist")
|
||||
.concluded_at
|
||||
.is_none());
|
||||
|
||||
// Run to timeout + 1 in order to executive on_finalize(timeout)
|
||||
run_to_block(start + dispute_conclusion_by_time_out_period + 1, |_| None);
|
||||
assert_eq!(
|
||||
<Disputes<Test>>::get(&session, &candidate_hash)
|
||||
.expect("dispute should exist")
|
||||
.concluded_at
|
||||
.expect("dispute should have concluded"),
|
||||
start + dispute_conclusion_by_time_out_period + 1
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Test pruning works
|
||||
#[test]
|
||||
fn test_initializer_on_new_session() {
|
||||
|
||||
Reference in New Issue
Block a user