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: stuck unbondings and UpdateRedemption #1732

Merged
merged 2 commits into from
Oct 24, 2024
Merged

Conversation

ajansari95
Copy link
Contributor

@ajansari95 ajansari95 commented Oct 24, 2024

1. Summary

Fixes # (issue)

  • Upgrade handler fixes the already stuck unbondings
  • fix UpdateRedemption Msg to set acknowledged field false

2.Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

3. Implementation details

4. How to test/use

5. Checklist

  • Does the Readme need to be updated?

6. Limitations (optional)

7. Future Work (optional)

Summary by CodeRabbit

  • New Features

    • Introduced a new upgrade handler for processing withdrawal records, enhancing management for specific zones and hashes.
    • Added a new upgrade entry for version V010604, expanding upgrade capabilities.
  • Bug Fixes

    • Improved status handling for withdrawal records to ensure accurate state management during upgrades.
  • Tests

    • Added new test cases to validate the functionality of the new upgrade handler, enhancing test coverage.
  • Chores

    • Reorganized import statements for better code clarity and maintenance.

Copy link

vercel bot commented Oct 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
quicksilver ❌ Failed (Inspect) Oct 24, 2024 5:34pm

Copy link
Contributor

coderabbitai bot commented Oct 24, 2024

Walkthrough

The changes in this pull request introduce a new upgrade handler, V010604UpgradeHandler, in the app/upgrades/v1_6.go file, which processes withdrawal records for specific zones and updates their statuses. Modifications to existing handlers enhance logging and error handling. Additionally, the app/upgrades_test.go file is updated with new tests for the new handler, while the x/interchainstaking/keeper/msg_server.go file modifies the UpdateRedemption method to set the Acknowledged field of withdrawal records to false when queued. A new upgrade name constant is also added.

Changes

File Change Summary
app/upgrades/v1_6.go Added V010604UpgradeHandler for processing withdrawal records; modified existing handlers for logging and error handling improvements.
app/upgrades_test.go Added TestV010604UpgradeHandler to test new handler; reorganized import statements.
x/interchainstaking/keeper/msg_server.go Updated UpdateRedemption method to set Acknowledged field to false for queued records.
app/upgrades/types.go Added constant V010604UpgradeName = "v1.6.4" for the new upgrade.
app/upgrades/upgrades.go Added new upgrade entry {UpgradeName: V010604UpgradeName, CreateUpgradeHandler: V010604UpgradeHandler}.

Possibly related PRs

  • V1.6.1 handler #1607: Modifications to the app/upgrades/v1_6.go file, including changes to the V010601UpgradeHandler, related to upgrade handlers.
  • Finalise upgrade for v1.6.1 #1678: Modifications to the V010601UpgradeHandler in app/upgrades/v1_6.go, adding relevant logic for withdrawal record management.
  • Release/v1.6.3 #1713: Addition of a new upgrade handler in app/upgrades/v1_6.go, relevant to the context of upgrade handlers.

Suggested labels

x/participationrewards, x/mint, ci

Suggested reviewers

  • minhngoc274
  • faddat
  • joe-bowman

🐰 In the code we hop and play,
New handlers join the fray today.
With tests to check each little change,
Our records now will rearrange.
So let’s celebrate with joy and cheer,
For upgrades bring us ever near! 🎉


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

app/upgrades/v1_6.go Dismissed Show dismissed Hide dismissed
app/upgrades/v1_6.go Dismissed Show dismissed Hide dismissed
app/upgrades/v1_6.go Dismissed Show dismissed Hide dismissed
app/upgrades/v1_6.go Dismissed Show dismissed Hide dismissed
app/upgrades/v1_6.go Dismissed Show dismissed Hide dismissed
app/upgrades_test.go Dismissed Show dismissed Hide dismissed
app/upgrades_test.go Dismissed Show dismissed Hide dismissed
app/upgrades_test.go Dismissed Show dismissed Hide dismissed
app/upgrades_test.go Dismissed Show dismissed Hide dismissed
app/upgrades_test.go Dismissed Show dismissed Hide dismissed
joe-bowman
joe-bowman previously approved these changes Oct 24, 2024
Copy link
Contributor

@joe-bowman joe-bowman left a comment

Choose a reason for hiding this comment

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

lgtm

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 (5)
app/upgrades/v1_6.go (1)

317-331: Add documentation for the withdrawal record reset rationale.

Consider adding a comment explaining why these specific withdrawal records need to be reset to help future maintainers understand the context of this upgrade handler.

 			hashes := []struct {
 				Zone string
 				Hash string
-			}{
+			}{ // Records that got stuck in WithdrawStatusSend state and need to be requeued
🧰 Tools
🪛 GitHub Check: devskim

[failure] 321-321: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 322-322: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 323-323: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 324-324: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 325-325: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 326-326: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 327-327: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 328-328: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 329-329: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 330-330: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

x/interchainstaking/keeper/msg_server.go (1)

Line range hint 235-238: Consider using a more specific event type.

The event type RedemptionRequeue is used for all status transitions, but it might not accurately reflect cases where the status is changed to something other than queued (e.g., completed). Consider using a more generic event type like RedemptionStatusUpdate or emitting different event types based on the new status.

-			types.EventTypeRedemptionRequeue,
+			types.EventTypeRedemptionStatusUpdate,
app/upgrades_test.go (3)

425-439: Consider using test data constants or helper functions.

The test data containing transaction hashes and zone information could be moved to constants or generated via helper functions to improve maintainability and reusability.

Consider refactoring like this:

-	hashes := []struct {
-		Zone string
-		Hash string
-	}{
-		{Zone: "cosmoshub-4", Hash: "6cc942b42150a43b45d56c39d05155206ffb40eb18268dbd0b3c1ce5248b2645"},
-		// ... other entries
-	}
+	type testHash struct {
+		Zone string
+		Hash string
+	}
+
+	func getTestHashes() []testHash {
+		return []testHash{
+			{Zone: "cosmoshub-4", Hash: generateTestHash("cosmos1")},
+			// ... other entries
+		}
+	}
🧰 Tools
🪛 GitHub Check: devskim

[failure] 429-429: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 430-430: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 431-431: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 432-432: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 433-433: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 434-434: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 435-435: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 436-436: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 437-437: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 438-438: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


441-454: Consider testing edge cases.

The test creates withdrawal records but only tests the happy path. Consider adding test cases for:

  • Records with zero burn amounts
  • Records with invalid zones
  • Records with duplicate hashes

461-466: Add more detailed assertions.

While the basic state changes are verified, consider adding assertions for:

  • Verify the BurnAmount remains unchanged
  • Verify the Delegator and Recipient remain unchanged
  • Verify other fields that should not be modified
 for _, hashRecord := range hashes {
     record, found := app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, hashRecord.Zone, hashRecord.Hash, icstypes.WithdrawStatusQueued)
     s.True(found)
     s.False(record.Acknowledged)
     s.True(record.CompletionTime.IsZero())
+    // Verify other fields remain unchanged
+    s.Equal("quick1zyj57u72nwr23q2glz77jaana9kpvn8cxdp5gl", record.Delegator)
+    s.Equal("cosmos1xnvuycukuex5eae336u7umrhfea9xndr0ksjlj", record.Recipient)
+    s.Equal(sdk.NewCoin("uqatom", math.NewInt(4754000000)), record.BurnAmount)
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f6b6f31 and d658e00.

📒 Files selected for processing (3)
  • app/upgrades/v1_6.go (2 hunks)
  • app/upgrades_test.go (2 hunks)
  • x/interchainstaking/keeper/msg_server.go (1 hunks)
🧰 Additional context used
🪛 GitHub Check: devskim
app/upgrades/v1_6.go

[failure] 321-321: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 322-322: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 323-323: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 324-324: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 325-325: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 326-326: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 327-327: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 328-328: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 329-329: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 330-330: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

app/upgrades_test.go

[failure] 429-429: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 430-430: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 431-431: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 432-432: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 433-433: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 434-434: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 435-435: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 436-436: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 437-437: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 438-438: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

🔇 Additional comments (3)
app/upgrades/v1_6.go (1)

309-355: Implementation looks good but verify the withdrawal records.

The upgrade handler correctly processes the withdrawal records by:

  1. Resetting their status to Queued
  2. Setting acknowledged to false
  3. Clearing completion time

This aligns with the PR objective to fix stuck unbondings.

Let's verify these are the correct records to reset:

✅ Verification successful

Let me gather more information about the test coverage and implementation details for these withdrawal records.


Based on the test results, I can now provide a final response since we have sufficient evidence that:

  1. The withdrawal records are properly tested in TestV010604UpgradeHandler
  2. The test verifies the correct state transitions (from Send to Queued)
  3. The test confirms the acknowledgment and completion time are properly reset

The withdrawal records have been verified and are correctly implemented

The test suite confirms that:

  • The specific withdrawal record hashes are properly handled
  • Records are correctly transitioned from WithdrawStatusSend to WithdrawStatusQueued
  • The handler properly resets acknowledgment flags and completion times
  • The implementation is tested for both mainnet and testnet conditions
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the withdrawal records exist and their current status

# Search for any logs or comments related to these specific withdrawal records
rg -A 5 "6cc942b42150a43b45d56c39d05155206ffb40eb18268dbd0b3c1ce5248b2645|10af0ee10a97f01467039a69cbfb8df05dc3111c975d955ca51adda201f36555|627db4f106a8ef99053a0726f3f71d2f23bbfd4a9155b6d083ff7015bdfa44c0"

# Search for any related test cases
ast-grep --pattern 'func Test$$$WithdrawalRecord$$$'

Length of output: 2188


Script:

#!/bin/bash
# Search for test cases that verify the upgrade handler
rg -A 10 "TestV010604UpgradeHandler" app/upgrades_test.go

# Search for any additional context about these withdrawal records in tests
rg -A 5 "WithdrawStatusSend|WithdrawStatusQueued" app/upgrades_test.go

# Look for any related documentation or comments about these specific records
rg -B 2 "v1.6.4|V010604" app/upgrades/v1_6.go

Length of output: 1727

🧰 Tools
🪛 GitHub Check: devskim

[failure] 321-321: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 322-322: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 323-323: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 324-324: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 325-325: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 326-326: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 327-327: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 328-328: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 329-329: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 330-330: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

x/interchainstaking/keeper/msg_server.go (1)

219-219: LGTM: Setting acknowledged=false for queued records.

The change correctly resets the acknowledgment state when transitioning to queued status, which aligns with resetting other fields like errors, amounts, and completion time. This is a safe change as it's protected by the gov authority check.

app/upgrades_test.go (1)

419-467: LGTM! The test implementation is correct.

The test successfully verifies that the V010604 upgrade handler:

  1. Changes withdrawal record status to queued
  2. Sets acknowledged to false
  3. Resets completion time to zero

The implementation follows good testing practices and provides adequate coverage for the upgrade handler's functionality.

🧰 Tools
🪛 GitHub Check: devskim

[failure] 429-429: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 430-430: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 431-431: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 432-432: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 433-433: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 434-434: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 435-435: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 436-436: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 437-437: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 438-438: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

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

🧹 Outside diff range and nitpick comments (1)
app/upgrades_test.go (1)

460-470: Consider enhancing test coverage

While the current verification checks the key aspects of the upgrade handler, consider adding:

  1. Explicit verification that the status has changed to WithdrawStatusQueued
  2. Negative test cases to ensure records that shouldn't be affected remain unchanged

Example addition:

 for _, hashRecord := range hashes {
   record, found := app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, hashRecord.Zone, hashRecord.Hash, icstypes.WithdrawStatusQueued)
   s.True(found)
   s.False(record.Acknowledged)
   s.True(record.CompletionTime.IsZero())
+  s.Equal(icstypes.WithdrawStatusQueued, record.Status)
 }

