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

Threw an error if weighted_stake_diffs.entry() is empty #25

Merged

Conversation

rwwwx
Copy link
Contributor

@rwwwx rwwwx commented Jul 17, 2024

No description provided.

Copy link

linear bot commented Jul 17, 2024

MTG-400 Throw errors on weighted_stake_diffs.entry()

s.cherviakov said in MTG-80:

rewardsPool.restake weighted_stake_diffs modification should be checked so we don't subtract from a non existing value

@rwwwx rwwwx requested a review from kstepanovdev July 17, 2024 09:11

/// 13
/// No need to transfer zero amount of rewards.
#[error("'weighted_stake_diffs' entry cannot be empty")]
Copy link
Collaborator

@kstepanovdev kstepanovdev Jul 17, 2024

Choose a reason for hiding this comment

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

Suggested change
#[error("'weighted_stake_diffs' entry cannot be empty")]
#[error("No changes at the date in weighted stake modifiers while they're expected")]

/// 13
/// No need to transfer zero amount of rewards.
#[error("'weighted_stake_diffs' entry cannot be empty")]
WeightedStakeDiffEntryIsEmpty,
Copy link
Collaborator

Choose a reason for hiding this comment

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

May this error be slightly more meaningful? What about NoWeightedStakeModifiersAtADate or something like that?

Copy link
Collaborator

@kstepanovdev kstepanovdev left a comment

Choose a reason for hiding this comment

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

lgtm besides error messages. Good job.

@rwwwx rwwwx merged commit 48f49d6 into refactor-and-bugfixing Jul 17, 2024
3 checks passed
@rwwwx rwwwx deleted the mtg-400-throw-errors-on-weighted_stake_diffs branch July 17, 2024 09:46
kstepanovdev added a commit that referenced this pull request Jul 22, 2024
* rename RestakeDeposit to ExtendStake

* add days lockup days to Flex

* imporove uninitialize assertion

* rename RewardPool:fill to RewardPool:distribute

* from now fill cannot be invoked if rewards equals to zero

* refactor DistributeRewards::process

* refactor withdraw_mining

* add fn for mining account closing

* deposit_authority don't have to be mutable in close_mining ix

* use more clear variable for RewardCalculator::update_index

* regenerate IDL and clients

* Initialize rewards-pool deposit authority signature (#15)

* Initialize rewards-pool deposit authority signature

* fixed comments and fmt

* Throw an error instead of returning Ok() when 'rewards == 0'

* removed elvis operator

* [MTG-237] ci cd (#17)

fixed CI/CD, added README.md and cargo audit

* Fix comment in instruction.rs

* Forbid closing mininig if there are pending rewards

* Add comment regarding closing accounts

* Unify Contexts && verification checks (#21)

Unify Contexts and verification checks

* mtg-425: Error handling improvements (#22)

improved error handling

* Threw an error if `weighted_stake_diffs.entry()` is empty (#25)

Threw an error if `weighted_stake_diffs.entry()` is empty

* [Mtg-296] delegated staking extend staking with delegate parameter (#18)

* initial design

* fix tests for delegated initial design

* Extend extend_stake instruction with delegate parameter
Extend deposit_mining instruction with delegate parameter

* Refactor and make arithmetic operations more readable

* Add tests for delegated staking

* minor fix

* [MTG-237] ci cd (#17)

fixed CI/CD, added README.md and cargo audit

* Change ordering for PartialOrd and Ord for LockupPeriod

* refactor

* refactor asserts

* remove redundant substraction from delegated stake check

* Forbid mining account from closing if it has stake_from_others

* remove useless comment

* add delegate_mining field to the withdraw_mining && remove verification for weighted stake since it's done on the staking contract

* initial design

* fix tests for delegated initial design

* Extend extend_stake instruction with delegate parameter
Extend deposit_mining instruction with delegate parameter

* Refactor and make arithmetic operations more readable

* Add tests for delegated staking

* Change ordering for PartialOrd and Ord for LockupPeriod

* refactor

* refactor asserts

* remove redundant substraction from delegated stake check

* Forbid mining account from closing if it has stake_from_others

* remove useless comment

* add delegate_mining field to the withdraw_mining && remove verification for weighted stake since it's done on the staking contract

* remove useless imports

* add more packing on closing account

* update tests

* remove redundant packing

* [mtg-308] (#24)

* add change delegate function

* change_delegate: add an early return for the case when new_delegate_mining and old_delegate_mining are the same

* satisfy clippy

* [mtg-297] add stake_from_others for rewards calculations (#26)

* add change delegate function

* change_delegate: add an early return for the case when new_delegate_mining and old_delegate_mining are the same

* satisfy clippy

* add stake_from_others for rewards calculations

* satisfy clippy

* update tests && rebase

* Add refreshing of rewards for delegate mining each time it's stake_from_others changes

* Update programs/rewards/src/instruction.rs

Co-authored-by: Stanislav Cherviakov <[email protected]>

* minor fix after merge commit

---------

Co-authored-by: Stanislav Cherviakov <[email protected]>

---------

Co-authored-by: Matiukhin Vlad <[email protected]>
Co-authored-by: Stanislav Cherviakov <[email protected]>

---------

Co-authored-by: Kyrylo Stepanov <[email protected]>
Co-authored-by: Matiukhin Vlad <[email protected]>
Co-authored-by: rwwwx <[email protected]>
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