Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
21bd35d
Update polkadot
pepyakin Feb 2, 2021
1606eab
Migrate all uses of MQC heads to merkle proofs
pepyakin Jan 29, 2021
ca992ed
Mass rename `relay_parent_storage_root`
pepyakin Feb 2, 2021
9e0724a
Restore parachain-system tests
pepyakin Feb 3, 2021
4a179c2
Update polkadot and libp2p swarm for testing
pepyakin Feb 5, 2021
94fad6c
Collapse match into an if let
pepyakin Feb 8, 2021
a4c1e72
Merge remote-tracking branch 'origin/ser-clean-pvd' into bkchr-aura-t…
bkchr Feb 8, 2021
d6c5060
Start with something
bkchr Feb 8, 2021
d1d06f0
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long…
bkchr Feb 16, 2021
cf17fbd
Update Substrate & Polkadot
bkchr Feb 16, 2021
17916d8
Merge branch 'bkchr-update-substrate-and-poladkot2132434we' into bkch…
bkchr Feb 16, 2021
677dc54
Start to make it compile
bkchr Feb 16, 2021
007dfce
Make it compile
bkchr Feb 17, 2021
a8b4652
Begin with something
bkchr Feb 18, 2021
0fc1f08
Yep
bkchr Feb 19, 2021
c4d80d6
I'm a hacker
bkchr Feb 19, 2021
d56c303
Bring back the builder
bkchr Feb 19, 2021
4733bb2
Make it work in some way
bkchr Feb 19, 2021
e27ea7f
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long…
bkchr Feb 27, 2021
26ab50d
Compile
bkchr Mar 1, 2021
440a513
Parachains use their own "slot"
bkchr Mar 1, 2021
f6d891f
Adds cumulus-pallet-aura
bkchr Mar 1, 2021
f734351
Wrap AuRa import queue to disable equivocation checking by default
bkchr Mar 2, 2021
8c1f788
Pass slot duration
bkchr Mar 2, 2021
e670750
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long…
bkchr Mar 4, 2021
c876cf9
Check the seal when validating a block
bkchr Mar 4, 2021
ad8e06e
Adds missing file
bkchr Mar 4, 2021
a5b385c
Try to make the seal working
bkchr Mar 4, 2021
b3452b9
Fix it
bkchr Mar 5, 2021
edd65c4
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long…
bkchr Mar 16, 2021
e3d3607
Some fixes
bkchr Mar 16, 2021
2a3f53c
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long…
bkchr Mar 16, 2021
b65c69b
Bring in the latest features to cleanup the code
bkchr Mar 16, 2021
c3fce33
Update and make it compile
bkchr Mar 17, 2021
7a1dc09
Improve the import
bkchr Mar 17, 2021
0438a9c
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long…
bkchr May 4, 2021
9064c08
Start fixing
bkchr May 4, 2021
a651bd3
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long…
bkchr May 4, 2021
2d64c7c
More work
bkchr May 6, 2021
c8bbc6f
Fix fix fix
bkchr May 6, 2021
de10387
Make everything compile
bkchr May 6, 2021
9619b67
Merge remote-tracking branch 'origin/master' into bkchr-aura-the-long…
bkchr May 6, 2021
d14e281
Small cleanups
bkchr May 7, 2021
d78e910
Rename and more docs
bkchr May 8, 2021
033b657
Docs
bkchr May 8, 2021
b4a4790
Fixes fixes fixes
bkchr May 8, 2021
1b94f39
Update rococo-parachains/src/chain_spec.rs
bkchr May 8, 2021
fe62ccc
Update client/consensus/aura/src/lib.rs
bkchr May 10, 2021
2c0072b
Update client/consensus/aura/src/lib.rs
bkchr May 10, 2021
fe48de7
Update primitives/parachain-inherent/Cargo.toml
bkchr May 10, 2021
548d69a
Update primitives/parachain-inherent/Cargo.toml
bkchr May 10, 2021
911dc06
Update primitives/parachain-inherent/Cargo.toml
bkchr May 10, 2021
35ec124
Update primitives/parachain-inherent/Cargo.toml
bkchr May 10, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Begin with something
  • Loading branch information
