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

Small Readability Improvement in Sync Code #5098

Merged
merged 1 commit into from
Jan 23, 2024
Merged
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: 1 addition & 2 deletions beacon_node/network/src/sync/block_lookups/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ pub trait RequestState<L: Lookup, T: BeaconChainTypes> {
fn build_request_and_send(
&mut self,
id: Id,
already_downloaded: bool,
cx: &SyncNetworkContext<T>,
) -> Result<(), LookupRequestError> {
// Check if request is necessary.
if already_downloaded || !matches!(self.get_state().state, State::AwaitingDownload) {
if !matches!(self.get_state().state, State::AwaitingDownload) {
return Ok(());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,18 @@ impl<L: Lookup, T: BeaconChainTypes> SingleBlockLookup<L, T> {
&mut self,
cx: &SyncNetworkContext<T>,
) -> Result<(), LookupRequestError> {
let block_root = self.block_root();
let block_already_downloaded = self.block_already_downloaded();
let blobs_already_downloaded = self.blobs_already_downloaded();

if block_already_downloaded && blobs_already_downloaded {
trace!(cx.log, "Lookup request already completed"; "block_root"=> ?block_root);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the deletion of this trace log statement intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah.. I don't think this log is very useful. There are hardly any tracing logs in this code & I just spent a long time tracking down a bug in this code & it required me to put a bunch of additional logs all over the place. I never turned on trace logs because there are hardly any of them and none of them would've helped me debug anyway, they would've only cluttered the output and made it more difficult.

return Ok(());
if !block_already_downloaded {
self.block_request_state
.build_request_and_send(self.id, cx)?;
}
if !blobs_already_downloaded {
self.blob_request_state
.build_request_and_send(self.id, cx)?;
}
let id = self.id;
self.block_request_state
.build_request_and_send(id, block_already_downloaded, cx)?;
self.blob_request_state
.build_request_and_send(id, blobs_already_downloaded, cx)
Ok(())
}

/// Returns a `CachedChild`, which is a wrapper around a `RpcBlock` that is either:
Expand Down
Loading