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 timeouts to eth client #2289

Merged
merged 5 commits into from
Mar 10, 2022
Merged

Conversation

leszko
Copy link
Contributor

@leszko leszko commented Feb 24, 2022

What does this pull request do? Explain your changes. (required)

Add timeouts for CheckTx() function and all ETH RPC calls.

Note that the timeout values are quite conservative, by default:

  • 5 min for CheckTx()
  • 10 min for every ETH RPC call

I don't think we need smaller numbers, because in the correct flow of action, these timeouts should never actually be reached.

Specific updates (required)

  • Add timeout for the CheckTx() execution
  • Add timeout for all ETH RPC (contracts) calls
  • Refactor client to not include contract sessions anymore

How did you test each of these updates (required)

  • Checked that using eth client and sending transactions still work fine
  • Change CheckTxTimeout to 1 ns and check that it always times out
  • Change ethRpcTimeout to 1 ns and check that all ETH RPC requests fail

Does this pull request close any open issues?

fix #2207

Checklist:

minterSess *contracts.MinterSession
livepeerTokenFaucetSess *contracts.LivepeerTokenFaucetSession
// Contracts
controller *contracts.Controller
Copy link
Member

Choose a reason for hiding this comment

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

Like the refactor, but is this related to the timeouts change? Seems to be the bulk of the PR here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is related because before adding the timeout, we actually needed to store sessions here (CallOpts was encapsulated in the session structs). Now, we don't need sessions, because we always provide our CallOpts.

Copy link
Member

Choose a reason for hiding this comment

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

Cool! Thanks for clarification

eth/client.go Outdated
@@ -1101,6 +1089,8 @@ func (c *client) CheckTx(tx *types.Transaction) error {

for {
select {
case <-time.After(c.checkTxTimeout):
Copy link
Member

Choose a reason for hiding this comment

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

I believe you actually need to create the time.After timer only once, outside the for loop, otherwise you will reset the timer for every receipt that you get even if not related to the tx you're checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated in a354f71

@leszko leszko requested a review from victorges March 1, 2022 08:49
Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

LGTM!

cmd/devtool/devtool.go Outdated Show resolved Hide resolved
eth/client.go Outdated Show resolved Hide resolved
eth/client_ticketbroker.go Show resolved Hide resolved
Copy link
Contributor Author

@leszko leszko left a comment

Choose a reason for hiding this comment

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

@yondonfu Addressed your comments. PTAL

@leszko leszko requested a review from yondonfu March 2, 2022 12:27
Copy link
Member

@yondonfu yondonfu left a comment

Choose a reason for hiding this comment

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

LGTM after squashing!

@leszko leszko force-pushed the 2207-add-timeouts-to-pubsub branch from ee6a8c1 to adeb060 Compare March 10, 2022 10:54
@leszko leszko merged commit 17b0b68 into livepeer:master Mar 10, 2022
@leszko leszko deleted the 2207-add-timeouts-to-pubsub branch March 10, 2022 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Feed PubSub mechanism
3 participants