mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 08:07:58 +00:00
integrate dispute finality (#3484)
* finality_target adjustments * fn finality_target * partially address review comments * fixins * more rustic if condition * fix tests * fixins * Update node/core/approval-voting/src/lib.rs Co-authored-by: Andronik Ordian <write@reusable.software> * Update node/core/approval-voting/src/lib.rs Co-authored-by: Robert Habermeier <rphmeier@gmail.com> * review comments part one * rename candidates -> block_descriptions * testing outline (incomplete, WIP) * test foo * split RelayChainSelection into RelayChainSelection{,WithFallback}, introduce HeaderProvider{,Provider} * make some stuff public (revert this soon™) * some test improvements * slips of pens * test fixins * add another trait abstraction * pending edge case tests + warnings fixes * more test cases * fin * chore fmt * fix cargo.lock * Undo obsolete changes * // comments * make mod pub(crate) * fix * minimize static bounds * resolve number() as before * fmt * post merge fix * address some nits Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: Robert Habermeier <rphmeier@gmail.com>
This commit is contained in:
committed by
GitHub
parent
bd9b743872
commit
6519ba987c
@@ -27,7 +27,7 @@ use polkadot_node_subsystem::{
|
||||
ApprovalVotingMessage, RuntimeApiMessage, RuntimeApiRequest, ChainApiMessage,
|
||||
ApprovalDistributionMessage, CandidateValidationMessage,
|
||||
AvailabilityRecoveryMessage, ChainSelectionMessage, DisputeCoordinatorMessage,
|
||||
ImportStatementsResult,
|
||||
ImportStatementsResult, HighestApprovedAncestorBlock, BlockDescription,
|
||||
},
|
||||
errors::RecoveryError,
|
||||
overseer::{self, SubsystemSender as _}, SubsystemContext, SubsystemError, SubsystemResult, SpawnedSubsystem,
|
||||
@@ -1180,7 +1180,7 @@ async fn handle_approved_ancestor(
|
||||
target: Hash,
|
||||
lower_bound: BlockNumber,
|
||||
wakeups: &Wakeups,
|
||||
) -> SubsystemResult<Option<(Hash, BlockNumber)>> {
|
||||
) -> SubsystemResult<Option<HighestApprovedAncestorBlock>> {
|
||||
const MAX_TRACING_WINDOW: usize = 200;
|
||||
const ABNORMAL_DEPTH_THRESHOLD: usize = 5;
|
||||
|
||||
@@ -1228,6 +1228,8 @@ async fn handle_approved_ancestor(
|
||||
Vec::new()
|
||||
};
|
||||
|
||||
let mut block_descriptions = Vec::new();
|
||||
|
||||
let mut bits: BitVec<Lsb0, u8> = Default::default();
|
||||
for (i, block_hash) in std::iter::once(target).chain(ancestry).enumerate() {
|
||||
// Block entries should be present as the assumption is that
|
||||
@@ -1259,8 +1261,10 @@ async fn handle_approved_ancestor(
|
||||
}
|
||||
} else if bits.len() <= ABNORMAL_DEPTH_THRESHOLD {
|
||||
all_approved_max = None;
|
||||
block_descriptions.clear();
|
||||
} else {
|
||||
all_approved_max = None;
|
||||
block_descriptions.clear();
|
||||
|
||||
let unapproved: Vec<_> = entry.unapproved_candidates().collect();
|
||||
tracing::debug!(
|
||||
@@ -1338,6 +1342,11 @@ async fn handle_approved_ancestor(
|
||||
}
|
||||
}
|
||||
}
|
||||
block_descriptions.push(BlockDescription {
|
||||
block_hash,
|
||||
session: entry.session(),
|
||||
candidates: entry.candidates().iter().map(|(_idx, candidate_hash)| *candidate_hash ).collect(),
|
||||
});
|
||||
}
|
||||
|
||||
tracing::trace!(
|
||||
@@ -1366,8 +1375,19 @@ async fn handle_approved_ancestor(
|
||||
},
|
||||
);
|
||||
|
||||
// `reverse()` to obtain the ascending order from lowest to highest
|
||||
// block within the candidates, which is the expected order
|
||||
block_descriptions.reverse();
|
||||
|
||||
let all_approved_max = all_approved_max.map(|(hash, block_number)| {
|
||||
HighestApprovedAncestorBlock{
|
||||
hash,
|
||||
number: block_number,
|
||||
descriptions: block_descriptions,
|
||||
}
|
||||
});
|
||||
match all_approved_max {
|
||||
Some((ref hash, ref number)) => {
|
||||
Some(HighestApprovedAncestorBlock { ref hash, ref number, .. }) => {
|
||||
span.add_uint_tag("approved-number", *number as u64);
|
||||
span.add_string_fmt_debug_tag("approved-hash", hash);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user