mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-27 01:33:33 +00:00
Fix wrong custody column count for lookup blocks (#7281)
Fixes - https://github.com/sigp/lighthouse/issues/7278 Don't assume 0 columns for `RpcBlockInner::Block`
This commit is contained in:
@@ -147,7 +147,7 @@ fn build_rpc_block(
|
||||
RpcBlock::new_with_custody_columns(None, block, columns.clone(), columns.len(), spec)
|
||||
.unwrap()
|
||||
}
|
||||
None => RpcBlock::new_without_blobs(None, block),
|
||||
None => RpcBlock::new_without_blobs(None, block, 0),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -370,6 +370,7 @@ async fn chain_segment_non_linear_parent_roots() {
|
||||
blocks[3] = RpcBlock::new_without_blobs(
|
||||
None,
|
||||
Arc::new(SignedBeaconBlock::from_block(block, signature)),
|
||||
harness.sampling_column_count,
|
||||
);
|
||||
|
||||
assert!(
|
||||
@@ -407,6 +408,7 @@ async fn chain_segment_non_linear_slots() {
|
||||
blocks[3] = RpcBlock::new_without_blobs(
|
||||
None,
|
||||
Arc::new(SignedBeaconBlock::from_block(block, signature)),
|
||||
harness.sampling_column_count,
|
||||
);
|
||||
|
||||
assert!(
|
||||
@@ -434,6 +436,7 @@ async fn chain_segment_non_linear_slots() {
|
||||
blocks[3] = RpcBlock::new_without_blobs(
|
||||
None,
|
||||
Arc::new(SignedBeaconBlock::from_block(block, signature)),
|
||||
harness.sampling_column_count,
|
||||
);
|
||||
|
||||
assert!(
|
||||
@@ -575,11 +578,16 @@ async fn invalid_signature_gossip_block() {
|
||||
.into_block_error()
|
||||
.expect("should import all blocks prior to the one being tested");
|
||||
let signed_block = SignedBeaconBlock::from_block(block, junk_signature());
|
||||
let rpc_block = RpcBlock::new_without_blobs(
|
||||
None,
|
||||
Arc::new(signed_block),
|
||||
harness.sampling_column_count,
|
||||
);
|
||||
let process_res = harness
|
||||
.chain
|
||||
.process_block(
|
||||
signed_block.canonical_root(),
|
||||
Arc::new(signed_block),
|
||||
rpc_block.block_root(),
|
||||
rpc_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
@@ -1541,12 +1549,13 @@ async fn add_base_block_to_altair_chain() {
|
||||
));
|
||||
|
||||
// Ensure that it would be impossible to import via `BeaconChain::process_block`.
|
||||
let base_rpc_block = RpcBlock::new_without_blobs(None, Arc::new(base_block.clone()), 0);
|
||||
assert!(matches!(
|
||||
harness
|
||||
.chain
|
||||
.process_block(
|
||||
base_block.canonical_root(),
|
||||
Arc::new(base_block.clone()),
|
||||
base_rpc_block.block_root(),
|
||||
base_rpc_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
@@ -1564,7 +1573,7 @@ async fn add_base_block_to_altair_chain() {
|
||||
harness
|
||||
.chain
|
||||
.process_chain_segment(
|
||||
vec![RpcBlock::new_without_blobs(None, Arc::new(base_block))],
|
||||
vec![RpcBlock::new_without_blobs(None, Arc::new(base_block), 0)],
|
||||
NotifyExecutionLayer::Yes,
|
||||
)
|
||||
.await,
|
||||
@@ -1677,12 +1686,13 @@ async fn add_altair_block_to_base_chain() {
|
||||
));
|
||||
|
||||
// Ensure that it would be impossible to import via `BeaconChain::process_block`.
|
||||
let altair_rpc_block = RpcBlock::new_without_blobs(None, Arc::new(altair_block.clone()), 0);
|
||||
assert!(matches!(
|
||||
harness
|
||||
.chain
|
||||
.process_block(
|
||||
altair_block.canonical_root(),
|
||||
Arc::new(altair_block.clone()),
|
||||
altair_rpc_block.block_root(),
|
||||
altair_rpc_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
@@ -1700,7 +1710,7 @@ async fn add_altair_block_to_base_chain() {
|
||||
harness
|
||||
.chain
|
||||
.process_chain_segment(
|
||||
vec![RpcBlock::new_without_blobs(None, Arc::new(altair_block))],
|
||||
vec![RpcBlock::new_without_blobs(None, Arc::new(altair_block), 0)],
|
||||
NotifyExecutionLayer::Yes
|
||||
)
|
||||
.await,
|
||||
@@ -1761,11 +1771,16 @@ async fn import_duplicate_block_unrealized_justification() {
|
||||
// Create two verified variants of the block, representing the same block being processed in
|
||||
// parallel.
|
||||
let notify_execution_layer = NotifyExecutionLayer::Yes;
|
||||
let verified_block1 = block
|
||||
let rpc_block = RpcBlock::new_without_blobs(
|
||||
Some(block_root),
|
||||
block.clone(),
|
||||
harness.sampling_column_count,
|
||||
);
|
||||
let verified_block1 = rpc_block
|
||||
.clone()
|
||||
.into_execution_pending_block(block_root, chain, notify_execution_layer)
|
||||
.unwrap();
|
||||
let verified_block2 = block
|
||||
let verified_block2 = rpc_block
|
||||
.into_execution_pending_block(block_root, chain, notify_execution_layer)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#![cfg(not(debug_assertions))]
|
||||
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use beacon_chain::{
|
||||
canonical_head::{CachedHead, CanonicalHead},
|
||||
test_utils::{BeaconChainHarness, EphemeralHarnessType},
|
||||
@@ -687,12 +688,14 @@ async fn invalidates_all_descendants() {
|
||||
assert_eq!(fork_parent_state.slot(), fork_parent_slot);
|
||||
let ((fork_block, _), _fork_post_state) =
|
||||
rig.harness.make_block(fork_parent_state, fork_slot).await;
|
||||
let fork_rpc_block =
|
||||
RpcBlock::new_without_blobs(None, fork_block.clone(), rig.harness.sampling_column_count);
|
||||
let fork_block_root = rig
|
||||
.harness
|
||||
.chain
|
||||
.process_block(
|
||||
fork_block.canonical_root(),
|
||||
fork_block,
|
||||
fork_rpc_block.block_root(),
|
||||
fork_rpc_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
@@ -788,12 +791,14 @@ async fn switches_heads() {
|
||||
let ((fork_block, _), _fork_post_state) =
|
||||
rig.harness.make_block(fork_parent_state, fork_slot).await;
|
||||
let fork_parent_root = fork_block.parent_root();
|
||||
let fork_rpc_block =
|
||||
RpcBlock::new_without_blobs(None, fork_block.clone(), rig.harness.sampling_column_count);
|
||||
let fork_block_root = rig
|
||||
.harness
|
||||
.chain
|
||||
.process_block(
|
||||
fork_block.canonical_root(),
|
||||
fork_block,
|
||||
fork_rpc_block.block_root(),
|
||||
fork_rpc_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
@@ -1057,8 +1062,10 @@ async fn invalid_parent() {
|
||||
));
|
||||
|
||||
// Ensure the block built atop an invalid payload is invalid for import.
|
||||
let rpc_block =
|
||||
RpcBlock::new_without_blobs(None, block.clone(), rig.harness.sampling_column_count);
|
||||
assert!(matches!(
|
||||
rig.harness.chain.process_block(block.canonical_root(), block.clone(), NotifyExecutionLayer::Yes, BlockImportSource::Lookup,
|
||||
rig.harness.chain.process_block(rpc_block.block_root(), rpc_block, NotifyExecutionLayer::Yes, BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
).await,
|
||||
Err(BlockError::ParentExecutionPayloadInvalid { parent_root: invalid_root })
|
||||
@@ -1380,11 +1387,13 @@ async fn recover_from_invalid_head_by_importing_blocks() {
|
||||
} = InvalidHeadSetup::new().await;
|
||||
|
||||
// Import the fork block, it should become the head.
|
||||
let fork_rpc_block =
|
||||
RpcBlock::new_without_blobs(None, fork_block.clone(), rig.harness.sampling_column_count);
|
||||
rig.harness
|
||||
.chain
|
||||
.process_block(
|
||||
fork_block.canonical_root(),
|
||||
fork_block.clone(),
|
||||
fork_rpc_block.block_root(),
|
||||
fork_rpc_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#![cfg(not(debug_assertions))]
|
||||
|
||||
use beacon_chain::attestation_verification::Error as AttnError;
|
||||
use beacon_chain::block_verification_types::RpcBlock;
|
||||
use beacon_chain::builder::BeaconChainBuilder;
|
||||
use beacon_chain::data_availability_checker::AvailableBlock;
|
||||
use beacon_chain::schema_change::migrate_schema;
|
||||
@@ -2643,12 +2644,17 @@ async fn process_blocks_and_attestations_for_unaligned_checkpoint() {
|
||||
assert_eq!(split.block_root, valid_fork_block.parent_root());
|
||||
assert_ne!(split.state_root, unadvanced_split_state_root);
|
||||
|
||||
let invalid_fork_rpc_block = RpcBlock::new_without_blobs(
|
||||
None,
|
||||
invalid_fork_block.clone(),
|
||||
harness.sampling_column_count,
|
||||
);
|
||||
// Applying the invalid block should fail.
|
||||
let err = harness
|
||||
.chain
|
||||
.process_block(
|
||||
invalid_fork_block.canonical_root(),
|
||||
invalid_fork_block.clone(),
|
||||
invalid_fork_rpc_block.block_root(),
|
||||
invalid_fork_rpc_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
@@ -2658,11 +2664,16 @@ async fn process_blocks_and_attestations_for_unaligned_checkpoint() {
|
||||
assert!(matches!(err, BlockError::WouldRevertFinalizedSlot { .. }));
|
||||
|
||||
// Applying the valid block should succeed, but it should not become head.
|
||||
let valid_fork_rpc_block = RpcBlock::new_without_blobs(
|
||||
None,
|
||||
valid_fork_block.clone(),
|
||||
harness.sampling_column_count,
|
||||
);
|
||||
harness
|
||||
.chain
|
||||
.process_block(
|
||||
valid_fork_block.canonical_root(),
|
||||
valid_fork_block.clone(),
|
||||
valid_fork_rpc_block.block_root(),
|
||||
valid_fork_rpc_block,
|
||||
NotifyExecutionLayer::Yes,
|
||||
BlockImportSource::Lookup,
|
||||
|| Ok(()),
|
||||
|
||||
Reference in New Issue
Block a user