mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 18:11:10 +00:00
Make BlockImport and Verifier async (#8472)
* Make grandpa work * Introduce `SharedData` * Add test and fix bugs * Switch to `SharedData` * Make grandpa tests working * More Babe work * Make it async * Fix fix * Use `async_trait` in sc-consensus-slots This makes the code a little bit easier to read and also expresses that there can always only be one call at a time to `on_slot`. * Make grandpa tests compile * More Babe tests work * Fix network test * Start fixing service test * Finish service-test * Fix sc-consensus-aura * Fix fix fix * More fixes * Make everything compile *yeah* * Fix build when we have Rust 1.51 * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/common/src/shared_data.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/babe/src/tests.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Update client/consensus/babe/src/tests.rs Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com> * Fix warning Co-authored-by: André Silva <123550+andresilva@users.noreply.github.com>
This commit is contained in:
@@ -534,7 +534,7 @@ pub fn new_light(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::{sync::Arc, borrow::Cow, any::Any, convert::TryInto};
|
||||
use std::{sync::Arc, borrow::Cow, convert::TryInto};
|
||||
use sc_consensus_babe::{CompatibleDigestItem, BabeIntermediate, INTERMEDIATE_KEY};
|
||||
use sc_consensus_epochs::descendent_query;
|
||||
use sp_consensus::{
|
||||
@@ -648,14 +648,14 @@ mod tests {
|
||||
&(slot * SLOT_DURATION),
|
||||
);
|
||||
|
||||
let epoch_descriptor = babe_link.epoch_changes().lock().epoch_descriptor_for_child_of(
|
||||
let epoch_descriptor = babe_link.epoch_changes().shared_data().epoch_descriptor_for_child_of(
|
||||
descendent_query(&*service.client()),
|
||||
&parent_hash,
|
||||
parent_number,
|
||||
slot.into(),
|
||||
).unwrap().unwrap();
|
||||
|
||||
let epoch = babe_link.epoch_changes().lock().epoch_data(
|
||||
let epoch = babe_link.epoch_changes().shared_data().epoch_data(
|
||||
&epoch_descriptor,
|
||||
|slot| sc_consensus_babe::Epoch::genesis(&babe_link.config(), slot),
|
||||
).unwrap();
|
||||
@@ -703,11 +703,11 @@ mod tests {
|
||||
params.body = Some(new_body);
|
||||
params.intermediates.insert(
|
||||
Cow::from(INTERMEDIATE_KEY),
|
||||
Box::new(BabeIntermediate::<Block> { epoch_descriptor }) as Box<dyn Any>,
|
||||
Box::new(BabeIntermediate::<Block> { epoch_descriptor }) as Box<_>,
|
||||
);
|
||||
params.fork_choice = Some(ForkChoiceStrategy::LongestChain);
|
||||
|
||||
block_import.import_block(params, Default::default())
|
||||
futures::executor::block_on(block_import.import_block(params, Default::default()))
|
||||
.expect("error importing test block");
|
||||
},
|
||||
|service, _| {
|
||||
|
||||
@@ -44,6 +44,7 @@ sp-runtime = { version = "3.0.0", path = "../../../primitives/runtime" }
|
||||
sp-externalities = { version = "0.9.0", path = "../../../primitives/externalities" }
|
||||
substrate-test-client = { version = "2.0.0", path = "../../../test-utils/client" }
|
||||
wat = "1.0"
|
||||
futures = "0.3.9"
|
||||
|
||||
[features]
|
||||
wasmtime = [
|
||||
|
||||
@@ -841,5 +841,5 @@ fn should_import_block_with_test_client() {
|
||||
let block_data = block1.0;
|
||||
let block = node_primitives::Block::decode(&mut &block_data[..]).unwrap();
|
||||
|
||||
client.import(BlockOrigin::Own, block).unwrap();
|
||||
futures::executor::block_on(client.import(BlockOrigin::Own, block)).unwrap();
|
||||
}
|
||||
|
||||
@@ -691,7 +691,7 @@ impl BenchContext {
|
||||
assert_eq!(self.client.chain_info().best_number, 0);
|
||||
|
||||
assert_eq!(
|
||||
self.client.import_block(import_params, Default::default())
|
||||
futures::executor::block_on(self.client.import_block(import_params, Default::default()))
|
||||
.expect("Failed to import block"),
|
||||
ImportResult::Imported(
|
||||
ImportedAux {
|
||||
|
||||
Reference in New Issue
Block a user