osmosis icon indicating copy to clipboard operation
osmosis copied to clipboard

feat!(lockups): Cancel in progress unlock, change lock duration higher

Open reecepbcups opened this issue 3 years ago • 0 comments

Closes: #382

What is the purpose of the change

This PR adds support to the CLI to change the lock duration via the NewExtendLockupByIDCmd now. Then building off this, it allows a user to cancel an unlock at any time to be reset to the original state duration time. Once this takes place, they can change to a higher duration or keep it at its original.

Brief Changelog

  • 2 new x/lockup Tx commands added (extend-lockup-by-id, cancel-lockup-by-id)
  • New cancelUnlock boolean added to Extend lockup message
  • Added test to ensure logic still works with original extend and new cancel unlock

Testing and Verifying

  • Added unit test for the message server which ensures you can cancel an active lock
  • Added unit test to ensure synthetic logic & canceling unlock work
  • 'make test' all pass
  • Manually verified with the following on a local chain
export OSMOSISD_NODE="http://localhost:26657"
CHAIN_ID="testing"
V1="--keyring-backend test --home=$HOME/.osmosisd/validator1 --from validator1 --chain-id testing --yes --broadcast-mode block"

osmosisd tx gamm create-pool $V1 --pool-file pool_file.json --chain-id $CHAIN_ID
# osmosisd q gamm pools

osmosisd tx gamm join-pool --pool-id 1 --max-amounts-in=100stake --max-amounts-in=100uosmo --share-amount-out=100 $V1

osmosisd tx gamm join-swap-extern-amount-in 1uosmo 387035722592697287 --pool-id 1 $V1
# osmosisd q gamm pool 1


osmosisd tx lockup lock-tokens 100gamm/pool/1 --duration 24h $V1
# osmosisd q tx 94A6B88CE29B80339D3BA71F6CB379A3C6F64922CF18151B75EEF7AB8EE1D1BA <- period_lock_id 1

osmosisd q lockup lock-by-id 1

# end the lockup from 1 day to 7 days
osmosisd tx lockup extend-lockup-by-id 1 --duration 168h $V1

# now  unbond this lockup
osmosisd tx lockup begin-unlock-by-id 1 $V1
# osmosisd q lockup lock-by-id 1 # < now has an end time, lets try and cancel it

# cancel the lockup by id
osmosisd tx lockup cancel-unlock-by-id 1 $V1

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? yes
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no)
  • How is the feature or change documented? not documented

reecepbcups avatar Oct 12 '22 17:10 reecepbcups