-
Notifications
You must be signed in to change notification settings - Fork 884
Fix for #7122 Avoid attempting to serve BlobsByRange RPC requests on Fulu slots #7328
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
base: unstable
Are you sure you want to change the base?
Changes from all commits
2c0311e
f79d741
6d18d89
e858190
356f9a8
ea2bbad
6f731d0
e83d93d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ use crate::network_beacon_processor::{NetworkBeaconProcessor, FUTURE_SLOT_TOLERA | |
use crate::service::NetworkMessage; | ||
use crate::status::ToStatusMessage; | ||
use crate::sync::SyncMessage; | ||
use beacon_chain::block_verification_types::AsBlock; | ||
use beacon_chain::{BeaconChainError, BeaconChainTypes, WhenSlotSkipped}; | ||
use itertools::{process_results, Itertools}; | ||
use lighthouse_network::rpc::methods::{ | ||
|
@@ -279,7 +280,38 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> { | |
let mut send_blob_count = 0; | ||
|
||
let mut blob_list_results = HashMap::new(); | ||
let mut is_fulu_by_root = HashMap::new(); | ||
for id in request.blob_ids.as_slice() { | ||
let BlobIdentifier { | ||
block_root: root, | ||
index, | ||
} = id; | ||
|
||
if !is_fulu_by_root.contains_key(root) { | ||
let epoch = if let Some(block) = self | ||
.chain | ||
.data_availability_checker | ||
.get_execution_valid_block(root) | ||
{ | ||
block.message().epoch() | ||
} else if let Some(block) = self.chain.early_attester_cache.get_block(*root) { | ||
block.message().epoch() | ||
} else if let Some(block) = self.chain.store.get_cached_block(root) { | ||
block.message().epoch() | ||
} else if let Ok(Some(block)) = self.chain.store.get_blinded_block(root) { | ||
block.message().epoch() | ||
} else { | ||
// If we can't find the block in either cache, we can't determine the epoch. | ||
continue; | ||
}; | ||
Comment on lines
+290
to
+306
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if we're opening up ourselves to a potential DOS vector here? Bogus blobs by root requests will force us to query multiple caches and the store itself. I guess peer rate limiting protects us so maybe thats a non-issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it be better to use fork choice as an initial check for the block root? |
||
|
||
is_fulu_by_root.insert(*root, self.chain.spec.is_peer_das_enabled_for_epoch(epoch)); | ||
} | ||
|
||
if *is_fulu_by_root.get(root).unwrap() { | ||
continue; | ||
} | ||
Comment on lines
+311
to
+313
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove unwrap |
||
|
||
// First attempt to get the blobs from the RPC cache. | ||
if let Ok(Some(blob)) = self.chain.data_availability_checker.get_blob(id) { | ||
self.send_response( | ||
|
@@ -289,11 +321,6 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> { | |
); | ||
send_blob_count += 1; | ||
} else { | ||
let BlobIdentifier { | ||
block_root: root, | ||
index, | ||
} = id; | ||
|
||
let blob_list_result = match blob_list_results.entry(root) { | ||
Entry::Vacant(entry) => { | ||
entry.insert(self.chain.get_blobs_checking_early_attester_cache(root)) | ||
|
@@ -882,8 +909,16 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> { | |
"Received BlobsByRange Request" | ||
); | ||
|
||
if req.count == 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, let's handle corner cases explicitly at some point There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will apply the same to other similar functions in this file if agreed |
||
return Err((RpcErrorResponse::InvalidRequest, "Request count is zero")); | ||
} | ||
|
||
let mut req = req; | ||
let request_start_slot = Slot::from(req.start_slot); | ||
let request_end_slot = Slot::from(req.start_slot + req.count - 1); | ||
let request_end_epoch = request_end_slot.epoch(T::EthSpec::slots_per_epoch()); | ||
|
||
// Check Deneb is enabled. Blobs are available since then. | ||
let data_availability_boundary_slot = match self.chain.data_availability_boundary() { | ||
Some(boundary) => boundary.start_slot(T::EthSpec::slots_per_epoch()), | ||
None => { | ||
|
@@ -919,6 +954,19 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> { | |
}; | ||
} | ||
|
||
// Check Fulu/PeerDAS is in the range. Blobs are not served since then. | ||
if self | ||
.chain | ||
.spec | ||
.is_peer_das_enabled_for_epoch(request_end_epoch) | ||
{ | ||
// Fulu epoch is Some type by the condition above. | ||
let fulu_epoch = self.chain.spec.fulu_fork_epoch.unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unwrap |
||
let fulu_start_slot = fulu_epoch.start_slot(T::EthSpec::slots_per_epoch()); | ||
// See the justification for the formula in PR https://github.com/sigp/lighthouse/pull/7328 | ||
req.count = fulu_start_slot.as_u64().saturating_sub(req.start_slot); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Justification:
Union of all cases results in |
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, rethinking this maybe this is too punishing? Why not allow the request to creep into Fulu and just check that the start slot is in Deneb. It's fine to return empty for slots in Fulu. Lighthouse only does by_range requests for a single epoch, but other clients may have different logic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I agree that it could be bit too punishing. The issue was vague in a way that we didn't set how much punishment we will give. Do you think it is okay to accept the request as long as it contains pre-Fulu slots? Also, it seems like there's no check from Lighthouse to not send Fulu slots as left on the comment #7122 (comment). So, we could potentially be penalized by ourselves There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feels like something that should be clarified in the spec to align behaviour on all clients. Do you want to raise an issue to the specs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure! Just raised a PR to the specs ethereum/consensus-specs#4286 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed as per the spec PR to not punish and return empty for Fulu slots |
||
|
||
let block_roots = | ||
self.get_block_roots_for_slot_range(req.start_slot, req.count, "BlobsByRange")?; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original code handles edge cases.