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

Report Cadence transaction status #270

Merged
merged 9 commits into from
May 28, 2024
Merged

Report Cadence transaction status #270

merged 9 commits into from
May 28, 2024

Conversation

devbugging
Copy link
Contributor

@devbugging devbugging commented May 28, 2024

Description

Report transaction status after transactions are submitted, this is starting point for transaction pool.


For contributor use:

  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the standards mentioned here.
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

Summary by CodeRabbit

  • Improvements
    • Enhanced transaction submission process for better readability and efficiency.
    • Introduced background processing to fetch transaction status post-submission for improved performance.

@devbugging devbugging self-assigned this May 28, 2024
Copy link
Contributor

coderabbitai bot commented May 28, 2024

Walkthrough

The recent changes to services/requester/requester.go focus on enhancing the readability and functionality of the signAndSend function. These updates include importing the time package, restructuring the function for better clarity, and adding a goroutine to asynchronously fetch transaction status after submission.

Changes

File Change Summary
services/requester/requester.go Added time package import, restructured signAndSend function, and introduced a goroutine for fetching transaction status post-submission.

Poem

In code so swift, a change was made,
With time in hand, new paths were laid.
signAndSend now clear and bright,
Goroutines fetch in the dead of night.
Transactions flow, as rabbits cheer,
For progress made, we hold so dear. 🐇✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to full the review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@@ -232,6 +238,41 @@ func (e *EVM) signAndSend(ctx context.Context, script []byte, args ...cadence.Va
return flow.EmptyID, fmt.Errorf("failed to send transaction: %w", err)
}

// get transaction status after it is submitted
go func(id flow.Identifier) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this allows an unbounded number of gorountines to be started, that are then held open for 10+ seconds. In situations where the network pauses sealing (rare but does happen), the number could grow very large.

I think a better approach is to add new tx into a list, and create a long running worker that periodically cycles through the list checking the tx.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I do plan to do that with transaction pool, already started some work on that, but this is just something I want to get out asap because it helps with monitoring for issues, the issue for it is here #264

case <-fetchTicker.C:
res, err := e.client.GetTransactionResult(context.Background(), id)
if err != nil {
e.logger.Error().Err(err).Msg("failed to get transaction result")
Copy link
Contributor

Choose a reason for hiding this comment

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

you should include the id in the message so its easier to debug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohh right

@devbugging devbugging requested a review from peterargue May 28, 2024 16:51
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.

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
services/requester/requester.go (1)

Line range hint 191-275: The restructuring of the signAndSend function improves readability and maintainability. However, the introduction of the goroutine to fetch transaction status asynchronously raises concerns about potential unbounded growth of goroutines, especially under network issues as noted in previous comments.

Consider implementing a more robust solution such as a worker pool or a managed queue to handle the asynchronous tasks more safely and efficiently. This would prevent potential resource exhaustion and improve system stability.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 0e5f7f0 and c82528c.
Files selected for processing (1)
  • services/requester/requester.go (3 hunks)
Additional comments not posted (1)
services/requester/requester.go (1)

11-11: The import of the time package is necessary for the new asynchronous functionality introduced in this PR.

@devbugging devbugging merged commit 1ee7712 into main May 28, 2024
2 checks passed
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.

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between c82528c and 7147b50.
Files selected for processing (1)
  • services/requester/requester.go (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • services/requester/requester.go

@m-Peter m-Peter deleted the gregor/tx-send-status branch July 29, 2024 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants