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

refactor: index submitted txs in tx client and improve nonce management #3830

Merged
merged 40 commits into from
Sep 25, 2024

Conversation

ninabarbakadze
Copy link
Member

@ninabarbakadze ninabarbakadze commented Aug 28, 2024

Overview

Fixes #3899

@ninabarbakadze ninabarbakadze self-assigned this Aug 28, 2024
@ninabarbakadze ninabarbakadze marked this pull request as ready for review September 2, 2024 13:27
@ninabarbakadze ninabarbakadze requested a review from a team as a code owner September 2, 2024 13:27
@ninabarbakadze ninabarbakadze requested review from staheri14 and rach-id and removed request for a team September 2, 2024 13:27
Copy link
Contributor

coderabbitai bot commented Sep 2, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes introduce a new struct, txInfo, to manage transaction information within the TxClient. A local transaction tracker is established to monitor submitted transactions, enhancing nonce management and error handling. The TxClient methods are updated to incorporate this new tracker, improving transaction confirmation and recovery from evictions. Additionally, a new test file is created to validate the pruning functionality of the transaction tracker.

Changes

Files Change Summary
pkg/user/tx_client.go Introduced txInfo struct for transaction information, added txTracker map to TxClient, modified methods for transaction management and confirmation.
pkg/user/pruning_test.go Implemented tests for pruning logic in the transaction tracker, validating the removal of old transactions.
Makefile Updated test-race target to skip TestEvictions when running tests in race mode.

Assessment against linked issues

Objective Addressed Explanation
Track submitted transactions for nonce management (#3899)
Improve transaction submission handling evictions (#3899)

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d7ea9b9 and ac47d8f.

📒 Files selected for processing (1)
  • pkg/user/pruning_test.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/user/pruning_test.go

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:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 do a full 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@ninabarbakadze ninabarbakadze marked this pull request as draft September 2, 2024 14:21
Copy link
Member Author

@ninabarbakadze ninabarbakadze left a comment

Choose a reason for hiding this comment

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

square size test started failing, investigating that.

@ninabarbakadze ninabarbakadze marked this pull request as ready for review September 3, 2024 09:15
@ninabarbakadze ninabarbakadze marked this pull request as draft September 3, 2024 09:36
@@ -137,6 +148,9 @@ type TxClient struct {
defaultGasPrice float64
defaultAccount string
defaultAddress sdktypes.AccAddress
txPool map[string]poolTxInfo
Copy link
Member Author

Choose a reason for hiding this comment

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

[Question] do we want to have a way of periodically clearing the cache?

Copy link
Member Author

Choose a reason for hiding this comment

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

@evan-forbes @cmwaters I'd appreciate your input here

Copy link
Member

Choose a reason for hiding this comment

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

ideally, it seems like we should never be a scenario where we need this to be cleared. Either a tx is included and we continually try to get it included, or we handle each case when that does not occur and remove the tx at that point

Copy link
Member Author

Choose a reason for hiding this comment

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

the only time tx doesn't get removed from this local cache is if context gets cancelled while polling for tx status which means that the said tx was never confirmed. If the transaction doesn't get confirmed it can linger in that cache until it ooms

Copy link
Member

@evan-forbes evan-forbes Sep 5, 2024

Choose a reason for hiding this comment

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

by periodically, do we mean a ttl?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes!

Copy link
Contributor

Choose a reason for hiding this comment

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

The scenario that I see as more problematic is if a user decides to use BroadcastTx which creates the map entry and doesn't use ConfirmTx which cleans it up (because maybe they don't care if it lands or not).

I think we should garbage collect, but not as a separate go routine but within BroadcastTx.

I would give at least 10 minutes before we clean up.

@celestia-bot celestia-bot requested a review from a team September 23, 2024 10:17
cmwaters
cmwaters previously approved these changes Sep 23, 2024
@ninabarbakadze
Copy link
Member Author

Fixes #3768

The PR description will close that issue when this PR merges which doesn't seem like what you want. Since #3768 is large in scope, it is not immediately obvious which parts of that issue this PR addresses. One idea is to convert that issue into a tracking issue with several smaller issues. Then this PR can close one of the smaller issues and leave the remaining ones open.

Created a new issue that this pr directly resolves #3899 i decided to keep the old one for context. Me and Callum can groom it/close it/delete it when we pm best txs stuff.

@ninabarbakadze ninabarbakadze changed the title fix: evictions issue in tx client refactor: index submitted txs in tx client and improve nonce management Sep 23, 2024
@ninabarbakadze ninabarbakadze enabled auto-merge (squash) September 23, 2024 21:09
@celestia-bot celestia-bot requested a review from a team September 23, 2024 21:09
staheri14
staheri14 previously approved these changes Sep 23, 2024
Copy link
Contributor

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

LGTM!

txClient.pruneTxTracker()
// Prunes the transactions that are 10 minutes old
// 5 transactions will be pruned
require.Equal(t, txTrackerBeforePruning-txsToBePruned, txsToBePruned)
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] Would be nice to apply this comment of coderabbit.

@celestia-bot celestia-bot requested a review from a team September 24, 2024 09:15
})
}

func TestEvictions(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we just need to add this test to the exceptions list to get past the race detector issue with testnode/sdk

Copy link
Member Author

Choose a reason for hiding this comment

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

resolved now. can I please get another approval? 🙏🏻

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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between def40f2 and d7ea9b9.

📒 Files selected for processing (1)
  • Makefile (1 hunks)
🔇 Additional comments not posted (1)
Makefile (1)

Line range hint 1-265: Overall Makefile structure is comprehensive

While not directly related to the change, it's worth noting that this Makefile is well-structured and includes a wide range of targets for building, testing, linting, and managing the celestia-app project. This comprehensive setup facilitates easier development, testing, and maintenance of the project.

Makefile Show resolved Hide resolved
@celestia-bot celestia-bot requested review from a team and evan-forbes and removed request for a team September 25, 2024 12:01
@ninabarbakadze ninabarbakadze merged commit e9278ed into main Sep 25, 2024
29 of 30 checks passed
@ninabarbakadze ninabarbakadze deleted the nina/evictions-bug branch September 25, 2024 19:24
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.

Index submitted transactions for nonce tracking in tx client
5 participants