mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Fix wrong columns getting processed on a CGC change (#7792)
This PR fixes a bug where wrong columns could get processed immediately after a CGC increase.
Scenario:
- The node's CGC increased due to additional validators attached to it (lets say from 10 to 11)
- The new CGC is advertised and new subnets are subscribed immediately, however the change won't be effective in the data availability check until the next epoch (See [this](ab0e8870b4/beacon_node/beacon_chain/src/validator_custody.rs (L93-L99))). Data availability checker still only require 10 columns for the current epoch.
- During this time, data columns for the additional custody column (lets say column 11) may arrive via gossip as we're already subscribed to the topic, and it may be incorrectly used to satisfy the existing data availability requirement (10 columns), and result in this additional column (instead of a required one) getting persisted, resulting in database inconsistency.
This commit is contained in:
@@ -198,7 +198,7 @@ impl<T: BeaconChainTypes, O: ObservationStrategy> Clone for GossipVerifiedDataCo
|
||||
impl<T: BeaconChainTypes, O: ObservationStrategy> GossipVerifiedDataColumn<T, O> {
|
||||
pub fn new(
|
||||
column_sidecar: Arc<DataColumnSidecar<T::EthSpec>>,
|
||||
subnet_id: u64,
|
||||
subnet_id: DataColumnSubnetId,
|
||||
chain: &BeaconChain<T>,
|
||||
) -> Result<Self, GossipDataColumnError> {
|
||||
let header = column_sidecar.signed_block_header.clone();
|
||||
@@ -472,7 +472,7 @@ where
|
||||
|
||||
pub fn validate_data_column_sidecar_for_gossip<T: BeaconChainTypes, O: ObservationStrategy>(
|
||||
data_column: Arc<DataColumnSidecar<T::EthSpec>>,
|
||||
subnet: u64,
|
||||
subnet: DataColumnSubnetId,
|
||||
chain: &BeaconChain<T>,
|
||||
) -> Result<GossipVerifiedDataColumn<T, O>, GossipDataColumnError> {
|
||||
let column_slot = data_column.slot();
|
||||
@@ -735,15 +735,14 @@ fn verify_proposer_and_signature<T: BeaconChainTypes>(
|
||||
|
||||
fn verify_index_matches_subnet<E: EthSpec>(
|
||||
data_column: &DataColumnSidecar<E>,
|
||||
subnet: u64,
|
||||
subnet: DataColumnSubnetId,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), GossipDataColumnError> {
|
||||
let expected_subnet: u64 =
|
||||
DataColumnSubnetId::from_column_index(data_column.index, spec).into();
|
||||
let expected_subnet = DataColumnSubnetId::from_column_index(data_column.index, spec);
|
||||
if expected_subnet != subnet {
|
||||
return Err(GossipDataColumnError::InvalidSubnetId {
|
||||
received: subnet,
|
||||
expected: expected_subnet,
|
||||
received: subnet.into(),
|
||||
expected: expected_subnet.into(),
|
||||
});
|
||||
}
|
||||
Ok(())
|
||||
@@ -821,7 +820,7 @@ mod test {
|
||||
};
|
||||
use crate::observed_data_sidecars::Observe;
|
||||
use crate::test_utils::BeaconChainHarness;
|
||||
use types::{DataColumnSidecar, EthSpec, ForkName, MainnetEthSpec};
|
||||
use types::{DataColumnSidecar, DataColumnSubnetId, EthSpec, ForkName, MainnetEthSpec};
|
||||
|
||||
type E = MainnetEthSpec;
|
||||
|
||||
@@ -860,7 +859,7 @@ mod test {
|
||||
|
||||
let result = validate_data_column_sidecar_for_gossip::<_, Observe>(
|
||||
column_sidecar.into(),
|
||||
index,
|
||||
DataColumnSubnetId::from_column_index(index, &harness.spec),
|
||||
&harness.chain,
|
||||
);
|
||||
assert!(matches!(
|
||||
|
||||
Reference in New Issue
Block a user