Skip to content

Commit

Permalink
Revert "Make BlockImport and Verifier async (paritytech#8472)"
Browse files Browse the repository at this point in the history
This reverts commit 6098a2f.
  • Loading branch information
jordy25519 committed Sep 17, 2021
1 parent f4eafe2 commit 8a99730
Show file tree
Hide file tree
Showing 65 changed files with 714 additions and 1,284 deletions.
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ check-web-wasm:
# Note: we don't need to test crates imported in `bin/node/cli`
- time cargo build --manifest-path=client/consensus/aura/Cargo.toml --target=wasm32-unknown-unknown --features getrandom
# Note: the command below is a bit weird because several Cargo issues prevent us from compiling the node in a more straight-forward way.
- time cargo +nightly build --manifest-path=bin/node/cli/Cargo.toml --no-default-features --features browser --target=wasm32-unknown-unknown
- time cargo +nightly build --manifest-path=bin/node/cli/Cargo.toml --no-default-features --features browser --target=wasm32-unknown-unknown -Z features=itarget
# with-tracing must be explicitly activated, we run a test to ensure this works as expected in both cases
- time cargo +nightly test --manifest-path primitives/tracing/Cargo.toml --no-default-features
- time cargo +nightly test --manifest-path primitives/tracing/Cargo.toml --no-default-features --features=with-tracing
Expand Down Expand Up @@ -411,7 +411,7 @@ test-browser-node:
CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER: "wasm-bindgen-test-runner"
WASM_BINDGEN_TEST_TIMEOUT: 120
script:
- cargo +nightly test --target wasm32-unknown-unknown -p node-browser-testing
- cargo +nightly test --target wasm32-unknown-unknown -p node-browser-testing -Z features=itarget

build-linux-substrate: &build-binary
stage: build
Expand Down
24 changes: 6 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
[workspace]
resolver = "2"

members = [
"bin/node-template/node",
"bin/node-template/pallets/template",
Expand Down
24 changes: 0 additions & 24 deletions bin/node-template/pallets/template/src/benchmarking.rs

This file was deleted.

28 changes: 6 additions & 22 deletions bin/node/cli/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ pub fn new_light(

#[cfg(test)]
mod tests {
use std::{sync::Arc, borrow::Cow, convert::TryInto};
use std::{sync::Arc, borrow::Cow, any::Any, convert::TryInto};
use sc_consensus_babe::{CompatibleDigestItem, BabeIntermediate, INTERMEDIATE_KEY};
use sc_consensus_epochs::descendent_query;
use sp_consensus::{
Expand Down Expand Up @@ -649,25 +649,9 @@ mod tests {

// even though there's only one authority some slots might be empty,
// so we must keep trying the next slots until we can claim one.
let (babe_pre_digest, epoch_descriptor) = loop {
inherent_data.replace_data(
sp_timestamp::INHERENT_IDENTIFIER,
&(slot * SLOT_DURATION),
);

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().shared_data().epoch_data(
&epoch_descriptor,
|slot| sc_consensus_babe::Epoch::genesis(&babe_link.config(), slot),
).unwrap();

if let Some(babe_pre_digest) = sc_consensus_babe::authorship::claim_slot(
let babe_pre_digest = loop {
inherent_data.replace_data(sp_timestamp::INHERENT_IDENTIFIER, &(slot * SLOT_DURATION));
if let Some(babe_pre_digest) = sc_consensus_babe::test_helpers::claim_slot(
slot.into(),
&parent_header,
&*service.client(),
Expand Down Expand Up @@ -712,11 +696,11 @@ mod tests {
params.body = Some(new_body);
params.intermediates.insert(
Cow::from(INTERMEDIATE_KEY),
Box::new(BabeIntermediate::<Block> { epoch_descriptor }) as Box<_>,
Box::new(BabeIntermediate::<Block> { epoch_descriptor }) as Box<dyn Any>,
);
params.fork_choice = Some(ForkChoiceStrategy::LongestChain);

futures::executor::block_on(block_import.import_block(params, Default::default()))
block_import.import_block(params, Default::default())
.expect("error importing test block");
},
|service, _| {
Expand Down
1 change: 0 additions & 1 deletion bin/node/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ 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 = [
Expand Down
2 changes: 1 addition & 1 deletion bin/node/executor/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -823,5 +823,5 @@ fn should_import_block_with_test_client() {
let block_data = block1.0;
let block = node_primitives::Block::decode(&mut &block_data[..]).unwrap();

futures::executor::block_on(client.import(BlockOrigin::Own, block)).unwrap();
client.import(BlockOrigin::Own, block).unwrap();
}
2 changes: 1 addition & 1 deletion bin/node/testing/src/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ impl BenchContext {
assert_eq!(self.client.chain_info().best_number, 0);

assert_eq!(
futures::executor::block_on(self.client.import_block(import_params, Default::default()))
self.client.import_block(import_params, Default::default())
.expect("Failed to import block"),
ImportResult::Imported(
ImportedAux {
Expand Down
27 changes: 13 additions & 14 deletions client/basic-authorship/src/basic_authorship.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ mod tests {
use sp_blockchain::HeaderBackend;
use sp_runtime::traits::NumberFor;
use sc_client_api::Backend;
use futures::executor::block_on;

const SOURCE: TransactionSource = TransactionSource::External;

Expand Down Expand Up @@ -455,11 +454,11 @@ mod tests {
client.clone(),
);

block_on(
futures::executor::block_on(
txpool.submit_at(&BlockId::number(0), SOURCE, vec![extrinsic(0), extrinsic(1)])
).unwrap();

block_on(
futures::executor::block_on(
txpool.maintain(chain_event(
client.header(&BlockId::Number(0u64))
.expect("header get error")
Expand Down Expand Up @@ -493,7 +492,7 @@ mod tests {

// when
let deadline = time::Duration::from_secs(3);
let block = block_on(
let block = futures::executor::block_on(
proposer.propose(Default::default(), Default::default(), deadline)
).map(|r| r.block).unwrap();

Expand Down Expand Up @@ -539,7 +538,7 @@ mod tests {
);

let deadline = time::Duration::from_secs(1);
block_on(
futures::executor::block_on(
proposer.propose(Default::default(), Default::default(), deadline)
).map(|r| r.block).unwrap();
}
Expand All @@ -560,11 +559,11 @@ mod tests {
let genesis_hash = client.info().best_hash;
let block_id = BlockId::Hash(genesis_hash);

block_on(
futures::executor::block_on(
txpool.submit_at(&BlockId::number(0), SOURCE, vec![extrinsic(0)]),
).unwrap();

block_on(
futures::executor::block_on(
txpool.maintain(chain_event(
client.header(&BlockId::Number(0u64))
.expect("header get error")
Expand All @@ -586,7 +585,7 @@ mod tests {
);

let deadline = time::Duration::from_secs(9);
let proposal = block_on(
let proposal = futures::executor::block_on(
proposer.propose(Default::default(), Default::default(), deadline),
).unwrap();

Expand Down Expand Up @@ -626,7 +625,7 @@ mod tests {
client.clone(),
);

block_on(
futures::executor::block_on(
txpool.submit_at(&BlockId::number(0), SOURCE, vec![
extrinsic(0),
extrinsic(1),
Expand Down Expand Up @@ -668,7 +667,7 @@ mod tests {

// when
let deadline = time::Duration::from_secs(9);
let block = block_on(
let block = futures::executor::block_on(
proposer.propose(Default::default(), Default::default(), deadline)
).map(|r| r.block).unwrap();

Expand All @@ -680,7 +679,7 @@ mod tests {
block
};

block_on(
futures::executor::block_on(
txpool.maintain(chain_event(
client.header(&BlockId::Number(0u64))
.expect("header get error")
Expand All @@ -690,9 +689,9 @@ mod tests {

// let's create one block and import it
let block = propose_block(&client, 0, 2, 7);
block_on(client.import(BlockOrigin::Own, block)).unwrap();
client.import(BlockOrigin::Own, block).unwrap();

block_on(
futures::executor::block_on(
txpool.maintain(chain_event(
client.header(&BlockId::Number(1))
.expect("header get error")
Expand All @@ -702,6 +701,6 @@ mod tests {

// now let's make sure that we can still make some progress
let block = propose_block(&client, 1, 2, 5);
block_on(client.import(BlockOrigin::Own, block)).unwrap();
client.import(BlockOrigin::Own, block).unwrap();
}
}
3 changes: 1 addition & 2 deletions client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ futures = "0.3.9"
futures-timer = "3.0.1"
sp-inherents = { version = "3.0.0", path = "../../../primitives/inherents" }
log = "0.4.8"
parking_lot = "0.11.1"
sp-core = { version = "3.0.0", path = "../../../primitives/core" }
sp-blockchain = { version = "3.0.0", path = "../../../primitives/blockchain" }
sp-io = { version = "3.0.0", path = "../../../primitives/io" }
Expand All @@ -37,7 +38,6 @@ sp-timestamp = { version = "3.0.0", path = "../../../primitives/timestamp" }
sp-keystore = { version = "0.9.0", path = "../../../primitives/keystore" }
sc-telemetry = { version = "3.0.0", path = "../../telemetry" }
prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../../utils/prometheus", version = "0.9.0"}
async-trait = "0.1.42"
# We enable it only for web-wasm check
# See https://docs.rs/getrandom/0.2.1/getrandom/#webassembly-support
getrandom = { version = "0.2", features = ["js"], optional = true }
Expand All @@ -52,4 +52,3 @@ sc-network-test = { version = "0.8.0", path = "../../network/test" }
sc-service = { version = "0.9.0", default-features = false, path = "../../service" }
substrate-test-runtime-client = { version = "2.0.0", path = "../../../test-utils/runtime/client" }
tempfile = "3.1.0"
parking_lot = "0.11.1"
Loading

0 comments on commit 8a99730

Please sign in to comment.