Fix conflicts rebasing eip4844
This commit is contained in:
parent
d292a3a6a8
commit
e9e198a2b6
@ -1017,6 +1017,7 @@ fn descriptive_db_error(item: &str, error: &StoreError) -> String {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::test_utils::EphemeralTestingSlotClockHarnessType;
|
||||||
use crate::validator_monitor::DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD;
|
use crate::validator_monitor::DEFAULT_INDIVIDUAL_TRACKING_THRESHOLD;
|
||||||
use eth2_hashing::hash;
|
use eth2_hashing::hash;
|
||||||
use genesis::{
|
use genesis::{
|
||||||
@ -1031,6 +1032,7 @@ mod test {
|
|||||||
use types::{EthSpec, MinimalEthSpec, Slot};
|
use types::{EthSpec, MinimalEthSpec, Slot};
|
||||||
|
|
||||||
type TestEthSpec = MinimalEthSpec;
|
type TestEthSpec = MinimalEthSpec;
|
||||||
|
type Builder = BeaconChainBuilder<EphemeralTestingSlotClockHarnessType<TestEthSpec>>;
|
||||||
|
|
||||||
fn get_logger() -> Logger {
|
fn get_logger() -> Logger {
|
||||||
let builder = NullLoggerBuilder;
|
let builder = NullLoggerBuilder;
|
||||||
@ -1063,7 +1065,7 @@ mod test {
|
|||||||
let (shutdown_tx, _) = futures::channel::mpsc::channel(1);
|
let (shutdown_tx, _) = futures::channel::mpsc::channel(1);
|
||||||
let runtime = TestRuntime::default();
|
let runtime = TestRuntime::default();
|
||||||
|
|
||||||
let chain = BeaconChainBuilder::new(MinimalEthSpec)
|
let chain = Builder::new(MinimalEthSpec)
|
||||||
.logger(log.clone())
|
.logger(log.clone())
|
||||||
.store(Arc::new(store))
|
.store(Arc::new(store))
|
||||||
.task_executor(runtime.task_executor.clone())
|
.task_executor(runtime.task_executor.clone())
|
||||||
|
@ -212,7 +212,7 @@ mod test {
|
|||||||
use types::*;
|
use types::*;
|
||||||
|
|
||||||
type BeaconChainHarness =
|
type BeaconChainHarness =
|
||||||
crate::test_utils::BeaconChainHarness<EphemeralHarnessType<MinimalEthSpec>>;
|
crate::test_utils::BeaconChainHarness<EphemeralTestingSlotClockHarnessType<MinimalEthSpec>>;
|
||||||
|
|
||||||
/// Returns two different committee caches for testing.
|
/// Returns two different committee caches for testing.
|
||||||
fn committee_caches() -> (Arc<CommitteeCache>, Arc<CommitteeCache>) {
|
fn committee_caches() -> (Arc<CommitteeCache>, Arc<CommitteeCache>) {
|
||||||
|
@ -69,6 +69,7 @@ pub type BaseHarnessType<TEthSpec, THotStore, TColdStore, TSlotClock> =
|
|||||||
Witness<TSlotClock, CachingEth1Backend<TEthSpec>, TEthSpec, THotStore, TColdStore>;
|
Witness<TSlotClock, CachingEth1Backend<TEthSpec>, TEthSpec, THotStore, TColdStore>;
|
||||||
|
|
||||||
pub type DiskHarnessType<E, TSlotClock> = BaseHarnessType<E, LevelDB<E>, LevelDB<E>, TSlotClock>;
|
pub type DiskHarnessType<E, TSlotClock> = BaseHarnessType<E, LevelDB<E>, LevelDB<E>, TSlotClock>;
|
||||||
|
|
||||||
pub type EphemeralHarnessType<E, TSlotClock> =
|
pub type EphemeralHarnessType<E, TSlotClock> =
|
||||||
BaseHarnessType<E, MemoryStore<E>, MemoryStore<E>, TSlotClock>;
|
BaseHarnessType<E, MemoryStore<E>, MemoryStore<E>, TSlotClock>;
|
||||||
|
|
||||||
@ -282,6 +283,18 @@ impl<E: EthSpec, S: SlotClock> Builder<DiskHarnessType<E, S>, S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<E, Hot, Cold> Builder<TestingSlotClockHarnessType<E, Hot, Cold>, TestingSlotClock>
|
||||||
|
where
|
||||||
|
E: EthSpec,
|
||||||
|
Hot: ItemStore<E>,
|
||||||
|
Cold: ItemStore<E>,
|
||||||
|
{
|
||||||
|
pub fn testing_slot_clock(mut self, slot_clock: TestingSlotClock) -> Self {
|
||||||
|
self.testing_slot_clock = Some(slot_clock);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<E, Hot, Cold, S> Builder<BaseHarnessType<E, Hot, Cold, S>, S>
|
impl<E, Hot, Cold, S> Builder<BaseHarnessType<E, Hot, Cold, S>, S>
|
||||||
where
|
where
|
||||||
E: EthSpec,
|
E: EthSpec,
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
use beacon_chain::{
|
use beacon_chain::{
|
||||||
attestation_verification::Error as AttnError,
|
attestation_verification::Error as AttnError,
|
||||||
test_utils::{
|
test_utils::{
|
||||||
test_spec, AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType,
|
test_spec, AttestationStrategy, BeaconChainHarness, BlockStrategy,
|
||||||
|
EphemeralTestingSlotClockHarnessType,
|
||||||
},
|
},
|
||||||
BeaconChain, BeaconChainError, BeaconChainTypes, WhenSlotSkipped,
|
BeaconChain, BeaconChainError, BeaconChainTypes, WhenSlotSkipped,
|
||||||
};
|
};
|
||||||
@ -31,7 +32,9 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a beacon chain harness.
|
/// Returns a beacon chain harness.
|
||||||
fn get_harness(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessType<E>> {
|
fn get_harness(
|
||||||
|
validator_count: usize,
|
||||||
|
) -> BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>> {
|
||||||
let mut spec = test_spec::<E>();
|
let mut spec = test_spec::<E>();
|
||||||
|
|
||||||
// A kind-of arbitrary number that ensures that _some_ validators are aggregators, but
|
// A kind-of arbitrary number that ensures that _some_ validators are aggregators, but
|
||||||
@ -189,7 +192,7 @@ fn get_non_aggregator<T: BeaconChainTypes>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct GossipTester {
|
struct GossipTester {
|
||||||
harness: BeaconChainHarness<EphemeralHarnessType<E>>,
|
harness: BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
/*
|
/*
|
||||||
* Valid unaggregated attestation
|
* Valid unaggregated attestation
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#![cfg(not(debug_assertions))]
|
#![cfg(not(debug_assertions))]
|
||||||
|
|
||||||
use beacon_chain::test_utils::{
|
use beacon_chain::test_utils::{
|
||||||
AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType,
|
AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralTestingSlotClockHarnessType,
|
||||||
};
|
};
|
||||||
use beacon_chain::{BeaconSnapshot, BlockError, ChainSegmentResult, NotifyExecutionLayer};
|
use beacon_chain::{BeaconSnapshot, BlockError, ChainSegmentResult, NotifyExecutionLayer};
|
||||||
use fork_choice::CountUnrealized;
|
use fork_choice::CountUnrealized;
|
||||||
@ -65,7 +65,9 @@ async fn get_chain_segment() -> Vec<BeaconSnapshot<E>> {
|
|||||||
segment
|
segment
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_harness(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessType<E>> {
|
fn get_harness(
|
||||||
|
validator_count: usize,
|
||||||
|
) -> BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>> {
|
||||||
let harness = BeaconChainHarness::builder(MainnetEthSpec)
|
let harness = BeaconChainHarness::builder(MainnetEthSpec)
|
||||||
.default_spec()
|
.default_spec()
|
||||||
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
||||||
@ -99,7 +101,7 @@ fn junk_aggregate_signature() -> AggregateSignature {
|
|||||||
|
|
||||||
fn update_proposal_signatures(
|
fn update_proposal_signatures(
|
||||||
snapshots: &mut [BeaconSnapshot<E>],
|
snapshots: &mut [BeaconSnapshot<E>],
|
||||||
harness: &BeaconChainHarness<EphemeralHarnessType<E>>,
|
harness: &BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
) {
|
) {
|
||||||
for snapshot in snapshots {
|
for snapshot in snapshots {
|
||||||
let spec = &harness.chain.spec;
|
let spec = &harness.chain.spec;
|
||||||
@ -329,7 +331,7 @@ async fn chain_segment_non_linear_slots() {
|
|||||||
|
|
||||||
async fn assert_invalid_signature(
|
async fn assert_invalid_signature(
|
||||||
chain_segment: &[BeaconSnapshot<E>],
|
chain_segment: &[BeaconSnapshot<E>],
|
||||||
harness: &BeaconChainHarness<EphemeralHarnessType<E>>,
|
harness: &BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
block_index: usize,
|
block_index: usize,
|
||||||
snapshots: &[BeaconSnapshot<E>],
|
snapshots: &[BeaconSnapshot<E>],
|
||||||
item: &str,
|
item: &str,
|
||||||
@ -400,7 +402,7 @@ async fn assert_invalid_signature(
|
|||||||
|
|
||||||
async fn get_invalid_sigs_harness(
|
async fn get_invalid_sigs_harness(
|
||||||
chain_segment: &[BeaconSnapshot<E>],
|
chain_segment: &[BeaconSnapshot<E>],
|
||||||
) -> BeaconChainHarness<EphemeralHarnessType<E>> {
|
) -> BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>> {
|
||||||
let harness = get_harness(VALIDATOR_COUNT);
|
let harness = get_harness(VALIDATOR_COUNT);
|
||||||
harness
|
harness
|
||||||
.chain
|
.chain
|
||||||
|
@ -48,7 +48,7 @@ async fn merge_with_terminal_block_hash_override() {
|
|||||||
|
|
||||||
spec.terminal_block_hash = genesis_pow_block_hash;
|
spec.terminal_block_hash = genesis_pow_block_hash;
|
||||||
|
|
||||||
let harness = BeaconChainHarness::builder(E::default(), TestingSlotClock)
|
let harness = BeaconChainHarness::builder(E::default())
|
||||||
.spec(spec)
|
.spec(spec)
|
||||||
.logger(logging::test_logger())
|
.logger(logging::test_logger())
|
||||||
.deterministic_keypairs(VALIDATOR_COUNT)
|
.deterministic_keypairs(VALIDATOR_COUNT)
|
||||||
@ -105,7 +105,7 @@ async fn base_altair_merge_with_terminal_block_after_fork() {
|
|||||||
|
|
||||||
let mut execution_payloads = vec![];
|
let mut execution_payloads = vec![];
|
||||||
|
|
||||||
let harness = BeaconChainHarness::builder(E::default(), TestingSlotClock)
|
let harness = BeaconChainHarness::builder(E::default())
|
||||||
.spec(spec)
|
.spec(spec)
|
||||||
.logger(logging::test_logger())
|
.logger(logging::test_logger())
|
||||||
.deterministic_keypairs(VALIDATOR_COUNT)
|
.deterministic_keypairs(VALIDATOR_COUNT)
|
||||||
|
@ -8,6 +8,7 @@ use beacon_chain::test_utils::{
|
|||||||
};
|
};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use sloggers::{null::NullLoggerBuilder, Build};
|
use sloggers::{null::NullLoggerBuilder, Build};
|
||||||
|
use slot_clock::TestingSlotClock;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use store::{LevelDB, StoreConfig};
|
use store::{LevelDB, StoreConfig};
|
||||||
use tempfile::{tempdir, TempDir};
|
use tempfile::{tempdir, TempDir};
|
||||||
@ -22,7 +23,7 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type E = MinimalEthSpec;
|
type E = MinimalEthSpec;
|
||||||
type TestHarness = BeaconChainHarness<DiskHarnessType<E>>;
|
type TestHarness = BeaconChainHarness<DiskHarnessType<E, TestingSlotClock>>;
|
||||||
type HotColdDB = store::HotColdDB<E, LevelDB<E>, LevelDB<E>>;
|
type HotColdDB = store::HotColdDB<E, LevelDB<E>, LevelDB<E>>;
|
||||||
|
|
||||||
fn get_store(db_path: &TempDir) -> Arc<HotColdDB> {
|
fn get_store(db_path: &TempDir) -> Arc<HotColdDB> {
|
||||||
|
@ -6,7 +6,7 @@ use beacon_chain::otb_verification_service::{
|
|||||||
};
|
};
|
||||||
use beacon_chain::{
|
use beacon_chain::{
|
||||||
canonical_head::{CachedHead, CanonicalHead},
|
canonical_head::{CachedHead, CanonicalHead},
|
||||||
test_utils::{BeaconChainHarness, EphemeralHarnessType},
|
test_utils::{BeaconChainHarness, EphemeralTestingSlotClockHarnessType},
|
||||||
BeaconChainError, BlockError, ExecutionPayloadError, NotifyExecutionLayer,
|
BeaconChainError, BlockError, ExecutionPayloadError, NotifyExecutionLayer,
|
||||||
OverrideForkchoiceUpdate, StateSkipConfig, WhenSlotSkipped,
|
OverrideForkchoiceUpdate, StateSkipConfig, WhenSlotSkipped,
|
||||||
INVALID_FINALIZED_MERGE_TRANSITION_BLOCK_SHUTDOWN_REASON,
|
INVALID_FINALIZED_MERGE_TRANSITION_BLOCK_SHUTDOWN_REASON,
|
||||||
@ -45,7 +45,7 @@ enum Payload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct InvalidPayloadRig {
|
struct InvalidPayloadRig {
|
||||||
harness: BeaconChainHarness<EphemeralHarnessType<E>>,
|
harness: BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
enable_attestations: bool,
|
enable_attestations: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ impl InvalidPayloadRig {
|
|||||||
self.harness.chain.canonical_head.cached_head()
|
self.harness.chain.canonical_head.cached_head()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn canonical_head(&self) -> &CanonicalHead<EphemeralHarnessType<E>> {
|
fn canonical_head(&self) -> &CanonicalHead<EphemeralTestingSlotClockHarnessType<E>> {
|
||||||
&self.harness.chain.canonical_head
|
&self.harness.chain.canonical_head
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ use lazy_static::lazy_static;
|
|||||||
use logging::test_logger;
|
use logging::test_logger;
|
||||||
use maplit::hashset;
|
use maplit::hashset;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use slot_clock::TestingSlotClock;
|
||||||
use state_processing::BlockReplayer;
|
use state_processing::BlockReplayer;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
@ -44,7 +45,7 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type E = MinimalEthSpec;
|
type E = MinimalEthSpec;
|
||||||
type TestHarness = BeaconChainHarness<DiskHarnessType<E>>;
|
type TestHarness = BeaconChainHarness<DiskHarnessType<E, TestingSlotClock>>;
|
||||||
|
|
||||||
fn get_store(db_path: &TempDir) -> Arc<HotColdDB<E, LevelDB<E>, LevelDB<E>>> {
|
fn get_store(db_path: &TempDir) -> Arc<HotColdDB<E, LevelDB<E>, LevelDB<E>>> {
|
||||||
get_store_with_spec(db_path, test_spec::<E>())
|
get_store_with_spec(db_path, test_spec::<E>())
|
||||||
@ -67,7 +68,7 @@ fn get_harness(
|
|||||||
store: Arc<HotColdDB<E, LevelDB<E>, LevelDB<E>>>,
|
store: Arc<HotColdDB<E, LevelDB<E>, LevelDB<E>>>,
|
||||||
validator_count: usize,
|
validator_count: usize,
|
||||||
) -> TestHarness {
|
) -> TestHarness {
|
||||||
let harness = BeaconChainHarness::builder(MinimalEthSpec)
|
let harness = TestHarness::builder(MinimalEthSpec)
|
||||||
.default_spec()
|
.default_spec()
|
||||||
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
||||||
.fresh_disk_store(store)
|
.fresh_disk_store(store)
|
||||||
@ -567,7 +568,7 @@ async fn delete_blocks_and_states() {
|
|||||||
let store = get_store(&db_path);
|
let store = get_store(&db_path);
|
||||||
let validators_keypairs =
|
let validators_keypairs =
|
||||||
types::test_utils::generate_deterministic_keypairs(LOW_VALIDATOR_COUNT);
|
types::test_utils::generate_deterministic_keypairs(LOW_VALIDATOR_COUNT);
|
||||||
let harness = BeaconChainHarness::builder(MinimalEthSpec)
|
let harness = TestHarness::builder(MinimalEthSpec)
|
||||||
.default_spec()
|
.default_spec()
|
||||||
.keypairs(validators_keypairs)
|
.keypairs(validators_keypairs)
|
||||||
.fresh_disk_store(store.clone())
|
.fresh_disk_store(store.clone())
|
||||||
@ -697,7 +698,7 @@ async fn multi_epoch_fork_valid_blocks_test(
|
|||||||
let store = get_store(&db_path);
|
let store = get_store(&db_path);
|
||||||
let validators_keypairs =
|
let validators_keypairs =
|
||||||
types::test_utils::generate_deterministic_keypairs(LOW_VALIDATOR_COUNT);
|
types::test_utils::generate_deterministic_keypairs(LOW_VALIDATOR_COUNT);
|
||||||
let harness = BeaconChainHarness::builder(MinimalEthSpec)
|
let harness = TestHarness::builder(MinimalEthSpec)
|
||||||
.default_spec()
|
.default_spec()
|
||||||
.keypairs(validators_keypairs)
|
.keypairs(validators_keypairs)
|
||||||
.fresh_disk_store(store)
|
.fresh_disk_store(store)
|
||||||
@ -2109,7 +2110,7 @@ async fn weak_subjectivity_sync() {
|
|||||||
|
|
||||||
// Initialise a new beacon chain from the finalized checkpoint
|
// Initialise a new beacon chain from the finalized checkpoint
|
||||||
let beacon_chain = Arc::new(
|
let beacon_chain = Arc::new(
|
||||||
BeaconChainBuilder::new(MinimalEthSpec)
|
BeaconChainBuilder::<DiskHarnessType<E, TestingSlotClock>>::new(MinimalEthSpec)
|
||||||
.store(store.clone())
|
.store(store.clone())
|
||||||
.custom_spec(test_spec::<E>())
|
.custom_spec(test_spec::<E>())
|
||||||
.task_executor(harness.chain.task_executor.clone())
|
.task_executor(harness.chain.task_executor.clone())
|
||||||
@ -2306,7 +2307,8 @@ async fn finalizes_after_resuming_from_db() {
|
|||||||
|
|
||||||
let original_chain = harness.chain;
|
let original_chain = harness.chain;
|
||||||
|
|
||||||
let resumed_harness = BeaconChainHarness::builder(MinimalEthSpec)
|
let resumed_harness =
|
||||||
|
BeaconChainHarness::<DiskHarnessType<E, TestingSlotClock>>::builder(MinimalEthSpec)
|
||||||
.default_spec()
|
.default_spec()
|
||||||
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
||||||
.resumed_disk_store(store)
|
.resumed_disk_store(store)
|
||||||
@ -2482,7 +2484,7 @@ async fn revert_minority_fork_on_resume() {
|
|||||||
drop(harness1);
|
drop(harness1);
|
||||||
let resume_store = get_store_with_spec(&db_path1, spec2.clone());
|
let resume_store = get_store_with_spec(&db_path1, spec2.clone());
|
||||||
|
|
||||||
let resumed_harness = BeaconChainHarness::builder(MinimalEthSpec)
|
let resumed_harness = TestHarness::builder(MinimalEthSpec)
|
||||||
.spec(spec2)
|
.spec(spec2)
|
||||||
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
||||||
.resumed_disk_store(resume_store)
|
.resumed_disk_store(resume_store)
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
#![cfg(not(debug_assertions))]
|
#![cfg(not(debug_assertions))]
|
||||||
|
|
||||||
use beacon_chain::sync_committee_verification::Error as SyncCommitteeError;
|
use beacon_chain::sync_committee_verification::Error as SyncCommitteeError;
|
||||||
use beacon_chain::test_utils::{BeaconChainHarness, EphemeralHarnessType, RelativeSyncCommittee};
|
use beacon_chain::test_utils::{
|
||||||
|
BeaconChainHarness, EphemeralTestingSlotClockHarnessType, RelativeSyncCommittee,
|
||||||
|
};
|
||||||
use int_to_bytes::int_to_bytes32;
|
use int_to_bytes::int_to_bytes32;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use safe_arith::SafeArith;
|
use safe_arith::SafeArith;
|
||||||
@ -23,7 +25,9 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a beacon chain harness.
|
/// Returns a beacon chain harness.
|
||||||
fn get_harness(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessType<E>> {
|
fn get_harness(
|
||||||
|
validator_count: usize,
|
||||||
|
) -> BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>> {
|
||||||
let mut spec = E::default_spec();
|
let mut spec = E::default_spec();
|
||||||
spec.altair_fork_epoch = Some(Epoch::new(0));
|
spec.altair_fork_epoch = Some(Epoch::new(0));
|
||||||
let harness = BeaconChainHarness::builder(MainnetEthSpec)
|
let harness = BeaconChainHarness::builder(MainnetEthSpec)
|
||||||
@ -42,7 +46,7 @@ fn get_harness(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessTyp
|
|||||||
///
|
///
|
||||||
/// Also returns some info about who created it.
|
/// Also returns some info about who created it.
|
||||||
fn get_valid_sync_committee_message(
|
fn get_valid_sync_committee_message(
|
||||||
harness: &BeaconChainHarness<EphemeralHarnessType<E>>,
|
harness: &BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
relative_sync_committee: RelativeSyncCommittee,
|
relative_sync_committee: RelativeSyncCommittee,
|
||||||
message_index: usize,
|
message_index: usize,
|
||||||
@ -68,7 +72,7 @@ fn get_valid_sync_committee_message(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_valid_sync_contribution(
|
fn get_valid_sync_contribution(
|
||||||
harness: &BeaconChainHarness<EphemeralHarnessType<E>>,
|
harness: &BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
relative_sync_committee: RelativeSyncCommittee,
|
relative_sync_committee: RelativeSyncCommittee,
|
||||||
) -> (SignedContributionAndProof<E>, usize, SecretKey) {
|
) -> (SignedContributionAndProof<E>, usize, SecretKey) {
|
||||||
let head_state = harness.chain.head_beacon_state_cloned();
|
let head_state = harness.chain.head_beacon_state_cloned();
|
||||||
@ -100,7 +104,7 @@ fn get_valid_sync_contribution(
|
|||||||
|
|
||||||
/// Returns a proof and index for a validator that is **not** an aggregator for the current sync period.
|
/// Returns a proof and index for a validator that is **not** an aggregator for the current sync period.
|
||||||
fn get_non_aggregator(
|
fn get_non_aggregator(
|
||||||
harness: &BeaconChainHarness<EphemeralHarnessType<E>>,
|
harness: &BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
slot: Slot,
|
slot: Slot,
|
||||||
) -> (usize, SecretKey) {
|
) -> (usize, SecretKey) {
|
||||||
let state = &harness.chain.head_snapshot().beacon_state;
|
let state = &harness.chain.head_snapshot().beacon_state;
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
use beacon_chain::{
|
use beacon_chain::{
|
||||||
attestation_verification::Error as AttnError,
|
attestation_verification::Error as AttnError,
|
||||||
test_utils::{
|
test_utils::{
|
||||||
AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType,
|
AttestationStrategy, BeaconChainHarness, BlockStrategy,
|
||||||
OP_POOL_DB_KEY,
|
EphemeralTestingSlotClockHarnessType, OP_POOL_DB_KEY,
|
||||||
},
|
},
|
||||||
BeaconChain, NotifyExecutionLayer, StateSkipConfig, WhenSlotSkipped,
|
BeaconChain, NotifyExecutionLayer, StateSkipConfig, WhenSlotSkipped,
|
||||||
};
|
};
|
||||||
@ -26,7 +26,9 @@ lazy_static! {
|
|||||||
static ref KEYPAIRS: Vec<Keypair> = types::test_utils::generate_deterministic_keypairs(VALIDATOR_COUNT);
|
static ref KEYPAIRS: Vec<Keypair> = types::test_utils::generate_deterministic_keypairs(VALIDATOR_COUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_harness(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessType<MinimalEthSpec>> {
|
fn get_harness(
|
||||||
|
validator_count: usize,
|
||||||
|
) -> BeaconChainHarness<EphemeralTestingSlotClockHarnessType<MinimalEthSpec>> {
|
||||||
let harness = BeaconChainHarness::builder(MinimalEthSpec)
|
let harness = BeaconChainHarness::builder(MinimalEthSpec)
|
||||||
.default_spec()
|
.default_spec()
|
||||||
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
||||||
@ -143,7 +145,7 @@ async fn iterators() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn find_reorg_slot(
|
fn find_reorg_slot(
|
||||||
chain: &BeaconChain<EphemeralHarnessType<MinimalEthSpec>>,
|
chain: &BeaconChain<EphemeralTestingSlotClockHarnessType<MinimalEthSpec>>,
|
||||||
new_state: &BeaconState<MinimalEthSpec>,
|
new_state: &BeaconState<MinimalEthSpec>,
|
||||||
new_block_root: Hash256,
|
new_block_root: Hash256,
|
||||||
) -> Slot {
|
) -> Slot {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use beacon_chain::{
|
use beacon_chain::{
|
||||||
test_utils::{
|
test_utils::{BeaconChainHarness, BoxedMutator, EphemeralTestingSlotClockHarnessType},
|
||||||
BeaconChainHarness, BoxedMutator, Builder as HarnessBuilder, EphemeralHarnessType,
|
|
||||||
},
|
|
||||||
BeaconChain, BeaconChainTypes,
|
BeaconChain, BeaconChainTypes,
|
||||||
};
|
};
|
||||||
use directory::DEFAULT_ROOT_DIR;
|
use directory::DEFAULT_ROOT_DIR;
|
||||||
@ -39,7 +37,7 @@ pub const EXTERNAL_ADDR: &str = "/ip4/0.0.0.0/tcp/9000";
|
|||||||
|
|
||||||
/// HTTP API tester that allows interaction with the underlying beacon chain harness.
|
/// HTTP API tester that allows interaction with the underlying beacon chain harness.
|
||||||
pub struct InteractiveTester<E: EthSpec> {
|
pub struct InteractiveTester<E: EthSpec> {
|
||||||
pub harness: BeaconChainHarness<EphemeralHarnessType<E>>,
|
pub harness: BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
pub client: BeaconNodeHttpClient,
|
pub client: BeaconNodeHttpClient,
|
||||||
pub network_rx: NetworkReceivers<E>,
|
pub network_rx: NetworkReceivers<E>,
|
||||||
_server_shutdown: oneshot::Sender<()>,
|
_server_shutdown: oneshot::Sender<()>,
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
use crate::common::{create_api_server, create_api_server_on_port, ApiServer};
|
use crate::common::{create_api_server, create_api_server_on_port, ApiServer};
|
||||||
use beacon_chain::test_utils::RelativeSyncCommittee;
|
use beacon_chain::test_utils::RelativeSyncCommittee;
|
||||||
use beacon_chain::{
|
use beacon_chain::{
|
||||||
test_utils::{AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType},
|
test_utils::{
|
||||||
|
AttestationStrategy, BeaconChainHarness, BlockStrategy,
|
||||||
|
EphemeralTestingSlotClockHarnessType,
|
||||||
|
},
|
||||||
BeaconChain, StateSkipConfig, WhenSlotSkipped, MAXIMUM_GOSSIP_CLOCK_DISPARITY,
|
BeaconChain, StateSkipConfig, WhenSlotSkipped, MAXIMUM_GOSSIP_CLOCK_DISPARITY,
|
||||||
};
|
};
|
||||||
use environment::null_logger;
|
use environment::null_logger;
|
||||||
@ -57,8 +60,8 @@ const SKIPPED_SLOTS: &[u64] = &[
|
|||||||
];
|
];
|
||||||
|
|
||||||
struct ApiTester {
|
struct ApiTester {
|
||||||
harness: Arc<BeaconChainHarness<EphemeralHarnessType<E>>>,
|
harness: Arc<BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>>,
|
||||||
chain: Arc<BeaconChain<EphemeralHarnessType<E>>>,
|
chain: Arc<BeaconChain<EphemeralTestingSlotClockHarnessType<E>>>,
|
||||||
client: BeaconNodeHttpClient,
|
client: BeaconNodeHttpClient,
|
||||||
next_block: SignedBeaconBlock<E>,
|
next_block: SignedBeaconBlock<E>,
|
||||||
reorg_block: SignedBeaconBlock<E>,
|
reorg_block: SignedBeaconBlock<E>,
|
||||||
|
@ -7,7 +7,7 @@ use crate::beacon_processor::work_reprocessing_queue::{
|
|||||||
use crate::beacon_processor::*;
|
use crate::beacon_processor::*;
|
||||||
use crate::{service::NetworkMessage, sync::SyncMessage};
|
use crate::{service::NetworkMessage, sync::SyncMessage};
|
||||||
use beacon_chain::test_utils::{
|
use beacon_chain::test_utils::{
|
||||||
AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType,
|
AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralTestingSlotClockHarnessType,
|
||||||
};
|
};
|
||||||
use beacon_chain::{BeaconChain, MAXIMUM_GOSSIP_CLOCK_DISPARITY};
|
use beacon_chain::{BeaconChain, MAXIMUM_GOSSIP_CLOCK_DISPARITY};
|
||||||
use lighthouse_network::{
|
use lighthouse_network::{
|
||||||
@ -28,7 +28,7 @@ use types::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
type E = MainnetEthSpec;
|
type E = MainnetEthSpec;
|
||||||
type T = EphemeralHarnessType<E>;
|
type T = EphemeralTestingSlotClockHarnessType<E>;
|
||||||
|
|
||||||
const SLOTS_PER_EPOCH: u64 = 32;
|
const SLOTS_PER_EPOCH: u64 = 32;
|
||||||
const VALIDATOR_COUNT: usize = SLOTS_PER_EPOCH as usize;
|
const VALIDATOR_COUNT: usize = SLOTS_PER_EPOCH as usize;
|
||||||
|
@ -768,7 +768,7 @@ mod release_tests {
|
|||||||
use super::attestation::earliest_attestation_validators;
|
use super::attestation::earliest_attestation_validators;
|
||||||
use super::*;
|
use super::*;
|
||||||
use beacon_chain::test_utils::{
|
use beacon_chain::test_utils::{
|
||||||
test_spec, BeaconChainHarness, EphemeralHarnessType, RelativeSyncCommittee,
|
test_spec, BeaconChainHarness, EphemeralTestingSlotClockHarnessType, RelativeSyncCommittee,
|
||||||
};
|
};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use maplit::hashset;
|
use maplit::hashset;
|
||||||
@ -787,8 +787,8 @@ mod release_tests {
|
|||||||
fn get_harness<E: EthSpec>(
|
fn get_harness<E: EthSpec>(
|
||||||
validator_count: usize,
|
validator_count: usize,
|
||||||
spec: Option<ChainSpec>,
|
spec: Option<ChainSpec>,
|
||||||
) -> BeaconChainHarness<EphemeralHarnessType<E>> {
|
) -> BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>> {
|
||||||
let harness = BeaconChainHarness::builder(E::default(), TestingSlotClock)
|
let harness = BeaconChainHarness::builder(E::default())
|
||||||
.spec_or_default(spec)
|
.spec_or_default(spec)
|
||||||
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
.keypairs(KEYPAIRS[0..validator_count].to_vec())
|
||||||
.fresh_ephemeral_store()
|
.fresh_ephemeral_store()
|
||||||
@ -803,7 +803,10 @@ mod release_tests {
|
|||||||
/// Test state for attestation-related tests.
|
/// Test state for attestation-related tests.
|
||||||
fn attestation_test_state<E: EthSpec>(
|
fn attestation_test_state<E: EthSpec>(
|
||||||
num_committees: usize,
|
num_committees: usize,
|
||||||
) -> (BeaconChainHarness<EphemeralHarnessType<E>>, ChainSpec) {
|
) -> (
|
||||||
|
BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
|
ChainSpec,
|
||||||
|
) {
|
||||||
let spec = test_spec::<E>();
|
let spec = test_spec::<E>();
|
||||||
|
|
||||||
let num_validators =
|
let num_validators =
|
||||||
@ -816,7 +819,10 @@ mod release_tests {
|
|||||||
/// Test state for sync contribution-related tests.
|
/// Test state for sync contribution-related tests.
|
||||||
async fn sync_contribution_test_state<E: EthSpec>(
|
async fn sync_contribution_test_state<E: EthSpec>(
|
||||||
num_committees: usize,
|
num_committees: usize,
|
||||||
) -> (BeaconChainHarness<EphemeralHarnessType<E>>, ChainSpec) {
|
) -> (
|
||||||
|
BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
|
ChainSpec,
|
||||||
|
) {
|
||||||
let mut spec = E::default_spec();
|
let mut spec = E::default_spec();
|
||||||
spec.altair_fork_epoch = Some(Epoch::new(0));
|
spec.altair_fork_epoch = Some(Epoch::new(0));
|
||||||
|
|
||||||
@ -1786,8 +1792,10 @@ mod release_tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cross_fork_harness<E: EthSpec>() -> (BeaconChainHarness<EphemeralHarnessType<E>>, ChainSpec)
|
fn cross_fork_harness<E: EthSpec>() -> (
|
||||||
{
|
BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
|
ChainSpec,
|
||||||
|
) {
|
||||||
let mut spec = E::default_spec();
|
let mut spec = E::default_spec();
|
||||||
|
|
||||||
// Give some room to sign surround slashings.
|
// Give some room to sign surround slashings.
|
||||||
|
@ -67,12 +67,6 @@ impl SlotClock for SystemTimeSlotClock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ManualSlotClock> for SystemTimeSlotClock {
|
|
||||||
fn from(clock: ManualSlotClock) -> Self {
|
|
||||||
SystemTimeSlotClock { clock }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -35,7 +35,7 @@ pub enum MutationDelay {
|
|||||||
|
|
||||||
/// A helper struct to make testing fork choice more ergonomic and less repetitive.
|
/// A helper struct to make testing fork choice more ergonomic and less repetitive.
|
||||||
struct ForkChoiceTest {
|
struct ForkChoiceTest {
|
||||||
harness: BeaconChainHarness<EphemeralHarnessType<E>>,
|
harness: BeaconChainHarness<EphemeralTestingSlotClockHarnessType<E>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Allows us to use `unwrap` in some cases.
|
/// Allows us to use `unwrap` in some cases.
|
||||||
@ -397,7 +397,7 @@ impl ForkChoiceTest {
|
|||||||
mut comparison_func: G,
|
mut comparison_func: G,
|
||||||
) -> Self
|
) -> Self
|
||||||
where
|
where
|
||||||
F: FnMut(&mut IndexedAttestation<E>, &BeaconChain<EphemeralHarnessType<E>>),
|
F: FnMut(&mut IndexedAttestation<E>, &BeaconChain<EphemeralTestingSlotClockHarnessType<E>>),
|
||||||
G: FnMut(Result<(), BeaconChainError>),
|
G: FnMut(Result<(), BeaconChainError>),
|
||||||
{
|
{
|
||||||
let head = self.harness.chain.head_snapshot();
|
let head = self.harness.chain.head_snapshot();
|
||||||
|
Loading…
Reference in New Issue
Block a user