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

Rework dispute-coordinator to use RuntimeInfo for obtaining session information instead of RollingSessionWindow #6968

Merged
merged 42 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
5e6e720
Pass `SessionInfo` directly to `CandidateEnvironment::new` otherwise …
tdimitrov Mar 26, 2023
2e8f1ec
Replace calls to `RollingSessionWindow` with `RuntimeInfo`
tdimitrov Mar 27, 2023
0fe349b
Modify `dispute-coordinator` initialization
tdimitrov Mar 27, 2023
bd4e7b6
Pass `Hash` to `process_on_chain_votes` so that `RuntimeInfo` calls c…
tdimitrov Mar 27, 2023
bdd43a5
Pass `Hash` to `handle_import_statements` to perform `RuntimeInfo` calls
tdimitrov Mar 27, 2023
1f16bc5
remove todo comments
tdimitrov Mar 27, 2023
00d3655
Remove `error` from `Initialized`
tdimitrov Mar 28, 2023
d9fa73e
Remove db code which is no longer used
tdimitrov Mar 28, 2023
e34dbcf
Update stale comment and remove unneeded type specification
tdimitrov Mar 28, 2023
234581f
Cache SessionInfo on startup
tdimitrov Mar 29, 2023
7e2a549
Use `DISPUTE_WINDOW` from primitives
tdimitrov Mar 29, 2023
8f8b427
Fix caching in `process_active_leaves_update`
tdimitrov Mar 29, 2023
903e3b2
handle_import_statements: leaf_hash -> block_hash
tdimitrov Mar 29, 2023
ab6a7cf
Restore `ensure_available_session_info`
tdimitrov Mar 29, 2023
493f006
Don't interrupt `process_on_chain_votes` if SessionInfo can't be fetched
tdimitrov Mar 29, 2023
4212016
Small style improvements in logging
tdimitrov Mar 29, 2023
16d4647
process_on_chain_votes: leaf_hash -> block_hash
tdimitrov Mar 29, 2023
c2775a6
Restore `note_earliest_session` - it is required to prune disputes an…
tdimitrov Mar 30, 2023
c027da3
Cache new sessions only when there is an actual session change
tdimitrov Mar 31, 2023
5ad4319
Fix tests
tdimitrov Mar 31, 2023
5b0c103
`CandidateEnvironment::new` gets `session_idx` and fetches SessionInf…
tdimitrov Apr 1, 2023
41be7ae
Fix handling of missing session info
tdimitrov Apr 1, 2023
eb01fe5
Move sessions caching in `handle_startup` and fix tests
tdimitrov Apr 1, 2023
3581e34
Load `relay_parent` from db in `handle_import_statements` instead of …
tdimitrov Apr 3, 2023
dbae23c
Don't do two db reads
tdimitrov Apr 3, 2023
866e4e6
Fix the twisted logic in `handle_import_statements`
tdimitrov Apr 4, 2023
6ba8b4f
fixup
tdimitrov Apr 4, 2023
f248b20
Small style fix
tdimitrov Apr 4, 2023
9fdd14a
Merge branch 'master' into tsv-rolling-session-dispute-coord
tdimitrov Apr 4, 2023
7010b0a
Decrease log levels for caching errors to debug and fix a typo
tdimitrov Apr 4, 2023
0349473
Update outdated comment
tdimitrov Apr 5, 2023
fd865f0
Remove `ensure_available_session_info`
tdimitrov Apr 5, 2023
978ad4f
Load relay parent from db in `process_on_chain_votes`
tdimitrov Apr 5, 2023
b65ff6e
Revert "Load relay parent from db in `process_on_chain_votes`"
tdimitrov Apr 5, 2023
71e2b7b
Keep track of highest seen session and last session cached without gaps.
tdimitrov Apr 5, 2023
8466d15
Apply suggestions from code review
tdimitrov Apr 12, 2023
e0ebe59
Handle session caching failure on startup correctly
tdimitrov Apr 12, 2023
838dda0
Update node/core/dispute-coordinator/src/initialized.rs
tdimitrov Apr 12, 2023
358f480
Simplify session caching retries
tdimitrov Apr 12, 2023
a7981b8
Update stale comment
tdimitrov Apr 12, 2023
9a47ca6
Fix lower bound calculation for session caching
tdimitrov Apr 15, 2023
055d8a1
Merge remote-tracking branch 'origin/master' into tsv-rolling-session…
tdimitrov Apr 24, 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
6 changes: 3 additions & 3 deletions node/core/dispute-coordinator/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use fatality::Nested;
use futures::channel::oneshot;

use polkadot_node_subsystem::{errors::ChainApiError, SubsystemError};
use polkadot_node_subsystem_util::{rolling_session_window::SessionsUnavailable, runtime};
use polkadot_node_subsystem_util::runtime;

use crate::{db, participation, LOG_TARGET};
use parity_scale_codec::Error as CodecError;
Expand Down Expand Up @@ -96,8 +96,8 @@ pub enum Error {
Codec(#[from] CodecError),

/// `RollingSessionWindow` was not able to retrieve `SessionInfo`s.
#[error("Sessions unavailable in `RollingSessionWindow`: {0}")]
RollingSessionWindow(#[from] SessionsUnavailable),
#[error("Session can't be fetched via `RuntimeInfo`")]
SessionInfo,

#[error(transparent)]
QueueError(#[from] participation::QueueError),
Expand Down
28 changes: 20 additions & 8 deletions node/core/dispute-coordinator/src/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ use std::collections::{BTreeMap, HashMap, HashSet};
use polkadot_node_primitives::{
disputes::ValidCandidateVotes, CandidateVotes, DisputeStatus, SignedDisputeStatement, Timestamp,
};
use polkadot_node_subsystem_util::rolling_session_window::RollingSessionWindow;
use polkadot_node_subsystem::overseer;
use polkadot_node_subsystem_util::runtime::RuntimeInfo;
use polkadot_primitives::{
CandidateReceipt, DisputeStatement, IndexedVec, SessionIndex, SessionInfo,
CandidateReceipt, DisputeStatement, Hash, IndexedVec, SessionIndex, SessionInfo,
ValidDisputeStatementKind, ValidatorId, ValidatorIndex, ValidatorPair, ValidatorSignature,
};
use sc_keystore::LocalKeystore;
Expand All @@ -50,18 +51,29 @@ pub struct CandidateEnvironment<'a> {
controlled_indices: HashSet<ValidatorIndex>,
}

#[overseer::contextbounds(DisputeCoordinator, prefix = self::overseer)]
impl<'a> CandidateEnvironment<'a> {
/// Create `CandidateEnvironment`.
///
/// Return: `None` in case session is outside of session window.
pub fn new(
pub async fn new<Context>(
keystore: &LocalKeystore,
session_window: &'a RollingSessionWindow,
ctx: &mut Context,
runtime_info: &'a mut RuntimeInfo,
session_index: SessionIndex,
) -> Option<Self> {
let session = session_window.session_info(session_index)?;
let controlled_indices = find_controlled_validator_indices(keystore, &session.validators);
Some(Self { session_index, session, controlled_indices })
relay_parent: Hash,
) -> Option<CandidateEnvironment<'a>> {
let session_info = match runtime_info
.get_session_info_by_index(ctx.sender(), relay_parent, session_index)
.await
{
Ok(extended_session_info) => &extended_session_info.session_info,
Err(_) => return None,
};

let controlled_indices =
find_controlled_validator_indices(keystore, &session_info.validators);
Some(Self { session_index, session: session_info, controlled_indices })
}

/// Validators in the candidate's session.
Expand Down
Loading