Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion beacon_node/beacon_chain/src/historical_data_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
&self,
epoch: Epoch,
historical_data_column_sidecar_list: DataColumnSidecarList<T::EthSpec>,
expected_cgc: u64,
) -> Result<usize, HistoricalDataColumnError> {
let mut total_imported = 0;
let mut ops = vec![];
Expand Down Expand Up @@ -136,7 +137,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {

self.data_availability_checker
.custody_context()
.update_and_backfill_custody_count_at_epoch(epoch);
.update_and_backfill_custody_count_at_epoch(epoch, expected_cgc);

self.safely_backfill_data_column_custody_info(epoch)
.map_err(|e| HistoricalDataColumnError::BeaconChainError(Box::new(e)))?;
Expand Down
19 changes: 16 additions & 3 deletions beacon_node/beacon_chain/src/validator_custody.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,17 @@ impl ValidatorRegistrations {

/// Updates the `epoch_validator_custody_requirements` map by pruning all values on/after `effective_epoch`
/// and updating the map to store the latest validator custody requirements for the `effective_epoch`.
pub fn backfill_validator_custody_requirements(&mut self, effective_epoch: Epoch) {
pub fn backfill_validator_custody_requirements(
&mut self,
effective_epoch: Epoch,
expected_cgc: u64,
) {
if let Some(latest_validator_custody) = self.latest_validator_custody_requirement() {
// If the expected cgc isn't equal to the latest validator custody a very recent cgc change may have occurred.
// We should not update the mapping.
if expected_cgc != latest_validator_custody {
return;
}
// Delete records if
// 1. The epoch is greater than or equal than `effective_epoch`
// 2. the cgc requirements match the latest validator custody requirements
Expand Down Expand Up @@ -386,10 +395,14 @@ impl<E: EthSpec> CustodyContext<E> {
&all_columns_ordered[..custody_group_count]
}

pub fn update_and_backfill_custody_count_at_epoch(&self, effective_epoch: Epoch) {
pub fn update_and_backfill_custody_count_at_epoch(
&self,
effective_epoch: Epoch,
expected_cgc: u64,
) {
self.validator_registrations
.write()
.backfill_validator_custody_requirements(effective_epoch);
.backfill_validator_custody_requirements(effective_epoch, expected_cgc);
}
}

Expand Down
4 changes: 3 additions & 1 deletion beacon_node/network/src/network_beacon_processor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,11 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
self: &Arc<Self>,
batch_id: CustodyBackfillBatchId,
data_columns: DataColumnSidecarList<T::EthSpec>,
expected_cgc: u64,
) -> Result<(), Error<T::EthSpec>> {
let processor = self.clone();
let process_fn = move || processor.process_historic_data_columns(batch_id, data_columns);
let process_fn =
move || processor.process_historic_data_columns(batch_id, data_columns, expected_cgc);

let work = Work::ChainSegmentBackfill(Box::new(process_fn));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
&self,
batch_id: CustodyBackfillBatchId,
downloaded_columns: DataColumnSidecarList<T::EthSpec>,
expected_cgc: u64,
) {
let _guard = debug_span!(
SPAN_CUSTODY_BACKFILL_SYNC_IMPORT_COLUMNS,
Expand All @@ -435,10 +436,11 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> {
.entered();

let sent_columns = downloaded_columns.len();
let result = match self
.chain
.import_historical_data_column_batch(batch_id.epoch, downloaded_columns)
{
let result = match self.chain.import_historical_data_column_batch(
batch_id.epoch,
downloaded_columns,
expected_cgc,
) {
Ok(imported_columns) => {
metrics::inc_counter_by(
&metrics::BEACON_PROCESSOR_CUSTODY_BACKFILL_COLUMN_IMPORT_SUCCESS_TOTAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ impl<T: BeaconChainTypes> CustodyBackFillSync<T> {
run_id: self.run_id,
},
data_columns,
self.cgc,
) {
crit!(
msg = "process_batch",
Expand Down