bkchr committed Feb 18, 2021
commit a8b465287d48bcd64ad1498650c3e3faf7bc9191
64 changes: 60 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = [
"client/consensus/aura",
"client/consensus/common",
"client/consensus/relay-chain",
"client/network",
Expand Down
37 changes: 37 additions & 0 deletions client/consensus/aura/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[package]
name = "cumulus-client-consensus-aura"
description = "AURA consensus algorithm for parachains"
version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2018"

[dependencies]
# Substrate dependencies
sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-inherents = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-block-builder = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-aura = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-consensus-slots = { git = "https://github.com/paritytech/substrate", branch = "master" }
substrate-prometheus-endpoint = { git = "https://github.com/paritytech/substrate", branch = "master" }

# Polkadot dependencies
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master", features = [ "real-overseer" ] }

# Cumulus dependencies
cumulus-client-consensus-common = { path = "../common" }
cumulus-primitives-core = { path = "../../../primitives/core" }
cumulus-primitives-parachain-inherent = { path = "../../../primitives/parachain-inherent" }

# Other deps
futures = { version = "0.3.8", features = ["compat"] }
codec = { package = "parity-scale-codec", version = "2.0.0", features = [ "derive" ] }
tracing = "0.1.22"
async-trait = "0.1.42"
parking_lot = "0.9"
144 changes: 144 additions & 0 deletions client/consensus/aura/src/import_queue.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// Copyright 2019 Parity Technologies (UK) Ltd.
// This file is part of Cumulus.

// Cumulus is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Cumulus is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.

use std::{marker::PhantomData, sync::Arc};

use sp_api::ProvideRuntimeApi;
use sp_block_builder::BlockBuilder as BlockBuilderApi;
use sp_blockchain::Result as ClientResult;
use sp_consensus::{
error::Error as ConsensusError,
import_queue::{BasicQueue, CacheKeyId, Verifier as VerifierT},
BlockImport, BlockImportParams, BlockOrigin, ForkChoiceStrategy,
};
use sp_inherents::{CreateInherentDataProviders, InherentDataProvider};
use sp_runtime::{
generic::BlockId,
traits::{Block as BlockT, Header as HeaderT},
Justification,
};

/// A verifier that just checks the inherents.
struct Verifier<Client, Block, IDP> {
client: Arc<Client>,
inherent_data_providers: IDP,
_marker: PhantomData<Block>,
}

#[async_trait::async_trait]
impl<Client, Block, IDP> VerifierT<Block> for Verifier<Client, Block, IDP>
where
Block: BlockT,
Client: ProvideRuntimeApi<Block> + Send + Sync,
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block>,
IDP: CreateInherentDataProviders<Block, ()> + Send + Sync,
IDP::InherentDataProviders: Send + Sync,
{
async fn verify(
&mut self,
origin: BlockOrigin,
header: Block::Header,
justification: Option<Justification>,
mut body: Option<Vec<Block::Extrinsic>>,
) -> Result<
(
BlockImportParams<Block, ()>,
Option<Vec<(CacheKeyId, Vec<u8>)>>,
),
String,
> {
if let Some(inner_body) = body.take() {
let inherent_data_providers = self
.inherent_data_providers
.create_inherent_data_providers(*header.parent_hash(), ())
.await
.map_err(|e| e.to_string())?;

let inherent_data = inherent_data_providers
.create_inherent_data()
.map_err(|e| e.into_string())?;

let block = Block::new(header.clone(), inner_body);

let inherent_res = self
.client
.runtime_api()
.check_inherents(
&BlockId::Hash(*header.parent_hash()),
block.clone(),
inherent_data,
)
.map_err(|e| format!("{:?}", e))?;

if !inherent_res.ok() {
for (i, e) in inherent_res.into_errors() {
match inherent_data_providers.try_handle_error(&i, &e) {
Some(r) => r.await.map_err(|e| e.to_string())?,
None => todo!(),
}
}
}

let (_, inner_body) = block.deconstruct();
body = Some(inner_body);
}

let post_hash = Some(header.hash());
let mut block_import_params = BlockImportParams::new(origin, header);
block_import_params.body = body;
block_import_params.justification = justification;

// Best block is determined by the relay chain, or if we are doing the intial sync
// we import all blocks as new best.
block_import_params.fork_choice = Some(ForkChoiceStrategy::Custom(
origin == BlockOrigin::NetworkInitialSync,
));
block_import_params.post_hash = post_hash;

Ok((block_import_params, None))
}
}

/// Start an import queue for a Cumulus collator that does not uses any special authoring logic.
pub fn import_queue<Client, Block: BlockT, I, IDP>(
client: Arc<Client>,
block_import: I,
inherent_data_providers: IDP,
spawner: &impl sp_core::traits::SpawnNamed,
registry: Option<&substrate_prometheus_endpoint::Registry>,
) -> ClientResult<BasicQueue<Block, I::Transaction>>
where
I: BlockImport<Block, Error = ConsensusError> + Send + Sync + 'static,
I::Transaction: Send,
Client: ProvideRuntimeApi<Block> + Send + Sync + 'static,
<Client as ProvideRuntimeApi<Block>>::Api: BlockBuilderApi<Block>,
IDP: CreateInherentDataProviders<Block, ()> + Send + Sync + 'static,
IDP::InherentDataProviders: Send + Sync,
{
let verifier = Verifier {
client,
inherent_data_providers,
_marker: PhantomData,
};

Ok(BasicQueue::new(
verifier,
Box::new(block_import),
None,
spawner,
registry,
))
}
Loading