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

Add Slasher double block detection to E2E #5936

Merged
merged 7 commits into from May 21, 2020
Merged

Conversation

0xKiwi
Copy link
Contributor

@0xKiwi 0xKiwi commented May 21, 2020

What type of PR is this?
Testing improvement

What does this PR do? Why is it needed?
This PR adds a test for double block detection to E2E, in order to test the slashers detection capabilities for broadcasted blocks.

This PR also adds --broadcast-slashing to E2E, in order to conveniently test slashing broadcasting as well.

@0xKiwi 0xKiwi requested a review from a team as a code owner May 21, 2020 04:05
@codecov
Copy link

codecov bot commented May 21, 2020

Codecov Report

Merging #5936 into master will decrease coverage by 0.46%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #5936      +/-   ##
==========================================
- Coverage   59.95%   59.49%   -0.47%     
==========================================
  Files         320      319       -1     
  Lines       27312    26819     -493     
==========================================
- Hits        16376    15955     -421     
+ Misses       8741     8705      -36     
+ Partials     2195     2159      -36     

@0xKiwi 0xKiwi added the Ready For Review A pull request ready for code review label May 21, 2020
rauljordan
rauljordan previously approved these changes May 21, 2020
return err
}
client := eth.NewBeaconNodeValidatorClient(conns[0])
_, err = client.ProposeAttestation(ctx, att)
Copy link
Contributor

Choose a reason for hiding this comment

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

if _, err = client.ProposeAttestation

}
slashedIndices = append(slashedIndices, committee[i])
}
return nil
}

func proposeDoubleBlock(conns ...*grpc.ClientConn) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can return more informative errors in each of the conditionals in this func, something like errors.Wrap(err, "could not do X")

@rauljordan rauljordan dismissed their stale review May 21, 2020 04:11

clicked approve by accident

return nil
}

func to32BytesSlice(byteArray []byte) []byte {
Copy link
Member

Choose a reason for hiding this comment

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

We don't have this in shared? I think we use this in other packages as well

}
slashedIndices = append(slashedIndices, committee[i])
}
return nil
}

func proposeDoubleBlock(conns ...*grpc.ClientConn) error {
conn := conns[0]
Copy link
Member

Choose a reason for hiding this comment

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

what happen if len(conns) != 1 is empty? Probably best to check the length and return error

Copy link
Contributor Author

@0xKiwi 0xKiwi May 21, 2020

Choose a reason for hiding this comment

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

It will always be something here, the test would fail much earlier elsewhere if it wasn't. That would mean we don't have any beacon nodes to connect to. At least 1 node is a guarantee here

Copy link
Member

Choose a reason for hiding this comment

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

Agree. But better to be defensive. Someone brand new can be writing an e2e test and use proposeDoubleBlock but 100% unaware conns[0] vs [1], [2] will be used

Copy link
Member

Choose a reason for hiding this comment

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

Also, why pass in conns, why do we need a list? why not just use conn?

Copy link
Contributor Author

@0xKiwi 0xKiwi May 21, 2020

Choose a reason for hiding this comment

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

Putting the check here would be very odd, these style of tests follow an interface for all of E2E. Only conns[0] is used here but in the dozen or so other E2E tests, the other conns are used. Using multiple conns here just adds little benefit. E2E is designed with the assumption that there will always be at least 1 beacon node, because if there isn't, the test wouldn't progress.

Copy link
Contributor Author

@0xKiwi 0xKiwi May 21, 2020

Choose a reason for hiding this comment

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

Tests are at least run with 1 node, so pinging for any chain data that shouldn't be node dependent is done with the node index that we know is running.

Copy link
Contributor Author

@0xKiwi 0xKiwi May 21, 2020

Choose a reason for hiding this comment

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

Also, only using one beacon node here helps test --broadcast-slashing, its why I removed the connection to other nodes from injectDoubleVote.

Copy link
Member

Choose a reason for hiding this comment

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

I see. I got confused. Perhaps we should add a comment to mention only con0 is explicitly used but input takes in a list of conns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure thing, that sounds good 👍

@prylabs-bulldozer prylabs-bulldozer bot merged commit 4fb3307 into master May 21, 2020
@delete-merged-branch delete-merged-branch bot deleted the e2e-double-block branch May 21, 2020 06:02
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.

None yet

3 participants