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

consensus: only call privValidator.GetPubKey once per block #5143

Merged
merged 7 commits into from Jul 30, 2020

Conversation

melekes
Copy link
Contributor

@melekes melekes commented Jul 22, 2020

Closes #4865

@auto-comment
Copy link

auto-comment bot commented Jul 22, 2020

👋 Thanks for creating a PR!

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Wrote tests
  • Updated CHANGELOG_PENDING.md
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments
  • Re-reviewed Files changed in the Github PR explorer
  • Applied Appropriate Labels

Thank you for your contribution to Tendermint! 🚀

@melekes melekes self-assigned this Jul 22, 2020
@melekes melekes marked this pull request as ready for review July 22, 2020 08:18
@melekes melekes requested a review from tessr as a code owner July 22, 2020 08:18
@codecov
Copy link

codecov bot commented Jul 22, 2020

Codecov Report

Merging #5143 into master will increase coverage by 1.73%.
The diff coverage is 40.54%.

@@            Coverage Diff             @@
##           master    #5143      +/-   ##
==========================================
+ Coverage   60.83%   62.57%   +1.73%     
==========================================
  Files         203      259      +56     
  Lines       20526    27272    +6746     
==========================================
+ Hits        12488    17066    +4578     
- Misses       6961     8716    +1755     
- Partials     1077     1490     +413     
Impacted Files Coverage Δ
consensus/state.go 73.37% <40.54%> (+0.58%) ⬆️
blockchain/v0/reactor.go 63.25% <0.00%> (-0.94%) ⬇️
proxy/multi_app_conn.go 58.02% <0.00%> (ø)
privval/signer_listener_endpoint.go 78.26% <0.00%> (ø)
privval/retry_signer_client.go 0.00% <0.00%> (ø)
light/client.go 71.45% <0.00%> (ø)
p2p/pex/addrbook.go 72.48% <0.00%> (ø)
p2p/pex/pex_reactor.go 80.95% <0.00%> (ø)
node/node.go 58.66% <0.00%> (ø)
light/trust_options.go 100.00% <0.00%> (ø)
... and 55 more

Comment on lines +279 to +281
if err := cs.updatePrivValidatorPubKey(); err != nil {
cs.Logger.Error("Can't get private validator pubkey", "err", err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a hard error condition? If we can't fetch the validator's public key on startup, is there even any point in continuing with consensus?

Copy link
Contributor Author

@melekes melekes Jul 22, 2020

Choose a reason for hiding this comment

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

the very first time we try to get pubkey is in node.go

pubKey, err := privValidator.GetPubKey()

there we exit upon failure

it's fine to continue here => validator will just not sign / vote on this block (or more depending on downtime)

Copy link
Contributor

@tac0turtle tac0turtle left a comment

Choose a reason for hiding this comment

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

There is another key cache in the metrics function could this be replaced with this change? Also is there any chance we could test this and see the improvement?

@melekes
Copy link
Contributor Author

melekes commented Jul 22, 2020

There is another key cache in the metrics function could this be replaced with this change?

I can't use privValidatorPubKey because privValidator might be nil, so we need this "cache" in any case.

Also is there any chance we could test this and see the improvement?

you mean write a test or test by hands?

@tac0turtle
Copy link
Contributor

you mean write a test or test by hands?

test by hand. I dont think we have e2e tests that could do this, do we?

@tac0turtle
Copy link
Contributor

is this PR good to go into master?

@erikgrinaker erikgrinaker added the S:automerge Automatically merge PR when requirements pass label Jul 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:automerge Automatically merge PR when requirements pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Excessive calls to GetPubkey() on external signer
3 participants