Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Fix all tests.
  • Loading branch information
eskimor committed Apr 13, 2022
commit b220963a58972cd32f42f7135b933ac38693073c
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/core/dispute-coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
assert_matches = "1.4.0"
test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" }
futures-timer = "3.0.2"

[features]
# If not enabled, the dispute coordinator will do nothing.
Expand Down
6 changes: 1 addition & 5 deletions node/core/dispute-coordinator/src/real/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use polkadot_node_subsystem::{
use polkadot_node_subsystem_util::{
database::Database, rolling_session_window::RollingSessionWindow,
};
use polkadot_primitives::v2::{ValidatorIndex, ValidatorPair, ScrapedOnChainVotes};
use polkadot_primitives::v2::{ScrapedOnChainVotes, ValidatorIndex, ValidatorPair};

use crate::{
error::{FatalResult, JfyiError, Result},
Expand Down Expand Up @@ -204,10 +204,6 @@ impl DisputeCoordinatorSubsystem {
},
};

// Before we move to the initialized state we need to check if we got at
// least on finality notification to prevent large ancestry block scraping,
// when the node is syncing.

let mut overlay_db = OverlayedBackend::new(&mut backend);
let (participations, votes, spam_slots, ordering_provider) = match self
.handle_startup(
Expand Down
7 changes: 7 additions & 0 deletions node/core/dispute-coordinator/src/real/participation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use std::collections::HashSet;
#[cfg(test)]
use std::time::Duration;

use futures::{
channel::{mpsc, oneshot},
FutureExt, SinkExt,
};
#[cfg(test)]
use futures_timer::Delay;

use polkadot_node_primitives::{ValidationResult, APPROVAL_EXECUTION_TIMEOUT};
use polkadot_node_subsystem::{
Expand Down Expand Up @@ -248,6 +252,9 @@ async fn participate(
block_hash: Hash,
req: ParticipationRequest,
) {
#[cfg(test)]
// Hack for tests, so we get recovery messages not too early.
Delay::new(Duration::from_millis(100)).await;
// in order to validate a candidate we need to start by recovering the
// available data
let (recover_available_data_tx, recover_available_data_rx) = oneshot::channel();
Expand Down
15 changes: 9 additions & 6 deletions node/core/dispute-coordinator/src/real/scraping/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,16 @@ impl ChainScraper {
.get_unfinalized_block_ancestors(sender, activated.hash, activated.number)
.await?;

gum::info!("After getting ancestors!");

// Ancestors block numbers are consecutive in the descending order.
let earliest_block_number = activated.number - ancestors.len() as u32;
let block_numbers = (earliest_block_number..=activated.number).rev();

let block_hashes = std::iter::once(activated.hash).chain(ancestors);

gum::info!("After getting relay parents!");

let mut on_chain_votes = Vec::new();
for (block_number, block_hash) in block_numbers.zip(block_hashes)
{
for (block_number, block_hash) in block_numbers.zip(block_hashes) {
gum::trace!(?block_number, ?block_hash, "In ancestor processesing.");

self.process_candidate_events(sender, block_number, block_hash).await?;

if let Some(votes) = get_on_chain_votes(sender, block_hash).await? {
Expand Down Expand Up @@ -181,6 +178,12 @@ impl ChainScraper {
});
for receipt in included {
let candidate_hash = receipt.hash();
gum::trace!(
target: LOG_TARGET,
?candidate_hash,
?block_number,
"Processing included event"
);
self.included_candidates.insert(candidate_hash);
self.candidates_by_block_number
.entry(block_number)
Expand Down
5 changes: 4 additions & 1 deletion node/core/dispute-coordinator/src/real/scraping/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ use polkadot_primitives::v2::{
GroupIndex, Hash, HashT, HeadData,
};

use crate::LOG_TARGET;

use super::ChainScraper;

type VirtualOverseer = TestSubsystemContextHandle<DisputeCoordinatorMessage>;
Expand Down Expand Up @@ -69,6 +71,7 @@ impl TestState {
let finalized_block_number = 0;
let overseer_fut = async {
assert_finalized_block_number_request(&mut ctx_handle, finalized_block_number).await;
gum::trace!(target: LOG_TARGET, "After assert_finalized_block_number");
// No ancestors requests, as list would be empty.
assert_candidate_events_request(&mut ctx_handle, &chain).await;
assert_chain_vote_request(&mut ctx_handle, &chain).await;
Expand All @@ -78,6 +81,7 @@ impl TestState {
.await
.0
.unwrap();
gum::trace!(target: LOG_TARGET, "After launching chain scraper");

let test_state = Self { chain, scraper, ctx };

Expand Down Expand Up @@ -224,7 +228,6 @@ async fn overseer_process_active_leaves_update(

#[test]
fn scraper_provides_included_state_when_initialized() {
sp_tracing::try_init_simple();
let candidate_1 = make_candidate_receipt(get_block_number_hash(1));
let candidate_2 = make_candidate_receipt(get_block_number_hash(2));
futures::executor::block_on(async {
Expand Down
Loading