Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

feat: add timeout when waiting for transaction to be minted #621

Merged

Conversation

rach-id
Copy link
Member

@rach-id rach-id commented Nov 26, 2023

Overview

This will make the relayer wait for 15 minutes before retrying to send the transaction again. This can be helpful when the relayer gets a gas price, then there is a network congestion and the transaction isn't picked up.

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

Summary by CodeRabbit

  • New Features

    • Implemented a configurable timeout for transaction processing to enhance robustness and prevent indefinite waiting.
  • Improvements

    • Updated transaction waiting logic to include a timeout parameter, allowing for more precise control over transaction confirmation times.
  • Configuration

    • Added a new command-line flag to set the timeout duration for EVM transaction retries.
  • Testing

    • Modified test functions to include a timeout parameter, ensuring tests reflect the new transaction waiting behavior.

@rach-id rach-id added enhancement New feature or request relayer relayer related labels Nov 26, 2023
@rach-id rach-id self-assigned this Nov 26, 2023
@rach-id rach-id requested a review from evan-forbes as a code owner November 26, 2023 22:28
Copy link
Contributor

coderabbitai bot commented Nov 26, 2023

Walkthrough

The codebase has been updated to include a timeout parameter for the WaitForTransaction function across various files. This enhancement allows specifying a maximum wait time for transactions to be mined, improving the robustness of the system by preventing indefinite waiting and providing more control over transaction confirmation processes.

Changes

File Path Change Summary
benchmark/main.go
cmd/blobstream/deploy/cmd.go
evm/evm_client.go
relayer/relayer.go
relayer/relayer_test.go
testing/qgb.go
testing/blobstream.go
Added a timeout parameter to the WaitForTransaction function calls and updated function signatures accordingly.
cmd/blobstream/base/config.go
cmd/blobstream/relayer/cmd.go
cmd/blobstream/relayer/config.go
Introduced a new command-line flag FlagEVMRetryTimeout and updated related functions and structs to handle the EVM retry timeout configuration.

🐇✨
In the code where transactions flow,
A rabbit set a timer, now we know
When to wait, when to hop,
No more endless wait-and-stop. 🕒🚀
✨🐇


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 33f7618 and 2cfa253.
Files selected for processing (5)
  • benchmark/main.go (1 hunks)
  • cmd/blobstream/deploy/cmd.go (2 hunks)
  • evm/evm_client.go (2 hunks)
  • relayer/relayer.go (1 hunks)
  • relayer/relayer_test.go (2 hunks)
Files skipped from review due to trivial changes (2)
  • relayer/relayer.go
  • relayer/relayer_test.go
Additional comments: 5
cmd/blobstream/deploy/cmd.go (2)
  • 3-9: The import of the "time" package is necessary for the timeout feature and is correctly placed in the import block.

  • 142-145: The WaitForTransaction function call correctly includes the new timeout parameter. Ensure that all other calls to this function in the codebase are updated to include the timeout parameter as well.

evm/evm_client.go (3)
  • 236-237: The context with timeout is correctly implemented, ensuring that the function will not wait indefinitely for a transaction to be mined.

  • 234-241: The logging within the WaitForTransaction function is sufficient and provides useful information for debugging.

  • 229-241: Ensure that all calls to the WaitForTransaction function throughout the codebase have been updated to include the new timeout parameter.

benchmark/main.go Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (33f7618) 26.13% compared to head (2cfa253) 26.10%.

Files Patch % Lines
evm/evm_client.go 0.00% 3 Missing ⚠️
relayer/relayer.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #621      +/-   ##
==========================================
- Coverage   26.13%   26.10%   -0.03%     
==========================================
  Files          29       29              
  Lines        3019     3022       +3     
==========================================
  Hits          789      789              
- Misses       2135     2138       +3     
  Partials       95       95              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

_, err = r.EVMClient.WaitForTransaction(ctx, ethClient, tx)
_, err = r.EVMClient.WaitForTransaction(ctx, ethClient, tx, 15*time.Minute)
Copy link
Member

Choose a reason for hiding this comment

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

can we make this configurable so users can change this on the fly? perhaps for other timeouts as well, but this one feels more important

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 2cfa253 and 93114c2.
Files selected for processing (5)
  • cmd/blobstream/base/config.go (2 hunks)
  • cmd/blobstream/relayer/cmd.go (1 hunks)
  • cmd/blobstream/relayer/config.go (3 hunks)
  • relayer/relayer.go (4 hunks)
  • testing/qgb.go (1 hunks)
Additional comments: 9
cmd/blobstream/base/config.go (1)
  • 76-82: The addition of the FlagEVMRetryTimeout flag and its associated helper functions GetEVMRetryTimeoutFlag and AddEVMRetryTimeoutFlag are correctly implemented and follow the existing code patterns.
cmd/blobstream/relayer/cmd.go (1)
  • 204-204: Verify the unit of config.EVMRetryTimeout and ensure it is clearly documented to avoid confusion, as the code multiplies it by time.Minute, implying that the value is expected to be in minutes.
cmd/blobstream/relayer/config.go (5)
  • 63-70: The addition of the retry-timeout configuration parameter in the DefaultConfigTemplate is correctly implemented and documented.

  • 89-94: The addRelayerStartFlags function has been correctly updated to include the new base.AddEVMRetryTimeoutFlag call.

  • 112-112: The EVMRetryTimeout field has been correctly added to the StartConfig struct to store the retry timeout configuration.

  • 125-125: The default value for EVMRetryTimeout is set to 15, which is consistent with the summary and the expected behavior.

  • 251-257: The parseRelayerStartFlags function has been correctly updated to parse the retry-timeout flag and set the EVMRetryTimeout field in the StartConfig struct.

relayer/relayer.go (1)
  • 38-44: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [38-62]

The changes to the Relayer struct and the NewRelayer function to include and initialize the RetryTimeout field are correctly implemented. The RetryTimeout is also being used appropriately in the Start method when calling WaitForTransaction. Ensure that the RetryTimeout is being set to a reasonable default value where NewRelayer is called, and verify that all other occurrences of WaitForTransaction in the codebase are updated to use the RetryTimeout if necessary.

testing/qgb.go (1)
  • 49-53: The hardcoded timeout value of 30 seconds in the test setup is noted. Ensure that this value is appropriate for the intended test scenarios.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 93114c2 and 9aeabbc.
Files selected for processing (4)
  • benchmark/main.go (1 hunks)
  • evm/evm_client.go (2 hunks)
  • relayer/relayer_test.go (2 hunks)
  • testing/blobstream.go (1 hunks)
Additional comments: 2
relayer/relayer_test.go (2)
  • 41-45: The changes to include a timeout when waiting for a transaction in the ProcessAttestation test function are correctly implemented.

  • 116-118: The changes to include a timeout when waiting for a transaction in the TestUseValsetFromP2P test function are correctly implemented.

relayer/relayer_test.go Show resolved Hide resolved
evm/evm_client.go Show resolved Hide resolved
testing/blobstream.go Show resolved Hide resolved
@evan-forbes
Copy link
Member

dope, thanks for adding the timeout

@rach-id rach-id enabled auto-merge (squash) November 28, 2023 15:12
@rach-id rach-id merged commit 577f257 into celestiaorg:main Nov 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request relayer relayer related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants