Skip to content

privval: add ctx to privval interface#6240

Merged
mergify[bot] merged 13 commits intomasterfrom
marko/privval_context
Mar 16, 2021
Merged

privval: add ctx to privval interface#6240
mergify[bot] merged 13 commits intomasterfrom
marko/privval_context

Conversation

@tac0turtle
Copy link
Contributor

@tac0turtle tac0turtle commented Mar 15, 2021

Description

  • Add context.Context to Privval interface

This pr does not introduce context into our custom privval connection protocol because this will be removed in the next release. When this pr is released.

@tac0turtle tac0turtle added the T:breaking Type: Breaking Change label Mar 15, 2021
@tac0turtle tac0turtle self-assigned this Mar 15, 2021
@tac0turtle tac0turtle marked this pull request as ready for review March 15, 2021 16:20
@tac0turtle tac0turtle requested a review from tychoish March 15, 2021 16:20
@codecov
Copy link

codecov bot commented Mar 15, 2021

Codecov Report

Merging #6240 (141e363) into master (fa781e6) will increase coverage by 0.04%.
The diff coverage is 63.49%.

@@            Coverage Diff             @@
##           master    #6240      +/-   ##
==========================================
+ Coverage   60.75%   60.80%   +0.04%     
==========================================
  Files         277      277              
  Lines       25921    25937      +16     
==========================================
+ Hits        15749    15771      +22     
- Misses       8533     8536       +3     
+ Partials     1639     1630       -9     
Impacted Files Coverage Δ
cmd/tendermint/commands/init.go 3.70% <0.00%> (-0.15%) ⬇️
cmd/tendermint/commands/root.go 42.85% <ø> (ø)
cmd/tendermint/commands/show_validator.go 0.00% <0.00%> (ø)
cmd/tendermint/commands/testnet.go 22.36% <0.00%> (-0.30%) ⬇️
config/config.go 76.11% <ø> (ø)
privval/file.go 68.22% <ø> (ø)
privval/grpc/client.go 45.45% <ø> (-8.40%) ⬇️
privval/retry_signer_client.go 0.00% <0.00%> (ø)
privval/signer_client.go 51.02% <ø> (ø)
types/test_util.go 39.02% <50.00%> (ø)
... and 28 more

Copy link
Contributor

@tychoish tychoish left a comment

Choose a reason for hiding this comment

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

In short: "yay contexts!"

pubKey, err := pv.GetPubKey()

ctx, cancel := context.WithTimeout(context.Background(), ctxTimeout)
defer cancel()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think eventually there should probably be one context.Context object per-process invocation and that all contexts should be descended from (to support being able to cancel all of the contexts from a signal handler, or some such,) rather than making these one off contexts.

Having said that, (of course), this is really fine and I don't have any functional changes to this patch, except that I'd change context.Background() to context.TODO() to indicate an intention to eventually move toward a single context tree.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the backgrounds, not in tests, to TODO(). Thanks for the pointer

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Changes look good, I left a few comments.

Comment on lines +2269 to +2270
// set a hard timeout for 2 seconds. This helps in avoiding blocking of the remote signer connection
ctx, cancel := context.WithTimeout(context.TODO(), 2*time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure 2 seconds is sufficient. Do we have any heuristics for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We dont have any data, I can test different values but with gRPC 2 seconds would be more than enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In testing this works fine. Not sure how to get results to build more confidence. I can leave a comment mentioning this is double the default time of prevote/precommit timeouts.

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
@tac0turtle tac0turtle added the S:automerge Automatically merge PR when requirements pass label Mar 16, 2021
@mergify mergify bot merged commit efd2fde into master Mar 16, 2021
@mergify mergify bot deleted the marko/privval_context branch March 16, 2021 14:41
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 T:breaking Type: Breaking Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants