Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Update dispute participation on active leaves update #6303

Merged
merged 37 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
c039614
Passed candidate events from scraper to participation
BradleyOlson64 Nov 15, 2022
7666c67
First draft PR 5875
BradleyOlson64 Nov 16, 2022
3829bd7
Merge branch 'master' of https://github.com/paritytech/polkadot into …
BradleyOlson64 Nov 16, 2022
1cdc72d
Added support for timestamp in changes
BradleyOlson64 Nov 16, 2022
e9d1273
Some necessary refactoring
BradleyOlson64 Nov 18, 2022
4eebacd
Removed SessionIndex from unconfirmed_disputes key
BradleyOlson64 Nov 19, 2022
45477d2
Removed duplicate logic in import statements
BradleyOlson64 Nov 19, 2022
5b11951
Merge branch 'master' of https://github.com/paritytech/polkadot into …
BradleyOlson64 Nov 19, 2022
04b214c
Replaced queue_participation call with re-prio
BradleyOlson64 Nov 19, 2022
58f6371
Simplifying refactor. Backed were already handled
BradleyOlson64 Nov 21, 2022
efa2870
Removed unneeded spam slots logic
BradleyOlson64 Nov 21, 2022
c0ee1fe
Implementers guide edits
BradleyOlson64 Nov 22, 2022
8b27aef
Undid the spam slots refactor
BradleyOlson64 Nov 22, 2022
319ea05
Added comments and implementers guide edit
BradleyOlson64 Nov 22, 2022
26c9ebe
Added test for participation upon backing
BradleyOlson64 Nov 25, 2022
78cc97b
Merge branch 'master' of https://github.com/paritytech/polkadot into …
BradleyOlson64 Nov 25, 2022
16edc2b
Merge branch 'master' into brad-issue-5875
Dec 1, 2022
e1c356c
Round of fixes + ran fmt
BradleyOlson64 Dec 1, 2022
a7615e5
Round of changes + fmt
BradleyOlson64 Dec 1, 2022
9aea6c6
Merge branch 'brad-issue-5875' of https://github.com/paritytech/polka…
BradleyOlson64 Dec 1, 2022
87cb5a2
Error handling draft
BradleyOlson64 Dec 3, 2022
595fe63
Changed errors to bubble up from reprioritization
BradleyOlson64 Dec 5, 2022
38c6986
Starting to construct new test
BradleyOlson64 Dec 5, 2022
afd63f6
Clarifying participation function rename
BradleyOlson64 Dec 6, 2022
efd7088
Reprio test draft
BradleyOlson64 Dec 9, 2022
8382edb
Merge branch 'master' of https://github.com/paritytech/polkadot into …
BradleyOlson64 Dec 9, 2022
e9eb4e8
Very rough bump to priority queue test draft
BradleyOlson64 Dec 13, 2022
d49bd0b
Improving logging
BradleyOlson64 Dec 15, 2022
7546335
Most concise reproduction of error on third import
BradleyOlson64 Dec 15, 2022
16e35c8
Add `handle_approval_vote_request`
tdimitrov Dec 16, 2022
2954a96
Removing reprioritization on included event test
BradleyOlson64 Dec 16, 2022
b3b3d8a
Removing unneeded test config
BradleyOlson64 Dec 16, 2022
72ae47a
cargo fmt
BradleyOlson64 Dec 16, 2022
e38a933
Test works
tdimitrov Dec 21, 2022
b53035c
Fixing final nits
BradleyOlson64 Dec 22, 2022
dede25c
Merge branch 'brad-issue-5875-temp' of https://github.com/paritytech/…
BradleyOlson64 Dec 22, 2022
d7f0250
Tweaks to test Tsveto figured out
BradleyOlson64 Dec 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Reprio test draft
  • Loading branch information
BradleyOlson64 committed Dec 9, 2022
commit efd7088572468c4fa140077456c00b2801e1075f
3 changes: 3 additions & 0 deletions node/core/dispute-coordinator/src/participation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ pub use queues::{ParticipationPriority, ParticipationRequest, QueueError};
/// This should be a relatively low value, while we might have a speedup once we fetched the data,
/// due to multi-core architectures, but the fetching itself can not be improved by parallel
/// requests. This means that higher numbers make it harder for a single dispute to resolve fast.
#[cfg(not(test))]
const MAX_PARALLEL_PARTICIPATIONS: usize = 3;
#[cfg(test)]
const MAX_PARALLEL_PARTICIPATIONS: usize = 1;

