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
33 commits
Select commit Hold shift + click to select a range
0fe90f7
core: make block justification optional
andresilva Nov 23, 2018
c9fdc56
runtime: update wasm binaries
andresilva Nov 23, 2018
cafa497
core: optionally pass justification on finalize_block
andresilva Nov 24, 2018
1fe5554
finality-grandpa: add channel to trigger authority set changes
andresilva Nov 26, 2018
8489541
finality-grandpa: move finalize_block to free function
andresilva Nov 27, 2018
208f097
finality-grandpa: add GrandpaOracle for auth set liveness checking
andresilva Nov 27, 2018
0c2912e
finality-grandpa: store justification on finalized transition blocks
andresilva Nov 28, 2018
b085e2e
finality-grandpa: check justification on authority set change blocks
andresilva Nov 28, 2018
fc284f7
finality-grandpa: poll grandpa liveness oracle every 10 seconds
andresilva Nov 29, 2018
4a90ba7
finality-grandpa: spawn grandpa oracle in service setup
andresilva Nov 30, 2018
0afa153
core: support multiple subscriptions per consensus gossip topic
andresilva Nov 30, 2018
4739e32
finality-grandpa: create and verify justifications
andresilva Nov 30, 2018
e4d5616
finality-grandpa: update to local branch of grandpa
andresilva Nov 30, 2018
f5ce910
finality-grandpa: update to finality-grandpa v0.5.0
andresilva Dec 2, 2018
711208b
finality-grandpa: move grandpa oracle code
andresilva Dec 2, 2018
cc46a45
finality-grandpa: fix canonality check
andresilva Dec 2, 2018
bac890e
finality-grandpa: clean up error handling
andresilva Dec 2, 2018
debd3b6
finality-grandpa: fix canonical_at_height
andresilva Dec 2, 2018
128eee0
finality-grandpa: fix tests
andresilva Dec 2, 2018
252817c
runtime: update wasm binaries
andresilva Dec 2, 2018
33392f5
core: add tests for finalizing block with justification
andresilva Dec 4, 2018
51eb2c5
finality-grandpa: improve validation of justifications
andresilva Dec 4, 2018
4a95dc3
core: remove unused IncompleteJustification block import error
andresilva Dec 4, 2018
101cba6
core: test multiple subscribers for same consensus gossip topic
andresilva Dec 4, 2018
a9e659b
Revert "finality-grandpa: improve validation of justifications"
andresilva Dec 5, 2018
d708849
finality-grandpa: fix commit validation
andresilva Dec 5, 2018
3ee13e0
Merge branch 'master' into andre/grandpa-handoff-justification
andresilva Dec 5, 2018
3f5732f
finality-grandpa: fix commit ancestry validation
andresilva Dec 5, 2018
1318a79
finality-grandpa: use grandpa v0.5.1
andresilva Dec 5, 2018
e5c593c
finality-grandpa: add docs
andresilva Dec 5, 2018
3a501ba
finality-grandpa: fix failing test
andresilva Dec 5, 2018
1e759d3
finality-grandpa: only allow a pending authority set change per fork
andresilva Dec 6, 2018
8c1981f
finality-grandpa: fix validator set transition test
andresilva Dec 7, 2018
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
Next Next commit
core: make block justification optional
  • Loading branch information
andresilva committed Nov 26, 2018
commit 0fe90f76682e77e9afd8390e205aab02f2bedb5c
6 changes: 3 additions & 3 deletions core/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
origin: BlockOrigin,
hash: Block::Hash,
import_headers: PrePostHeader<Block::Header>,
justification: Justification,
justification: Option<Justification>,
body: Option<Vec<Block::Extrinsic>>,
authorities: Option<Vec<AuthorityId>>,
finalized: bool,
Expand Down Expand Up @@ -678,7 +678,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
transaction.set_block_data(
import_headers.post().clone(),
body,
Some(justification),
justification,
leaf_state,
)?;

