Skip to content

Commit 6a157e9

Browse files
authored
fix: valid header check (#769)
1 parent e16f337 commit 6a157e9

File tree

1 file changed

+6
-23
lines changed

1 file changed

+6
-23
lines changed

ethereum/consensus-core/src/consensus_core.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use crate::proof::{
1818
};
1919
use crate::types::bls::Signature;
2020
use crate::types::{
21-
BeaconBlockHeader, Bootstrap, ExecutionPayloadHeader, FinalityUpdate, Forks, GenericUpdate,
22-
LightClientHeader, LightClientStore, OptimisticUpdate, Update,
21+
BeaconBlockHeader, Bootstrap, FinalityUpdate, Forks, GenericUpdate, LightClientHeader,
22+
LightClientStore, OptimisticUpdate, Update,
2323
};
2424
use crate::utils::{
2525
calculate_fork_version, compute_committee_sign_root, compute_fork_data_root,
@@ -512,27 +512,10 @@ fn is_valid_header<S: ConsensusSpec>(header: &LightClientHeader, forks: &Forks)
512512
// includes blocks that have the blob fields set pre-deneb.
513513
if epoch < forks.capella.epoch {
514514
header.execution().is_err() && header.execution_branch().is_err()
515-
} else if header.execution().is_ok() && header.execution_branch().is_ok() {
516-
let execution = header.execution().unwrap();
517-
let execution_branch = header.execution_branch().unwrap();
518-
519-
let valid_execution_type = match execution {
520-
ExecutionPayloadHeader::Electra(_) => epoch >= forks.electra.epoch,
521-
ExecutionPayloadHeader::Deneb(_) => {
522-
epoch >= forks.deneb.epoch && epoch < forks.electra.epoch
523-
}
524-
ExecutionPayloadHeader::Capella(_) => {
525-
epoch >= forks.capella.epoch && epoch < forks.deneb.epoch
526-
}
527-
ExecutionPayloadHeader::Bellatrix(_) => {
528-
epoch >= forks.bellatrix.epoch && epoch < forks.capella.epoch
529-
}
530-
};
531-
532-
let proof_valid =
533-
is_execution_payload_proof_valid(header.beacon(), execution, execution_branch);
534-
535-
proof_valid && valid_execution_type
515+
} else if let (Ok(execution), Ok(execution_branch)) =
516+
(header.execution(), header.execution_branch())
517+
{
518+
is_execution_payload_proof_valid(header.beacon(), execution, execution_branch)
536519
} else {
537520
false
538521
}

0 commit comments

Comments
 (0)