spec v0.6.1: process proposer/attester slashings
This commit is contained in:
parent
dab11c1eed
commit
857c4ed2db
@ -2,17 +2,15 @@
|
|||||||
mod macros;
|
mod macros;
|
||||||
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
//pub mod get_genesis_state;
|
pub mod get_genesis_state;
|
||||||
pub mod per_block_processing;
|
pub mod per_block_processing;
|
||||||
pub mod per_epoch_processing;
|
pub mod per_epoch_processing;
|
||||||
//pub mod per_slot_processing;
|
pub mod per_slot_processing;
|
||||||
|
|
||||||
/*
|
pub use get_genesis_state::get_genesis_beacon_state;
|
||||||
pub use get_genesis_state::get_genesis_state;
|
|
||||||
pub use per_block_processing::{
|
pub use per_block_processing::{
|
||||||
errors::{BlockInvalid, BlockProcessingError},
|
errors::{BlockInvalid, BlockProcessingError},
|
||||||
per_block_processing, per_block_processing_without_verifying_block_signature,
|
per_block_processing, per_block_processing_without_verifying_block_signature,
|
||||||
};
|
};
|
||||||
pub use per_epoch_processing::{errors::EpochProcessingError, per_epoch_processing};
|
pub use per_epoch_processing::{errors::EpochProcessingError, per_epoch_processing};
|
||||||
pub use per_slot_processing::{per_slot_processing, Error as SlotProcessingError};
|
pub use per_slot_processing::{per_slot_processing, Error as SlotProcessingError};
|
||||||
*/
|
|
||||||
|
@ -5,8 +5,7 @@ use tree_hash::{SignedRoot, TreeHash};
|
|||||||
use types::*;
|
use types::*;
|
||||||
|
|
||||||
pub use self::verify_attester_slashing::{
|
pub use self::verify_attester_slashing::{
|
||||||
gather_attester_slashing_indices, gather_attester_slashing_indices_modular,
|
gather_attester_slashing_indices, get_slashable_indices, verify_attester_slashing,
|
||||||
verify_attester_slashing,
|
|
||||||
};
|
};
|
||||||
pub use self::verify_proposer_slashing::verify_proposer_slashing;
|
pub use self::verify_proposer_slashing::verify_proposer_slashing;
|
||||||
pub use validate_attestation::{
|
pub use validate_attestation::{
|
||||||
@ -214,7 +213,7 @@ pub fn process_eth1_data<T: EthSpec>(
|
|||||||
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
|
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
|
||||||
/// an `Err` describing the invalid object or cause of failure.
|
/// an `Err` describing the invalid object or cause of failure.
|
||||||
///
|
///
|
||||||
/// Spec v0.5.1
|
/// Spec v0.6.1
|
||||||
pub fn process_proposer_slashings<T: EthSpec>(
|
pub fn process_proposer_slashings<T: EthSpec>(
|
||||||
state: &mut BeaconState<T>,
|
state: &mut BeaconState<T>,
|
||||||
proposer_slashings: &[ProposerSlashing],
|
proposer_slashings: &[ProposerSlashing],
|
||||||
@ -236,18 +235,18 @@ pub fn process_proposer_slashings<T: EthSpec>(
|
|||||||
|
|
||||||
// Update the state.
|
// Update the state.
|
||||||
for proposer_slashing in proposer_slashings {
|
for proposer_slashing in proposer_slashings {
|
||||||
slash_validator(state, proposer_slashing.proposer_index as usize, spec)?;
|
slash_validator(state, proposer_slashing.proposer_index as usize, None, spec)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Validates each `AttesterSlsashing` and updates the state, short-circuiting on an invalid object.
|
/// Validates each `AttesterSlashing` and updates the state, short-circuiting on an invalid object.
|
||||||
///
|
///
|
||||||
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
|
/// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns
|
||||||
/// an `Err` describing the invalid object or cause of failure.
|
/// an `Err` describing the invalid object or cause of failure.
|
||||||
///
|
///
|
||||||
/// Spec v0.5.1
|
/// Spec v0.6.1
|
||||||
pub fn process_attester_slashings<T: EthSpec>(
|
pub fn process_attester_slashings<T: EthSpec>(
|
||||||
state: &mut BeaconState<T>,
|
state: &mut BeaconState<T>,
|
||||||
attester_slashings: &[AttesterSlashing],
|
attester_slashings: &[AttesterSlashing],
|
||||||
@ -289,11 +288,11 @@ pub fn process_attester_slashings<T: EthSpec>(
|
|||||||
)
|
)
|
||||||
.map_err(|e| e.into_with_index(i))?;
|
.map_err(|e| e.into_with_index(i))?;
|
||||||
|
|
||||||
let indexed_indices = gather_attester_slashing_indices(&state, &attester_slashing, spec)
|
let slashable_indices = get_slashable_indices(&state, &attester_slashing, spec)
|
||||||
.map_err(|e| e.into_with_index(i))?;
|
.map_err(|e| e.into_with_index(i))?;
|
||||||
|
|
||||||
for i in indexed_indices {
|
for i in indexed_indices {
|
||||||
slash_validator(state, i as usize, spec)?;
|
slash_validator(state, i as usize, None, spec)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -546,10 +546,10 @@ impl<T: EthSpec> BeaconState<T> {
|
|||||||
|
|
||||||
/// Replace `active_index_roots` with clones of `index_root`.
|
/// Replace `active_index_roots` with clones of `index_root`.
|
||||||
///
|
///
|
||||||
/// Spec v0.5.1
|
/// Spec v0.6.1
|
||||||
pub fn fill_active_index_roots_with(&mut self, index_root: Hash256) {
|
pub fn fill_active_index_roots_with(&mut self, index_root: Hash256) {
|
||||||
self.latest_active_index_roots =
|
self.latest_active_index_roots =
|
||||||
vec![index_root; self.latest_active_index_roots.len() as usize].into()
|
vec![index_root; self.latest_active_index_roots.len()].into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Safely obtains the index for latest state roots, given some `slot`.
|
/// Safely obtains the index for latest state roots, given some `slot`.
|
||||||
|
Loading…
Reference in New Issue
Block a user