Expand Down Expand Up @@ -858,7 +858,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
-> error::Result<Option<SignedBlock<Block>>>
{
Ok(match (self.header(id)?, self.body(id)?, self.justification(id)?) {
(Some(header), Some(extrinsics), Some(justification)) =>
(Some(header), Some(extrinsics), justification) =>
Some(SignedBlock { block: Block::new(header, extrinsics), justification }),
_ => None,
})
Expand Down
8 changes: 4 additions & 4 deletions core/consensus/aura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use codec::Encode;
use consensus_common::{Authorities, BlockImport, Environment, Proposer};
use client::ChainHead;
use consensus_common::{ImportBlock, BlockOrigin};
use runtime_primitives::{generic, generic::BlockId};
use runtime_primitives::{generic, generic::BlockId, Justification};
use runtime_primitives::traits::{Block, Header, Digest, DigestItemFor};
use network::import_queue::{Verifier, BasicQueue};
use primitives::{AuthorityId, ed25519};
Expand Down Expand Up @@ -243,7 +243,7 @@ pub fn start_aura<B, C, E, I, SO, Error>(
let import_block = ImportBlock {
origin: BlockOrigin::Own,
header,
justification: Vec::new(),
justification: None,
post_digests: vec![item],
body: Some(body),
finalized: false,
Expand Down Expand Up @@ -366,7 +366,7 @@ impl<B: Block, C, E> Verifier<B> for AuraVerifier<C, E> where
&self,
origin: BlockOrigin,
header: B::Header,
_justification: Vec<u8>,
_justification: Option<Justification>,
body: Option<Vec<B::Extrinsic>>
) -> Result<(ImportBlock<B>, Option<Vec<AuthorityId>>), String> {
let slot_now = slot_now(self.config.slot_duration)
Expand All @@ -392,7 +392,7 @@ impl<B: Block, C, E> Verifier<B> for AuraVerifier<C, E> where
let import_block = ImportBlock {
origin,
header: pre_header,
justification: Vec::new(),
justification: None,
post_digests: vec![item],
body,
finalized: false,
Expand Down
6 changes: 3 additions & 3 deletions core/consensus/common/src/block_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ pub struct ImportBlock<Block: BlockT> {
/// re-executed in a runtime that checks digest equivalence -- the
/// post-runtime digests are pushed back on after.
pub header: Block::Header,
/// Justification provided for this block from the outside:.
pub justification: Justification,
/// Justification provided for this block from the outside.
pub justification: Option<Justification>,
/// Digest items that have been added after the runtime for external
/// work, like a consensus signature.
pub post_digests: Vec<DigestItemFor<Block>>,
Expand All @@ -91,7 +91,7 @@ impl<Block: BlockT> ImportBlock<Block> {
-> (
BlockOrigin,
<Block as BlockT>::Header,
Justification,
Option<Justification>,
Vec<DigestItemFor<Block>>,
Option<Vec<<Block as BlockT>::Extrinsic>>,
bool,
Expand Down
36 changes: 15 additions & 21 deletions core/network/src/import_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use parking_lot::{Condvar, Mutex, RwLock};
use network_libp2p::{NodeIndex, Severity};
use primitives::AuthorityId;

use runtime_primitives::Justification;
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero};

pub use blocks::BlockData;
Expand All @@ -57,7 +58,7 @@ pub trait Verifier<B: BlockT>: Send + Sync + Sized {
&self,
origin: BlockOrigin,
header: B::Header,
justification: Vec<u8>,
justification: Option<Justification>,
body: Option<Vec<B::Extrinsic>>
) -> Result<(ImportBlock<B>, Option<Vec<AuthorityId>>), String>;
}
Expand Down Expand Up @@ -411,7 +412,7 @@ fn import_single_block<B: BlockT, V: Verifier<B>>(
let block = block.block;

let (header, justification) = match (block.header, block.justification) {
(Some(header), Some(justification)) => (header, justification),
(Some(header), justification) => (header, justification),
(None, _) => {
if let Some(peer) = peer {
debug!(target: "sync", "Header {} was not provided by {} ", block.hash, peer);
Expand All @@ -420,14 +421,6 @@ fn import_single_block<B: BlockT, V: Verifier<B>>(
}
return Err(BlockImportError::IncompleteHeader(peer)) //TODO: use persistent ID
},
(_, None) => {
if let Some(peer) = peer {
debug!(target: "sync", "Justification set for block {} was not provided by {} ", block.hash, peer);
} else {
debug!(target: "sync", "Justification set for block {} was not provided", block.hash);
}
return Err(BlockImportError::IncompleteJustification(peer)) //TODO: use persistent ID
}
};

let number = header.number().clone();
Expand Down Expand Up @@ -555,15 +548,15 @@ impl<B: BlockT> Verifier<B> for PassThroughVerifier {
&self,
origin: BlockOrigin,
header: B::Header,
justification: Vec<u8>,
justification: Option<Justification>,
body: Option<Vec<B::Extrinsic>>
) -> Result<(ImportBlock<B>, Option<Vec<AuthorityId>>), String> {
Ok((ImportBlock {
origin,
header,
body,
finalized: self.0,
justification: justification,
justification,
post_digests: vec![],
auxiliary: Vec::new(),
}, None))
Expand Down Expand Up @@ -745,15 +738,16 @@ pub mod tests {
);
}

#[test]
fn import_single_good_block_without_justification_fails() {
let (_, _, _, mut block) = prepare_good_block();
block.block.justification = None;
assert_eq!(
import_single_block(&test_client::new(), BlockOrigin::File, block, Arc::new(PassThroughVerifier(true))),
Err(BlockImportError::IncompleteJustification(Some(0)))
);
}
// FIXME: replace with test where `IncompleteJustification` error is created by the `BlockImport` handle
// #[test]
// fn import_single_good_block_without_justification_fails() {
// let (_, _, _, mut block) = prepare_good_block();
// block.block.justification = None;
// assert_eq!(
// import_single_block(&test_client::new(), BlockOrigin::File, block, Arc::new(PassThroughVerifier(true))),
// Err(BlockImportError::IncompleteJustification(Some(0)))
// );
// }

#[test]
fn process_import_result_works() {
Expand Down
5 changes: 2 additions & 3 deletions core/rpc/src/chain/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ fn should_return_a_block() {
let block_hash = block.hash();
api.client.justify_and_import(BlockOrigin::Own, block).unwrap();


// Genesis block is not justified, so we can't query it?
// Genesis block is not justified
assert_matches!(
api.block(Some(api.client.genesis_hash()).into()),
Ok(None)
Ok(Some(SignedBlock { justification: None, .. }))
);

assert_matches!(
Expand Down
2 changes: 1 addition & 1 deletion core/service/src/chain_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub fn import_blocks<F, E, R>(mut config: FactoryFullConfiguration<F>, exit: E,
let hash = header.hash();
let block = message::BlockData::<F::Block> {
hash: hash,
justification: Some(signed.justification),
justification: signed.justification,
header: Some(header),
body: Some(extrinsics),
receipt: None,
Expand Down
2 changes: 1 addition & 1 deletion core/sr-primitives/src/generic/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ pub struct SignedBlock<Block> {
/// Full block.
pub block: Block,
/// Block justification.
pub justification: Justification,
pub justification: Option<Justification>,
}

// TODO: Remove Deserialize for SignedBlock once RPC no longer needs it #1098
Expand Down
2 changes: 1 addition & 1 deletion core/test-client/src/client_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<B, E, RA> TestClient for Client<B, E, runtime::Block, RA>
let import = ImportBlock {
origin,
header: block.header,
justification: vec![],
justification: Some(vec![]),
post_digests: vec![],
body: Some(block.extrinsics),
finalized: false,
Expand Down