pub fn verify_weak_subjectivity_checkpoint(
        &self,
        wss_checkpoint: Checkpoint,
        beacon_block_root: Hash256,
        state: &BeaconState<T::EthSpec>,
    ) -> Result<(), BeaconChainError> {
        let finalized_checkpoint = state.finalized_checkpoint;
        info!(self.log, "Verifying the configured weak subjectivity checkpoint"; "weak_subjectivity_epoch" => wss_checkpoint.epoch, "weak_subjectivity_root" => ?wss_checkpoint.root);
        // If epochs match, simply compare roots.
        if wss_checkpoint.epoch == finalized_checkpoint.epoch
            && wss_checkpoint.root != finalized_checkpoint.root
        {
            crit!(
                self.log,
                 "Root found at the specified checkpoint differs";
                  "weak_subjectivity_root" => ?wss_checkpoint.root,
                  "finalized_checkpoint_root" => ?finalized_checkpoint.root
            );
            return Err(BeaconChainError::WeakSubjectivtyVerificationFailure);
        } else if wss_checkpoint.epoch < finalized_checkpoint.epoch {
            let slot = wss_checkpoint
                .epoch
                .start_slot(T::EthSpec::slots_per_epoch());

            // Iterate backwards through block roots from the given state. If first slot of the epoch is a skip-slot,
            // this will return the root of the closest prior non-skipped slot.
            match self.root_at_slot_from_state(slot, beacon_block_root, state)? {
                Some(root) => {
                    if root != wss_checkpoint.root {
                        crit!(
                            self.log,
                             "Root found at the specified checkpoint differs";
                              "weak_subjectivity_root" => ?wss_checkpoint.root,
                              "finalized_checkpoint_root" => ?finalized_checkpoint.root
                        );
                        return Err(BeaconChainError::WeakSubjectivtyVerificationFailure);
                    }
                }
                None => {
                    crit!(self.log, "The root at the start slot of the given epoch could not be found";
                    "wss_checkpoint_slot" => ?slot);
                    return Err(BeaconChainError::WeakSubjectivtyVerificationFailure);
                }
            }
        }
        Ok(())
    }
/// This function takes a configured weak subjectivity `Checkpoint` and the latest finalized `Checkpoint`.
/// If the weak subjectivity checkpoint and finalized checkpoint share the same epoch, we compare
/// roots. If we the weak subjectivity checkpoint is from an older epoch, we iterate back through
/// roots in the canonical chain until we reach the finalized checkpoint from the correct epoch, and
/// compare roots. This must called on startup and during verification of any block which causes a finality
/// change affecting the weak subjectivity checkpoint.
This function takes a configured weak subjectivity `Checkpoint` and the latest finalized `Checkpoint`.
If the weak subjectivity checkpoint and finalized checkpoint share the same epoch, we compare
roots. If we the weak subjectivity checkpoint is from an older epoch, we iterate back through
roots in the canonical chain until we reach the finalized checkpoint from the correct epoch, and
compare roots. This must called on startup and during verification of any block which causes a finality
change affecting the weak subjectivity checkpoint.
This function takes a configured weak subjectivity ` Checkpoint ` and the latest finalized ` Checkpoint ` . If the weak subjectivity checkpoint and finalized checkpoint share the same epoch we compare roots . If we the weak subjectivity checkpoint is from an older epoch we iterate back through roots in the canonical chain until we reach the finalized checkpoint from the correct epoch and compare roots . This must called on startup and during verification of any block which causes a finality change affecting the weak subjectivity checkpoint .
pub fn verify_weak_subjectivity_checkpoint(
        &self,
        wss_checkpoint: Checkpoint,
        beacon_block_root: Hash256,
        state: &BeaconState<T::EthSpec>,
    ) -> Result<(), BeaconChainError> {
        let finalized_checkpoint = state.finalized_checkpoint;
        info!(self.log, "Verifying the configured weak subjectivity checkpoint"; "weak_subjectivity_epoch" => wss_checkpoint.epoch, "weak_subjectivity_root" => ?wss_checkpoint.root);
        // If epochs match, simply compare roots.
        if wss_checkpoint.epoch == finalized_checkpoint.epoch
            && wss_checkpoint.root != finalized_checkpoint.root
        {
            crit!(
                self.log,
                 "Root found at the specified checkpoint differs";
                  "weak_subjectivity_root" => ?wss_checkpoint.root,
                  "finalized_checkpoint_root" => ?finalized_checkpoint.root
            );
            return Err(BeaconChainError::WeakSubjectivtyVerificationFailure);
        } else if wss_checkpoint.epoch < finalized_checkpoint.epoch {
            let slot = wss_checkpoint
                .epoch
                .start_slot(T::EthSpec::slots_per_epoch());
            // Iterate backwards through block roots from the given state. If first slot of the epoch is a skip-slot,
            // this will return the root of the closest prior non-skipped slot.
            match self.root_at_slot_from_state(slot, beacon_block_root, state)? {
                Some(root) => {
                    if root != wss_checkpoint.root {
                        crit!(
                            self.log,
                             "Root found at the specified checkpoint differs";
                              "weak_subjectivity_root" => ?wss_checkpoint.root,
                              "finalized_checkpoint_root" => ?finalized_checkpoint.root
                        );
                        return Err(BeaconChainError::WeakSubjectivtyVerificationFailure);
                    }
                }
                None => {
                    crit!(self.log, "The root at the start slot of the given epoch could not be found";
                    "wss_checkpoint_slot" => ?slot);
                    return Err(BeaconChainError::WeakSubjectivtyVerificationFailure);
                }
            }
        }
        Ok(())
    }
pub fn verify_weak_subjectivity_checkpoint ( & self , wss_checkpoint : Checkpoint , beacon_block_root : Hash256 , state : & BeaconState < T :: EthSpec > , ) -> Result < ( ) , BeaconChainError > { let finalized_checkpoint = state . finalized_checkpoint ; info ! ( self log " " " " wss_checkpoint epoch " " wss_checkpoint root ) ; // If epochs match, simply compare roots. if wss_checkpoint . epoch == finalized_checkpoint . epoch && wss_checkpoint . root != finalized_checkpoint . root { crit ! ( self log " " " " wss_checkpoint root " " finalized_checkpoint root ) ; return Err ( BeaconChainError :: WeakSubjectivtyVerificationFailure ) ; } else if wss_checkpoint . epoch < finalized_checkpoint . epoch { let slot = wss_checkpoint . epoch . start_slot ( T :: EthSpec :: slots_per_epoch ( ) ) ; // Iterate backwards through block roots from the given state. If first slot of the epoch is a skip-slot, // this will return the root of the closest prior non-skipped slot. match self . root_at_slot_from_state ( slot , beacon_block_root , state ) ? { Some ( root ) => { if root != wss_checkpoint . root { crit ! ( self log " " " " wss_checkpoint root " " finalized_checkpoint root ) ; return Err ( BeaconChainError :: WeakSubjectivtyVerificationFailure ) ; } } None => { crit ! ( self log " " " " slot ) ; return Err ( BeaconChainError :: WeakSubjectivtyVerificationFailure ) ; } } } Ok ( ( ) ) }
This function takes a configured weak subjectivity `Checkpoint` and the latest finalized `Checkpoint`.
This function takes a configured weak subjectivity ` Checkpoint ` and the latest finalized ` Checkpoint ` .
&self
wss_checkpoint
Checkpoint
beacon_block_root
Hash256
state
&BeaconState<T::EthSpec>