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

Issue 4804: Notify chain selection of concluded disputes directly #6512

Merged
merged 33 commits into from
Jan 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
658f9de
Setting up new ChainSelectionMessage
BradleyOlson64 Dec 28, 2022
c66ea70
Partial first pass
BradleyOlson64 Jan 2, 2023
8ef1202
Got dispute conclusion data to provisioner
BradleyOlson64 Jan 3, 2023
e69a5b4
Finished first draft for 4804 code
BradleyOlson64 Jan 5, 2023
94e231a
Merge branch 'master' of https://github.com/paritytech/polkadot into …
BradleyOlson64 Jan 5, 2023
b370985
A bit of polish and code comments
BradleyOlson64 Jan 5, 2023
043f505
cargo fmt
BradleyOlson64 Jan 5, 2023
85db7c9
Implementers guide and code comments
BradleyOlson64 Jan 5, 2023
161122d
More formatting, and naming issues
BradleyOlson64 Jan 6, 2023
6a72033
Wrote test for ChainSelection side of change
BradleyOlson64 Jan 6, 2023
59e0453
Added dispute coordinator side test
BradleyOlson64 Jan 6, 2023
e12bfca
Merge branch 'master' of https://github.com/paritytech/polkadot into …
BradleyOlson64 Jan 6, 2023
682545d
FMT
BradleyOlson64 Jan 6, 2023
3b026ad
Merge branch 'master' of https://github.com/paritytech/polkadot into …
BradleyOlson64 Jan 9, 2023
87fc1f5
Addressing Marcin's comments
BradleyOlson64 Jan 9, 2023
013c4eb
fmt
BradleyOlson64 Jan 9, 2023
6442838
Addressing further Marcin comment
BradleyOlson64 Jan 9, 2023
bd6fe63
Removing unnecessary test line
BradleyOlson64 Jan 9, 2023
eff981b
Rough draft addressing Robert changes
BradleyOlson64 Jan 11, 2023
428e016
Clean up and test modification
BradleyOlson64 Jan 12, 2023
9f6f2ab
Majorly refactored scraper change
BradleyOlson64 Jan 13, 2023
5b89cf8
Minor fixes for ChainSelection
BradleyOlson64 Jan 13, 2023
d2454d8
Polish and fmt
BradleyOlson64 Jan 13, 2023
32b6f79
Condensing inclusions per candidate logic
BradleyOlson64 Jan 13, 2023
548e11b
Addressing Tsveto's comments
BradleyOlson64 Jan 16, 2023
bd283f0
Addressing Robert's Comments
BradleyOlson64 Jan 17, 2023
a257a1c
Altered inclusions struct to use nested BTreeMaps
BradleyOlson64 Jan 17, 2023
7c1149b
Naming fix
BradleyOlson64 Jan 17, 2023
a75cda3
Fixing inclusions struct comments
BradleyOlson64 Jan 17, 2023
992f240
Update node/core/dispute-coordinator/src/scraping/mod.rs
BradleyOlson64 Jan 17, 2023
492c7ed
Optimizing removal at block height for inclusions
BradleyOlson64 Jan 18, 2023
f6779cd
fmt
BradleyOlson64 Jan 18, 2023
f9b92fa
Using copy trait
BradleyOlson64 Jan 19, 2023
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
4 changes: 2 additions & 2 deletions node/core/chain-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use parity_scale_codec::Error as CodecError;
use std::{
sync::Arc,
time::{Duration, SystemTime, UNIX_EPOCH},
collections::HashSet,
};

use crate::backend::{Backend, BackendWriteOp, OverlayedBackend};
Expand Down Expand Up @@ -684,7 +683,8 @@ fn handle_approved_block(backend: &mut impl Backend, approved_block: Hash) -> Re
}

// Here we revert a provided group of blocks. The most common cause for this is that
// the dispute coordinator has notified chain selection
// the dispute coordinator has notified chain selection of a dispute which concluded
// against a candidate.
fn handle_revert_blocks(
backend: &impl Backend,
blocks_to_revert: Vec<(BlockNumber, Hash)>,
Expand Down
11 changes: 7 additions & 4 deletions node/core/chain-selection/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ fn stagnant_makes_childless_parent_leaf() {
}

#[test]
fn dispute_concluded_against_message_triggers_proper_reversion() {
fn revert_blocks_message_triggers_proper_reversion() {
test_harness(|backend, _, mut virtual_overseer| async move {
// Building mini chain with 1 finalized block and 3 unfinalized blocks
let finalized_number = 0;
Expand Down Expand Up @@ -2045,7 +2045,7 @@ fn dispute_concluded_against_message_triggers_proper_reversion() {
let (_, write_rx) = backend.await_next_write();
virtual_overseer
.send(FromOrchestra::Communication {
msg: ChainSelectionMessage::RevertBlocks(Vec::from({(2, block_2_hash)})),
msg: ChainSelectionMessage::RevertBlocks(Vec::from([(2, block_2_hash)])),
})
.await;

Expand Down Expand Up @@ -2080,7 +2080,7 @@ fn dispute_concluded_against_message_triggers_proper_reversion() {
}

#[test]
fn dispute_reversion_against_finalized_is_ignored() {
fn revert_blocks_against_finalized_is_ignored() {
test_harness(|backend, _, mut virtual_overseer| async move {
// Building mini chain with 1 finalized block and 3 unfinalized blocks
let finalized_number = 0;
Expand All @@ -2103,7 +2103,10 @@ fn dispute_reversion_against_finalized_is_ignored() {
// Sending dispute conculded against message
BradleyOlson64 marked this conversation as resolved.
Show resolved Hide resolved
virtual_overseer
.send(FromOrchestra::Communication {
msg: ChainSelectionMessage::RevertBlocks(Vec::from({(finalized_number, finalized_hash)})),
msg: ChainSelectionMessage::RevertBlocks(Vec::from([(
finalized_number,
finalized_hash,
)])),
})
.await;

Expand Down
1 change: 1 addition & 0 deletions node/core/chain-selection/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ fn propagate_viability_update(
*viability_pivots.entry(new_entry.parent_hash).or_insert(0) += 1;
}
}

backend.write_block_entry(new_entry);

tree_frontier
Expand Down
4 changes: 2 additions & 2 deletions node/core/dispute-coordinator/src/initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,11 +1036,11 @@ impl Initialized {
ctx.send_message(ChainSelectionMessage::RevertBlocks(blocks_to_revert.clone()))
.await;
} else {
gum::error!(
gum::trace!(
BradleyOlson64 marked this conversation as resolved.
Show resolved Hide resolved
target: LOG_TARGET,
?candidate_hash,
?session,
"Could not find parent block info for concluded candidate!"
"Could not find an including block for candidate against which a dispute has concluded."
BradleyOlson64 marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion node/core/dispute-coordinator/src/scraping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl ScrapedUpdates {

/// A structure meant to facilitate chain reversions in the event of a dispute
/// concluding against a candidate. Each candidate hash maps to a vector of block
/// numbers and hashes for all blocks which included the candidate. The entries
/// number + hash pairs for all blocks which included the candidate. The entries
/// in each vector are ordered by decreasing parent block number to facilitate
/// minimal cost pruning.
pub struct InclusionsPerCandidate {
Expand Down