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

docs(x/accounts/defaults/lockup): Add slash document for lockup account #22783

Merged
merged 4 commits into from
Dec 6, 2024

Conversation

sontrinh16
Copy link
Member

@sontrinh16 sontrinh16 commented Dec 6, 2024

Description

Closes: #XXXX


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

  • New Features

    • Introduced a new section in the README for lockup accounts titled "In An Event Of Slashing," explaining the implications of slashing on delegated amounts.
  • Documentation

    • Added detailed calculations and scenarios regarding the spendable amount and the impact of slashing on lockup accounts.

@sontrinh16 sontrinh16 requested review from testinginprod and a team as code owners December 6, 2024 05:08
Copy link
Contributor

coderabbitai bot commented Dec 6, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces a new section titled "In An Event Of Slashing" to the README.md file for the lockup accounts module. This section explains the implications of slashing on DelegatedLocking amounts, detailing how slashing can create discrepancies between actual delegated amounts and those recorded in the lockup account. It also presents a formula for calculating the spendable amount and illustrates three scenarios regarding notBondedLockedAmount changes due to slashing. The section emphasizes the complexity of managing slashing events within the x/accounts module.

Changes

File Path Change Summary
x/accounts/defaults/lockup/README.md Added a new section "In An Event Of Slashing" detailing implications of slashing on lockup accounts.

Possibly related PRs

Suggested labels

C:x/slashing

Suggested reviewers

  • testinginprod
  • julienrbrt
  • tac0turtle

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.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 10c5400 and cdbc212.

