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> { ) -> Result<(), Error> {
verify!(block.slot == state.slot, Invalid::StateSlotMismatch); verify!(block.slot == state.slot, Invalid::StateSlotMismatch);
let expected_previous_block_root =
Hash256::from_slice(&state.latest_block_header.signed_root());
verify!( verify!(
block.previous_block_root == Hash256::from_slice(&state.latest_block_header.signed_root()), block.previous_block_root == expected_previous_block_root,
Invalid::ParentBlockRootMismatch Invalid::ParentBlockRootMismatch {
state: expected_previous_block_root,
block: block.previous_block_root,
}
); );
state.latest_block_header = block.temporary_block_header(spec); state.latest_block_header = block.temporary_block_header(spec);

View File

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