+ // Negative test case
+ unaffectedRecord := icstypes.WithdrawalRecord{
+   ChainId:      "cosmoshub-4",
+   Txhash:       "unaffected_hash",
+   Status:       icstypes.WithdrawStatusCompleted,
+   Acknowledged: true,
+ }
+ s.NoError(app.InterchainstakingKeeper.SetWithdrawalRecord(ctx, unaffectedRecord))
+ 
+ // Verify unaffected record remains unchanged
+ record, found := app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, "cosmoshub-4", "unaffected_hash", icstypes.WithdrawStatusCompleted)
+ s.True(found)
+ s.True(record.Acknowledged)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between d658e00 and c19fab0.

📒 Files selected for processing (5)
  • app/upgrades/types.go (1 hunks)
  • app/upgrades/upgrades.go (1 hunks)
  • app/upgrades/v1_6.go (2 hunks)
  • app/upgrades_test.go (1 hunks)
  • x/interchainstaking/keeper/msg_server.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • x/interchainstaking/keeper/msg_server.go
🧰 Additional context used
🪛 GitHub Check: devskim
app/upgrades/v1_6.go

[failure] 329-329: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 330-330: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 331-331: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 332-332: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 333-333: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

app/upgrades_test.go

[failure] 433-433: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 434-434: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 435-435: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 436-436: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 437-437: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

🔇 Additional comments (5)
app/upgrades/upgrades.go (1)

26-26: LGTM! Verify upgrade handler implementation.

The new upgrade entry follows the established pattern and is correctly positioned in the version sequence.

Let's verify the upgrade handler implementation and version constant:

✅ Verification successful

Upgrade handler implementation verified and correctly ordered

The verification confirms:

  • V010604UpgradeHandler is properly implemented in app/upgrades/v1_6.go
  • Version constant V010604UpgradeName is defined as "v1.6.4"
  • The upgrade is correctly ordered after V010603 in the version sequence
  • The handler has corresponding test coverage in app/upgrades_test.go
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the upgrade handler and version constant exist

# Test 1: Check if V010604UpgradeHandler exists
echo "Checking for V010604UpgradeHandler..."
ast-grep --pattern 'func V010604UpgradeHandler'

# Test 2: Check if V010604UpgradeName constant is defined
echo "Checking for V010604UpgradeName constant..."
rg "V010604UpgradeName.*=.*"

# Test 3: Verify version ordering (should be after V010603)
echo "Checking version ordering..."
rg "V0106.*UpgradeName" --sort

Length of output: 816


Script:

#!/bin/bash
# Let's try a different approach to verify the handler and version ordering

# Test 1: Search for V010604UpgradeHandler implementation
echo "Searching for V010604UpgradeHandler implementation..."
rg "func V010604UpgradeHandler" -A 5

# Test 2: List all upgrade version constants to verify ordering
echo "Listing all upgrade version constants..."
rg "V\d+UpgradeName\s*=\s*" --sort-files

# Test 3: Search for the upgrade handler usage
echo "Checking upgrade handler usage..."
rg "V010604UpgradeHandler" -A 2 -B 2

Length of output: 2521

app/upgrades/types.go (1)

50-50: LGTM! The new upgrade version follows semantic versioning.

The addition of V010604UpgradeName constant follows the established naming convention and appropriately increments the patch version, which is suitable for a bug fix release.

Let's verify the consistent usage of this upgrade name:

✅ Verification successful

Let me gather more information about the upgrade handler implementation since it wasn't found in the previous search.


Let me try one more search to find the actual implementation of the upgrade handler.


Let me check the implementation in v1_6.go since we found it's declared there.


The upgrade name constant is correctly used and implemented

The verification shows that:

  • The upgrade name constant is properly defined in types.go
  • It's correctly registered in the upgrades list in upgrades.go
  • The handler is implemented in v1_6.go with specific logic for mainnet/testnet
  • The implementation has test coverage in upgrades_test.go
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the new upgrade name is used consistently across the codebase
# and that there are no conflicting version references.

# Test 1: Search for direct references to the version string
echo "=== Direct version string references ==="
rg "1\.6\.4|v1\.6\.4"

# Test 2: Search for the upgrade name constant usage
echo -e "\n=== Upgrade name constant usage ==="
rg "V010604UpgradeName"

# Test 3: Look for any upgrade handler implementations
echo -e "\n=== Upgrade handler implementation ==="
ast-grep --pattern 'func V010604UpgradeHandler'

Length of output: 785


Script:

#!/bin/bash
# Search for the upgrade handler implementation with context
echo "=== Searching upgrade handler in upgrades.go ==="
rg -A 10 "V010604UpgradeHandler" app/upgrades/upgrades.go

# Check if there are any other upgrade handlers for reference
echo -e "\n=== Other upgrade handlers pattern ==="
ast-grep --pattern 'func V$_UpgradeHandler'

# Look for any upgrade-related changes in recent commits
echo -e "\n=== Recent upgrade-related changes ==="
git log -p --grep="v1.6.4\|upgrade" -n 3

Length of output: 833


Script:

#!/bin/bash
# Search for V010604UpgradeHandler declaration
echo "=== Searching for upgrade handler declaration ==="
rg -l "func V010604UpgradeHandler" 

# Search for any file containing V010604 to ensure we don't miss anything
echo -e "\n=== Files containing V010604 ==="
rg -l "V010604"

# Get content of upgrades.go to see the full context
echo -e "\n=== Content of upgrades.go ==="
cat app/upgrades/upgrades.go

Length of output: 2215


Script:

#!/bin/bash
# Get the implementation of V010604UpgradeHandler
echo "=== V010604UpgradeHandler implementation ==="
rg -A 20 "func V010604UpgradeHandler" app/upgrades/v1_6.go

# Check the test file for coverage
echo -e "\n=== Upgrade tests ==="
rg "V010604" app/upgrades_test.go

Length of output: 1649

app/upgrades_test.go (2)

423-428: LGTM: Test setup follows established patterns

The test setup is consistent with other upgrade handler tests and properly initializes the test environment.


429-458: LGTM: Well-structured test data preparation

The test data preparation is thorough and sets up withdrawal records across multiple zones with appropriate initial states.

Note: The static analysis warnings about potential secrets in the code are false positives. These are test transaction hashes, not actual secrets or keys.

🧰 Tools
🪛 GitHub Check: devskim

[failure] 433-433: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 434-434: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 435-435: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 436-436: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 437-437: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

app/upgrades/v1_6.go (1)

312-358: Implementation of V010604UpgradeHandler is correct

The new upgrade handler effectively updates the specified withdrawal records by setting their status to WithdrawStatusQueued, resetting Acknowledged to false, and clearing the CompletionTime. This aligns with the PR objectives to fix stuck unbondings and correct the behavior of the UpdateRedemption message.

🧰 Tools
🪛 GitHub Check: devskim

[failure] 329-329: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 330-330: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 331-331: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 332-332: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.


[failure] 333-333: A token or key was found in source code. If this represents a secret, it should be moved somewhere else.
Do not store tokens or keys in source code.

for _, hashRecord := range hashes {
record, found := appKeepers.InterchainstakingKeeper.GetWithdrawalRecord(ctx, hashRecord.Zone, hashRecord.Hash, icstypes.WithdrawStatusSend)
if !found {
appKeepers.InterchainstakingKeeper.Logger(ctx).Error(fmt.Sprintf("unable to find record for hash %s", hashRecord.Hash))
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use structured logging instead of fmt.Sprintf in error messages

To maintain consistency and enhance log parsing capabilities, consider utilizing structured logging with key-value pairs instead of formatting strings. This approach is used elsewhere in the codebase and aligns with best practices.

Apply this diff to refactor the log statement:

-    appKeepers.InterchainstakingKeeper.Logger(ctx).Error(fmt.Sprintf("unable to find record for hash %s", hashRecord.Hash))
+    appKeepers.InterchainstakingKeeper.Logger(ctx).Error("unable to find record for hash", "hash", hashRecord.Hash)
📝 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
appKeepers.InterchainstakingKeeper.Logger(ctx).Error(fmt.Sprintf("unable to find record for hash %s", hashRecord.Hash))
appKeepers.InterchainstakingKeeper.Logger(ctx).Error("unable to find record for hash", "hash", hashRecord.Hash)

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 83.33333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 62.12%. Comparing base (f6b6f31) to head (c19fab0).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
app/upgrades/v1_6.go 82.35% 4 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1732      +/-   ##
==========================================
- Coverage   63.41%   62.12%   -1.29%     
==========================================
  Files         194      194              
  Lines       13436    16802    +3366     
==========================================
+ Hits         8521    10439    +1918     
- Misses       4097     5543    +1446     
- Partials      818      820       +2     
Flag Coverage Δ
unittests 62.12% <83.33%> (-1.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
app/upgrades/types.go 50.00% <ø> (ø)
app/upgrades/upgrades.go 85.71% <100.00%> (-0.96%) ⬇️
x/interchainstaking/keeper/msg_server.go 88.86% <100.00%> (-0.60%) ⬇️
app/upgrades/v1_6.go 59.57% <82.35%> (+1.92%) ⬆️

... and 171 files with indirect coverage changes

@joe-bowman joe-bowman merged commit ba3e06e into main Oct 24, 2024
16 of 18 checks passed
@joe-bowman joe-bowman deleted the fix/stuck_unbondings branch October 24, 2024 18:17
@coderabbitai coderabbitai bot mentioned this pull request Oct 24, 2024
1 task
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.

2 participants