diff --git a/beacon_node/beacon_chain/src/test_utils.rs b/beacon_node/beacon_chain/src/test_utils.rs index a2dcdeefe..d2abcadd0 100644 --- a/beacon_node/beacon_chain/src/test_utils.rs +++ b/beacon_node/beacon_chain/src/test_utils.rs @@ -837,16 +837,6 @@ where .collect() } - pub fn get_finalized_checkpoints(&self) -> HashSet { - let chain_dump = self.chain.chain_dump().unwrap(); - chain_dump - .iter() - .cloned() - .map(|checkpoint| checkpoint.beacon_state.finalized_checkpoint().root.into()) - .filter(|block_hash| *block_hash != Hash256::zero().into()) - .collect() - } - /// Deprecated: Do not modify the slot clock manually; rely on add_attested_blocks_at_slots() /// instead /// @@ -863,18 +853,6 @@ where self.chain.slot_clock.set_current_time(time); } - /// Deprecated: Use make_block() instead - /// - /// Returns a newly created block, signed by the proposer for the given slot. - pub async fn build_block( - &self, - state: BeaconState, - slot: Slot, - _block_strategy: BlockStrategy, - ) -> (SignedBeaconBlock, BeaconState) { - self.make_block(state, slot).await - } - /// Uses `Self::extend_chain` to build the chain out to the `target_slot`. pub async fn extend_to_slot(&self, target_slot: Slot) -> Hash256 { if self.chain.slot().unwrap() == self.chain.canonical_head.cached_head().head_slot() { @@ -1086,6 +1064,16 @@ where self.chain.canonical_head.cached_head().head_block_root() } + pub fn get_finalized_checkpoints(&self) -> HashSet { + let chain_dump = self.chain.chain_dump().unwrap(); + chain_dump + .iter() + .cloned() + .map(|checkpoint| checkpoint.beacon_state.finalized_checkpoint().root.into()) + .filter(|block_hash| *block_hash != Hash256::zero().into()) + .collect() + } + pub fn finalized_checkpoint(&self) -> Checkpoint { self.chain .canonical_head @@ -1141,6 +1129,18 @@ where state.get_block_root(slot).unwrap() == state.get_block_root(slot - 1).unwrap() } + /// Deprecated: Use make_block() instead + /// + /// Returns a newly created block, signed by the proposer for the given slot. + pub async fn build_block( + &self, + state: BeaconState, + slot: Slot, + _block_strategy: BlockStrategy, + ) -> (SignedBeaconBlock, BeaconState) { + self.make_block(state, slot).await + } + pub async fn make_block( &self, mut state: BeaconState, @@ -2122,6 +2122,30 @@ where self.make_attestations(validators, state, state_root, block_hash, block.slot()); self.process_attestations(attestations); } + + pub fn process_sync_contributions( + &self, + sync_contributions: HarnessSyncContributions, + ) -> Result<(), SyncCommitteeError> { + let mut verified_contributions = Vec::with_capacity(sync_contributions.len()); + + for (_, contribution_and_proof) in sync_contributions { + let signed_contribution_and_proof = contribution_and_proof.unwrap(); + + let verified_contribution = self + .chain + .verify_sync_contribution_for_gossip(signed_contribution_and_proof)?; + + verified_contributions.push(verified_contribution); + } + + for verified_contribution in verified_contributions { + self.chain + .add_contribution_to_block_inclusion_pool(verified_contribution)?; + } + + Ok(()) + } } // Junk `Debug` impl to satistfy certain trait bounds during testing. diff --git a/beacon_node/beacon_chain/tests/rewards.rs b/beacon_node/beacon_chain/tests/rewards.rs index b61bea124..a10368cbd 100644 --- a/beacon_node/beacon_chain/tests/rewards.rs +++ b/beacon_node/beacon_chain/tests/rewards.rs @@ -3,7 +3,8 @@ use std::collections::HashMap; use beacon_chain::test_utils::{ - generate_deterministic_keypairs, BeaconChainHarness, EphemeralHarnessType, + generate_deterministic_keypairs, BeaconChainHarness, + EphemeralTestingSlotClockHarnessType as HarnessType, }; use beacon_chain::{ test_utils::{AttestationStrategy, BlockStrategy, RelativeSyncCommittee}, @@ -17,7 +18,7 @@ lazy_static! { static ref KEYPAIRS: Vec = generate_deterministic_keypairs(VALIDATOR_COUNT); } -fn get_harness() -> BeaconChainHarness> { +fn get_harness() -> BeaconChainHarness> { let mut spec = E::default_spec(); spec.altair_fork_epoch = Some(Epoch::new(0)); // We use altair for all tests diff --git a/consensus/types/src/beacon_state/tests.rs b/consensus/types/src/beacon_state/tests.rs index dfbb496a0..333caf4ed 100644 --- a/consensus/types/src/beacon_state/tests.rs +++ b/consensus/types/src/beacon_state/tests.rs @@ -2,7 +2,7 @@ use crate::test_utils::*; use crate::test_utils::{SeedableRng, XorShiftRng}; use beacon_chain::test_utils::{ - interop_genesis_state, test_spec, BeaconChainHarness, + interop_genesis_state_with_eth1, test_spec, BeaconChainHarness, EphemeralTestingSlotClockHarnessType as HarnessType, DEFAULT_ETH1_BLOCK_HASH, }; use beacon_chain::types::{