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

v1.7.6 upgradehandler #1809

Merged
merged 3 commits into from
Jan 30, 2025
Merged

v1.7.6 upgradehandler #1809

merged 3 commits into from
Jan 30, 2025

Conversation

joe-bowman
Copy link
Contributor

@joe-bowman joe-bowman commented Jan 30, 2025

1. Summary

Upgrade handler for v1.7.6;

  • requeue 2x stuck unbondings (regen, sommelier) from epoch 130.
  • gc old unbonding records

Enable periodic garbage collection on UBRs.

Add tests for v1.7.6.

Summary by CodeRabbit

  • New Features

    • Added a new upgrade handler for processing and cleaning up unbonding records
    • Implemented mechanism to unblock stuck withdrawal records in specific network environments
  • Bug Fixes

    • Improved handling of matured unbondings by activating previously commented-out function call
    • Updated block interval logic for consistent zone task execution
  • Tests

    • Added comprehensive test suite for the new upgrade handler
    • Introduced test scenarios for withdrawal and unbonding record management

Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

The pull request introduces an upgrade handler (V010706UpgradeHandler) in the interchain staking module that addresses two primary tasks: unblocking stuck unbonding records and performing garbage collection on old unbonding records. For mainnet and test environments, the handler identifies specific unbonding record hashes, resets their properties, and updates their status. Additionally, it implements a cleanup mechanism that removes unbonding records with empty or outdated completion times, ensuring system data integrity and efficiency.

Changes

File Change Summary
app/upgrades/v1_7.go Added V010706UpgradeHandler with logic to unblock and clean up unbonding records
app/upgrades_test.go Added TestV010706UpgradeHandler to test the new upgrade handler with withdrawal and unbonding record scenarios
x/interchainstaking/keeper/abci.go Uncommented and updated HandleMaturedUnbondings call, replacing hardcoded block interval with blockInterval constant

Sequence Diagram

sequenceDiagram
    participant UH as Upgrade Handler
    participant WR as Withdrawal Records
    participant UR as Unbonding Records
    
    UH->>WR: Identify stuck records
    UH->>WR: Reset record properties
    UH->>WR: Update record status
    
    UH->>UR: Iterate through records
    UH->>UR: Remove old/empty records
    UH->>UR: Log deleted records
Loading

Possibly related PRs

Suggested labels

x/participationrewards

Suggested reviewers

  • faddat
  • ajansari95

Poem

🐰 Unbonding records, once stuck in time,
Now dance free with logic sublime
Garbage collected, status reset
A rabbit's upgrade, a clean-code bet!
Hop, hop, hurray for system might! 🚀

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

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_7.go Dismissed Show dismissed Hide dismissed
app/upgrades/v1_7.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
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
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

🧹 Nitpick comments (1)
app/upgrades_test.go (1)

616-624: Consider adding more assertions.

While the current assertions verify the deletion of records, consider adding checks for:

  1. The state of requeued withdrawal records
  2. The logging of deleted unbonding records

Add these assertions:

 _, found = app.InterchainstakingKeeper.GetUnbondingRecord(ctx, "sommelier-3", "sommvaloper1y0few0kgxa7vtq8nskjsdwdtyqglj3k5pv2c4d", 243)
 s.True(found)
+
+// Check requeued withdrawal records
+record, found := app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, "regen-1", "ee0b5f5c423508c8dd6a501168a77a0b72d5a8aaf1702a64804e522334ff272b", icstypes.WithdrawStatusQueued)
+s.True(found)
+s.Equal(icstypes.WithdrawStatusQueued, record.Status)
+s.Equal(int64(0), record.SendErrors)
+s.True(record.CompletionTime.IsZero())
+
+record, found = app.InterchainstakingKeeper.GetWithdrawalRecord(ctx, "sommelier-3", "a55f1f4deaa501ff5671ef96fbbb5b60e225d4b8db4825ae3706893bb94e052c", icstypes.WithdrawStatusQueued)
+s.True(found)
+s.Equal(icstypes.WithdrawStatusQueued, record.Status)
+s.Equal(int64(0), record.SendErrors)
+s.True(record.CompletionTime.IsZero())
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b26f4b8 and f4fb666.

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

[failure] 176-176: 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] 177-177: 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] 531-531: 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] 552-552: 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] 574-574: 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] 575-575: 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] 576-576: 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] 577-577: 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] 591-591: 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] 602-602: 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.

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: test quicksilver (darwin, arm64)
  • GitHub Check: test quicksilver (amd64, windows)
  • GitHub Check: Analyze
  • GitHub Check: test quicksilver (amd64, linux)
🔇 Additional comments (4)
x/interchainstaking/keeper/abci.go (1)

34-36: LGTM! Activated handling of matured unbondings.

The uncommented line enables periodic processing of matured unbondings every 30 blocks, which aligns with the PR objectives.

app/upgrades/v1_7.go (1)

169-191: LGTM! Unblocking stuck unbondings for Regen and Sommelier networks.

The implementation correctly resets and requeues the specified unbonding records by:

  1. Resetting error counts, amounts, and completion time
  2. Setting status back to queued
🧰 Tools
🪛 GitHub Check: devskim

[failure] 176-176: 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] 177-177: 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 (2)

527-565: LGTM! Comprehensive test coverage for withdrawal records.

The test correctly sets up withdrawal records for both chains with appropriate test data.

🧰 Tools
🪛 GitHub Check: devskim

[failure] 531-531: 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] 552-552: 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.


566-610: LGTM! Good test coverage for different unbonding scenarios.

The test covers all edge cases for unbonding records:

  1. Empty completion time
  2. Future completion time
  3. Past completion time (12 hours ago)
🧰 Tools
🪛 GitHub Check: devskim

[failure] 574-574: 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] 575-575: 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] 576-576: 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] 577-577: 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] 591-591: 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] 602-602: 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_7.go Show resolved Hide resolved
Copy link

codecov bot commented Jan 30, 2025

Codecov Report

Attention: Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.

Project coverage is 63.43%. Comparing base (19aa433) to head (0573d1d).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
app/upgrades/v1_7.go 92.59% 1 Missing and 1 partial ⚠️
x/interchainstaking/keeper/abci.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1809      +/-   ##
==========================================
+ Coverage   63.37%   63.43%   +0.06%     
==========================================
  Files         172      172              
  Lines       15422    15449      +27     
==========================================
+ Hits         9773     9800      +27     
  Misses       4838     4838              
  Partials      811      811              
Flag Coverage Δ
unittests 63.43% <86.20%> (+0.06%) ⬆️

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

Files with missing lines Coverage Δ
app/upgrades/v1_7.go 31.74% <92.59%> (+18.74%) ⬆️
x/interchainstaking/keeper/abci.go 25.97% <0.00%> (-0.35%) ⬇️

Copy link
Contributor

@arhamchordia arhamchordia left a comment

Choose a reason for hiding this comment

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

Rest of the changes look good to me.

@joe-bowman joe-bowman merged commit 906c027 into main Jan 30, 2025
21 checks passed
@joe-bowman joe-bowman deleted the upgradehandler-v176 branch January 30, 2025 16:57
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