-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fixes/improvements for disputes #3753
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -582,12 +582,12 @@ async fn handle_incoming( | |
.await?; | ||
}, | ||
DisputeCoordinatorMessage::DetermineUndisputedChain { | ||
base_number, | ||
base: (base_number, base_hash), | ||
block_descriptions, | ||
tx, | ||
} => { | ||
let undisputed_chain = | ||
determine_undisputed_chain(overlay_db, base_number, block_descriptions)?; | ||
determine_undisputed_chain(overlay_db, base_number, base_hash, block_descriptions)?; | ||
|
||
let _ = tx.send(undisputed_chain); | ||
}, | ||
|
@@ -882,7 +882,7 @@ async fn issue_local_statement( | |
|
||
// Do import | ||
if !statements.is_empty() { | ||
let (pending_confirmation, _rx) = oneshot::channel(); | ||
let (pending_confirmation, rx) = oneshot::channel(); | ||
handle_import_statements( | ||
ctx, | ||
overlay_db, | ||
|
@@ -895,6 +895,32 @@ async fn issue_local_statement( | |
pending_confirmation, | ||
) | ||
.await?; | ||
match rx.await { | ||
Err(_) => { | ||
tracing::error!( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suspect these will get noisy. Metrics? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually no, those should not be noisy. The errors I would not expect to happen at all (hence errors) and the trace also only happens on |
||
target: LOG_TARGET, | ||
?candidate_hash, | ||
?session, | ||
"pending confirmation receiver got dropped by `handle_import_statements` for our own votes!" | ||
); | ||
}, | ||
Ok(ImportStatementsResult::InvalidImport) => { | ||
tracing::error!( | ||
target: LOG_TARGET, | ||
?candidate_hash, | ||
?session, | ||
"handle_import_statements` considers our own votes invalid!" | ||
); | ||
}, | ||
Ok(ImportStatementsResult::ValidImport) => { | ||
tracing::trace!( | ||
target: LOG_TARGET, | ||
?candidate_hash, | ||
?session, | ||
"handle_import_statements` successfully imported our vote!" | ||
); | ||
}, | ||
} | ||
} | ||
|
||
Ok(()) | ||
|
@@ -970,11 +996,13 @@ fn make_dispute_message( | |
fn determine_undisputed_chain( | ||
overlay_db: &mut OverlayedBackend<'_, impl Backend>, | ||
base_number: BlockNumber, | ||
base_hash: Hash, | ||
block_descriptions: Vec<BlockDescription>, | ||
) -> Result<Option<(BlockNumber, Hash)>, Error> { | ||
) -> Result<(BlockNumber, Hash), Error> { | ||
let last = block_descriptions | ||
.last() | ||
.map(|e| (base_number + block_descriptions.len() as BlockNumber, e.block_hash)); | ||
.map(|e| (base_number + block_descriptions.len() as BlockNumber, e.block_hash)) | ||
.unwrap_or((base_number, base_hash)); | ||
|
||
// Fast path for no disputes. | ||
let recent_disputes = match overlay_db.load_recent_disputes()? { | ||
|
@@ -992,12 +1020,9 @@ fn determine_undisputed_chain( | |
for (i, BlockDescription { session, candidates, .. }) in block_descriptions.iter().enumerate() { | ||
if candidates.iter().any(|c| is_possibly_invalid(*session, *c)) { | ||
if i == 0 { | ||
return Ok(None) | ||
return Ok((base_number, base_hash)) | ||
} else { | ||
return Ok(Some(( | ||
base_number + i as BlockNumber, | ||
block_descriptions[i - 1].block_hash, | ||
))) | ||
return Ok((base_number + i as BlockNumber, block_descriptions[i - 1].block_hash)) | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -434,7 +434,7 @@ where | |
overseer | ||
.send_msg( | ||
DisputeCoordinatorMessage::DetermineUndisputedChain { | ||
base_number: target_number, | ||
base: (target_number, target_hash), | ||
block_descriptions: subchain_block_descriptions, | ||
tx, | ||
}, | ||
|
@@ -444,8 +444,7 @@ where | |
let (subchain_number, subchain_head) = rx | ||
.await | ||
.map_err(Error::OverseerDisconnected) | ||
.map_err(|e| ConsensusError::Other(Box::new(e)))? | ||
.unwrap_or_else(|| (subchain_number, subchain_head)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we would previously use subchain_number/subchain_head in case we get There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it |
||
.map_err(|e| ConsensusError::Other(Box::new(e)))?; | ||
|
||
// The the total lag accounting for disputes. | ||
let lag_disputes = initial_leaf_number.saturating_sub(subchain_number); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: split this into
base_number
andbase_hash
instead on the messages already,base
is never used as tuple.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They really belong together, so I liked the grouping to highlight that relationship.