Fix issue with last_justified_block_hash

Previously we were just checking it exists in the DB. This is incorrect
because the last_justified_block_hash _must_ be in the chain referenced
by the block.

I.e., it's not OK for a block to reference a justified block in another
chain.
This commit is contained in:
Paul Hauner
2018-10-09 12:14:59 +11:00
parent f13a4fffea
commit cf9f8c1e85
5 changed files with 20 additions and 25 deletions

View File

@@ -72,6 +72,8 @@ pub struct BlockValidationContext<T>
pub cycle_length: u8,
/// The last justified slot as per the client's view of the canonical chain.
pub last_justified_slot: u64,
/// The last justified block hash as per the client's view of the canonical chain.
pub last_justified_block_hash: Hash256,
/// The last finalized slot as per the client's view of the canonical chain.
pub last_finalized_slot: u64,
/// A vec of the hashes of the blocks preceeding the present slot.
@@ -205,8 +207,8 @@ impl<T> BlockValidationContext<T>
block_slot,
cycle_length: self.cycle_length,
last_justified_slot: self.last_justified_slot,
last_justified_block_hash: self.last_justified_block_hash,
parent_hashes: self.parent_hashes.clone(),
block_store: self.block_store.clone(),
validator_store: self.validator_store.clone(),
attester_map: self.attester_map.clone(),
});