Skip to content

Clean up data types in dex module#24

Merged
codchen merged 5 commits intomasterfrom
tony-chen-fix-types
Jun 5, 2022
Merged

Clean up data types in dex module#24
codchen merged 5 commits intomasterfrom
tony-chen-fix-types

Conversation

@codchen
Copy link
Collaborator

@codchen codchen commented May 31, 2022

  • Change all price/quantity/leverage data type to sdk.Dec which is a fixed 18-decimal-place numeric representation.
  • Change all denom data type to an enum
  • Remove nonce
  • Add migration logics for data type changes of the following states: long book, short book, settlements, registered pairs, twap

Tested in local chain with the following steps:

  • Started chain of the current master version (i.e. old version)
  • Populated states by sending orders to dex (at this point the states are in old data type)
  • Sent and passed proposal to upgrade
  • Resumed chain of this commit's version (i.e. new version)
  • Queried states and observed that the states are all in new data type correctly

@codchen codchen requested a review from LCyson May 31, 2022 03:18
@codchen codchen force-pushed the tony-chen-fix-types branch from 075039c to e76ec0c Compare June 1, 2022 03:36
@codchen codchen requested review from philipsu522 and udpatil June 1, 2022 05:48
var val legacytypes.LongBook
cdc.MustUnmarshal(iterator.Value(), &val)
key := iterator.Key()
store.Delete(key)
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 wait until the end to delete?

key := iterator.Key()
store.Delete(key)
priceDenom, err := types.GetDenomFromStr(val.Entry.PriceDenom)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

rather than just continuing, should we log it so that we can revisit and try to fix this later? If we delete at the end the value is still there

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

together with the .Delete comment above, my thought was to prevent any bad state from lingering in the blockchain after the migration since a bad state could potentially crash the chain during logics in Begin/EndBlock, and I don't know of a good way to fix bad states after migrations. Maybe we can just panic here? So that migration will fail, and we can go back and add in any missed edge cases and rerun migration

@codchen codchen force-pushed the tony-chen-fix-types branch from 250b27e to 3bc155f Compare June 5, 2022 01:37
@codchen codchen requested a review from philipsu522 June 5, 2022 01:38
@codchen codchen merged commit 6008711 into master Jun 5, 2022
masih pushed a commit that referenced this pull request Sep 29, 2025
* Add accesscontrol module

* mod tidy

* proto files

* move out of param

* linting

* AccessOps instead

* Address comments
masih pushed a commit that referenced this pull request Sep 30, 2025
* Add accesscontrol module

* mod tidy

* proto files

* move out of param

* linting

* AccessOps instead

* Address comments
masih pushed a commit that referenced this pull request Oct 1, 2025
* Cherry-pick rollback

* debug

* change log
masih pushed a commit that referenced this pull request Oct 9, 2025
@masih masih deleted the tony-chen-fix-types branch October 31, 2025 15:53
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