Ensure that parent_block.slot < block.slot
This commit is contained in:
parent
1f089d423e
commit
e8daca4c80
@ -53,6 +53,7 @@ pub enum SszBlockValidationError {
|
|||||||
UnknownPoWChainRef,
|
UnknownPoWChainRef,
|
||||||
UnknownParentHash,
|
UnknownParentHash,
|
||||||
BadAttestationSsz,
|
BadAttestationSsz,
|
||||||
|
ParentSlotHigherThanBlockSlot,
|
||||||
AttestationValidationError(AttestationValidationError),
|
AttestationValidationError(AttestationValidationError),
|
||||||
AttestationSignatureFailed,
|
AttestationSignatureFailed,
|
||||||
ProposerAttestationHasObliqueHashes,
|
ProposerAttestationHasObliqueHashes,
|
||||||
@ -204,6 +205,15 @@ impl<T> BlockValidationContext<T>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The parent block slot must be less than the block slot.
|
||||||
|
*
|
||||||
|
* In other words, the parent must come before the child.
|
||||||
|
*/
|
||||||
|
if parent_block_slot >= block_slot {
|
||||||
|
return Err(SszBlockValidationError::ParentSlotHigherThanBlockSlot);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate the context in which attestations will be validated.
|
* Generate the context in which attestations will be validated.
|
||||||
*/
|
*/
|
||||||
|
@ -94,6 +94,22 @@ fn test_block_validation_valid_known_block() {
|
|||||||
assert_eq!(status.unwrap(), (BlockStatus::KnownBlock, None));
|
assert_eq!(status.unwrap(), (BlockStatus::KnownBlock, None));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_block_validation_parent_slot_too_high() {
|
||||||
|
let params = get_simple_params();
|
||||||
|
|
||||||
|
let mutator = |mut block: Block, attester_map, proposer_map, stores| {
|
||||||
|
block.slot_number = params.validation_context_justified_slot + 1;
|
||||||
|
(block, attester_map, proposer_map, stores)
|
||||||
|
};
|
||||||
|
|
||||||
|
let status = run_block_validation_scenario(
|
||||||
|
¶ms,
|
||||||
|
mutator);
|
||||||
|
|
||||||
|
assert_eq!(status, Err(SszBlockValidationError::ParentSlotHigherThanBlockSlot));
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_block_validation_invalid_future_slot() {
|
fn test_block_validation_invalid_future_slot() {
|
||||||
let params = get_simple_params();
|
let params = get_simple_params();
|
||||||
|
Loading…
Reference in New Issue
Block a user