mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 12:35:42 +00:00
grandpa: don't use block_on in Environment::report_equivocation (#9154)
* grandpa: don't use block_on in Environment::report_equivocation * grandpa: add issue number to todo
This commit is contained in:
@@ -503,19 +503,19 @@ where
|
|||||||
|
|
||||||
let is_descendent_of = is_descendent_of(&*self.client, None);
|
let is_descendent_of = is_descendent_of(&*self.client, None);
|
||||||
|
|
||||||
// TODO: add proper async support here
|
let (best_block_hash, best_block_number) = {
|
||||||
let best_header = futures::executor::block_on(
|
// TODO [#9158]: Use SelectChain::best_chain() to get a potentially
|
||||||
self.select_chain
|
// more accurate best block
|
||||||
.best_chain()
|
let info = self.client.info();
|
||||||
.map_err(|e| Error::Blockchain(e.to_string())),
|
(info.best_hash, info.best_number)
|
||||||
)?;
|
};
|
||||||
|
|
||||||
let authority_set = self.authority_set.inner();
|
let authority_set = self.authority_set.inner();
|
||||||
|
|
||||||
// block hash and number of the next pending authority set change in the
|
// block hash and number of the next pending authority set change in the
|
||||||
// given best chain.
|
// given best chain.
|
||||||
let next_change = authority_set
|
let next_change = authority_set
|
||||||
.next_change(&best_header.hash(), &is_descendent_of)
|
.next_change(&best_block_hash, &is_descendent_of)
|
||||||
.map_err(|e| Error::Safety(e.to_string()))?;
|
.map_err(|e| Error::Safety(e.to_string()))?;
|
||||||
|
|
||||||
// find the hash of the latest block in the current set
|
// find the hash of the latest block in the current set
|
||||||
@@ -528,7 +528,7 @@ where
|
|||||||
// the next set starts at `n` so the current one lasts until `n - 1`. if
|
// the next set starts at `n` so the current one lasts until `n - 1`. if
|
||||||
// `n` is later than the best block, then the current set is still live
|
// `n` is later than the best block, then the current set is still live
|
||||||
// at best block.
|
// at best block.
|
||||||
Some((_, n)) if n > *best_header.number() => best_header.hash(),
|
Some((_, n)) if n > best_block_number => best_block_hash,
|
||||||
Some((h, _)) => {
|
Some((h, _)) => {
|
||||||
// this is the header at which the new set will start
|
// this is the header at which the new set will start
|
||||||
let header = self.client.header(BlockId::Hash(h))?.expect(
|
let header = self.client.header(BlockId::Hash(h))?.expect(
|
||||||
@@ -541,7 +541,7 @@ where
|
|||||||
}
|
}
|
||||||
// there is no pending change, the latest block for the current set is
|
// there is no pending change, the latest block for the current set is
|
||||||
// the best block.
|
// the best block.
|
||||||
None => best_header.hash(),
|
None => best_block_hash,
|
||||||
};
|
};
|
||||||
|
|
||||||
// generate key ownership proof at that block
|
// generate key ownership proof at that block
|
||||||
@@ -570,7 +570,7 @@ where
|
|||||||
self.client
|
self.client
|
||||||
.runtime_api()
|
.runtime_api()
|
||||||
.submit_report_equivocation_unsigned_extrinsic(
|
.submit_report_equivocation_unsigned_extrinsic(
|
||||||
&BlockId::Hash(best_header.hash()),
|
&BlockId::Hash(best_block_hash),
|
||||||
equivocation_proof,
|
equivocation_proof,
|
||||||
key_owner_proof,
|
key_owner_proof,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user