Skip to content

Conversation

@technicallyty
Copy link
Contributor

@technicallyty technicallyty commented Apr 24, 2025

Description

  • changes flag behavior for timeouts to take a duration, which simply gets added to the current time.
  • change flag name to timeout-duration to better reflect the above change

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. Your PR will not be merged unless you satisfy
all of these items.

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

Summary by CodeRabbit

  • Improvements
    • Replaced the transaction timeout flag with a new duration-based flag, allowing users to specify how long a transaction remains valid in the mempool.
    • Updated command-line help messages and error handling to reflect the new timeout flag.
  • Bug Fixes
    • Improved error reporting for duplicate unordered transactions in system tests.
  • Tests
    • Refactored system tests to use the new timeout duration flag and streamlined transaction creation, signing, and broadcasting steps.

@ironbird-prod
Copy link

ironbird-prod bot commented Apr 24, 2025

Ironbird - launch a network To use Ironbird, you can use the following commands:
  • /ironbird start OR /ironbird start --load-test-config= - Launch a testnet with the specified chain and load test configuration.
  • /ironbird chains - List of chain images that ironbird can use to spin-up testnet
  • /ironbird loadtests - List of load test modes that ironbird can run against testnet
Custom Load Test Configuration You can provide a custom load test configuration using the `--load-test-config=` flag:
/ironbird start cosmos --load-test-config={
  "block_gas_limit_target": 0.75,
  "num_of_blocks": 50,
  "msgs": [
    {"weight": 0.3, "type": "MsgSend"},
    {"weight": 0.3, "type": "MsgMultiSend"},
	{"weight": 0.4, "type": "MsgArr", "ContainedType": "MsgSend", "NumMsgs": 3300}
  ]
}

Use /ironbird loadtests to see more examples.

@github-actions github-actions bot added the C:CLI label Apr 24, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Apr 24, 2025

📝 Walkthrough

Walkthrough

The changes replace the TimeoutTimestamp flag with a new TimeoutDuration flag in the client module, affecting how transaction timeouts are specified and processed. The TimeoutDuration flag now takes a duration value, which is added to the current time to compute the timeout timestamp for unordered transactions. Corresponding updates were made to flag declarations, usage messages, and mutual exclusivity constraints. The transaction factory logic was updated to use the new flag, and system tests were refactored to adopt a multi-step transaction process (generate, sign, broadcast) using the new timeout flag. Documentation and test error handling were also updated.

Changes

File(s) Change Summary
CHANGELOG.md Added an entry under "Improvements" to document the replacement of TimeoutTimestamp with TimeoutDuration in the client module.
client/flags/flags.go Renamed FlagTimeoutTimestamp to TimeoutDuration, updated flag type to Duration, revised descriptions, usage messages, and updated mutual exclusivity/required-together constraints.
client/tx/factory.go Updated logic in NewFactoryCLI to calculate timeout timestamp using TimeoutDuration (current time plus duration) instead of a fixed timestamp.
systemtests/cli.go Prepended keyring-related flags to CLI command arguments in RunCommandWithArgs method.
tests/systemtests/unordered_tx_test.go Refactored transaction test to use a multi-step process (generate, sign, broadcast), replaced --timeout-timestamp with --timeout-duration, updated error handling, and changed imports for temporary file utilities.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant TxFactory
    participant Blockchain

    User->>CLI: Submit tx with --timeout-duration
    CLI->>TxFactory: Parse timeout-duration flag
    TxFactory->>TxFactory: Compute timeoutTimestamp = now + duration
    TxFactory->>Blockchain: Broadcast transaction with computed timeoutTimestamp
    Blockchain-->>CLI: Accept or reject transaction based on timeout
    CLI-->>User: Return result
Loading
sequenceDiagram
    participant Test
    participant CLI
    participant FileSystem
    participant Blockchain

    Test->>CLI: Generate unsigned tx (--generate-only, --timeout-duration)
    CLI->>FileSystem: Write unsigned tx to temp file
    Test->>CLI: Sign tx (input: unsigned tx file)
    CLI->>FileSystem: Write signed tx to temp file
    Test->>CLI: Broadcast signed tx file
    CLI->>Blockchain: Broadcast transaction
    Blockchain-->>CLI: Return broadcast result
    CLI-->>Test: Output result
    Test->>CLI: Broadcast same signed tx file again
    CLI->>Blockchain: Broadcast duplicate transaction
    Blockchain-->>CLI: Return duplicate error
    CLI-->>Test: Output duplicate error
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

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 UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb91d18 and 8840e39.

📒 Files selected for processing (5)
  • CHANGELOG.md (1 hunks)
  • client/flags/flags.go (3 hunks)
  • client/tx/factory.go (1 hunks)
  • systemtests/cli.go (1 hunks)
  • tests/systemtests/unordered_tx_test.go (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
client/tx/factory.go (1)
client/flags/flags.go (1)
  • TimeoutDuration (77-77)
⏰ Context from checks skipped due to timeout of 90000ms (15)
  • GitHub Check: test-system-legacy
  • GitHub Check: test-system
  • GitHub Check: tests (03)
  • GitHub Check: tests (02)
  • GitHub Check: tests (01)
  • GitHub Check: tests (00)
  • GitHub Check: test-sim-nondeterminism
  • GitHub Check: test-e2e
  • GitHub Check: test-integration
  • GitHub Check: build (arm64)
  • GitHub Check: build (amd64)
  • GitHub Check: Analyze
  • GitHub Check: Gosec
  • GitHub Check: golangci-lint
  • GitHub Check: Summary
🔇 Additional comments (12)
client/flags/flags.go (3)

77-77: Good improvement to the flag naming

Renaming from FlagTimeoutTimestamp to TimeoutDuration better reflects the actual parameter users will provide (a duration rather than an absolute timestamp).


140-142: Good usability improvement for transaction timeout flags

The changes improve user experience by:

  1. Clearly marking the timestamp approach as deprecated
  2. Changing to a duration-based parameter which is more intuitive for users
  3. Updating the description to clearly explain the behavior

This change makes the API more intuitive - users can specify "how long" a transaction should be valid rather than calculating a specific Unix timestamp.


152-153: Appropriate constraint updates for the new flag

Correctly updated the mutual exclusivity and required-together constraints to use the new TimeoutDuration flag, maintaining the same logical relationships between flags.

CHANGELOG.md (1)

69-69: Well-documented change in the CHANGELOG

The entry clearly explains the functional change: timeout timestamps for unordered transactions are now calculated by adding the specified duration to the current time. This is properly categorized as an improvement since it enhances usability.

systemtests/cli.go (1)

198-198: Good consistency improvement for CLI command execution

Adding keyring flags to all commands executed through RunCommandWithArgs ensures consistent behavior across the testing framework when dealing with transactions. This supports the broader changes to transaction timeout handling.

client/tx/factory.go (1)

91-95: Well-implemented timeout calculation logic

The implementation elegantly handles the new timeout duration paradigm:

  1. Reads the duration value from command flags
  2. Only calculates a timeout timestamp when a positive duration is provided
  3. Sets the timestamp by adding the duration to the current time

This approach is more intuitive for users as they can specify "how long" a transaction should be valid rather than calculating an absolute Unix timestamp.

tests/systemtests/unordered_tx_test.go (6)

10-10: Appropriate import change for new file operations

The import change from assert to testutil aligns with the new approach of using temporary files for transaction processing.


20-21: Improved test description clarity

The updated comment clarifies that rejection happens due to the same unordered nonce rather than implying it's due to the same transaction hash, making the test's purpose more explicit.


35-40: Good implementation of multi-step transaction flow with duration-based timeout

The code now follows a better practice of separating transaction generation from signing and broadcasting, while also implementing the new --timeout-duration flag instead of --timeout-timestamp. The temporary file handling is also properly implemented with error checking.


46-48: Clean transaction broadcast implementation

The broadcast step is correctly implemented, leveraging the previously signed transaction file.


50-56: Improved error verification for duplicate transaction

The approach for testing duplicate transaction rejection is cleaner now, directly verifying the expected error code rather than using custom error matching. The previous approach may have been more fragile.


95-95: Correctly updated timeout flag in backward compatibility test

The backward compatibility test has been properly updated to use the new --timeout-duration flag, maintaining consistency with the changes in the client module.

Comment on lines 41 to 45
signCmd := []string{"tx", "sign", txFile.Name(), "--from=" + account1Addr, "--chain-id=testing"}
rsp1 = cli.RunCommandWithArgs(signCmd...)
signedFile := testutil.TempFile(t)
signedFile.WriteString(rsp1)

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Properly implemented transaction signing step

The explicit signing step is correctly implemented using the transaction file and chain ID. Note that line 44 is missing error handling for the file write operation.

Add error handling for the file write operation:

-signedFile.WriteString(rsp1)
+_, err = signedFile.WriteString(rsp1)
+require.NoError(t, err)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
signCmd := []string{"tx", "sign", txFile.Name(), "--from=" + account1Addr, "--chain-id=testing"}
rsp1 = cli.RunCommandWithArgs(signCmd...)
signedFile := testutil.TempFile(t)
signedFile.WriteString(rsp1)
signCmd := []string{"tx", "sign", txFile.Name(), "--from=" + account1Addr, "--chain-id=testing"}
rsp1 = cli.RunCommandWithArgs(signCmd...)
signedFile := testutil.TempFile(t)
_, err = signedFile.WriteString(rsp1)
require.NoError(t, err)

timeout := clientCtx.Viper.GetDuration(flags.TimeoutDuration)
var timeoutTimestamp time.Time
if timeout > 0 {
timeoutTimestamp = time.Now().Add(timeout)

Check warning

Code scanning / CodeQL

Calling the system time Warning

Calling the system time may be a possible source of non-determinism
Copy link
Contributor

@aljo242 aljo242 left a comment

Choose a reason for hiding this comment

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

lgtm just needs lint

Copy link
Contributor

@aljo242 aljo242 left a comment

Choose a reason for hiding this comment

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

are there docs we need to update?

@technicallyty
Copy link
Contributor Author

are there docs we need to update?

we did not have the flag documented, so i just added some in the recent commit.

@aljo242 aljo242 merged commit e2c7604 into main Apr 24, 2025
48 of 49 checks passed
@aljo242 aljo242 deleted the technicallyty/better-timeout-timestamp-ux branch April 24, 2025 18:22
warpbuild-benchmark-bot bot added a commit to WarpBuilds/cosmos-sdk that referenced this pull request Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants