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

fix(x/auth/tx): add missing timeoutTimestamp in newBuilderFromDecodedTx #23492

Merged
merged 1 commit into from
Jan 24, 2025

Conversation

mmsqe
Copy link
Contributor

@mmsqe mmsqe commented Jan 24, 2025

Description

Closes: #23491


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

  • Bug Fixes

    • Added missing timeout timestamp in transaction builder, improving transaction processing reliability
    • Resolved an issue in the authentication module's transaction handling
  • Tests

    • Introduced new test to validate timeout timestamp functionality in transaction builder

The changes enhance transaction management by ensuring proper timeout configuration and validation.

@mmsqe mmsqe requested a review from a team as a code owner January 24, 2025 00:31
Copy link
Contributor

coderabbitai bot commented Jan 24, 2025

📝 Walkthrough

Walkthrough

The pull request addresses a bug in the Cosmos SDK's transaction builder where the timeoutTimestamp was being lost when wrapping a transaction. The changes modify the x/auth/tx/builder.go file to ensure that the timeout timestamp is correctly preserved during transaction creation. Additionally, the CHANGELOG.md was updated to reflect API breaking changes, including the removal of the x/params module and deprecation of certain fields in the block response.

Changes

File Change Summary
CHANGELOG.md Updated "Bug Fixes" and "API Breaking Changes" sections
x/auth/tx/builder.go - Added timeoutTimestamp field to builder struct
- Added SetTimeoutTimestamp method
- Modified newBuilderFromDecodedTx to preserve timeout timestamp
x/auth/tx/builder_test.go Added new test TestBuilderWithTimeoutTimestamp to verify timeout timestamp handling

Assessment against linked issues

Objective Addressed Explanation
Preserve TimeoutTimestamp when wrapping transaction [#23491]
Fix loss of timeout timestamp in newBuilderFromDecodedTx

Possibly related PRs

Suggested labels

C:x/auth, C:x/tx, backport/v0.52.x

Suggested reviewers

  • julienrbrt
  • aljo242
  • tac0turtle
  • testinginprod
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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>, please review it.
    • 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 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. (Beta)
  • @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.

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 comments (1)
CHANGELOG.md (1)

Line range hint 1-1000: Add missing section for security fixes

The changelog should include a dedicated section for security-related fixes to help users identify critical updates.

# Changelog

## [v0.47.16](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.16) - 2024-12-16

+### Security
+
+* Fix [ABS-0043/ABS-0044](https://github.com/cosmos/cosmos-sdk/security/advisories/GHSA-8wcc-m6j2-qxvm) Limit recursion depth for unknown field detection and unpack any
+* (x/auth/vesting) [GHSA-4j93-fm92-rp4m] Add BlockedAddr check in CreatePeriodicVestingAccount
+
### Features
🧹 Nitpick comments (3)
x/auth/tx/builder_test.go (1)

21-37: Strengthen the assertions in this test.
The test only checks that timeoutTimestamp is not zero but does not confirm it matches a specific expected time. Consider explicitly setting a known timestamp and verifying that the builder retains this exact value post-encoding/decoding.

CHANGELOG.md (2)

57-58: Fix inconsistent formatting in bug fix entry

The bug fix entry should follow the same format as other entries with a proper description.

-* (x/auth/tx) [#23492](https://github.com/cosmos/cosmos-sdk/pull/23492) Add missing timeoutTimestamp in newBuilderFromDecodedTx.
+* (x/auth/tx) [#23492](https://github.com/cosmos/cosmos-sdk/pull/23492) Added missing timeoutTimestamp field in newBuilderFromDecodedTx function to properly handle transaction timeouts.

Line range hint 1-1000: Improve changelog organization

The changelog would be more readable with consistent formatting and grouping of related changes.

  1. Group related changes together within sections
  2. Use consistent punctuation at the end of entries
  3. Standardize capitalization in descriptions
  4. Add subsection headers for major components when there are many related changes

Example structure:

### API Breaking Changes

#### Baseapp
* Change 1
* Change 2

#### Modules  
* Change 1
* Change 2
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8493d4f and 0af845f.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • x/auth/tx/builder.go (1 hunks)
  • x/auth/tx/builder_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
x/auth/tx/builder_test.go (2)

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


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

x/auth/tx/builder.go (1)

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

CHANGELOG.md (1)

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

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: tests (00)
  • GitHub Check: test-system-v2
  • GitHub Check: Analyze
  • GitHub Check: Summary
🔇 Additional comments (5)
x/auth/tx/builder_test.go (2)

9-10: Imports look fine.
No apparent issues. They appear consistent with Go conventions and do not raise any style or performance concerns.


13-13: New import is appropriate.
The newly added import for authclient is relevant to reading transactions from file and is necessary for the test.

x/auth/tx/builder.go (1)

66-66: Validate or document the timestamp usage.
Storing the timeout timestamp from the decoded transaction is correct. However, consider clarifying or validating edge-case timestamps (e.g., in the distant past or future) to prevent potential misuse.

CHANGELOG.md (2)

Line range hint 1-3: LGTM: Standard changelog header format

The header follows the standard format with version number and release date.


Line range hint 13-20: Verify completeness of breaking changes section

The breaking changes section should be verified against the actual code changes to ensure no breaking changes are missed.

✅ Verification successful

Breaking changes section is complete and accurate

The breaking changes section in CHANGELOG.md correctly documents all breaking changes. The recent code modifications only include a bug fix (adding missing timeoutTimestamp) and do not introduce any new breaking changes.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any additional breaking changes in the codebase
# Look for interface changes, removed functions, etc.

rg -g '*.go' -l 'interface|func.*\bremove\b|func.*\bdelete\b|func.*\bdeprecate\b' | while read -r file; do
  echo "Checking $file for potential breaking changes..."
  rg 'interface|func.*\bremove\b|func.*\bdelete\b|func.*\bdeprecate\b' "$file"
done

Length of output: 131070


Script:

#!/bin/bash

# Search for breaking change markers in recent commits
echo "=== Checking recent commits for breaking change markers ==="
git log --oneline -n 20 | grep -i "breaking"

# Check CHANGELOG.md for breaking changes section
echo -e "\n=== Checking CHANGELOG.md for breaking changes ==="
if [ -f CHANGELOG.md ]; then
  echo "Breaking changes section from CHANGELOG.md:"
  awk '/^## \[Unreleased\]/,/^## \[[0-9]/' CHANGELOG.md | grep -A 5 "BREAKING CHANGES"
fi

# Get list of modified files
echo -e "\n=== Checking modified files ==="
git diff --name-only HEAD~1

Length of output: 624


Script:

#!/bin/bash

# Check the actual changes in builder.go
echo "=== Changes in x/auth/tx/builder.go ==="
git diff HEAD~1 x/auth/tx/builder.go

# Check CHANGELOG.md changes
echo -e "\n=== Changes in CHANGELOG.md ==="
git diff HEAD~1 CHANGELOG.md

Length of output: 1414

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 comments (1)
CHANGELOG.md (1)

Changelog Format Issues Found

The changelog has several formatting inconsistencies that should be addressed:

  • The guiding principles and usage instructions at the top of the file should be moved to a separate documentation file or properly formatted as comments using HTML comment tags
  • All changelog entries should start with either * or - bullet points
  • Metadata and section headers should be clearly separated from changelog entries

Recommended fixes:

  • Move the "Guiding Principles" and "Usage" sections to a CONTRIBUTING.md file
  • Ensure all changelog entries start with bullet points
  • Use proper HTML comment syntax for any non-changelog content that must remain in the file

The core changelog structure (sections and version headers) is correct, but these formatting improvements will make the changelog more consistent and easier to read.

🔗 Analysis chain

Line range hint 1-15000: Verify changelog format consistency

Let's verify that all changelog entries follow the Keep a Changelog format conventions.


|>|[|<!--)" CHANGELOG.md |
grep -v "^[A-Z]" |
grep -v "^[[:space:]]*$" |
head -n 10


---

|>|<!--|\[|ATTENTION:|EOL|Security|This|Users|\s*\}|\s*\{))" CHANGELOG.md | \
while IFS=: read -r line_num content; do
    echo "Line $line_num: $content"
done

echo "Checking for proper section headers..."
grep -n "^###" CHANGELOG.md
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for consistent changelog entry formatting
echo "Checking changelog format consistency..."

# Check for proper section headers
if ! grep -q "^### Features" CHANGELOG.md || \
   ! grep -q "^### Bug Fixes" CHANGELOG.md || \
   ! grep -q "^### Improvements" CHANGELOG.md; then
  echo "Error: Missing standard changelog sections"
  exit 1
fi

# Check entry format (should start with * or -)
if grep -Pv "^(\s*[\*\-]|#|$)" CHANGELOG.md; then
  echo "Error: Found entries not starting with * or -"
  exit 1
fi

echo "Changelog format appears consistent"

Length of output: 17303


Script:

#!/bin/bash
# Find lines that don't match expected changelog format but should
grep -Pv "^(\s*[\*\-]|###|##|#|$|\s*

Length of output: 116


Script:

#!/bin/bash

echo "Checking for improperly formatted changelog entries..."

# Find lines that don't match expected format but excluding valid elements
grep -n -P "^(?!(\s*[\*\-]|###|##|#|$|\s*

Length of output: 235


Script:

#!/bin/bash

echo "=== Checking CHANGELOG.md format ==="

echo "1. Checking for required sections..."
for section in "### Features" "### Bug Fixes" "### Improvements" "### API Breaking Changes" "### State Machine Breaking"; do
    if grep -q "^$section" CHANGELOG.md; then
        echo "✓ Found section: $section"
    else
        echo "✗ Missing section: $section"
    fi
done

echo -e "\n2. Checking entry formatting..."
# Count lines that should be entries (non-empty, non-header, non-code block lines)
grep -v "^$\|^#\|^[[:space:]]*$\|^[[:space:]]*\`\`\`" CHANGELOG.md | \
grep -v "^[[:space:]]*[-*]" | \
head -n 5

echo -e "\n3. Checking version headers..."
grep "^## \[v" CHANGELOG.md | head -n 3

Length of output: 2158

🧹 Nitpick comments (3)
x/auth/tx/builder_test.go (1)

21-37: Expand the test to validate an explicit timestamp value.

While the test checks that timeoutTimestamp is set (not zero), consider setting and verifying a specific timestamp value to ensure the builder preserves the exact value.

CHANGELOG.md (2)

Line range hint 1-1: Add missing title and version badge

The changelog should start with a clear title and version badge for better visibility and reference.

+ # Changelog
+ [![Stargate](https://img.shields.io/badge/STARGATE-v0.47.0-blue.svg)](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.47.0)

Line range hint 1-15000: Improve version organization

The changelog mixes multiple versions together which makes it harder to track changes for specific releases. Consider splitting into separate files per major version.

Consider reorganizing the changelog into separate files:

  • CHANGELOG_v0.47.md
  • CHANGELOG_v0.46.md
  • CHANGELOG_v0.45.md
    etc.

This would make it easier to track changes for specific major versions while keeping the main CHANGELOG.md focused on the latest release.

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8493d4f and 0af845f.

📒 Files selected for processing (3)
  • CHANGELOG.md (1 hunks)
  • x/auth/tx/builder.go (1 hunks)
  • x/auth/tx/builder_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
x/auth/tx/builder_test.go (2)

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


Pattern **/*_test.go: "Assess the unit test code assessing sufficient code coverage for the changes associated in the pull request"

x/auth/tx/builder.go (1)

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

CHANGELOG.md (1)

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

⏰ Context from checks skipped due to timeout of 90000ms (10)
  • GitHub Check: stf
  • GitHub Check: Check go mod tidy
  • GitHub Check: server-v2
  • GitHub Check: build (arm64)
  • GitHub Check: runtime-v2
  • GitHub Check: Analyze
  • GitHub Check: build (amd64)
  • GitHub Check: dependency-review
  • GitHub Check: golangci-lint
  • GitHub Check: Summary
🔇 Additional comments (5)
x/auth/tx/builder_test.go (2)

9-13: Good addition of required imports.

These import statements align with the usage in the forthcoming test. Everything looks consistent with typical Go import style.


20-20: Empty line clarified.

The blank line here is purely stylistic and doesn't pose any issue. Proceeding without concerns.

x/auth/tx/builder.go (1)

66-66: Ensure decoded timeout timestamp aligns with actual blockchain expectations.

Using decoded.GetTimeoutTimeStamp() is correct for persisting the field, but confirm it reflects the intended semantic of “timeout” (e.g., block time or OS time). If the chain uses block time differently, convert or clarify in documentation.

CHANGELOG.md (2)

57-58: LGTM: Clear bug fix entry

The bug fix entry for adding missing timeoutTimestamp is well documented with a clear reference to the PR number.


Line range hint 1-15000: Verify PR references

Let's verify that all PR references are valid and point to existing pull requests.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Jan 24, 2025
@julienrbrt julienrbrt added this pull request to the merge queue Jan 24, 2025
Merged via the queue into cosmos:main with commit 494389d Jan 24, 2025
72 of 78 checks passed
mergify bot pushed a commit that referenced this pull request Jan 24, 2025
…Tx (#23492)

(cherry picked from commit 494389d)

# Conflicts:
#	CHANGELOG.md
julienrbrt added a commit that referenced this pull request Jan 24, 2025
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:x/auth
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: newBuilderFromDecodedTx looses TimeoutTimestamp when wraps a transaction
2 participants