📒 Files selected for processing (1)
  • x/accounts/defaults/lockup/README.md (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
x/accounts/defaults/lockup/README.md (1)

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

🪛 LanguageTool
x/accounts/defaults/lockup/README.md

[grammar] ~114-~114: Consider using either the past participle “slashed” or the present participle “slashing” here.
Context: ... that the lockup account delegate to is slash which affect the actual delegation amou...

(BEEN_PART_AGREEMENT)


[style] ~114-~114: Consider removing “of” to be more concise
Context: ...n excess amount even if user undelegate all of the account delegated amount. This excess ...

(ALL_OF_THE)


[uncategorized] ~134-~134: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...annot assume certain account types exist so the handling of slashing event would ha...

(COMMA_COMPOUND_SENTENCE_2)


[grammar] ~134-~134: This is normally spelled as one word.
Context: ... of lockup account would make the logic over complicated. As the above effects are only an edge ...

(OVER_COMPOUNDS)


[uncategorized] ~134-~134: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...e only an edge case that affect a small amount of users, so here we would accept the t...

(AMOUNTOF_TO_NUMBEROF)


[uncategorized] ~134-~134: When ‘trade-off’ is used as a noun or modifier, it needs to be hyphenated.
Context: ...t of users, so here we would accept the trade off for a simpler design. The same design i...

(VERB_NOUN_CONFUSION)

🔇 Additional comments (2)
x/accounts/defaults/lockup/README.md (2)

11-11: LGTM!

The table of contents update is correctly formatted and properly linked.


234-234: LGTM!

The reference to the slashing section is properly added and helps readers understand the excess DV amount scenario.

Comment on lines 112 to 134
## In An Event Of Slashing

As defined, base lockup store `DelegatedLocking` by amount. In an event of a validator that the lockup account delegate to is slash which affect the actual delegation amount, this will leave the `DelegatedLocking` have an excess amount even if user undelegate all of the
account delegated amount. This excess amount would affect the spendable amount, further details are as below:

Spendable amount are calculated as
`spendableAmount` = `balance` - `notBondedLockedAmout`
Whereas `notBondedLockedAmout` = `lockedAmount` - `Min(LockedAmount, DelegatedLockedAmount)`

As seen in the formula `notBondedLockedAmout` can only be 0 or a positive value when `DelegatedLockedAmount` < `LockedAmount`
if the `notBondedLockedAmout` is positive then `spendableAmount` is less than the actual balance. Let call `NewDelegatedLockedAmount` is the `delegatedLockedAmount` when applying N slash

1. Case 1: where originally `DelegatedLockedAmount` > `lockedAmount` but when applying the slash amount the `NewDelegatedLockedAmount` < `lockedAmount` then
* When not applying slash `notBondedLockedAmout` will be 0
* When apply slash `notBondedLockedAmout` will be `lockedAmount` - `NewDelegatedLockedAmount` = a positive amount
2. Case 2: where originally `DelegatedLockedAmount` < `lockedAmount` when applying the slash amount the `NewDelegatedLockedAmount` < `lockedAmount` then
* When not applying slash `lockedAmount` - `DelegatedLockedAmount`
* When apply slash `notBondedLockedAmout` will be `lockedAmount` - `NewDelegatedLockedAmount` = `lockedAmount` - `(DelegatedLockedAmount - N)` = `lockedAmount` - `DelegatedLockedAmount` + N
3. Case 3: where originally `DelegatedLockedAmount` > `lockedAmount` when applying the slash amount still the `NewDelegatedLockedAmount` > `lockedAmount` then `notBondedLockedAmout` will be 0 applying slash or not

In the 3 cases, case 1 and case 2 seen the `notBondedLockedAmout` decrease when not applying the slash, make the `spendableAmount` higher.

Due to the natural of x/accounts, as other modules cannot assume certain account types exist so the handling of slashing event would have to be done internally inside x/accounts's accounts which in the case of lockup account would make the logic over complicated. As the above effects are only an edge case that affect a small amount of users, so here we would accept the trade off for a simpler design. The same design intention is also present in the legacy vesting account.
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

Improve clarity and fix grammatical issues in the slashing documentation

The technical content is accurate, but the section needs improvements in clarity and grammar:

Apply these changes:

-As defined, base lockup store `DelegatedLocking` by amount. In an event of a validator that the lockup account delegate to is slash which affect the actual delegation amount, this will leave the `DelegatedLocking` have an excess amount even if user undelegate all of the 
-account delegated amount. This excess amount would affect the spendable amount, further details are as below:
+The base lockup stores `DelegatedLocking` by amount. When a validator that the lockup account is delegated to gets slashed, affecting the actual delegation amount, the `DelegatedLocking` will have an excess amount even if the user undelegates all delegated amounts. This excess amount affects the spendable amount as detailed below:

-Spendable amount are calculated as
-`spendableAmount` = `balance` - `notBondedLockedAmout` 
-Whereas `notBondedLockedAmout`  = `lockedAmount` - `Min(LockedAmount, DelegatedLockedAmount)`
+The spendable amount is calculated as:
+```
+spendableAmount = balance - notBondedLockedAmount
+where notBondedLockedAmount = lockedAmount - Min(lockedAmount, delegatedLockedAmount)
+```

-As seen in the formula `notBondedLockedAmout` can only be 0 or a positive value when `DelegatedLockedAmount` < `LockedAmount`
-if the `notBondedLockedAmout` is positive then `spendableAmount` is less than the actual balance. Let call `NewDelegatedLockedAmount` is the `delegatedLockedAmount` when applying N slash
+As seen in the formula, `notBondedLockedAmount` can only be 0 or a positive value when `delegatedLockedAmount` < `lockedAmount`.
+If `notBondedLockedAmount` is positive, then `spendableAmount` is less than the actual balance. Let's define `newDelegatedLockedAmount` as the `delegatedLockedAmount` after applying N slashes.

-1. Case 1: where originally `DelegatedLockedAmount` > `lockedAmount` but when applying the slash amount the `NewDelegatedLockedAmount` < `lockedAmount` then 
-    * When not applying slash  `notBondedLockedAmout` will be 0 
-    * When apply slash `notBondedLockedAmout` will be `lockedAmount` - `NewDelegatedLockedAmount` =  a positive amount
+1. Case 1: Originally `delegatedLockedAmount` > `lockedAmount`, but after slashing, `newDelegatedLockedAmount` < `lockedAmount`:
+    * Before slashing: `notBondedLockedAmount = 0`
+    * After slashing: `notBondedLockedAmount = lockedAmount - newDelegatedLockedAmount` (a positive amount)

-2. Case 2: where originally `DelegatedLockedAmount` < `lockedAmount` when applying the slash amount the `NewDelegatedLockedAmount` < `lockedAmount` then 
-    * When not applying slash `lockedAmount` - `DelegatedLockedAmount`
-    * When apply slash `notBondedLockedAmout` will be `lockedAmount` - `NewDelegatedLockedAmount` = `lockedAmount` - `(DelegatedLockedAmount - N)` = `lockedAmount` - `DelegatedLockedAmount` + N 
+2. Case 2: Originally `delegatedLockedAmount` < `lockedAmount`, and after slashing, `newDelegatedLockedAmount` < `lockedAmount`:
+    * Before slashing: `notBondedLockedAmount = lockedAmount - delegatedLockedAmount`
+    * After slashing: `notBondedLockedAmount = lockedAmount - newDelegatedLockedAmount = lockedAmount - (delegatedLockedAmount - N) = lockedAmount - delegatedLockedAmount + N`

-3. Case 3:  where originally `DelegatedLockedAmount` > `lockedAmount` when applying the slash amount still the `NewDelegatedLockedAmount` > `lockedAmount` then `notBondedLockedAmout` will be 0 applying slash or not
+3. Case 3: Originally `delegatedLockedAmount` > `lockedAmount`, and after slashing, `newDelegatedLockedAmount` > `lockedAmount`:
+    * Both before and after slashing: `notBondedLockedAmount = 0`

-In the 3 cases, case 1 and case 2 seen the `notBondedLockedAmout` decrease when not applying the slash, make the `spendableAmount` higher.  
+In cases 1 and 2, `notBondedLockedAmount` decreases when not applying the slash, resulting in a higher `spendableAmount`.

-Due to the natural of x/accounts, as other modules cannot assume certain account types exist so the handling of slashing event would have to be done internally inside x/accounts's accounts which in the case of lockup account would make the logic over complicated. As the above effects are only an edge case that affect a small amount of users, so here we would accept the trade off for a simpler design. The same design intention is also present in the legacy vesting account.
+Due to the nature of x/accounts, where other modules cannot assume certain account types exist, the handling of slashing events must be done internally within x/accounts. For lockup accounts, this would make the logic overcomplicated. Since these effects only impact a small number of users, we accept the trade-off for a simpler design. This design decision aligns with the legacy vesting account implementation.
📝 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
## In An Event Of Slashing
As defined, base lockup store `DelegatedLocking` by amount. In an event of a validator that the lockup account delegate to is slash which affect the actual delegation amount, this will leave the `DelegatedLocking` have an excess amount even if user undelegate all of the
account delegated amount. This excess amount would affect the spendable amount, further details are as below:
Spendable amount are calculated as
`spendableAmount` = `balance` - `notBondedLockedAmout`
Whereas `notBondedLockedAmout` = `lockedAmount` - `Min(LockedAmount, DelegatedLockedAmount)`
As seen in the formula `notBondedLockedAmout` can only be 0 or a positive value when `DelegatedLockedAmount` < `LockedAmount`
if the `notBondedLockedAmout` is positive then `spendableAmount` is less than the actual balance. Let call `NewDelegatedLockedAmount` is the `delegatedLockedAmount` when applying N slash
1. Case 1: where originally `DelegatedLockedAmount` > `lockedAmount` but when applying the slash amount the `NewDelegatedLockedAmount` < `lockedAmount` then
* When not applying slash `notBondedLockedAmout` will be 0
* When apply slash `notBondedLockedAmout` will be `lockedAmount` - `NewDelegatedLockedAmount` = a positive amount
2. Case 2: where originally `DelegatedLockedAmount` < `lockedAmount` when applying the slash amount the `NewDelegatedLockedAmount` < `lockedAmount` then
* When not applying slash `lockedAmount` - `DelegatedLockedAmount`
* When apply slash `notBondedLockedAmout` will be `lockedAmount` - `NewDelegatedLockedAmount` = `lockedAmount` - `(DelegatedLockedAmount - N)` = `lockedAmount` - `DelegatedLockedAmount` + N
3. Case 3: where originally `DelegatedLockedAmount` > `lockedAmount` when applying the slash amount still the `NewDelegatedLockedAmount` > `lockedAmount` then `notBondedLockedAmout` will be 0 applying slash or not
In the 3 cases, case 1 and case 2 seen the `notBondedLockedAmout` decrease when not applying the slash, make the `spendableAmount` higher.
Due to the natural of x/accounts, as other modules cannot assume certain account types exist so the handling of slashing event would have to be done internally inside x/accounts's accounts which in the case of lockup account would make the logic over complicated. As the above effects are only an edge case that affect a small amount of users, so here we would accept the trade off for a simpler design. The same design intention is also present in the legacy vesting account.
## In An Event Of Slashing
The base lockup stores `DelegatedLocking` by amount. When a validator that the lockup account is delegated to gets slashed, affecting the actual delegation amount, the `DelegatedLocking` will have an excess amount even if the user undelegates all delegated amounts. This excess amount affects the spendable amount as detailed below:
The spendable amount is calculated as:
🧰 Tools
🪛 LanguageTool

[grammar] ~114-~114: Consider using either the past participle “slashed” or the present participle “slashing” here.
Context: ... that the lockup account delegate to is slash which affect the actual delegation amou...

(BEEN_PART_AGREEMENT)


[style] ~114-~114: Consider removing “of” to be more concise
Context: ...n excess amount even if user undelegate all of the account delegated amount. This excess ...

(ALL_OF_THE)


[uncategorized] ~134-~134: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...annot assume certain account types exist so the handling of slashing event would ha...

(COMMA_COMPOUND_SENTENCE_2)


[grammar] ~134-~134: This is normally spelled as one word.
Context: ... of lockup account would make the logic over complicated. As the above effects are only an edge ...

(OVER_COMPOUNDS)


[uncategorized] ~134-~134: ‘Amount of’ should usually only be used with uncountable or mass nouns. Consider using “number” if this is not the case.
Context: ...e only an edge case that affect a small amount of users, so here we would accept the t...

(AMOUNTOF_TO_NUMBEROF)


[uncategorized] ~134-~134: When ‘trade-off’ is used as a noun or modifier, it needs to be hyphenated.
Context: ...t of users, so here we would accept the trade off for a simpler design. The same design i...

(VERB_NOUN_CONFUSION)

@julienrbrt julienrbrt changed the title chore(x/accounts/defaults/lockup): Add slash document for lockup account docs(x/accounts/defaults/lockup): Add slash document for lockup account Dec 6, 2024
@julienrbrt julienrbrt added the backport/v0.52.x PR scheduled for inclusion in the v0.52's next stable release label Dec 6, 2024
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: 2

🧹 Outside diff range and nitpick comments (1)
x/accounts/defaults/lockup/README.md (1)

117-119: Improve formula presentation

The formula presentation could be enhanced for better readability.

Consider using a code block with proper formatting:

-The spendable amount is calculated as:
-`spendableAmount` = `balance` - `notBondedLockedAmount`
-where `notBondedLockedAmount` = `lockedAmount` - `Min(lockedAmount, delegatedLockedAmount)`
+The spendable amount is calculated as follows:
+```
+spendableAmount = balance - notBondedLockedAmount
+where:
+  notBondedLockedAmount = lockedAmount - Min(lockedAmount, delegatedLockedAmount)
+```
📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 72c34be and c7e6918.

📒 Files selected for processing (1)
  • x/accounts/defaults/lockup/README.md (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
x/accounts/defaults/lockup/README.md (1)

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

🪛 LanguageTool
x/accounts/defaults/lockup/README.md

[uncategorized] ~114-~114: This verb may not be in the correct form. Consider using a different form for this context.
Context: ... that the lockup account delegate to is slash which affect the actual delegation amou...

(AI_EN_LECTOR_REPLACEMENT_VERB_FORM)


[uncategorized] ~114-~114: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...ckup account delegate to is slash which affect the actual delegation amount, this will...

(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)


[uncategorized] ~114-~114: You might be missing the article “the” here.
Context: ...dLocking` have an excess amount even if user undelegate all of the account delegate...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[style] ~114-~114: Consider removing “of” to be more concise
Context: ...n excess amount even if user undelegate all of the account delegated amount. This excess ...

(ALL_OF_THE)


[uncategorized] ~133-~133: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...annot assume certain account types exist so the handling of slashing event must be ...

(COMMA_COMPOUND_SENTENCE_2)


[style] ~133-~133: Specify a number, remove phrase, use “a few”, or use “some”
Context: ...fects are only an edge case that affect a small number of users, so here we would accept the trad...

(SMALL_NUMBER_OF)


[uncategorized] ~133-~133: When ‘trade-off’ is used as a noun or modifier, it needs to be hyphenated.
Context: ...r of users, so here we would accept the trade off for a simpler design. This design decis...

(VERB_NOUN_CONFUSION)

🔇 Additional comments (3)
x/accounts/defaults/lockup/README.md (3)

11-11: LGTM: Table of contents entry is correctly formatted

The new section is properly added to the table of contents with the correct link format.


233-233: LGTM: Helpful cross-reference added

The reference to the slashing section is well-placed and helps readers understand the excess DV amount scenario.


114-115: 🛠️ Refactor suggestion

Fix grammar and clarity in the introduction

The opening paragraph needs grammatical improvements for better clarity.

Apply this change:

-As defined, base lockup store `DelegatedLocking` by amount. In an event of a validator that the lockup account delegate to is slash which affect the actual delegation amount, this will leave the `DelegatedLocking` have an excess amount even if user undelegate all of the 
-account delegated amount. This excess amount would affect the spendable amount, further details are as below:
+The base lockup stores delegation amounts in `DelegatedLocking`. When a validator that the lockup account is delegated to gets slashed, affecting the actual delegation amount, the `DelegatedLocking` may retain an excess amount even after the user undelegates all delegated amounts. This excess amount affects the spendable amount as detailed below:

Likely invalid or redundant comment.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~114-~114: This verb may not be in the correct form. Consider using a different form for this context.
Context: ... that the lockup account delegate to is slash which affect the actual delegation amou...

(AI_EN_LECTOR_REPLACEMENT_VERB_FORM)


[uncategorized] ~114-~114: This verb does not appear to agree with the subject. Consider using a different form.
Context: ...ckup account delegate to is slash which affect the actual delegation amount, this will...

(AI_EN_LECTOR_REPLACEMENT_VERB_AGREEMENT)


[uncategorized] ~114-~114: You might be missing the article “the” here.
Context: ...dLocking` have an excess amount even if user undelegate all of the account delegate...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[style] ~114-~114: Consider removing “of” to be more concise
Context: ...n excess amount even if user undelegate all of the account delegated amount. This excess ...

(ALL_OF_THE)

Comment on lines +121 to +129
As seen in the formula `notBondedLockedAmout` can only be 0 or a positive value when `DelegatedLockedAmount` < `LockedAmount`. Let call `NewDelegatedLockedAmount` is the `delegatedLockedAmount` when applying N slash

1. Case 1: Originally `DelegatedLockedAmount` > `lockedAmount` but when applying the slash amount the `NewDelegatedLockedAmount` < `lockedAmount` then
* When not applying slash `notBondedLockedAmout` will be 0
* When apply slash `notBondedLockedAmout` will be `lockedAmount` - `NewDelegatedLockedAmount` = a positive amount
2. Case 2: where originally `DelegatedLockedAmount` < `lockedAmount` when applying the slash amount the `NewDelegatedLockedAmount` < `lockedAmount` then
* When not applying slash `lockedAmount` - `DelegatedLockedAmount`
* When apply slash `notBondedLockedAmout` will be `lockedAmount` - `NewDelegatedLockedAmount` = `lockedAmount` - `(DelegatedLockedAmount - N)` = `lockedAmount` - `DelegatedLockedAmount` + N
3. Case 3: where originally `DelegatedLockedAmount` > `lockedAmount` when applying the slash amount still the `NewDelegatedLockedAmount` > `lockedAmount` then `notBondedLockedAmout` will be 0 applying slash or not
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

Fix inconsistencies and improve case descriptions

There are inconsistencies in terminology and formatting of the cases.

Apply these changes:

  1. Fix spelling: notBondedLockedAmoutnotBondedLockedAmount
  2. Standardize variable names: DelegatedLockedAmountdelegatedLockedAmount
  3. Improve case formatting for consistency
  4. Add proper code blocks for formulas

Would you like me to provide the complete diff for these changes?


In cases 1 and 2, `notBondedLockedAmount` decreases when not applying the slash, resulting in a higher `spendableAmount`.

Due to the nature of x/accounts, as other modules cannot assume certain account types exist so the handling of slashing event must be done internally within x/accounts's accounts. For lockup accounts, this would make the logic overcomplicated. Since these effects are only an edge case that affect a small number of users, so here we would accept the trade off for a simpler design. This design decision aligns with the legacy vesting account implementation.
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

Fix grammar and hyphenation in the conclusion

The concluding paragraph needs grammatical improvements and proper hyphenation.

Apply this change:

-Due to the nature of x/accounts, as other modules cannot assume certain account types exist so the handling of slashing event must be done internally within x/accounts's accounts. For lockup accounts, this would make the logic overcomplicated. Since these effects are only an edge case that affect a small number of users, so here we would accept the trade off for a simpler design. This design decision aligns with the legacy vesting account implementation.
+Due to the nature of x/accounts, where other modules cannot assume certain account types exist, the handling of slashing events must be done internally within x/accounts. For lockup accounts, this would make the logic overcomplicated. Since these effects only impact a small number of users, we accept the trade-off for a simpler design. This design decision aligns with the legacy vesting account implementation.
📝 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
Due to the nature of x/accounts, as other modules cannot assume certain account types exist so the handling of slashing event must be done internally within x/accounts's accounts. For lockup accounts, this would make the logic overcomplicated. Since these effects are only an edge case that affect a small number of users, so here we would accept the trade off for a simpler design. This design decision aligns with the legacy vesting account implementation.
Due to the nature of x/accounts, where other modules cannot assume certain account types exist, the handling of slashing events must be done internally within x/accounts. For lockup accounts, this would make the logic overcomplicated. Since these effects only impact a small number of users, we accept the trade-off for a simpler design. This design decision aligns with the legacy vesting account implementation.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~133-~133: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...annot assume certain account types exist so the handling of slashing event must be ...

(COMMA_COMPOUND_SENTENCE_2)


[style] ~133-~133: Specify a number, remove phrase, use “a few”, or use “some”
Context: ...fects are only an edge case that affect a small number of users, so here we would accept the trad...

(SMALL_NUMBER_OF)


[uncategorized] ~133-~133: When ‘trade-off’ is used as a noun or modifier, it needs to be hyphenated.
Context: ...r of users, so here we would accept the trade off for a simpler design. This design decis...

(VERB_NOUN_CONFUSION)

@tac0turtle tac0turtle added this pull request to the merge queue Dec 6, 2024
Merged via the queue into main with commit 9c40d0f Dec 6, 2024
69 checks passed
@tac0turtle tac0turtle deleted the son/add_slash_document_for_lockup_account branch December 6, 2024 13:10
mergify bot pushed a commit that referenced this pull request Dec 6, 2024
julienrbrt pushed a commit that referenced this pull request Dec 6, 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/accounts/lockup C:x/accounts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants