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

Unify usage of context in slasher client #5684

Merged
merged 7 commits into from
Apr 29, 2020
Merged

Unify usage of context in slasher client #5684

merged 7 commits into from
Apr 29, 2020

Conversation

0xKiwi
Copy link
Contributor

@0xKiwi 0xKiwi commented Apr 29, 2020

What type of PR is this?

Improvement

What does this PR do? Why is it needed?
This mirrors #5671 to the slasher client, to ensure SIGTERM cancels when it should be, and also makes sure the wrong context isn't passed into functions.

@0xKiwi 0xKiwi requested a review from a team as a code owner April 29, 2020 19:15
prestonvanloon
prestonvanloon previously approved these changes Apr 29, 2020
@prestonvanloon
Copy link
Member

Build fails

@shayzluf
Copy link
Contributor

did you try it in runtime?

@0xKiwi
Copy link
Contributor Author

0xKiwi commented Apr 29, 2020

did you try it in runtime?

Yes! Gets cancelled instantly, before it would always hand and I'd have to manually interrupt it.

@0xKiwi 0xKiwi added the Ready For Review A pull request ready for code review label Apr 29, 2020
@@ -134,6 +134,10 @@ func (bs *Service) collectReceivedAttestations(ctx context.Context) {
case att := <-bs.receivedAttestationsBuffer:
atts = append(atts, att)
case collectedAtts := <-bs.collectedAttestationsBuffer:
if err := ctx.Err(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is in a for select block <-ctx.Err(): should be its own case

@@ -56,6 +56,10 @@ func (ds *Service) detectIncomingAttestations(ctx context.Context, ch chan *ethp
for {
select {
case indexedAtt := <-ch:
if err := ctx.Err(); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 as above

@@ -93,7 +93,7 @@ func (ds *Service) Start() {
// our gRPC client to keep detecting slashable offenses.
go ds.detectIncomingBlocks(ds.ctx, ds.blocksChan)
go ds.detectIncomingAttestations(ds.ctx, ds.attsChan)
go ds.detectHistoricalChainData(ds.ctx)
//go ds.detectHistoricalChainData(ds.ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

plz no commented code

@codecov
Copy link

codecov bot commented Apr 29, 2020

Codecov Report

Merging #5684 into master will decrease coverage by 41.38%.
The diff coverage is 61.36%.

@@             Coverage Diff             @@
##           master    #5684       +/-   ##
===========================================
- Coverage   54.14%   12.76%   -41.39%     
===========================================
  Files         311      117      -194     
  Lines       25982     9132    -16850     
===========================================
- Hits        14069     1166    -12903     
+ Misses       9859     7818     -2041     
+ Partials     2054      148     -1906     

@0xKiwi 0xKiwi merged commit 2f88174 into master Apr 29, 2020
@delete-merged-branch delete-merged-branch bot deleted the slasher-unify-ctx branch April 29, 2020 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants