From 468dc2ceb013540947531381c08febb1af9c8118 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Tue, 21 May 2019 16:40:48 +1000 Subject: [PATCH] per-block processing: minor fixups --- eth2/state_processing/src/get_genesis_state.rs | 2 +- eth2/state_processing/src/per_block_processing.rs | 10 ++++++---- .../per_block_processing/verify_attester_slashing.rs | 7 ++++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/eth2/state_processing/src/get_genesis_state.rs b/eth2/state_processing/src/get_genesis_state.rs index 1c2fdc0ee..d11154888 100644 --- a/eth2/state_processing/src/get_genesis_state.rs +++ b/eth2/state_processing/src/get_genesis_state.rs @@ -35,7 +35,7 @@ pub fn get_genesis_beacon_state( // Set all the active index roots to be the genesis active index root. let active_validator_indices = state - .get_cached_active_validator_indices(RelativeEpoch::Current, spec)? + .get_cached_active_validator_indices(RelativeEpoch::Current)? .to_vec(); let genesis_active_index_root = Hash256::from_slice(&active_validator_indices.tree_hash_root()); state.fill_active_index_roots_with(genesis_active_index_root); diff --git a/eth2/state_processing/src/per_block_processing.rs b/eth2/state_processing/src/per_block_processing.rs index 555f58c8e..aae621072 100644 --- a/eth2/state_processing/src/per_block_processing.rs +++ b/eth2/state_processing/src/per_block_processing.rs @@ -4,9 +4,7 @@ use rayon::prelude::*; use tree_hash::{SignedRoot, TreeHash}; use types::*; -pub use self::verify_attester_slashing::{ - gather_attester_slashing_indices, get_slashable_indices, verify_attester_slashing, -}; +pub use self::verify_attester_slashing::{get_slashable_indices, verify_attester_slashing}; pub use self::verify_proposer_slashing::verify_proposer_slashing; pub use validate_attestation::{ validate_attestation, validate_attestation_time_independent_only, @@ -91,9 +89,11 @@ fn per_block_processing_signature_optional( process_proposer_slashings(&mut state, &block.body.proposer_slashings, spec)?; process_attester_slashings(&mut state, &block.body.attester_slashings, spec)?; process_attestations(&mut state, &block.body.attestations, spec)?; + /* process_deposits(&mut state, &block.body.deposits, spec)?; process_exits(&mut state, &block.body.voluntary_exits, spec)?; process_transfers(&mut state, &block.body.transfers, spec)?; + */ Ok(()) } @@ -293,7 +293,7 @@ pub fn process_attester_slashings( let slashable_indices = get_slashable_indices(&state, &attester_slashing, spec) .map_err(|e| e.into_with_index(i))?; - for i in indexed_indices { + for i in slashable_indices { slash_validator(state, i as usize, None, spec)?; } } @@ -350,6 +350,7 @@ pub fn process_attestations( Ok(()) } +/* /// Validates each `Deposit` and updates the state, short-circuiting on an invalid object. /// /// Returns `Ok(())` if the validation and state updates completed successfully, otherwise returns @@ -481,3 +482,4 @@ pub fn process_transfers( Ok(()) } +*/ diff --git a/eth2/state_processing/src/per_block_processing/verify_attester_slashing.rs b/eth2/state_processing/src/per_block_processing/verify_attester_slashing.rs index 0fdf92be7..9f99feeae 100644 --- a/eth2/state_processing/src/per_block_processing/verify_attester_slashing.rs +++ b/eth2/state_processing/src/per_block_processing/verify_attester_slashing.rs @@ -1,5 +1,6 @@ use super::errors::{AttesterSlashingInvalid as Invalid, AttesterSlashingValidationError as Error}; use super::verify_indexed_attestation::verify_indexed_attestation; +use std::collections::HashSet; use types::*; /// Indicates if an `AttesterSlashing` is valid to be included in a block in the current epoch of the given @@ -19,8 +20,8 @@ pub fn verify_attester_slashing( // Spec: is_slashable_attestation_data verify!( - attestation_1.is_double_vote(attestation_2, spec) - || attestation_1.is_surround_vote(attestation_2, spec), + attestation_1.is_double_vote(attestation_2) + || attestation_1.is_surround_vote(attestation_2), Invalid::NotSlashable ); @@ -44,7 +45,7 @@ pub fn get_slashable_indices( attester_slashing: &AttesterSlashing, spec: &ChainSpec, ) -> Result, Error> { - gather_attester_slashing_indices_modular( + get_slashable_indices_modular( state, attester_slashing, |_, validator| validator.is_slashable_at(state.current_epoch()),