mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-24 19:25:55 +00:00
core: revert grandpa authorities unless imported blocked is queued (#1508)
* core: revert grandpa authorities unless imported blocked is queued * core: fix deadlock in `GrandpaBlockImport`
This commit is contained in:
committed by
Robert Habermeier
parent
603392a9b9
commit
7ccd294de4
@@ -1104,18 +1104,27 @@ impl<B, E, Block: BlockT<Hash=H256>, RA, PRA> BlockImport<Block>
|
|||||||
// we don't want to finalize on `inner.import_block`
|
// we don't want to finalize on `inner.import_block`
|
||||||
let justification = block.justification.take();
|
let justification = block.justification.take();
|
||||||
let enacts_consensus_change = new_authorities.is_some();
|
let enacts_consensus_change = new_authorities.is_some();
|
||||||
let import_result = self.inner.import_block(block, new_authorities).map_err(|e| {
|
let import_result = self.inner.import_block(block, new_authorities);
|
||||||
if let Some((old_set, mut authorities)) = just_in_case {
|
|
||||||
debug!(target: "afg", "Restoring old set after block import error: {:?}", e);
|
|
||||||
*authorities = old_set;
|
|
||||||
}
|
|
||||||
e
|
|
||||||
});
|
|
||||||
|
|
||||||
let import_result = match import_result {
|
let import_result = {
|
||||||
Ok(ImportResult::Queued) => ImportResult::Queued,
|
// we scope this so that `just_in_case` is dropped eagerly and releases the authorities lock
|
||||||
Ok(r) => return Ok(r),
|
let revert_authorities = || if let Some((old_set, mut authorities)) = just_in_case {
|
||||||
Err(e) => return Err(ConsensusErrorKind::ClientImport(e.to_string()).into()),
|
*authorities = old_set;
|
||||||
|
};
|
||||||
|
|
||||||
|
match import_result {
|
||||||
|
Ok(ImportResult::Queued) => ImportResult::Queued,
|
||||||
|
Ok(r) => {
|
||||||
|
debug!(target: "afg", "Restoring old authority set after block import result: {:?}", r);
|
||||||
|
revert_authorities();
|
||||||
|
return Ok(r);
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
debug!(target: "afg", "Restoring old authority set after block import error: {:?}", e);
|
||||||
|
revert_authorities();
|
||||||
|
return Err(ConsensusErrorKind::ClientImport(e.to_string()).into());
|
||||||
|
},
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let enacts_change = self.authority_set.inner().read().enacts_change(number, |canon_number| {
|
let enacts_change = self.authority_set.inner().read().enacts_change(number, |canon_number| {
|
||||||
|
|||||||
Reference in New Issue
Block a user