Add extra info to block proc. error message

This commit is contained in:
Paul Hauner 2019-04-17 13:59:40 +10:00
parent f592183aa9
commit c3779caede
No known key found for this signature in database
GPG Key ID: D362883A9218FCC6
2 changed files with 11 additions and 3 deletions

View File

@ -107,9 +107,14 @@ pub fn process_block_header(
) -> Result<(), Error> {
verify!(block.slot == state.slot, Invalid::StateSlotMismatch);
let expected_previous_block_root =
Hash256::from_slice(&state.latest_block_header.signed_root());
verify!(
block.previous_block_root == Hash256::from_slice(&state.latest_block_header.signed_root()),
Invalid::ParentBlockRootMismatch
block.previous_block_root == expected_previous_block_root,
Invalid::ParentBlockRootMismatch {
state: expected_previous_block_root,
block: block.previous_block_root,
}
);
state.latest_block_header = block.temporary_block_header(spec);

View File

@ -67,7 +67,10 @@ impl_from_beacon_state_error!(BlockProcessingError);
#[derive(Debug, PartialEq)]
pub enum BlockInvalid {
StateSlotMismatch,
ParentBlockRootMismatch,
ParentBlockRootMismatch {
state: Hash256,
block: Hash256,
},
BadSignature,
BadRandaoSignature,
MaxAttestationsExceeded,