mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 12:54:27 +00:00
Refactor Custody Context Availability Checks (#9515)
Co-Authored-By: Mark Mackey <mark@sigmaprime.io>
This commit is contained in:
@@ -200,7 +200,7 @@ pub async fn publish_execution_payload_envelope<T: BeaconChainTypes>(
|
||||
}
|
||||
|
||||
let epoch = slot.epoch(T::EthSpec::slots_per_epoch());
|
||||
let sampling_column_indices = chain.sampling_columns_for_epoch(epoch);
|
||||
let sampling_column_indices = chain.custody_context.sampling_columns_for_epoch(epoch);
|
||||
let sampling_columns = gossip_verified_columns
|
||||
.into_iter()
|
||||
.filter(|col| sampling_column_indices.contains(&col.index()))
|
||||
|
||||
@@ -602,7 +602,9 @@ mod tests {
|
||||
"precondition: test block must not be imported into fork choice yet"
|
||||
);
|
||||
|
||||
let sampling_columns = chain.sampling_columns_for_epoch(block.epoch());
|
||||
let sampling_columns = chain
|
||||
.custody_context
|
||||
.sampling_columns_for_epoch(block.epoch());
|
||||
let data_columns = generate_data_column_sidecars_from_block(&block, &chain.spec)
|
||||
.into_iter()
|
||||
.filter(|column| sampling_columns.contains(column.index()))
|
||||
@@ -615,8 +617,7 @@ mod tests {
|
||||
let available_block = AvailableBlock::new(
|
||||
block.clone(),
|
||||
AvailableBlockData::new_with_data_columns(data_columns),
|
||||
&chain.data_availability_checker,
|
||||
chain.spec.clone(),
|
||||
&chain.custody_context,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ pub fn info<T: BeaconChainTypes>(
|
||||
.map_err(|e| custom_server_error(format!("error reading DataColumnCustodyInfo: {e:?}")))?;
|
||||
|
||||
let column_data_availability_boundary = chain
|
||||
.custody_context
|
||||
.column_data_availability_boundary()
|
||||
.ok_or_else(|| custom_server_error("unreachable: Fulu should be enabled".to_string()))?;
|
||||
|
||||
@@ -38,12 +39,13 @@ pub fn info<T: BeaconChainTypes>(
|
||||
// Compute the custody columns and the CGC *at the earliest custodied slot*. The node might
|
||||
// have some columns prior to this, but this value is the most up-to-date view of the data the
|
||||
// node is custodying.
|
||||
let custody_context = chain.data_availability_checker.custody_context();
|
||||
let custody_columns = custody_context
|
||||
.custody_columns_for_epoch(Some(earliest_custodied_data_column_epoch), &chain.spec)
|
||||
let custody_columns = chain
|
||||
.custody_context
|
||||
.custody_columns_for_epoch(Some(earliest_custodied_data_column_epoch))
|
||||
.to_vec();
|
||||
let custody_group_count = custody_context
|
||||
.custody_group_count_at_epoch(earliest_custodied_data_column_epoch, &chain.spec);
|
||||
let custody_group_count = chain
|
||||
.custody_context
|
||||
.custody_group_count_at_epoch(earliest_custodied_data_column_epoch);
|
||||
|
||||
Ok(CustodyInfo {
|
||||
earliest_custodied_data_column_slot,
|
||||
|
||||
@@ -3179,10 +3179,11 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
.head_slot()
|
||||
.epoch(T::EthSpec::slots_per_epoch())
|
||||
+ 1;
|
||||
let custody_context = chain.data_availability_checker.custody_context();
|
||||
// Reset validator custody requirements to `effective_epoch` with the latest
|
||||
// cgc requiremnets.
|
||||
custody_context.reset_validator_custody_requirements(effective_epoch);
|
||||
chain
|
||||
.custody_context
|
||||
.reset_validator_custody_requirements(effective_epoch);
|
||||
// Update `DataColumnCustodyInfo` to reflect the custody change.
|
||||
chain.update_data_column_custody_info(Some(
|
||||
effective_epoch.start_slot(T::EthSpec::slots_per_epoch()),
|
||||
|
||||
@@ -217,7 +217,7 @@ pub async fn publish_block<T: BeaconChainTypes, B: IntoGossipVerifiedBlock<T>>(
|
||||
warp_utils::reject::custom_server_error("unable to publish data column sidecars".into())
|
||||
})?;
|
||||
let epoch = block.slot().epoch(T::EthSpec::slots_per_epoch());
|
||||
let sampling_columns_indices = chain.sampling_columns_for_epoch(epoch);
|
||||
let sampling_columns_indices = chain.custody_context.sampling_columns_for_epoch(epoch);
|
||||
let sampling_columns = gossip_verified_columns
|
||||
.into_iter()
|
||||
.filter(|data_column| sampling_columns_indices.contains(&data_column.index()))
|
||||
|
||||
@@ -855,9 +855,8 @@ pub fn post_validator_prepare_beacon_proposer<T: BeaconChainTypes>(
|
||||
let current_slot =
|
||||
chain.slot().map_err(warp_utils::reject::unhandled_error)?;
|
||||
if let Some(cgc_change) = chain
|
||||
.data_availability_checker
|
||||
.custody_context()
|
||||
.register_validators(validators_and_balances, current_slot, &chain.spec)
|
||||
.custody_context
|
||||
.register_validators(validators_and_balances, current_slot)
|
||||
{
|
||||
chain.update_data_column_custody_info(Some(
|
||||
cgc_change
|
||||
|
||||
Reference in New Issue
Block a user