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

refactor(x/staking)!: removing unbonding queue index #22795

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

tac0turtle
Copy link
Member

@tac0turtle tac0turtle commented Dec 7, 2024

Description

Closes: #20715

This pr removes specific logic needed for interchain security that is not used any more.

i adopted some api breaking changes and removed the hook, but let me know if you think some of it is too much and i can revert


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

Release Notes

  • New Features

    • Simplified unbonding and redelegation processes by removing unnecessary ID parameters, streamlining entry management.
    • Enhanced error handling for various staking queries, improving clarity and robustness.
    • Introduced the ability to change the MinCommissionRate for all validators through MsgUpdateParams.
  • Bug Fixes

    • Improved error handling for empty requests and invalid arguments in staking queries.
    • Prevented overslashing of unbonding delegations after a redelegation.
  • Tests

    • Expanded test coverage for delegation and unbonding functionalities, ensuring comprehensive validation of edge cases.
    • Added new test cases for various scenarios in unbonding delegation cancellation.
  • Chores

    • Removed deprecated methods and streamlined code to enhance maintainability and readability.
    • Updated simulation tests for improved state comparison and genesis state initialization.

Copy link
Contributor

coderabbitai bot commented Dec 7, 2024

📝 Walkthrough
📝 Walkthrough

The pull request introduces significant changes to the staking module, particularly in the management of unbonding and redelegation processes. Key modifications include the removal of ID parameters from various methods, which simplifies the handling of unbonding and redelegation entries. Additionally, checks related to unbonding statuses have been removed, altering the conditions under which entries are processed. Error handling improvements and test suite enhancements are also included, alongside the removal of deprecated methods and files, streamlining the overall functionality and clarity of the staking module.

Changes

File Path Change Summary
x/staking/keeper/delegation.go Removed id parameter from SetUnbondingDelegationEntry and SetRedelegationEntry. Simplified maturity checks in CompleteUnbonding and CompleteRedelegation. Improved error handling in GetUnbondingDelegation.
x/staking/keeper/delegation_test.go Updated UnbondingDelegation constructor, refined entry management logic, enhanced redelegation tests, and improved error handling across test cases.
x/staking/keeper/grpc_query.go Added error handling for empty requests and invalid arguments in various query methods. Improved pagination handling.
x/staking/keeper/msg_server_test.go Expanded test cases for message types, modified NewUnbondingDelegation function signature, and enhanced validation checks.
x/staking/keeper/slash.go Simplified conditions in SlashUnbondingDelegation and SlashRedelegation methods by removing hold status checks.
x/staking/keeper/unbonding.go Deleted file containing functions for managing unbonding operations, including ID handling and state management.
x/staking/keeper/unbonding_test.go Deleted file with unit tests for unbonding functionality, covering various edge cases and accessors.
x/staking/keeper/val_state_change.go Removed logic for incrementing and tracking unbonding IDs in BeginUnbondingValidator.
x/staking/keeper/validator.go Eliminated checks for UnbondingOnHoldRefCount and unbonding ID management in the unbonding process.
x/staking/types/delegation.go Removed unbondingID parameter from NewUnbondingDelegationEntry, NewUnbondingDelegation, and related methods.
x/staking/types/delegation_test.go Updated function signatures to remove unnecessary integer parameters in delegation and redelegation constructors.
x/staking/types/expected_keepers.go Removed AfterUnbondingInitiated method from StakingHooks interface.
x/staking/types/hooks.go Removed AfterUnbondingInitiated method from MultiStakingHooks.

Assessment against linked issues

Objective Addressed Explanation
Remove unbonding pausing logic (#[20715])
Remove AfterUnbondingInitiated hook (#[20715])

Possibly related PRs

  • test: e2e/staking to system tests #21882: The changes in this PR enhance the testing framework for the staking module, ensuring that validator updates are validated, which is relevant to the modifications in the main PR that simplify delegation and unbonding logic.
  • fix(x/staking): make metadata nullable #22556: This PR addresses the nullable metadata field in the staking module, which relates to the overall simplification and changes in handling unbonding and redelegation entries in the main PR.
  • fix(x/staking): use staking bonddenom in check #22646: The adjustments made in this PR to ensure the correct staking bond denomination is utilized in checks may connect with the changes in the main PR that streamline the logic for handling delegations and unbonding.
  • test(integration): port x/slashing tests to server v2 #22754: The porting of slashing tests to server v2 includes updates that may interact with the changes made in the main PR regarding the simplification of unbonding and redelegation processes.

Suggested labels

backport/v0.52.x, Type: CI

Suggested reviewers

  • JulianToledano
  • kocubinski
  • facundomedica
  • testinginprod
  • ziscky

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. (Experiment)
  • @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.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 2

🛑 Comments failed to post (2)
x/staking/keeper/validator.go (2)

550-550: ⚠️ Potential issue

Correct the argument type in k.RemoveValidator

At line 550, k.RemoveValidator expects a sdk.ValAddress, but val.GetOperator() returns a string. This causes a type mismatch error.

Apply this diff to fix the argument type:

-	k.RemoveValidator(ctx, val.GetOperator())
+	valAddr, err := k.validatorAddressCodec.StringToBytes(val.GetOperator())
+	if err != nil {
+		return err
+	}
+	err = k.RemoveValidator(ctx, sdk.ValAddress(valAddr))
+	if err != nil {
+		return 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.

			valAddr, err := k.validatorAddressCodec.StringToBytes(val.GetOperator())
			if err != nil {
				return err
			}
			err = k.RemoveValidator(ctx, sdk.ValAddress(valAddr))
			if err != nil {
				return err
			}
🧰 Tools
🪛 GitHub Check: tests (03)

[failure] 550-550:
cannot use val.GetOperator() (value of type string) as "github.com/cosmos/cosmos-sdk/types".ValAddress value in argument to k.RemoveValidator


[failure] 550-550:
cannot use val.GetOperator() (value of type string) as "github.com/cosmos/cosmos-sdk/types".ValAddress value in argument to k.RemoveValidator


548-548: ⚠️ Potential issue

Fix assignment to handle multiple return values

At line 548, k.UnbondingToUnbonded returns two values, but only one is being assigned. This results in an assignment mismatch error.

Apply this diff to correct the assignment:

-val = k.UnbondingToUnbonded(ctx, val)
+val, err = k.UnbondingToUnbonded(ctx, val)
+if err != nil {
+    return err
+}

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: tests (03)

[failure] 548-548:
assignment mismatch: 1 variable but k.UnbondingToUnbonded returns 2 values


[failure] 548-548:
assignment mismatch: 1 variable but k.UnbondingToUnbonded returns 2 values

@tac0turtle tac0turtle marked this pull request as ready for review December 11, 2024 19:02
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 (5)
x/staking/keeper/msg_server_test.go (1)

942-942: Ensure test coverage reflects changes in unbonding logic

With the removal of the unbonding pausing logic, please verify that this test case adequately covers the updated behavior of NewUnbondingDelegation. Consider adding additional test cases or assertions to ensure all aspects of the unbonding process are thoroughly tested without the unbonding ID parameter.

x/staking/migrations/v6/store.go (1)

Line range hint 7-8: Update function comment to reflect all deleted keys

The comment for MigrateStore states that it deletes the ValidatorUpdatesKey from the store. However, the function now also deletes HistoricalInfoKey, UnbondingIDKey, UnbondingIndexKey, and UnbondingTypeKey. Please update the comment to accurately describe all the keys being deleted.

Apply this diff to update the comment:

- // It deletes the ValidatorUpdatesKey from the store.
+ // It deletes the ValidatorUpdatesKey, HistoricalInfoKey, UnbondingIDKey, UnbondingIndexKey, and UnbondingTypeKey from the store.
x/staking/CHANGELOG.md (2)

107-107: Typo: Correct 'there' to 'their'

In the sentence "...no longer take an ID in there function signatures", 'there' should be 'their' to indicate possession.

Apply this diff to fix the typo:

- * [#22795](https://github.com/cosmos/cosmos-sdk/pull/22795) `NewUnbondingDelegationEntry`, `NewUnbondingDelegation`, `AddEntry`, `NewRedelegationEntry`, `NewRedelegation` and `NewRedelegationEntryResponse` no longer take an ID in there function signatures.
+ * [#22795](https://github.com/cosmos/cosmos-sdk/pull/22795) `NewUnbondingDelegationEntry`, `NewUnbondingDelegation`, `AddEntry`, `NewRedelegationEntry`, `NewRedelegation` and `NewRedelegationEntryResponse` no longer take an ID in their function signatures.

112-112: Correct article usage: Replace 'a' with 'an'

In the sentence "In a undelegation or redelegation...", 'undelegation' starts with a vowel sound, so the article 'a' should be replaced with 'an'.

Apply this diff to fix the grammatical error:

- * [#18841](https://github.com/cosmos/cosmos-sdk/pull/18841) In a undelegation or redelegation if the shares being left delegated correspond to less than 1 token (in base denom) the entire delegation gets removed.
+ * [#18841](https://github.com/cosmos/cosmos-sdk/pull/18841) In an undelegation or redelegation if the shares being left delegated correspond to less than 1 token (in base denom) the entire delegation gets removed.
🧰 Tools
🪛 LanguageTool

[misspelling] ~112-~112: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ub.com//pull/18841) In a undelegation or redelegation if the sha...

(EN_A_VS_AN)

x/staking/types/delegation.go (1)

Remove UnbondingOnHoldRefCount field and related code

The UnbondingOnHoldRefCount field and its related code should be removed as it's part of the ICS unbonding pausing logic being deprecated. Evidence shows:

  • Field is only initialized to 0 in constructors
  • Only one business logic usage in OnHold() method
  • Error constant ErrUnbondingOnHoldRefCountNegative is no longer needed
  • All other occurrences are in generated protobuf files

Locations needing cleanup:

  • x/staking/types/delegation.go: Remove field from UnbondingDelegationEntry and RedelegationEntry structs and their constructors
  • x/staking/types/validator.go: Remove field from Validator struct
  • x/staking/types/delegation.go: Remove OnHold() method
  • x/staking/types/errors.go: Remove ErrUnbondingOnHoldRefCountNegative error constant
  • Update protobuf definitions to remove the field
🔗 Analysis chain

Line range hint 69-108: Consider removing UnbondingOnHoldRefCount field

Since the ICS unbonding pausing logic is being removed, the UnbondingOnHoldRefCount field in UnbondingDelegationEntry appears to be unused now.

Let's verify if this field is still used elsewhere:


Let me verify if this field is still actively used in the codebase beyond just the generated files:


Let me check if there are any methods that use this field for business logic:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining usage of UnbondingOnHoldRefCount
rg "UnbondingOnHoldRefCount" --type go

Length of output: 8607


Script:

#!/bin/bash
# Search for UnbondingOnHoldRefCount excluding generated files
rg "UnbondingOnHoldRefCount" --type go -g '!*.pb.go' -g '!*.pulsar.go'

Length of output: 471


Script:

#!/bin/bash
# Search for methods or functions that use UnbondingOnHoldRefCount
ast-grep --pattern 'func $$$UnbondingOnHoldRefCount$$$'

Length of output: 57


Script:

#!/bin/bash
# Search for any function or method that uses UnbondingOnHoldRefCount in its body
rg "UnbondingOnHoldRefCount" --type go -g '!*.pb.go' -g '!*.pulsar.go' -C 5

Length of output: 4186

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between f6f14ca and ab9ac71.

⛔ Files ignored due to path filters (1)
  • x/staking/types/staking.pb.go is excluded by !**/*.pb.go
📒 Files selected for processing (26)
  • api/cosmos/staking/v1beta1/staking.pulsar.go (4 hunks)
  • simapp/sim_test.go (0 hunks)
  • tests/integration/staking/keeper/deterministic_test.go (4 hunks)
  • tests/integration/staking/keeper/msg_server_test.go (0 hunks)
  • tests/integration/staking/keeper/slash_test.go (6 hunks)
  • tests/integration/staking/keeper/unbonding_test.go (0 hunks)
  • x/staking/CHANGELOG.md (1 hunks)
  • x/staking/keeper/delegation.go (4 hunks)
  • x/staking/keeper/delegation_test.go (7 hunks)
  • x/staking/keeper/grpc_query.go (0 hunks)
  • x/staking/keeper/keeper.go (0 hunks)
  • x/staking/keeper/msg_server_test.go (1 hunks)
  • x/staking/keeper/slash.go (2 hunks)
  • x/staking/keeper/unbonding.go (0 hunks)
  • x/staking/keeper/unbonding_test.go (0 hunks)
  • x/staking/keeper/val_state_change.go (0 hunks)
  • x/staking/keeper/validator.go (1 hunks)
  • x/staking/migrations/v6/keys.go (1 hunks)
  • x/staking/migrations/v6/store.go (1 hunks)
  • x/staking/proto/cosmos/staking/v1beta1/staking.proto (1 hunks)
  • x/staking/testutil/expected_keepers_mocks.go (0 hunks)
  • x/staking/types/delegation.go (8 hunks)
  • x/staking/types/delegation_test.go (4 hunks)
  • x/staking/types/expected_keepers.go (0 hunks)
  • x/staking/types/hooks.go (0 hunks)
  • x/staking/types/keys.go (0 hunks)
🔥 Files not summarized due to errors (1)
  • api/cosmos/staking/v1beta1/staking.pulsar.go: Error: Server error: no LLM provider could handle the message
💤 Files with no reviewable changes (12)
  • x/staking/types/expected_keepers.go
  • x/staking/keeper/val_state_change.go
  • x/staking/types/hooks.go
  • tests/integration/staking/keeper/unbonding_test.go
  • x/staking/types/keys.go
  • simapp/sim_test.go
  • x/staking/testutil/expected_keepers_mocks.go
  • x/staking/keeper/unbonding_test.go
  • tests/integration/staking/keeper/msg_server_test.go
  • x/staking/keeper/grpc_query.go
  • x/staking/keeper/keeper.go
  • x/staking/keeper/unbonding.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • x/staking/keeper/slash.go
  • x/staking/keeper/validator.go
  • x/staking/types/delegation_test.go
🧰 Additional context used
📓 Path-based instructions (10)
api/cosmos/staking/v1beta1/staking.pulsar.go (1)

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

x/staking/migrations/v6/store.go (1)

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

tests/integration/staking/keeper/deterministic_test.go (3)

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


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


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

x/staking/migrations/v6/keys.go (1)

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

x/staking/keeper/msg_server_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/staking/keeper/delegation.go (1)

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

tests/integration/staking/keeper/slash_test.go (3)

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


Pattern tests/**/*: "Assess the integration and e2e test code assessing sufficient code coverage for the changes associated in the pull request"


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

x/staking/CHANGELOG.md (1)

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

x/staking/keeper/delegation_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/staking/types/delegation.go (1)

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

🪛 LanguageTool
x/staking/CHANGELOG.md

[misspelling] ~112-~112: Use “an” instead of ‘a’ if the following word starts with a vowel sound, e.g. ‘an article’, ‘an hour’.
Context: ...ub.com//pull/18841) In a undelegation or redelegation if the sha...

(EN_A_VS_AN)

🔇 Additional comments (23)
api/cosmos/staking/v1beta1/staking.pulsar.go (3)

15462-15463: LGTM: Proper deprecation notice added

The deprecation notice for the UnbondingId field is correctly formatted and aligns with the PR objectives of removing the unbonding queue index.


15517-15517: LGTM: Consistent deprecation of getter method

The GetUnbondingId method is properly marked as deprecated, maintaining consistency with the field deprecation while preserving backward compatibility.


Line range hint 16322-16543: Skip review of generated binary data

These are auto-generated protobuf binary data changes that reflect the deprecation modifications.

x/staking/proto/cosmos/staking/v1beta1/staking.proto (1)

262-262: Deprecation of unbonding_id aligns with PR objectives.

The deprecation of unbonding_id field is consistent with the removal of unbonding pausing logic.

✅ Verification successful

Deprecation of unbonding_id is correctly marked and aligns with codebase

The verification confirms that the unbonding_id field is being properly deprecated in the proto file. The search results show:

  • The field is only used in generated code and test data files
  • No new usages of the deprecated field are being introduced
  • The deprecation is consistent with the existing codebase structure
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify no new usages of the deprecated field
rg -l "unbonding_id" --type proto

Length of output: 63


Script:

#!/bin/bash
# Search for unbonding_id usage across all files
rg -l "unbonding_id"

Length of output: 323


Script:

#!/bin/bash
# Find proto files and search for unbonding_id
fd -e proto -x rg -l "unbonding_id" {}

Length of output: 95


Script:

#!/bin/bash
# Find all proto files to understand the proto file structure
fd -e proto

Length of output: 8633


Script:

#!/bin/bash
# Check the content of files that use unbonding_id to understand the context
rg "unbonding_id" -B 2 -A 2

Length of output: 58291


Script:

#!/bin/bash
# Check if there are any new usages or references to unbonding_id in recent changes
git diff HEAD~1 | rg "unbonding_id"

Length of output: 35

tests/integration/staking/keeper/deterministic_test.go (4)

555-555: Updated deterministic iteration count is correct.

The reduction in iteration count from 3719 to 3707 is consistent with the removal of unbonding queue index logic.


635-635: Updated deterministic iteration count is correct.

The reduction in iteration count from 1621 to 1615 aligns with the simplified unbonding structure.


758-758: Updated deterministic iteration count is correct.

The reduction in iteration count from 1302 to 1290 reflects the removal of unbonding-related fields.


878-878: Updated deterministic iteration count is correct.

The reduction in iteration count from 3926 to 3920 is consistent with the simplified redelegation structure.

tests/integration/staking/keeper/slash_test.go (4)

82-82: LGTM: Proper address codec initialization

The addition of address codecs ensures correct address encoding/decoding for validator and delegator addresses in the unbonding delegation test.


141-141: LGTM: Consistent address codec usage

The redelegation test correctly initializes address codecs for both validator and delegator addresses.


288-288: LGTM: Address codec initialization in unbonding test

The test properly initializes address codecs for the unbonding delegation with validator slashing scenario.


418-418: LGTM: Proper address handling in redelegation test

The redelegation test correctly handles address encoding through proper codec initialization.

x/staking/keeper/delegation.go (4)

515-518: Streamlined redelegation entry creation

The redelegation entry creation has been simplified while maintaining proper address codec handling.


967-967: LGTM: Simplified maturity check

The entry maturity check has been simplified by removing the OnHold status check, aligning with the removal of unbonding queue index.


1104-1104: LGTM: Consistent maturity handling

The redelegation entry maturity check follows the same simplified pattern as unbonding entries.


315-317: Simplified unbonding delegation entry handling

The code has been simplified by removing unbonding ID management, making the entry handling more straightforward.

✅ Verification successful

Let me generate additional verification scripts to check if there are any remaining references to unbonding IDs in the actual business logic code, excluding test files, proto definitions and generated code.


Let me search specifically for any remaining code that might be using the unbonding ID functionality in the actual implementation files.


Unbonding ID management has been safely removed

The verification confirms that the unbonding ID management has been safely removed from the codebase. The only remaining references are empty hook implementations in the slashing and distribution modules that are designed to be no-ops, indicating that the unbonding ID functionality has been properly deprecated and removed from the core staking logic.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that no code still relies on unbonding IDs
rg -A 3 "UnbondingId|unbondingId|unbonding_id" 

Length of output: 67935


Script:

#!/bin/bash
# Search for unbonding ID references in business logic code, excluding tests, proto and generated files
rg -g '!{*.pb.go,*.pulsar.go,*_test.go,*.proto}' -A 3 "UnbondingId|unbondingId|unbonding_id" 

Length of output: 38001


Script:

#!/bin/bash
# Search for unbonding ID related code in implementation files
rg -g '!{*.pb.go,*.pulsar.go,*_test.go,*.proto,*.yaml,*.json,*.md}' -A 3 "UnbondingId|unbondingId|unbonding_id|AfterUnbondingInitiated|PutUnbondingOnHold|UnbondingCanComplete" 

Length of output: 594

x/staking/keeper/delegation_test.go (3)

345-346: LGTM: Consistent address codec initialization in tests

The tests properly initialize address codecs for both validator and delegator addresses across different test scenarios.

Also applies to: 1109-1110, 1150-1151


718-718: LGTM: Updated redelegation test cases

The redelegation test cases have been updated to reflect the simplified entry handling without unbonding IDs.

Also applies to: 748-748


1116-1116: LGTM: Proper entry merging verification

The tests verify that entries with the same creation height are correctly merged, and new entries are properly appended.

Also applies to: 1125-1125, 1181-1181

x/staking/types/delegation.go (4)

Line range hint 114-134: LGTM: Changes align with unbonding queue index removal

The modifications to AddEntry are consistent with the removal of ICS unbonding pausing logic while preserving the core functionality of managing delegation entries.


322-327: LGTM: Response type changes are consistent

The changes to NewRedelegationEntryResponse properly align with the removal of the unbonding queue index from the core types.


Line range hint 176-219: Remove unused ICS-related code

The following items appear to be remnants of the ICS unbonding pausing logic and should be removed:

  1. UnbondingOnHoldRefCount field in RedelegationEntry
  2. OnHold method which checks this field

Let's verify if these are still used:


225-227: Consider harmonizing AddEntry behavior with UnbondingDelegation

Unlike UnbondingDelegation.AddEntry, this method doesn't check for existing entries with matching creationHeight and completionTime. Consider whether this difference in behavior is intentional.

Let's check if this behavioral difference is documented or tested:

Comment on lines +6 to +8
UnbondingTypeKey = collections.NewPrefix(57) // prefix for an index containing the type of unbonding operations
UnbondingIDKey = collections.NewPrefix(55) // key for the counter for the incrementing id for UnbondingOperations
UnbondingIndexKey = collections.NewPrefix(56) // prefix for an index for looking up unbonding operations by their IDs
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

Remove unused variables related to unbonding operations

The variables UnbondingTypeKey, UnbondingIDKey, and UnbondingIndexKey are defined but appear to be unused due to the removal of the unbonding pausing logic. Consider removing these variables to clean up the codebase.

Apply this diff to remove the unused variables:

- UnbondingTypeKey    = collections.NewPrefix(57) // prefix for an index containing the type of unbonding operations
- UnbondingIDKey      = collections.NewPrefix(55) // key for the counter for the incrementing id for UnbondingOperations
- UnbondingIndexKey   = collections.NewPrefix(56) // prefix for an index for looking up unbonding operations by their IDs

@aljo242 aljo242 self-requested a review December 11, 2024 19:46
@julienrbrt julienrbrt changed the title chore(staking)!: removing unbonding queue index refactor(x/staking)!: removing unbonding queue index Dec 12, 2024
Copy link
Member

@julienrbrt julienrbrt left a comment

Choose a reason for hiding this comment

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

Yes!! Better to have this now indeed. API breaks aren't much worse that the removal for collections migration, so I think it is fine.
Once this has landed, I'll start preparing v0.52 modules for rc release.

@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Dec 12, 2024
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/staking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: Remove unbonding pausing logic
7 participants