Skip to content

Commit 8a99730

Browse files
committed
Revert "Make BlockImport and Verifier async (paritytech#8472)"
This reverts commit 6098a2f.
1 parent f4eafe2 commit 8a99730

65 files changed

Lines changed: 714 additions & 1284 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ check-web-wasm:
340340
# Note: we don't need to test crates imported in `bin/node/cli`
341341
- time cargo build --manifest-path=client/consensus/aura/Cargo.toml --target=wasm32-unknown-unknown --features getrandom
342342
# Note: the command below is a bit weird because several Cargo issues prevent us from compiling the node in a more straight-forward way.
343-
- time cargo +nightly build --manifest-path=bin/node/cli/Cargo.toml --no-default-features --features browser --target=wasm32-unknown-unknown
343+
- time cargo +nightly build --manifest-path=bin/node/cli/Cargo.toml --no-default-features --features browser --target=wasm32-unknown-unknown -Z features=itarget
344344
# with-tracing must be explicitly activated, we run a test to ensure this works as expected in both cases
345345
- time cargo +nightly test --manifest-path primitives/tracing/Cargo.toml --no-default-features
346346
- time cargo +nightly test --manifest-path primitives/tracing/Cargo.toml --no-default-features --features=with-tracing
@@ -411,7 +411,7 @@ test-browser-node:
411411
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: "wasm-bindgen-test-runner"
412412
WASM_BINDGEN_TEST_TIMEOUT: 120
413413
script:
414-
- cargo +nightly test --target wasm32-unknown-unknown -p node-browser-testing
414+
- cargo +nightly test --target wasm32-unknown-unknown -p node-browser-testing -Z features=itarget
415415

416416
build-linux-substrate: &build-binary
417417
stage: build

Cargo.lock

Lines changed: 6 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
[workspace]
2-
resolver = "2"
3-
42
members = [
53
"bin/node-template/node",
64
"bin/node-template/pallets/template",

bin/node-template/pallets/template/src/benchmarking.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

bin/node/cli/src/service.rs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ pub fn new_light(
534534

535535
#[cfg(test)]
536536
mod tests {
537-
use std::{sync::Arc, borrow::Cow, convert::TryInto};
537+
use std::{sync::Arc, borrow::Cow, any::Any, convert::TryInto};
538538
use sc_consensus_babe::{CompatibleDigestItem, BabeIntermediate, INTERMEDIATE_KEY};
539539
use sc_consensus_epochs::descendent_query;
540540
use sp_consensus::{
@@ -649,25 +649,9 @@ mod tests {
649649

650650
// even though there's only one authority some slots might be empty,
651651
// so we must keep trying the next slots until we can claim one.
652-
let (babe_pre_digest, epoch_descriptor) = loop {
653-
inherent_data.replace_data(
654-
sp_timestamp::INHERENT_IDENTIFIER,
655-
&(slot * SLOT_DURATION),
656-
);
657-
658-
let epoch_descriptor = babe_link.epoch_changes().shared_data().epoch_descriptor_for_child_of(
659-
descendent_query(&*service.client()),
660-
&parent_hash,
661-
parent_number,
662-
slot.into(),
663-
).unwrap().unwrap();
664-
665-
let epoch = babe_link.epoch_changes().shared_data().epoch_data(
666-
&epoch_descriptor,
667-
|slot| sc_consensus_babe::Epoch::genesis(&babe_link.config(), slot),
668-
).unwrap();
669-
670-
if let Some(babe_pre_digest) = sc_consensus_babe::authorship::claim_slot(
652+
let babe_pre_digest = loop {
653+
inherent_data.replace_data(sp_timestamp::INHERENT_IDENTIFIER, &(slot * SLOT_DURATION));
654+
if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot(
671655
slot.into(),
672656
&parent_header,
673657
&*service.client(),
@@ -712,11 +696,11 @@ mod tests {
712696
params.body = Some(new_body);
713697
params.intermediates.insert(
714698
Cow::from(INTERMEDIATE_KEY),
715-
Box::new(BabeIntermediate::<Block> { epoch_descriptor }) as Box<_>,
699+
Box::new(BabeIntermediate::<Block> { epoch_descriptor }) as Box<dyn Any>,
716700
);
717701
params.fork_choice = Some(ForkChoiceStrategy::LongestChain);
718702

719-
futures::executor::block_on(block_import.import_block(params, Default::default()))
703+
block_import.import_block(params, Default::default())
720704
.expect("error importing test block");
721705
},
722706
|service, _| {

bin/node/executor/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ sp-runtime = { version = "3.0.0", path = "../../../primitives/runtime" }
4444
sp-externalities = { version = "0.9.0", path = "../../../primitives/externalities" }
4545
substrate-test-client = { version = "2.0.0", path = "../../../test-utils/client" }
4646
wat = "1.0"
47-
futures = "0.3.9"
4847

4948
[features]
5049
wasmtime = [

bin/node/executor/tests/basic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,5 +823,5 @@ fn should_import_block_with_test_client() {
823823
let block_data = block1.0;
824824
let block = node_primitives::Block::decode(&mut &block_data[..]).unwrap();
825825

826-
futures::executor::block_on(client.import(BlockOrigin::Own, block)).unwrap();
826+
client.import(BlockOrigin::Own, block).unwrap();
827827
}

bin/node/testing/src/bench.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ impl BenchContext {
690690
assert_eq!(self.client.chain_info().best_number, 0);
691691

692692
assert_eq!(
693-
futures::executor::block_on(self.client.import_block(import_params, Default::default()))
693+
self.client.import_block(import_params, Default::default())
694694
.expect("Failed to import block"),
695695
ImportResult::Imported(
696696
ImportedAux {

client/basic-authorship/src/basic_authorship.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ mod tests {
420420
use sp_blockchain::HeaderBackend;
421421
use sp_runtime::traits::NumberFor;
422422
use sc_client_api::Backend;
423-
use futures::executor::block_on;
424423

425424
const SOURCE: TransactionSource = TransactionSource::External;
426425

@@ -455,11 +454,11 @@ mod tests {
455454
client.clone(),
456455
);
457456

458-
block_on(
457+
futures::executor::block_on(
459458
txpool.submit_at(&BlockId::number(0), SOURCE, vec![extrinsic(0), extrinsic(1)])
460459
).unwrap();
461460

462-
block_on(
461+
futures::executor::block_on(
463462
txpool.maintain(chain_event(
464463
client.header(&BlockId::Number(0u64))
465464
.expect("header get error")
@@ -493,7 +492,7 @@ mod tests {
493492

494493
// when
495494
let deadline = time::Duration::from_secs(3);
496-
let block = block_on(
495+
let block = futures::executor::block_on(
497496
proposer.propose(Default::default(), Default::default(), deadline)
498497
).map(|r| r.block).unwrap();
499498

@@ -539,7 +538,7 @@ mod tests {
539538
);
540539

541540
let deadline = time::Duration::from_secs(1);
542-
block_on(
541+
futures::executor::block_on(
543542
proposer.propose(Default::default(), Default::default(), deadline)
544543
).map(|r| r.block).unwrap();
545544
}
@@ -560,11 +559,11 @@ mod tests {
560559
let genesis_hash = client.info().best_hash;
561560
let block_id = BlockId::Hash(genesis_hash);
562561

563-
block_on(
562+
futures::executor::block_on(
564563
txpool.submit_at(&BlockId::number(0), SOURCE, vec![extrinsic(0)]),
565564
).unwrap();
566565

567-
block_on(
566+
futures::executor::block_on(
568567
txpool.maintain(chain_event(
569568
client.header(&BlockId::Number(0u64))
570569
.expect("header get error")
@@ -586,7 +585,7 @@ mod tests {
586585
);
587586

588587
let deadline = time::Duration::from_secs(9);
589-
let proposal = block_on(
588+
let proposal = futures::executor::block_on(
590589
proposer.propose(Default::default(), Default::default(), deadline),
591590
).unwrap();
592591

@@ -626,7 +625,7 @@ mod tests {
626625
client.clone(),
627626
);
628627

629-
block_on(
628+
futures::executor::block_on(
630629
txpool.submit_at(&BlockId::number(0), SOURCE, vec![
631630
extrinsic(0),
632631
extrinsic(1),
@@ -668,7 +667,7 @@ mod tests {
668667

669668
// when
670669
let deadline = time::Duration::from_secs(9);
671-
let block = block_on(
670+
let block = futures::executor::block_on(
672671
proposer.propose(Default::default(), Default::default(), deadline)
673672
).map(|r| r.block).unwrap();
674673

@@ -680,7 +679,7 @@ mod tests {
680679
block
681680
};
682681

683-
block_on(
682+
futures::executor::block_on(
684683
txpool.maintain(chain_event(
685684
client.header(&BlockId::Number(0u64))
686685
.expect("header get error")
@@ -690,9 +689,9 @@ mod tests {
690689

691690
// let's create one block and import it
692691
let block = propose_block(&client, 0, 2, 7);
693-
block_on(client.import(BlockOrigin::Own, block)).unwrap();
692+
client.import(BlockOrigin::Own, block).unwrap();
694693

695-
block_on(
694+
futures::executor::block_on(
696695
txpool.maintain(chain_event(
697696
client.header(&BlockId::Number(1))
698697
.expect("header get error")
@@ -702,6 +701,6 @@ mod tests {
702701

703702
// now let's make sure that we can still make some progress
704703
let block = propose_block(&client, 1, 2, 5);
705-
block_on(client.import(BlockOrigin::Own, block)).unwrap();
704+
client.import(BlockOrigin::Own, block).unwrap();
706705
}
707706
}

client/consensus/aura/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ futures = "0.3.9"
2626
futures-timer = "3.0.1"
2727
sp-inherents = { version = "3.0.0", path = "../../../primitives/inherents" }
2828
log = "0.4.8"
29+
parking_lot = "0.11.1"
2930
sp-core = { version = "3.0.0", path = "../../../primitives/core" }
3031
sp-blockchain = { version = "3.0.0", path = "../../../primitives/blockchain" }
3132
sp-io = { version = "3.0.0", path = "../../../primitives/io" }
@@ -37,7 +38,6 @@ sp-timestamp = { version = "3.0.0", path = "../../../primitives/timestamp" }
3738
sp-keystore = { version = "0.9.0", path = "../../../primitives/keystore" }
3839
sc-telemetry = { version = "3.0.0", path = "../../telemetry" }
3940
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.9.0"}
40-
async-trait = "0.1.42"
4141
# We enable it only for web-wasm check
4242
# See https://docs.rs/getrandom/0.2.1/getrandom/#webassembly-support
4343
getrandom = { version = "0.2", features = ["js"], optional = true }
@@ -52,4 +52,3 @@ sc-network-test = { version = "0.8.0", path = "../../network/test" }
5252
sc-service = { version = "0.9.0", default-features = false, path = "../../service" }
5353
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
5454
tempfile = "3.1.0"
55-
parking_lot = "0.11.1"

0 commit comments

Comments
 (0)