-
Notifications
You must be signed in to change notification settings - Fork 893
Avoid attempting to serve blobs after Fulu fork #7756
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?
Conversation
if let Some(fulu_slot) = fulu_start_slot { | ||
if blob.slot() >= fulu_slot { |
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.
This can be simplified slightly using fulu_start_slot.is_some_and(|fulu_slot| blob.slot() >= fulu_slot)
.
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 fulu_slot
is used in the logging below. So after changing, the compiler is saying fulu_sot
not found.
Should I remove fulu_slot
from the logging?
if let Some(fulu_slot) = fulu_start_slot { | ||
if blob_sidecar.slot() >= fulu_slot { |
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.
As above
// First attempt to get the blobs from the RPC cache. | ||
if let Ok(Some(blob)) = self.chain.data_availability_checker.get_blob(id) { | ||
// Check if the blob requested is from a Fulu slot, if so, skip the current blob id and proceed to the next |
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.
I think if the block is after fulu slot, this condition will never satisfy, as the result will always be Ok(None)
as we never store blobs from Fulu. I don't think we need to handle it here as it should be unreachable.
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.
Revised in bf20880
@@ -306,6 +326,20 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> { | |||
Ok(blobs_sidecar_list) => { | |||
'inner: for blob_sidecar in blobs_sidecar_list.iter() { | |||
if blob_sidecar.index == *index { | |||
// Same logic as above to check for Fulu slot | |||
if let Some(fulu_slot) = fulu_start_slot { |
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.
This will also be unreachable.
The purpose to avoid serving post-fulu slots in the byRange method is to save us work from doing block roots lookup - it doesn't seem as relevant here, as we've already hit the database and incurred the cost.
The spec also says the following, so we can't really penalise these peers during this deprecation period
Clients SHOULD NOT penalize peers for requesting blob sidecars from FULU_FORK_EPOCH.
I think we could probably check all the caches to see if we have the block before hitting the database?
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.
Revised in bf20880, trying to avoid touching the database
beacon_node/network/src/network_beacon_processor/rpc_methods.rs
Outdated
Show resolved
Hide resolved
beacon_node/network/src/network_beacon_processor/rpc_methods.rs
Outdated
Show resolved
Hide resolved
beacon_node/network/src/network_beacon_processor/rpc_methods.rs
Outdated
Show resolved
Hide resolved
@@ -884,6 +918,36 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> { | |||
); | |||
|
|||
let request_start_slot = Slot::from(req.start_slot); | |||
// This variable may only change when the request_start_slot + req.count spans across the Fulu fork slot | |||
let mut effective_count = req.count; |
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.
You could make the if / else
block return the count, and that would allow you to remove the mut
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.
Try to revise this in 32c3ab0, not sure if it is good?
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.
yep that's better!
beacon_node/network/src/network_beacon_processor/rpc_methods.rs
Outdated
Show resolved
Hide resolved
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.
Hi @chong-he I've added some comments.
I think it might be worth adding something similar to data columns methods, to avoid block roots retrieval if the slots are before Fulu
lighthouse/beacon_node/network/src/network_beacon_processor/rpc_methods.rs
Lines 1064 to 1085 in befef72
pub fn handle_data_columns_by_range_request_inner( | |
&self, | |
peer_id: PeerId, | |
inbound_request_id: InboundRequestId, | |
req: DataColumnsByRangeRequest, | |
) -> Result<(), (RpcErrorResponse, &'static str)> { | |
debug!( | |
%peer_id, | |
count = req.count, | |
start_slot = req.start_slot, | |
"Received DataColumnsByRange Request" | |
); | |
// Should not send more than max request data columns | |
if req.max_requested::<T::EthSpec>() > self.chain.spec.max_request_data_column_sidecars { | |
return Err(( | |
RpcErrorResponse::InvalidRequest, | |
"Request exceeded `MAX_REQUEST_BLOBS_SIDECARS`", | |
)); | |
} | |
let request_start_slot = Slot::from(req.start_slot); |
Some required checks have failed. Could you please take a look @chong-he? 🙏 |
let request_start_epoch = request_start_slot.epoch(T::EthSpec::slots_per_epoch()); | ||
// Should not send more than max request blob sidecars | ||
if req.max_blobs_requested(request_start_epoch, &self.chain.spec) | ||
> self.chain.spec.max_request_blob_sidecars_electra |
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.
should we use the spec.max_request_blob_sidecars(fork_name)
function here?
keeping those fields private means we don't leak the logic elsewhere -if we ever need to use a different config value for a different fork, we only need to update the above function.
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.
Thanks, revised in 0cbd9fd
I didn't notice this function is available, when I use the Electra one I was feeling unsure about it
} | ||
|
||
#[tokio::test] | ||
async fn test_blobs_by_range_spans_fulu_fork() { |
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.
I don't think this test would fail before your PR?
but i think it's useful that it covers blobs by range works before Fulu
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.
Yes this test wouldn't fail even without this PR change, which is why I think the test is not robust enough.
I have already started from mid-epoch slot, and the blob request spans across fork boundary. I wonder if I am missing something in the test?
|
||
#[tokio::test] | ||
async fn test_blobs_by_root_post_fulu_should_return_empty() { | ||
// Only test for Fulu fork |
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.
i think it would be worth adding a test to confirm it still work right before fulu fork?
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.
Added a test in 0cbd9fd
@@ -268,21 +268,64 @@ impl<T: BeaconChainTypes> NetworkBeaconProcessor<T> { | |||
inbound_request_id: InboundRequestId, | |||
request: BlobsByRootRequest, | |||
) -> Result<(), (RpcErrorResponse, &'static str)> { | |||
let Some(requested_root) = request.blob_ids.as_slice().first().map(|id| id.block_root) | |||
let Some(_requested_root) = request.blob_ids.as_slice().first().map(|id| id.block_root) |
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.
This block is now redundant and can be removed
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.
Sure. The reason I am keeping this is, if we remove this, then it wouldn't have the check that if the request is empty before proceeding. wdyt?
Anyway I removed it in 0cbd9fd
let mut blob_list_results = HashMap::new(); | ||
let mut retrieve_blob_slot = HashMap::new(); |
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.
I think it's fine being a bit more verbose here to help readability - what about using the map naming convention values_by_key
, e.g. slots_by_block_root
?
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.
Rename the variable as suggested
retrieve_blob_slot.insert(*root, slot); | ||
Some(slot) | ||
} else { | ||
// Blobs not found in cache, return None to avoid hitting the database |
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.
This is the case where block is not found in cache, and we just need to hit the database right?
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.
Revise the comment to be clearer, thanks!
"BlobsByRoot request is at or after Fulu slot, returning empty response" | ||
); | ||
break 'inner; | ||
} |
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.
I think we can remove this block - if we have the blob then it means fulu is not activated and there's no need to check for fulu slot
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.
Removed in 0cbd9fd
debug!( | ||
%peer_id, | ||
%request_start_slot, | ||
%fulu_start_slot, |
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.
i think we can remove all the fulu start slot logging to reduce the logging noise - this doesn't give us much during debugging as there's many easy way to find out, e.g. /config/spec, network config etc
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.
All fulu-related logging removed in 0cbd9fd
%block_root, | ||
?blobs_indices, | ||
returned = send_blob_count, | ||
"BlobsByRoot outgoing response processed" |
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.
This log isn't accurate because send_blob_count
is the total number of returned responses.
Maybe we could just log one entry, and the list of unique roots requested?
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.
Only log once after the revision 0cbd9fd
Thanks for the detailed review @jimmygchen. I have address all comments as above. |
Issue Addressed