mirror of
https://gitlab.com/pulsechaincom/lighthouse-pulse.git
synced 2025-01-08 20:11:22 +00:00
Separate parent block checking and proposer checking
This commit is contained in:
parent
c30a9a7565
commit
e2d45eafae
@ -181,6 +181,23 @@ impl<T> BlockValidationContext<T>
|
|||||||
return Err(SszBlockValidationError::ProposerAttestationHasObliqueHashes);
|
return Err(SszBlockValidationError::ProposerAttestationHasObliqueHashes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read the parent hash from the block we are validating then attempt to load
|
||||||
|
* that parent block ssz from the database.
|
||||||
|
*
|
||||||
|
* If that parent doesn't exist in the database or is invalid, reject the block.
|
||||||
|
*
|
||||||
|
* Also, read the slot from the parent block for later use.
|
||||||
|
*/
|
||||||
|
let parent_hash = b.parent_hash();
|
||||||
|
let parent_slot = match self.block_store.get_serialized_block(&parent_hash)? {
|
||||||
|
None => return Err(SszBlockValidationError::UnknownParentHash),
|
||||||
|
Some(ssz) => {
|
||||||
|
let parent_block = SszBlock::from_slice(&ssz[..])?;
|
||||||
|
parent_block.slot_number()
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Generate the context in which attestations will be validated.
|
* Generate the context in which attestations will be validated.
|
||||||
*/
|
*/
|
||||||
@ -201,28 +218,16 @@ impl<T> BlockValidationContext<T>
|
|||||||
.validate_attestation(&first_attestation)?;
|
.validate_attestation(&first_attestation)?;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Read the parent hash from the block we are validating then attempt to load
|
* Attempt to read load the parent block proposer from the proposer map. Return with an
|
||||||
* the parent block ssz from the database. If that parent doesn't exist in
|
* error if it fails.
|
||||||
* the database, reject the block.
|
|
||||||
*
|
*
|
||||||
* If the parent does exist in the database, read the slot of that parent. Then,
|
* If the signature of proposer for the parent slot was not present in the first (0'th)
|
||||||
* determine the proposer of that slot (the parent slot) by looking it up
|
|
||||||
* in the proposer map.
|
|
||||||
*
|
|
||||||
* If that proposer (the proposer of the parent block) was not present in the first (0'th)
|
|
||||||
* attestation of this block, reject the block.
|
* attestation of this block, reject the block.
|
||||||
*/
|
*/
|
||||||
let parent_hash = b.parent_hash();
|
let parent_block_proposer = self.proposer_map.get(&parent_slot)
|
||||||
match self.block_store.get_serialized_block(&parent_hash)? {
|
.ok_or(SszBlockValidationError::BadProposerMap)?;
|
||||||
None => return Err(SszBlockValidationError::UnknownParentHash),
|
if !attestation_voters.contains(&parent_block_proposer) {
|
||||||
Some(ssz) => {
|
return Err(SszBlockValidationError::NoProposerSignature);
|
||||||
let parent_block = SszBlock::from_slice(&ssz[..])?;
|
|
||||||
let proposer = self.proposer_map.get(&parent_block.slot_number())
|
|
||||||
.ok_or(SszBlockValidationError::BadProposerMap)?;
|
|
||||||
if !attestation_voters.contains(&proposer) {
|
|
||||||
return Err(SszBlockValidationError::NoProposerSignature);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user