Grandpa validator set handoff justification (#1190)

* core: make block justification optional

* runtime: update wasm binaries

* core: optionally pass justification on finalize_block

* finality-grandpa: add channel to trigger authority set changes

this will allow the `BlockImport` to trigger an authority set change when
importing a change block that provides a justification (when syncing)

* finality-grandpa: move finalize_block to free function

* finality-grandpa: add GrandpaOracle for auth set liveness checking

this will be used by `BlockImport` to check whether the authority set for a
given block is still live, if the authority set isn't live then importing a
change block requires a justification.

* finality-grandpa: store justification on finalized transition blocks

* finality-grandpa: check justification on authority set change blocks

* finality-grandpa: poll grandpa liveness oracle every 10 seconds

* finality-grandpa: spawn grandpa oracle in service setup

* core: support multiple subscriptions per consensus gossip topic

* finality-grandpa: create and verify justifications

* finality-grandpa: update to local branch of grandpa

* finality-grandpa: update to finality-grandpa v0.5.0

* finality-grandpa: move grandpa oracle code

* finality-grandpa: fix canonality check

* finality-grandpa: clean up error handling

* finality-grandpa: fix canonical_at_height

* finality-grandpa: fix tests

* runtime: update wasm binaries

* core: add tests for finalizing block with justification

* finality-grandpa: improve validation of justifications

* core: remove unused IncompleteJustification block import error

* core: test multiple subscribers for same consensus gossip topic

* Revert "finality-grandpa: improve validation of justifications"

This reverts commit 51eb2c58c2219801e876af6d6c9371bdd9ff2477.

* finality-grandpa: fix commit validation

* finality-grandpa: fix commit ancestry validation

* finality-grandpa: use grandpa v0.5.1

* finality-grandpa: add docs

* finality-grandpa: fix failing test

* finality-grandpa: only allow a pending authority set change per fork

* finality-grandpa: fix validator set transition test
This commit is contained in:
André Silva
2018-12-08 05:34:59 +00:00
committed by Gav Wood
parent da822276dd
commit e779eeb2ec
29 changed files with 1115 additions and 389 deletions
+9 -10
View File
@@ -70,13 +70,12 @@ fn should_return_a_block() {
let block = api.client.new_block().unwrap().bake().unwrap();
let block_hash = block.hash();
api.client.justify_and_import(BlockOrigin::Own, block).unwrap();
api.client.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!(
@@ -140,7 +139,7 @@ fn should_return_block_hash() {
);
let block = client.client.new_block().unwrap().bake().unwrap();
client.client.justify_and_import(BlockOrigin::Own, block.clone()).unwrap();
client.client.import(BlockOrigin::Own, block.clone()).unwrap();
assert_matches!(
client.block_hash(Some(0u64).into()),
@@ -170,7 +169,7 @@ fn should_return_finalised_hash() {
// import new block
let builder = client.client.new_block().unwrap();
client.client.justify_and_import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
client.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
// no finalisation yet
assert_matches!(
client.finalised_head(),
@@ -178,7 +177,7 @@ fn should_return_finalised_hash() {
);
// finalise
client.client.finalize_block(BlockId::number(1), true).unwrap();
client.client.finalize_block(BlockId::number(1), None, true).unwrap();
assert_matches!(
client.finalised_head(),
Ok(ref x) if x == &client.client.block_hash(1).unwrap().unwrap()
@@ -203,7 +202,7 @@ fn should_notify_about_latest_block() {
assert_eq!(core.block_on(id), Ok(Ok(SubscriptionId::Number(1))));
let builder = api.client.new_block().unwrap();
api.client.justify_and_import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
api.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
}
// assert initial head sent.
@@ -234,8 +233,8 @@ fn should_notify_about_finalised_block() {
assert_eq!(core.block_on(id), Ok(Ok(SubscriptionId::Number(1))));
let builder = api.client.new_block().unwrap();
api.client.justify_and_import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
api.client.finalize_block(BlockId::number(1), true).unwrap();
api.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
api.client.finalize_block(BlockId::number(1), None, true).unwrap();
}
// assert initial head sent.
+3 -3
View File
@@ -69,7 +69,7 @@ fn should_notify_about_storage_changes() {
amount: 42,
nonce: 0,
}).unwrap();
api.client.justify_and_import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
api.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
}
// assert notification sent to transport
@@ -102,7 +102,7 @@ fn should_send_initial_storage_changes_and_notifications() {
amount: 42,
nonce: 0,
}).unwrap();
api.client.justify_and_import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
api.client.import(BlockOrigin::Own, builder.bake().unwrap()).unwrap();
}
// assert initial values sent to transport
@@ -131,7 +131,7 @@ fn should_query_storage() {
}).unwrap();
let block = builder.bake().unwrap();
let hash = block.header.hash();
client.justify_and_import(BlockOrigin::Own, block).unwrap();
client.import(BlockOrigin::Own, block).unwrap();
hash
};
let block1_hash = add_block(0);