Skip to content

Commit 697d2fe

Browse files
committed
Add data column test
1 parent a5ec707 commit 697d2fe

File tree

3 files changed

+118
-3
lines changed

3 files changed

+118
-3
lines changed

beacon_node/beacon_chain/tests/blob_verification.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ static KEYPAIRS: LazyLock<Vec<Keypair>> =
2323
fn get_harness(
2424
validator_count: usize,
2525
spec: Arc<ChainSpec>,
26-
supernode: bool,
2726
) -> BeaconChainHarness<EphemeralHarnessType<E>> {
2827
create_test_tracing_subscriber();
2928
let harness = BeaconChainHarness::builder(MainnetEthSpec)
@@ -33,7 +32,6 @@ fn get_harness(
3332
..ChainConfig::default()
3433
})
3534
.keypairs(KEYPAIRS[0..validator_count].to_vec())
36-
.import_all_data_columns(supernode)
3735
.fresh_ephemeral_store()
3836
.mock_execution_layer()
3937
.build();
@@ -53,7 +51,7 @@ async fn rpc_blobs_with_invalid_header_signature() {
5351
return;
5452
}
5553

56-
let harness = get_harness(VALIDATOR_COUNT, spec, false);
54+
let harness = get_harness(VALIDATOR_COUNT, spec);
5755

5856
let num_blocks = E::slots_per_epoch() as usize;
5957

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#![cfg(not(debug_assertions))]
2+
3+
use beacon_chain::test_utils::{
4+
AttestationStrategy, BeaconChainHarness, BlockStrategy, EphemeralHarnessType,
5+
generate_data_column_sidecars_from_block, test_spec,
6+
};
7+
use beacon_chain::{
8+
AvailabilityProcessingStatus, BlockError, ChainConfig, InvalidSignature, NotifyExecutionLayer,
9+
block_verification_types::AsBlock,
10+
};
11+
use logging::create_test_tracing_subscriber;
12+
use std::sync::{Arc, LazyLock};
13+
use types::*;
14+
15+
type E = MainnetEthSpec;
16+
17+
// Should ideally be divisible by 3.
18+
const VALIDATOR_COUNT: usize = 24;
19+
20+
/// A cached set of keys.
21+
static KEYPAIRS: LazyLock<Vec<Keypair>> =
22+
LazyLock::new(|| types::test_utils::generate_deterministic_keypairs(VALIDATOR_COUNT));
23+
24+
fn get_harness(
25+
validator_count: usize,
26+
spec: Arc<ChainSpec>,
27+
supernode: bool,
28+
) -> BeaconChainHarness<EphemeralHarnessType<E>> {
29+
create_test_tracing_subscriber();
30+
let harness = BeaconChainHarness::builder(MainnetEthSpec)
31+
.spec(spec)
32+
.chain_config(ChainConfig {
33+
reconstruct_historic_states: true,
34+
..ChainConfig::default()
35+
})
36+
.keypairs(KEYPAIRS[0..validator_count].to_vec())
37+
.import_all_data_columns(supernode)
38+
.fresh_ephemeral_store()
39+
.mock_execution_layer()
40+
.build();
41+
42+
harness.advance_slot();
43+
44+
harness
45+
}
46+
47+
// Regression test for https://github.com/sigp/lighthouse/issues/7650
48+
#[tokio::test]
49+
async fn rpc_columns_with_invalid_header_signature() {
50+
let spec = Arc::new(test_spec::<E>());
51+
52+
// Only run this test if columns are enabled.
53+
if !spec.is_fulu_scheduled() {
54+
return;
55+
}
56+
57+
let supernode = true;
58+
let harness = get_harness(VALIDATOR_COUNT, spec, supernode);
59+
60+
let num_blocks = E::slots_per_epoch() as usize;
61+
62+
// Add some chain depth.
63+
harness
64+
.extend_chain(
65+
num_blocks,
66+
BlockStrategy::OnCanonicalHead,
67+
AttestationStrategy::AllValidators,
68+
)
69+
.await;
70+
71+
// Produce a block with blobs.
72+
let head_state = harness.get_current_state();
73+
let slot = head_state.slot() + 1;
74+
let ((signed_block, opt_blobs), _) = harness.make_block(head_state, slot).await;
75+
let (_, blobs) = opt_blobs.unwrap();
76+
assert!(!blobs.is_empty());
77+
let block_root = signed_block.canonical_root();
78+
79+
// Process the block without blobs so that it doesn't become available.
80+
harness.advance_slot();
81+
let rpc_block = harness
82+
.build_rpc_block_from_blobs(block_root, signed_block.clone(), None)
83+
.unwrap();
84+
let availability = harness
85+
.chain
86+
.process_block(
87+
block_root,
88+
rpc_block,
89+
NotifyExecutionLayer::Yes,
90+
BlockImportSource::RangeSync,
91+
|| Ok(()),
92+
)
93+
.await
94+
.unwrap();
95+
assert_eq!(
96+
availability,
97+
AvailabilityProcessingStatus::MissingComponents(slot, block_root)
98+
);
99+
100+
// Build blob sidecars with invalid signatures in the block header.
101+
let mut corrupt_block = (*signed_block).clone();
102+
*corrupt_block.signature_mut() = Signature::infinity().unwrap();
103+
104+
let data_column_sidecars =
105+
generate_data_column_sidecars_from_block(&corrupt_block, &harness.chain.spec);
106+
107+
let err = harness
108+
.chain
109+
.process_rpc_custody_columns(data_column_sidecars)
110+
.await
111+
.unwrap_err();
112+
assert!(matches!(
113+
err,
114+
BlockError::InvalidSignature(InvalidSignature::ProposerSignature)
115+
));
116+
}

beacon_node/beacon_chain/tests/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod bellatrix;
44
mod blob_verification;
55
mod block_verification;
66
mod capella;
7+
mod column_verification;
78
mod events;
89
mod op_verification;
910
mod payload_invalidation;

0 commit comments

Comments
 (0)