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

[Validator Staking ADO]: Query unbonding period #323

Merged

Conversation

cowboy0015
Copy link
Member

Motivation

Staking ADO is currently using static unbonding period for calculating completion time of the unstaking process. The original issue is created here.

Implementation

Implementing custom message using proto to get staking params was not worthy for this case, as integration test becomes complicated. Thus, the reply is defined for Undelegate message to get the event details which contains completion time and fund information.

  • unstaking information is pushed to UNSTAKING_QUEUE in reply entry point (in on_validator_unstake function).

Testing

  • tests-integration/tests/validator_staking.rs is updated from using static unbonding period to use completion time.

@cowboy0015 cowboy0015 requested a review from crnbarr93 March 13, 2024 19:43
}

pub fn on_validator_unstake(deps: DepsMut, msg: Reply) -> Result<Response, ContractError> {
let attributes = &msg.result.unwrap().events[0].attributes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure that events can't be an empty vector? If not we could use events.first() instead to cover that case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Events can not be an empty vector as it is called from a reply entry point. Only if undelegate msg executed successfully, on_validator_unstake is called with msg which contains an event for the undelegate msg

@cowboy0015 cowboy0015 self-assigned this Mar 13, 2024
@crnbarr93 crnbarr93 changed the title query unbonding period [Validator Staking ADO]: Query unbonding period Mar 14, 2024
Copy link
Contributor

@crnbarr93 crnbarr93 left a comment

Choose a reason for hiding this comment

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

Small dependency check

contracts/finance/andromeda-validator-staking/Cargo.toml Outdated Show resolved Hide resolved
@crnbarr93 crnbarr93 merged commit 246b3b6 into feature/staking Mar 14, 2024
4 checks passed
@crnbarr93 crnbarr93 deleted the feature/staking-withdraw-funds-with-completion-time branch March 14, 2024 16:28
crnbarr93 pushed a commit that referenced this pull request Mar 18, 2024
* Feature/staking state management (#298)

* created validator staking contract in finance subdirectory

* added contract instantiation implementation and created state management

* added schema

* updated andromeda finance package's toml file to use staking feature of cosmwasm std

* removed unncessary macro and renamed improper helper function

* fixed issues for pr

* Feature/staking execute stake (#300)

* added execute and query entrypoint for validator staking

* added integration test

* added unit test for validator staking

* fixed linting error

* fixed clippy error

* Feature/staking claim rewards (#304)

* added execute and query entrypoint for validator staking

* added integration test

* added unit test for validator staking

* fixed linting error

* fixed clippy error

* undelegate functionality added

* test case added for unstaking with invalid validator and owner

* claim reward function added

* lint error fixed and optimized

* updated some validation code with ensure! macro

* added AMP handler & updated validator staking unit test mock info to use owner

* unauthorized unit test added for claim reward and unstake

* Feature/staking withdraw unstaked tokens (#310)

* added execute and query entrypoint for validator staking

* added integration test

* added unit test for validator staking

* fixed linting error

* fixed clippy error

* undelegate functionality added

* test case added for unstaking with invalid validator and owner

* claim reward function added

* lint error fixed and optimized

* updated some validation code with ensure! macro

* updated integration test to reflect the effect of undelegation

* added AMP handler & updated validator staking unit test mock info to use owner

* unauthorized unit test added for claim reward and unstake

* merged with feature/staking branch & added WithdrawFund message

* added withdraw fund handler

* query for unstaked tokens added

* renamed msgs for clarity

* [Validator Staking ADO]: Query unbonding period (#323)

* unstaking history saved to storage

* removed stargate feature from validator staking

* adjusted chrono version to 3 for rust version compatibility

* added doc for validator staking
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