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

feat(tx)!: make timeout_height time based #20870

Merged
merged 51 commits into from
Jul 29, 2024
Merged

Conversation

sontrinh16
Copy link
Member

@sontrinh16 sontrinh16 commented Jul 4, 2024

Description

ref: 20658

  • Add timeout_timestamp field in txbody
  • x/auth TxTimeoutHeightDecorator and UnorderedTxDecorator validateTx check accounts for timeout timestamp
  • unorderedtx manager now have additional map for txHash for timestamp so that purging loop now works with block time
  • add new flag for timeout timestamp in tx builder and client tx factory
  • update tests accordingly to the changes

Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

Please see Pull Request Reviewer section in the contributing guide for more information on how to review a pull request.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added a timeout-timestamp flag for transaction time-based timeout.
    • Introduced new methods for handling timeout timestamps within transaction factories and decorators.
  • Bug Fixes

    • Updated timeout handling from height-based to timestamp-based for improved accuracy.
  • Documentation

    • Refined the handling of unordered transactions to utilize timeout_timestamp.
  • Chores

    • Increased gas cost for processing the new timeout timestamp field in transactions.

Copy link
Contributor

coderabbitai bot commented Jul 4, 2024

Warning

Rate limit exceeded

@sontrinh16 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 25 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 48c0c5f and ff273d1.

Walkthrough

Walkthrough

The updates transition the transaction timeout mechanism from a block-height-based system to a timestamp-based approach within the Cosmos SDK. This enhancement allows for more accurate transaction management by implementing changes across various components, including decorators, transaction managers, and testing frameworks. The command-line interface has also been updated to reflect the new flag for setting timeouts, ensuring consistency and improving transaction handling and replay protection.

Changes

File Path Change Summary
x/auth/ante/unorderedtx/snapshotter_test.go Updated TestSnapshotter to utilize the current time for timestamp calculations.
x/auth/tx/builder.go, client/tx/factory.go Introduced timeoutTimestamp field and related methods to handle timestamp settings in both builder and Factory structs.
client/flags/flags.go Replaced FlagTimeoutHeight with FlagTimeoutTimestamp for a time-based timeout mechanism.
tests/systemtests/unordered_tx_test.go Changed timeout handling from height-based to timestamp-based, updating related function calls.
docs/architecture/adr-070-unordered-transactions.md Documented the shift from timeout_height to timeout_timestamp, adjusting data structures and enhancing duplicate checks.
CHANGELOG.md Noted increased gas costs for processing the timeout timestamp and added --timeout-timestamp flag.
client/v2/autocli/testdata/help-echo-msg.golden Updated command-line help documentation to reflect the new --timeout-timestamp flag, replacing --timeout-height.

Sequence Diagrams

sequenceDiagram
    participant User
    participant CLI
    participant TxManager
    participant Block
    Note over User,CLI: New Transaction Flow with Timestamp
    User->>CLI: Send Transaction with --timeout-timestamp
    CLI->>TxManager: Validate and Process Transaction
    TxManager->>Block: Check Transaction Timeout Timestamp
    Block->>TxManager: Return Confirmation
    TxManager->>CLI: Confirmation/Failure
    CLI->>User: Transaction Processed
Loading
sequenceDiagram
    participant User
    participant System
    participant TxManager
    participant Block
    Note over User,System: Old Transaction Flow with Block Height
    User->>System: Send Transaction with --timeout-height
    System->>TxManager: Validate and Process Transaction
    TxManager->>Block: Check Transaction Timeout Height
    Block->>TxManager: Return Confirmation
    TxManager->>System: Confirmation/Failure
    System->>User: Transaction Processed
Loading

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 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.

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

CodeRabbit Configuration 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.

x/auth/ante/unorderedtx/manager.go Fixed Show fixed Hide fixed
x/auth/ante/unorderedtx/manager.go Fixed Show fixed Hide fixed
types/context.go Outdated Show resolved Hide resolved
x/auth/ante/unorderedtx/manager.go Fixed Show fixed Hide fixed
x/auth/ante/unorderedtx/manager.go Fixed Show fixed Hide fixed
@sontrinh16 sontrinh16 marked this pull request as ready for review July 9, 2024 05:37
@sontrinh16 sontrinh16 requested a review from a team as a code owner July 9, 2024 05:37

This comment has been minimized.

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.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 234d250 and 9ac9527.

Files selected for processing (5)
  • CHANGELOG.md (2 hunks)
  • client/flags/flags.go (3 hunks)
  • tests/e2e/baseapp/block_gas_test.go (1 hunks)
  • types/tx_msg.go (3 hunks)
  • x/auth/tx/builder.go (4 hunks)
Files skipped from review as they are similar to previous changes (5)
  • CHANGELOG.md
  • client/flags/flags.go
  • tests/e2e/baseapp/block_gas_test.go
  • types/tx_msg.go
  • x/auth/tx/builder.go

@tac0turtle tac0turtle changed the title feat(tx)!: make timeout_height time based feat(tx): make timeout_height time based Jul 23, 2024
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.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 9ac9527 and e5b2a8e.

Files selected for processing (1)
  • client/v2/autocli/testdata/help-echo-msg.golden (1 hunks)
Additional comments not posted (1)
client/v2/autocli/testdata/help-echo-msg.golden (1)

30-30: LGTM! The new --timeout-timestamp flag is correctly added.

The flag is consistent with the other command-line options and the description is clear.

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.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e5b2a8e and 4323483.

Files selected for processing (2)
  • client/flags/flags.go (2 hunks)
  • client/tx/factory.go (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • client/tx/factory.go
Additional context used
Path-based instructions (1)
client/flags/flags.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (1)
client/flags/flags.go (1)

76-76: LGTM!

The addition of the FlagTimeoutTimestamp constant is appropriate and aligns with the PR objectives.

client/flags/flags.go Show resolved Hide resolved
sontrinh16 and others added 3 commits July 24, 2024 06:26
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4323483 and a85d969.

Files selected for processing (1)
  • client/flags/flags.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • client/flags/flags.go

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.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a85d969 and f6c0df5.

Files selected for processing (1)
  • client/v2/autocli/testdata/help-echo-msg.golden (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • client/v2/autocli/testdata/help-echo-msg.golden

@aaronc aaronc changed the title feat(tx): make timeout_height time based feat(tx)!: make timeout_height time based Jul 24, 2024
@tac0turtle tac0turtle added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Jul 25, 2024
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, codebase verification and nitpick comments (1)
CHANGELOG.md (1)

64-64: Fix grammatical error and add missing space.

There is a missing space after "timeout." and "defines" should be "defining".

-  Add `timeout-timestamp` field for tx body defines time based timeout.Add `WithTimeoutTimestamp` to tx factory. Increased gas cost for processing newly added timeout timestamp field in tx body.
+  Add `timeout-timestamp` field for tx body, defining time-based timeout. Add `WithTimeoutTimestamp` to tx factory. Increased gas cost for processing newly added timeout timestamp field in tx body.
Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f6c0df5 and bc94df3.

Files selected for processing (3)
  • CHANGELOG.md (2 hunks)
  • UPGRADING.md (1 hunks)
  • client/tx/factory.go (7 hunks)
Files skipped from review as they are similar to previous changes (1)
  • client/tx/factory.go
Additional context used
Path-based instructions (2)
UPGRADING.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

Additional comments not posted (2)
UPGRADING.md (1)

106-106: Ensure Consistency in Function Argument Naming.

The argument unorderedtx.DefaultMaxTimeoutDuration is correctly used, but ensure consistency in naming conventions throughout the documentation and codebase.

CHANGELOG.md (1)

203-203: LGTM!

The entry correctly describes the breaking changes.

Copy link
Member

@aaronc aaronc left a comment

Choose a reason for hiding this comment

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

Pre-approving. Code LGTM, but the CHANGELOG needs to be updated to reflect exactly what is and isn't breaking, now CLI is for instance, but we aren't removing timeout height from the state machine

s.Require().Equal(286, testTxs[5].size)
s.Require().Equal(277, testTxs[6].size)
s.Require().Equal(277, testTxs[7].size)
s.Require().Equal(277, testTxs[8].size)
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated to this PR but these types of tests are fragile and hard to maintain.

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.yml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between bc94df3 and 48c0c5f.

Files selected for processing (3)
  • CHANGELOG.md (2 hunks)
  • UPGRADING.md (1 hunks)
  • baseapp/abci_test.go (1 hunks)
Files skipped from review as they are similar to previous changes (3)
  • CHANGELOG.md
  • UPGRADING.md
  • baseapp/abci_test.go

@sontrinh16 sontrinh16 added this pull request to the merge queue Jul 29, 2024
Merged via the queue into main with commit 5853356 Jul 29, 2024
78 of 79 checks passed
@sontrinh16 sontrinh16 deleted the son/timeout_height_time_based branch July 29, 2024 11:57
mergify bot pushed a commit that referenced this pull request Jul 29, 2024
Co-authored-by: Marko <marko@baricevic.me>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
(cherry picked from commit 5853356)
tac0turtle pushed a commit that referenced this pull request Jul 29, 2024
Co-authored-by: son trinh <trinhleson2000@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release C:CLI C:x/auth Type: ADR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants