Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve some PeerDAS todos #6434

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from
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
12 changes: 2 additions & 10 deletions beacon_node/network/src/sync/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,22 +1103,14 @@ impl<T: BeaconChainTypes> SyncManager<T> {
}

fn on_sampling_result(&mut self, requester: SamplingRequester, result: SamplingResult) {
// TODO(das): How is a consumer of sampling results?
// - Fork-choice for trailing DA
// - Single lookups to complete import requirements
// - Range sync to complete import requirements? Can sampling for syncing lag behind and
// accumulate in fork-choice?

match requester {
SamplingRequester::ImportedBlock(block_root) => {
debug!(self.log, "Sampling result"; "block_root" => %block_root, "result" => ?result);

// TODO(das): Consider moving SamplingResult to the beacon_chain crate and import
// here. No need to add too much enum variants, just whatever the beacon_chain or
// fork-choice needs to make a decision. Currently the fork-choice only needs to
// be notified of successful samplings, i.e. sampling failures don't trigger pruning
Comment on lines -1106 to -1119
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary comments

match result {
Ok(_) => {
// Notify the fork-choice of a successful sampling result to mark the block
// branch as safe.
if let Err(e) = self
.network
.beacon_processor()
Expand Down
2 changes: 0 additions & 2 deletions beacon_node/network/src/sync/network_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,6 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
self.log.clone(),
);

// TODO(das): start request
// Note that you can only send, but not handle a response here
match request.continue_requests(self) {
Ok(_) => {
Expand All @@ -814,7 +813,6 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
self.custody_by_root_requests.insert(requester, request);
Ok(LookupRequestResult::RequestSent(req_id))
}
// TODO(das): handle this error properly
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This refers to the fact that custody request errors are "nested" but it's okay. So far they are okay to debug

Err(e) => Err(RpcRequestSendError::CustodyRequestError(e)),
}
}
Expand Down
17 changes: 9 additions & 8 deletions beacon_node/network/src/sync/sampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ pub type SamplingResult = Result<(), SamplingError>;
type DataColumnSidecarList<E> = Vec<Arc<DataColumnSidecar<E>>>;

pub struct Sampling<T: BeaconChainTypes> {
// TODO(das): stalled sampling request are never cleaned up
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request can't go stale

requests: HashMap<SamplingRequester, ActiveSamplingRequest<T>>,
sampling_config: SamplingConfig,
log: slog::Logger,
Expand Down Expand Up @@ -268,9 +267,9 @@ impl<T: BeaconChainTypes> ActiveSamplingRequest<T> {
.iter()
.position(|data| &data.index == column_index)
else {
// Peer does not have the requested data.
// TODO(das) what to do?
debug!(self.log, "Sampling peer claims to not have the data"; "block_root" => %self.block_root, "column_index" => column_index);
// Peer does not have the requested data, mark peer as "dont have" and try
// again with a different peer.
debug!(self.log, "Custody peer claims to not have the data"; "block_root" => %self.block_root, "column_index" => column_index);
request.on_sampling_error()?;
continue;
};
Expand Down Expand Up @@ -315,7 +314,9 @@ impl<T: BeaconChainTypes> ActiveSamplingRequest<T> {
sampling_request_id,
},
) {
// TODO(das): Beacon processor is overloaded, what should we do?
// Beacon processor is overloaded, drop sampling attempt. Failing to sample
// is not a permanent state so we should recover once the node has capacity
// and receives a descendant block.
error!(self.log, "Dropping sampling"; "block" => %self.block_root, "reason" => e.to_string());
return Err(SamplingError::SendFailed("beacon processor send failure"));
}
Expand All @@ -325,8 +326,8 @@ impl<T: BeaconChainTypes> ActiveSamplingRequest<T> {
debug!(self.log, "Sample download error"; "block_root" => %self.block_root, "column_indexes" => ?column_indexes, "error" => ?err);
metrics::inc_counter_vec(&metrics::SAMPLE_DOWNLOAD_RESULT, &[metrics::FAILURE]);

// Error downloading, maybe penalize peer and retry again.
// TODO(das) with different peer or different peer?
// Error downloading, malicious network errors are already penalized before
// reaching this function. Mark the peer as failed and try again with another.
for column_index in column_indexes {
let Some(request) = self.column_requests.get_mut(column_index) else {
warn!(
Expand Down Expand Up @@ -386,7 +387,7 @@ impl<T: BeaconChainTypes> ActiveSamplingRequest<T> {
debug!(self.log, "Sample verification failure"; "block_root" => %self.block_root, "column_indexes" => ?column_indexes, "reason" => ?err);
metrics::inc_counter_vec(&metrics::SAMPLE_VERIFY_RESULT, &[metrics::FAILURE]);

// TODO(das): Peer sent invalid data, penalize and try again from different peer
// Peer sent invalid data, penalize and try again from different peer
// TODO(das): Count individual failures
for column_index in column_indexes {
let Some(request) = self.column_requests.get_mut(column_index) else {
Expand Down
Loading