mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-10 20:22:02 +00:00
Add progress on state_processing fixed-len update
This commit is contained in:
@@ -9,8 +9,8 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `Attestation` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn validate_attestation(
|
||||
state: &BeaconState,
|
||||
pub fn validate_attestation<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
attestation: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -18,8 +18,8 @@ pub fn validate_attestation(
|
||||
}
|
||||
|
||||
/// Like `validate_attestation` but doesn't run checks which may become true in future states.
|
||||
pub fn validate_attestation_time_independent_only(
|
||||
state: &BeaconState,
|
||||
pub fn validate_attestation_time_independent_only<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
attestation: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -32,8 +32,8 @@ pub fn validate_attestation_time_independent_only(
|
||||
/// Returns `Ok(())` if the `Attestation` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn validate_attestation_without_signature(
|
||||
state: &BeaconState,
|
||||
pub fn validate_attestation_without_signature<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
attestation: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -45,8 +45,8 @@ pub fn validate_attestation_without_signature(
|
||||
///
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn validate_attestation_parametric(
|
||||
state: &BeaconState,
|
||||
fn validate_attestation_parametric<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
attestation: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
verify_signature: bool,
|
||||
@@ -168,9 +168,9 @@ fn validate_attestation_parametric(
|
||||
/// match the current (or previous) justified epoch and root from the state.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn verify_justified_epoch_and_root(
|
||||
fn verify_justified_epoch_and_root<T: BeaconStateTypes>(
|
||||
attestation: &Attestation,
|
||||
state: &BeaconState,
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
let state_epoch = state.slot.epoch(spec.slots_per_epoch);
|
||||
@@ -223,8 +223,8 @@ fn verify_justified_epoch_and_root(
|
||||
/// - A `validator_index` in `committee` is not in `state.validator_registry`.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn verify_attestation_signature(
|
||||
state: &BeaconState,
|
||||
fn verify_attestation_signature<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
committee: &[usize],
|
||||
a: &Attestation,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -8,8 +8,8 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `AttesterSlashing` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_attester_slashing(
|
||||
state: &BeaconState,
|
||||
pub fn verify_attester_slashing<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
attester_slashing: &AttesterSlashing,
|
||||
should_verify_slashable_attestations: bool,
|
||||
spec: &ChainSpec,
|
||||
@@ -42,8 +42,8 @@ pub fn verify_attester_slashing(
|
||||
/// Returns Ok(indices) if `indices.len() > 0`.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn gather_attester_slashing_indices(
|
||||
state: &BeaconState,
|
||||
pub fn gather_attester_slashing_indices<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
attester_slashing: &AttesterSlashing,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<Vec<u64>, Error> {
|
||||
@@ -57,8 +57,8 @@ pub fn gather_attester_slashing_indices(
|
||||
|
||||
/// Same as `gather_attester_slashing_indices` but allows the caller to specify the criteria
|
||||
/// for determining whether a given validator should be considered slashed.
|
||||
pub fn gather_attester_slashing_indices_modular<F>(
|
||||
state: &BeaconState,
|
||||
pub fn gather_attester_slashing_indices_modular<F, T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
attester_slashing: &AttesterSlashing,
|
||||
is_slashed: F,
|
||||
spec: &ChainSpec,
|
||||
|
||||
@@ -16,8 +16,8 @@ use types::*;
|
||||
/// Note: this function is incomplete.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_deposit(
|
||||
state: &BeaconState,
|
||||
pub fn verify_deposit<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
deposit: &Deposit,
|
||||
verify_merkle_branch: bool,
|
||||
spec: &ChainSpec,
|
||||
@@ -47,7 +47,10 @@ pub fn verify_deposit(
|
||||
/// Verify that the `Deposit` index is correct.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_deposit_index(state: &BeaconState, deposit: &Deposit) -> Result<(), Error> {
|
||||
pub fn verify_deposit_index<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
deposit: &Deposit,
|
||||
) -> Result<(), Error> {
|
||||
verify!(
|
||||
deposit.index == state.deposit_index,
|
||||
Invalid::BadIndex {
|
||||
@@ -65,8 +68,8 @@ pub fn verify_deposit_index(state: &BeaconState, deposit: &Deposit) -> Result<()
|
||||
/// ## Errors
|
||||
///
|
||||
/// Errors if the state's `pubkey_cache` is not current.
|
||||
pub fn get_existing_validator_index(
|
||||
state: &BeaconState,
|
||||
pub fn get_existing_validator_index<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
deposit: &Deposit,
|
||||
) -> Result<Option<u64>, Error> {
|
||||
let deposit_input = &deposit.deposit_data.deposit_input;
|
||||
@@ -89,7 +92,11 @@ pub fn get_existing_validator_index(
|
||||
/// Verify that a deposit is included in the state's eth1 deposit root.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
fn verify_deposit_merkle_proof(state: &BeaconState, deposit: &Deposit, spec: &ChainSpec) -> bool {
|
||||
fn verify_deposit_merkle_proof<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
deposit: &Deposit,
|
||||
spec: &ChainSpec,
|
||||
) -> bool {
|
||||
let leaf = hash(&get_serialized_deposit_data(deposit));
|
||||
verify_merkle_proof(
|
||||
Hash256::from_slice(&leaf),
|
||||
|
||||
@@ -8,8 +8,8 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `Exit` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_exit(
|
||||
state: &BeaconState,
|
||||
pub fn verify_exit<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
exit: &VoluntaryExit,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -17,8 +17,8 @@ pub fn verify_exit(
|
||||
}
|
||||
|
||||
/// Like `verify_exit` but doesn't run checks which may become true in future states.
|
||||
pub fn verify_exit_time_independent_only(
|
||||
state: &BeaconState,
|
||||
pub fn verify_exit_time_independent_only<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
exit: &VoluntaryExit,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -26,8 +26,8 @@ pub fn verify_exit_time_independent_only(
|
||||
}
|
||||
|
||||
/// Parametric version of `verify_exit` that skips some checks if `time_independent_only` is true.
|
||||
fn verify_exit_parametric(
|
||||
state: &BeaconState,
|
||||
fn verify_exit_parametric<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
exit: &VoluntaryExit,
|
||||
spec: &ChainSpec,
|
||||
time_independent_only: bool,
|
||||
|
||||
@@ -8,9 +8,9 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `ProposerSlashing` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_proposer_slashing(
|
||||
pub fn verify_proposer_slashing<T: BeaconStateTypes>(
|
||||
proposer_slashing: &ProposerSlashing,
|
||||
state: &BeaconState,
|
||||
state: &BeaconState<T>,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
let proposer = state
|
||||
|
||||
@@ -11,8 +11,8 @@ use types::*;
|
||||
/// Returns `Ok(())` if the `SlashableAttestation` is valid, otherwise indicates the reason for invalidity.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_slashable_attestation(
|
||||
state: &BeaconState,
|
||||
pub fn verify_slashable_attestation<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
slashable_attestation: &SlashableAttestation,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
@@ -11,8 +11,8 @@ use types::*;
|
||||
/// Note: this function is incomplete.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn verify_transfer(
|
||||
state: &BeaconState,
|
||||
pub fn verify_transfer<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
transfer: &Transfer,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -20,8 +20,8 @@ pub fn verify_transfer(
|
||||
}
|
||||
|
||||
/// Like `verify_transfer` but doesn't run checks which may become true in future states.
|
||||
pub fn verify_transfer_time_independent_only(
|
||||
state: &BeaconState,
|
||||
pub fn verify_transfer_time_independent_only<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
transfer: &Transfer,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
@@ -29,8 +29,8 @@ pub fn verify_transfer_time_independent_only(
|
||||
}
|
||||
|
||||
/// Parametric version of `verify_transfer` that allows some checks to be skipped.
|
||||
fn verify_transfer_parametric(
|
||||
state: &BeaconState,
|
||||
fn verify_transfer_parametric<T: BeaconStateTypes>(
|
||||
state: &BeaconState<T>,
|
||||
transfer: &Transfer,
|
||||
spec: &ChainSpec,
|
||||
time_independent_only: bool,
|
||||
@@ -123,8 +123,8 @@ fn verify_transfer_parametric(
|
||||
/// Does not check that the transfer is valid, however checks for overflow in all actions.
|
||||
///
|
||||
/// Spec v0.5.1
|
||||
pub fn execute_transfer(
|
||||
state: &mut BeaconState,
|
||||
pub fn execute_transfer<T: BeaconStateTypes>(
|
||||
state: &mut BeaconState<T>,
|
||||
transfer: &Transfer,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
|
||||
Reference in New Issue
Block a user