Mallory - Single commit

This commit is contained in:
Age Manning
2025-03-25 16:53:10 +11:00
parent b8178515cd
commit e2acce9468
118 changed files with 4753 additions and 3938 deletions

View File

@@ -42,7 +42,10 @@ enum DataSidecars<E: EthSpec> {
}
async fn get_chain_segment() -> (Vec<BeaconSnapshot<E>>, Vec<Option<DataSidecars<E>>>) {
let harness = get_harness(VALIDATOR_COUNT);
// The assumption that you can re-import a block based on what you have in your DB
// is no longer true, as fullnodes stores less than what they sample.
// We use a supernode here to build a chain segment.
let harness = get_harness(VALIDATOR_COUNT, true);
harness
.extend_chain(
@@ -101,7 +104,10 @@ async fn get_chain_segment() -> (Vec<BeaconSnapshot<E>>, Vec<Option<DataSidecars
(segment, segment_sidecars)
}
fn get_harness(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessType<E>> {
fn get_harness(
validator_count: usize,
supernode: bool,
) -> BeaconChainHarness<EphemeralHarnessType<E>> {
let harness = BeaconChainHarness::builder(MainnetEthSpec)
.default_spec()
.chain_config(ChainConfig {
@@ -109,6 +115,7 @@ fn get_harness(validator_count: usize) -> BeaconChainHarness<EphemeralHarnessTyp
..ChainConfig::default()
})
.keypairs(KEYPAIRS[0..validator_count].to_vec())
.import_all_data_columns(supernode)
.fresh_ephemeral_store()
.mock_execution_layer()
.build();
@@ -252,7 +259,7 @@ fn update_data_column_signed_header<E: EthSpec>(
#[tokio::test]
async fn chain_segment_full_segment() {
let harness = get_harness(VALIDATOR_COUNT);
let harness = get_harness(VALIDATOR_COUNT, false);
let (chain_segment, chain_segment_blobs) = get_chain_segment().await;
let blocks: Vec<RpcBlock<E>> = chain_segment_blocks(&chain_segment, &chain_segment_blobs)
.into_iter()
@@ -290,7 +297,7 @@ async fn chain_segment_full_segment() {
#[tokio::test]
async fn chain_segment_varying_chunk_size() {
for chunk_size in &[1, 2, 3, 5, 31, 32, 33, 42] {
let harness = get_harness(VALIDATOR_COUNT);
let harness = get_harness(VALIDATOR_COUNT, false);
let (chain_segment, chain_segment_blobs) = get_chain_segment().await;
let blocks: Vec<RpcBlock<E>> = chain_segment_blocks(&chain_segment, &chain_segment_blobs)
.into_iter()
@@ -322,7 +329,7 @@ async fn chain_segment_varying_chunk_size() {
#[tokio::test]
async fn chain_segment_non_linear_parent_roots() {
let harness = get_harness(VALIDATOR_COUNT);
let harness = get_harness(VALIDATOR_COUNT, false);
let (chain_segment, chain_segment_blobs) = get_chain_segment().await;
harness
@@ -379,7 +386,7 @@ async fn chain_segment_non_linear_parent_roots() {
#[tokio::test]
async fn chain_segment_non_linear_slots() {
let harness = get_harness(VALIDATOR_COUNT);
let harness = get_harness(VALIDATOR_COUNT, false);
let (chain_segment, chain_segment_blobs) = get_chain_segment().await;
harness
.chain
@@ -521,7 +528,7 @@ async fn assert_invalid_signature(
async fn get_invalid_sigs_harness(
chain_segment: &[BeaconSnapshot<E>],
) -> BeaconChainHarness<EphemeralHarnessType<E>> {
let harness = get_harness(VALIDATOR_COUNT);
let harness = get_harness(VALIDATOR_COUNT, false);
harness
.chain
.slot_clock
@@ -979,7 +986,7 @@ fn unwrap_err<T, U>(result: Result<T, U>) -> U {
#[tokio::test]
async fn block_gossip_verification() {
let harness = get_harness(VALIDATOR_COUNT);
let harness = get_harness(VALIDATOR_COUNT, false);
let (chain_segment, chain_segment_blobs) = get_chain_segment().await;
let block_index = CHAIN_SEGMENT_LENGTH - 2;
@@ -1382,7 +1389,7 @@ async fn verify_block_for_gossip_slashing_detection() {
#[tokio::test]
async fn verify_block_for_gossip_doppelganger_detection() {
let harness = get_harness(VALIDATOR_COUNT);
let harness = get_harness(VALIDATOR_COUNT, false);
let state = harness.get_current_state();
let ((block, _), _) = harness.make_block(state.clone(), Slot::new(1)).await;
@@ -1730,6 +1737,8 @@ async fn add_altair_block_to_base_chain() {
));
}
// This is a regression test for this bug:
// https://github.com/sigp/lighthouse/issues/4332#issuecomment-1565092279
#[tokio::test]
async fn import_duplicate_block_unrealized_justification() {
let spec = MainnetEthSpec::default_spec();
@@ -1791,7 +1800,7 @@ async fn import_duplicate_block_unrealized_justification() {
.await
.unwrap();
// Unrealized justification should NOT have updated.
// The store's global unrealized justification should update immediately and match the block.
let unrealized_justification = {
let fc = chain.canonical_head.fork_choice_read_lock();
assert_eq!(fc.justified_checkpoint().epoch, 0);
@@ -1808,9 +1817,12 @@ async fn import_duplicate_block_unrealized_justification() {
};
// Import the second verified block, simulating a block processed via RPC.
import_execution_pending_block(chain.clone(), verified_block2)
.await
.unwrap();
assert_eq!(
import_execution_pending_block(chain.clone(), verified_block2)
.await
.unwrap_err(),
format!("DuplicateFullyImported({block_root})")
);
// Unrealized justification should still be updated.
let fc3 = chain.canonical_head.fork_choice_read_lock();