Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Generalize the Consensus Infrastructure (#883)
Browse files Browse the repository at this point in the history
* Split out Consensus
* Supply ImportQueue through network-service
  - simplify ImportQueue.import_blocks
  - remove Deadlock on import_block
  - Adding Verifier-Trait
  - Implement import_queue provisioning in service; allow cli to import
* Allow to actually customize import queue
* Consensus Gossip: Cache Message hash per Topic
  • Loading branch information
gnunicorn authored Oct 16, 2018
1 parent 15e955d commit 14ff8f9
Show file tree
Hide file tree
Showing 61 changed files with 1,861 additions and 3,230 deletions.
1,624 changes: 828 additions & 796 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ vergen = "2"

[workspace]
members = [
"core/bft",
"core/cli",
"core/client",
"core/client/db",
"core/consensus/common",
"core/consensus/rhd",
"core/executor",
"core/finality-grandpa",
"core/keyring",
"core/misbehavior-check",
"core/network",
"core/primitives",
"core/rpc",
Expand Down
20 changes: 0 additions & 20 deletions core/bft/Cargo.toml

This file was deleted.

13 changes: 0 additions & 13 deletions core/bft/README.adoc

This file was deleted.

2 changes: 1 addition & 1 deletion core/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hex-literal = "0.1"
futures = "0.1.17"
slog = "^2"
heapsize = "0.4"
substrate-bft = { path = "../bft" }
substrate-consensus-rhd = { path = "../consensus/rhd" }
parity-codec = "2.0"
substrate-executor = { path = "../executor" }
substrate-primitives = { path = "../primitives" }
Expand Down
9 changes: 4 additions & 5 deletions core/client/db/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ use kvdb::{KeyValueDB, DBTransaction};
use trie::MemoryDB;
use parking_lot::RwLock;
use primitives::{H256, AuthorityId, Blake2Hasher};
use runtime_primitives::generic::BlockId;
use runtime_primitives::bft::Justification;
use runtime_primitives::{generic::BlockId, Justification};
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, As, NumberFor, Zero, Digest, DigestItem};
use runtime_primitives::BuildStorage;
use state_machine::backend::Backend as StateBackend;
Expand Down Expand Up @@ -127,7 +126,7 @@ mod columns {

struct PendingBlock<Block: BlockT> {
header: Block::Header,
justification: Option<Justification<Block::Hash>>,
justification: Option<Justification>,
body: Option<Vec<Block::Extrinsic>>,
leaf_state: NewBlockState,
}
Expand Down Expand Up @@ -241,7 +240,7 @@ impl<Block: BlockT> client::blockchain::Backend<Block> for BlockchainDb<Block> {
}
}

fn justification(&self, id: BlockId<Block>) -> Result<Option<Justification<Block::Hash>>, client::error::Error> {
fn justification(&self, id: BlockId<Block>) -> Result<Option<Justification>, client::error::Error> {
match read_db(&*self.db, columns::HASH_LOOKUP, columns::JUSTIFICATION, id)? {
Some(justification) => match Decode::decode(&mut &justification[..]) {
Some(justification) => Ok(Some(justification)),
Expand Down Expand Up @@ -286,7 +285,7 @@ where Block: BlockT,
&mut self,
header: Block::Header,
body: Option<Vec<Block::Extrinsic>>,
justification: Option<Justification<Block::Hash>>,
justification: Option<Justification>,
leaf_state: NewBlockState,
) -> Result<(), client::error::Error> {
assert!(self.pending_block.is_none(), "Only one block per operation is allowed");
Expand Down
5 changes: 2 additions & 3 deletions core/client/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
use error;
use primitives::AuthorityId;
use runtime_primitives::bft::Justification;
use runtime_primitives::generic::BlockId;
use runtime_primitives::{generic::BlockId, Justification};
use runtime_primitives::traits::{Block as BlockT, NumberFor};
use state_machine::backend::Backend as StateBackend;
use state_machine::ChangesTrieStorage as StateChangesTrieStorage;
Expand Down Expand Up @@ -64,7 +63,7 @@ where
&mut self,
header: Block::Header,
body: Option<Vec<Block::Extrinsic>>,
justification: Option<Justification<Block::Hash>>,
justification: Option<Justification>,
state: NewBlockState,
) -> error::Result<()>;

Expand Down
5 changes: 2 additions & 3 deletions core/client/src/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use primitives::AuthorityId;
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use runtime_primitives::generic::BlockId;
use runtime_primitives::bft::Justification;
use runtime_primitives::Justification;

use error::{ErrorKind, Result};

Expand Down Expand Up @@ -47,10 +47,9 @@ pub trait Backend<Block: BlockT>: HeaderBackend<Block> {
/// Get block body. Returns `None` if block is not found.
fn body(&self, id: BlockId<Block>) -> Result<Option<Vec<<Block as BlockT>::Extrinsic>>>;
/// Get block justification. Returns `None` if justification does not exist.
fn justification(&self, id: BlockId<Block>) -> Result<Option<Justification<Block::Hash>>>;
fn justification(&self, id: BlockId<Block>) -> Result<Option<Justification>>;
/// Get last finalized block hash.
fn last_finalized(&self) -> Result<Block::Hash>;

/// Returns data cache reference, if it is enabled on this backend.
fn cache(&self) -> Option<&Cache<Block>>;

Expand Down
Loading

0 comments on commit 14ff8f9

Please sign in to comment.