/// Keep track of disputes we need to participate in.
///
Expand Down
183 changes: 164 additions & 19 deletions node/core/dispute-coordinator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3330,23 +3330,47 @@ fn participation_requests_reprioritized_for_newly_included() {
let session = 1;
test_state.handle_resume_sync(&mut virtual_overseer, session).await;

// Making our two candidates. Since participation is secondarily ordered
// by candidate hash, we take advantage of this to produce two candidates
// for which the initial participation order is known. But our plan is to
// upset this ordering by marking last_candidate as included. This should
// place last candidate in the priority queue, resulting in a different
// order of participation.
let first_candidate_receipt = make_valid_candidate_receipt();
// Making our three candidates. Since participation is secondarily ordered by
// candidate hash, we take advantage of this to produce candidates for which
// the initial participation order is known. But our plan is to upset this
// ordering by marking last_candidate as included. This should place last
// candidate in the priority queue, resulting in a different order of
// participation. We expect to trigger participation in the first candidate
// immediately on vote import. Then we manually trigger two more participations,
// expecting the altered ordering third, then second.
let mut first_candidate_receipt = make_valid_candidate_receipt();
// Altering this receipt so its hash will be changed
first_candidate_receipt.descriptor.pov_hash = Hash::from([
122, 200, 116, 29, 232, 183, 20, 109, 138, 86, 23, 253, 70, 41, 20, 85, 127, 230,
60, 38, 90, 127, 28, 16, 231, 218, 227, 40, 88, 237, 187, 128,
]);
let first_candidate_hash = first_candidate_receipt.hash();
let last_candidate_receipt = make_invalid_candidate_receipt();
let last_candidate_hash = last_candidate_receipt.hash();

// We participate in least hash first. Make sure our hashes have the correct ordering
assert!(first_candidate_hash < last_candidate_hash);
let second_candidate_receipt = make_valid_candidate_receipt();
let second_candidate_hash = second_candidate_receipt.hash();
let mut third_candidate_receipt = make_valid_candidate_receipt();
// Altering this receipt so its hash will be changed
third_candidate_receipt.descriptor.pov_hash = Hash::from([
122, 200, 117, 29, 232, 183, 20, 109, 138, 86, 23, 253, 70, 41, 20, 85, 127, 230,
60, 38, 90, 127, 28, 16, 231, 218, 227, 40, 88, 237, 187, 128,
]);
let third_candidate_hash = third_candidate_receipt.hash();

// We participate in lesser hash first. Make sure our hashes have the correct ordering
assert!(first_candidate_hash < second_candidate_hash);
assert!(second_candidate_hash < third_candidate_hash);

// activate leaf - without candidate included event
test_state
.activate_leaf_at_session(&mut virtual_overseer, session, 1, vec![])
.activate_leaf_at_session(
&mut virtual_overseer,
session,
1,
vec![
make_candidate_backed_event(first_candidate_receipt.clone()),
make_candidate_backed_event(second_candidate_receipt.clone()),
make_candidate_backed_event(third_candidate_receipt.clone()),
],
)
.await;

// generate two votes per candidate
Expand All @@ -3368,24 +3392,145 @@ fn participation_requests_reprioritized_for_newly_included() {
)
.await;

let last_valid_vote = test_state
let second_valid_vote = test_state
.issue_explicit_statement_with_index(
ValidatorIndex(1),
last_candidate_hash,
ValidatorIndex(3),
second_candidate_hash,
session,
true,
)
.await;

let last_invalid_vote = test_state
let second_invalid_vote = test_state
.issue_explicit_statement_with_index(
ValidatorIndex(2),
last_candidate_hash,
ValidatorIndex(4),
second_candidate_hash,
session,
false,
)
.await;

let third_valid_vote = test_state
.issue_explicit_statement_with_index(
ValidatorIndex(5),
third_candidate_hash,
session,
true,
)
.await;

let third_invalid_vote = test_state
.issue_explicit_statement_with_index(
ValidatorIndex(6),
third_candidate_hash,
session,
false,
)
.await;

// Importing votes for the three candidates in order
virtual_overseer
.send(FromOrchestra::Communication {
msg: DisputeCoordinatorMessage::ImportStatements {
candidate_receipt: first_candidate_receipt.clone(),
session,
statements: vec![
(first_valid_vote, ValidatorIndex(1)),
(first_invalid_vote, ValidatorIndex(2)),
],
pending_confirmation: None,
},
})
.await;
gum::debug!("After First import!");

handle_approval_vote_request(
&mut virtual_overseer,
&first_candidate_hash,
HashMap::new(),
)
.await;

participation_with_distribution(
&mut virtual_overseer,
&first_candidate_hash,
first_candidate_receipt.commitments_hash,
)
.await;

virtual_overseer
.send(FromOrchestra::Communication {
msg: DisputeCoordinatorMessage::ImportStatements {
candidate_receipt: second_candidate_receipt.clone(),
session,
statements: vec![
(second_valid_vote, ValidatorIndex(3)),
(second_invalid_vote, ValidatorIndex(4)),
],
pending_confirmation: None,
},
})
.await;
gum::debug!("After Second import!");

handle_approval_vote_request(
&mut virtual_overseer,
&second_candidate_hash,
HashMap::new(),
)
.await;

participation_with_distribution(
&mut virtual_overseer,
&second_candidate_hash,
second_candidate_receipt.commitments_hash,
)
.await;

virtual_overseer
.send(FromOrchestra::Communication {
msg: DisputeCoordinatorMessage::ImportStatements {
candidate_receipt: third_candidate_receipt.clone(),
session,
statements: vec![
(third_valid_vote, ValidatorIndex(5)),
(third_invalid_vote, ValidatorIndex(6)),
],
pending_confirmation: None,
},
})
.await;

handle_approval_vote_request(
&mut virtual_overseer,
&third_candidate_hash,
HashMap::new(),
)
.await;

participation_with_distribution(
&mut virtual_overseer,
&third_candidate_hash,
third_candidate_receipt.commitments_hash,
)
.await;

// Issue candidate included event for third candidate. This should place
// the corresponding third participation request in the priority queue.
test_state
.activate_leaf_at_session(
&mut virtual_overseer,
session,
1,
vec![make_candidate_included_event(third_candidate_receipt.clone())],
)
.timeout(TEST_TIMEOUT)
.await;

assert_matches!(virtual_overseer.recv().timeout(TEST_TIMEOUT).await, None);

// Trigger participation by importing another vote

// Wrap up
virtual_overseer.send(FromOrchestra::Signal(OverseerSignal::Conclude)).await;

Expand Down