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

feat(evmstaking): replace staking keeper endblocker #209

Merged
merged 1 commit into from
Oct 16, 2024

Conversation

0xHansLee
Copy link
Contributor

With this implementation, I replaced the EndBlocker of staking keeper.
It now returns the array of completed unbonding, so we can use them for processing withdrawal.

issue: #197

@0xHansLee 0xHansLee force-pushed the feat/replace-staking-endblocker branch from 38493f3 to 9ed02e5 Compare October 16, 2024 06:40
@0xHansLee 0xHansLee changed the title feat(evmstaking): replace staking keeper EndBlocker feat(evmstaking): replace staking keeper endblocker Oct 16, 2024
Comment on lines -92 to -113
spendableAmount := k.bankKeeper.SpendableCoin(ctx, delegatorAddr, sdk.DefaultBondDenom).Amount
if spendableAmount.IsZero() {
log.Warn(ctx, "No spendable coins for undelegation",
errors.New("no spendable coins for undelegation"),
"delegator", entry.delegatorAddress,
"validator", entry.validatorAddress,
"original_amount", entry.amount.String())

continue
}

// If the requested undelegation amount is greater than the spendable amount, set the real undelegation amount to
// the total spendable amount.
if entry.amount.GT(spendableAmount) {
entry.amount = spendableAmount
log.Warn(ctx, "Spendable amount is less than the requested undelegation amount",
errors.New("spendable amount is less than the requested undelegation amount"),
"delegator", entry.delegatorAddress,
"validator", entry.validatorAddress,
"requested_amount", entry.amount.String(),
"spendable_amount", spendableAmount.String())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add tests to ensure this invariance is not broken? cc @limengformal

We should also add the crisis module for invariance checks, cc @edisonz0718.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will add a test to cover that this invariance is not broken in the following PR.

Copy link
Contributor

@edisonz0718 edisonz0718 left a comment

Choose a reason for hiding this comment

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

lgtm

@0xHansLee 0xHansLee force-pushed the feat/replace-staking-endblocker branch from 9ed02e5 to bd0d8fc Compare October 16, 2024 17:47
@0xHansLee 0xHansLee force-pushed the feat/replace-staking-endblocker branch from bd0d8fc to 9befa97 Compare October 16, 2024 19:46
@0xHansLee 0xHansLee merged commit d2e195c into main Oct 16, 2024
6 checks passed
@0xHansLee 0xHansLee deleted the feat/replace-staking-endblocker branch October 16, 2024 20:35
Copy link

Binary uploaded successfully 🎉

📦 Version Name: 0.12.0-d2e195c
📦 Download Source: AWS S3

leeren added a commit that referenced this pull request Oct 16, 2024
* chore(release): release version 0.12.1 unstable

* feat(epochs): revert epoch module (#198)

* feat(api): revert add epochs api

* feat(epochs): revert porting epochs module

* feat(evmstaking): use deterministic cosmos sdk (#211)

* feat(evmstaking): replace staking keeper endblocker (#209)

---------

Co-authored-by: Hans Lee <38912532+0xHansLee@users.noreply.github.com>
Co-authored-by: Zerui Ge <gezerui1997@gmail.com>
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.

3 participants