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

Various code inspection resolutions #7438

Merged
merged 28 commits into from
Oct 12, 2020
Merged

Various code inspection resolutions #7438

merged 28 commits into from
Oct 12, 2020

Conversation

prestonvanloon
Copy link
Member

@prestonvanloon prestonvanloon commented Oct 5, 2020

What type of PR is this?

Other

What does this PR do? Why is it needed?

In the spirit of improving code health, this PR resolves the following:

  • Remove unused/dead code
  • Remove use of defer within a loop
  • Remove unused constants
  • Check for nil slice before accessing element
  • Remove unused args in methods
  • Replace empty slice declarations (prefer var s []stuff over s := []stuff{})
  • Rename pointer receivers to be consistent with others in the package
  • Remove bootnode query tool for libp2p based bootnodes (obsolete by discv5)
  • Remove //test directory (unused)
  • Remove old k8s script
  • Remove old gcp script

Which issues(s) does this PR fix?

N/A

Other notes for review

Normally I would break these up into smaller PRs, but there are so many that it would bog down our CI pipeline and review process.

@prestonvanloon prestonvanloon added Cleanup Code health! Ready For Review A pull request ready for code review labels Oct 5, 2020
@prestonvanloon prestonvanloon marked this pull request as ready for review October 5, 2020 18:29
@prestonvanloon prestonvanloon requested a review from a team as a code owner October 5, 2020 18:29
rauljordan
rauljordan previously approved these changes Oct 5, 2020
@prestonvanloon
Copy link
Member Author

Tests failing... fixing

@prestonvanloon
Copy link
Member Author

Flaky test, passed on second run.

@codecov
Copy link

codecov bot commented Oct 5, 2020

Codecov Report

Merging #7438 into master will increase coverage by 0.09%.
The diff coverage is 89.40%.

@@            Coverage Diff             @@
##           master    #7438      +/-   ##
==========================================
+ Coverage   60.43%   60.52%   +0.09%     
==========================================
  Files         427      427              
  Lines       30654    30351     -303     
==========================================
- Hits        18526    18371     -155     
+ Misses       9100     8983     -117     
+ Partials     3028     2997      -31     

@rkapka
Copy link
Contributor

rkapka commented Oct 5, 2020

This is great stuff. My two cents:

Replace empty slice declarations (prefer var s []stuff over s := []stuff{})

GoLand complains that this might change semantics (example). Just making sure that you're aware of this.

Please also take a look at comments from @nisdas in #6864 - some code was purposefully not removed even though it was unused. We better verify whether we still want to keep it.

@prestonvanloon
Copy link
Member Author

@nisdas can you please review? I am not sure which comments to be concerned about from #6864. If there is deadcode that we want to keep around, it must be used or have some comment to keep it. Otherwise it's just code rot, in my opinion.

terencechain
terencechain previously approved these changes Oct 8, 2020
Copy link
Member

@terencechain terencechain left a comment

Choose a reason for hiding this comment

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

I glanced through most and it looked good. Will be good to get another 👀 on this

@terencechain
Copy link
Member

@prestonvanloon this is collecting conflicts.

bump @nisdas for the questions with #6864

@prestonvanloon
Copy link
Member Author

Yeah, this is going to get nasty real fast with conflicts.

If there is no concern over deleting unused code by EOD, then we should move forward on this PR

Copy link
Member

@nisdas nisdas left a comment

Choose a reason for hiding this comment

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

The PR looks good, although this is technically 'dead' code, capturing block propagation times is pretty useful from a metrics point of view. We just need to hook it up through our gossip validators.
@prestonvanloon

@@ -100,13 +96,6 @@ var (
Name: "beacon_reorg_total",
Help: "Count the number of times beacon chain has a reorg",
})
sentBlockPropagationHistogram = promauto.NewHistogram(
Copy link
Member

Choose a reason for hiding this comment

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

This is a pretty useful metric, can we continue using it ?
We just need to hook captureSentTimeMetric for blocks received through gossip

Copy link
Member

Choose a reason for hiding this comment

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

What you are looking for is block_arrival_latency_milliseconds

It's hooked up and used today (captureArrivalTimeMetric): https://github.com/prysmaticlabs/prysm/blob/master/beacon-chain/sync/validate_beacon_blocks.go#L100

Copy link
Contributor

@farazdagi farazdagi left a comment

Choose a reason for hiding this comment

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

This PR will rot quickly. So, approving to have these changes merged.
The only important code that might be useful (as pointed out by Nishant) is block propagation metric, which can be restored at a later stage, should we need it.

NB: there were couple of minor issues reported by DS blocking the merging, so pushed an update to them too.

@prylabs-bulldozer prylabs-bulldozer bot merged commit 7cc32c4 into master Oct 12, 2020
@delete-merged-branch delete-merged-branch bot deleted the gl-inspections branch October 12, 2020 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cleanup Code health! Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants