Fix conflicts rebasing eip4844

This commit is contained in:
Emilia Hane 2023-02-06 16:10:57 +01:00
parent c7b49feb9e
commit 2653f88b5f
No known key found for this signature in database
GPG Key ID: E73394F9C09206FA
3 changed files with 50 additions and 25 deletions

View File

@ -837,16 +837,6 @@ where
.collect()
}
pub fn get_finalized_checkpoints(&self) -> HashSet<SignedBeaconBlockHash> {
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<E>,
slot: Slot,
_block_strategy: BlockStrategy,
) -> (SignedBeaconBlock<E>, BeaconState<E>) {
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<SignedBeaconBlockHash> {
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<E>,
slot: Slot,
_block_strategy: BlockStrategy,
) -> (SignedBeaconBlock<E>, BeaconState<E>) {
self.make_block(state, slot).await
}
pub async fn make_block(
&self,
mut state: BeaconState<E>,
@ -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<E>,
) -> 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.

View File

@ -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<Keypair> = generate_deterministic_keypairs(VALIDATOR_COUNT);
}
fn get_harness<E: EthSpec>() -> BeaconChainHarness<EphemeralHarnessType<E>> {
fn get_harness<E: EthSpec>() -> BeaconChainHarness<HarnessType<E>> {
let mut spec = E::default_spec();
spec.altair_fork_epoch = Some(Epoch::new(0)); // We use altair for all tests

View File

@ -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::{