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

refactor: expedited proposals parameter migrations #303

Merged
merged 10 commits into from
Aug 8, 2022

Conversation

xBalbinus
Copy link

@xBalbinus xBalbinus commented Aug 1, 2022

Closes: #2249

What is the purpose of the change

For expedited proposals we added 2 new parameters:

MinExpeditedDeposit
ExpeditedVotingPeriod
ExpeditedThreshold

However, these parameters have not been set / migrated to. We need to implement the migrations to set the parameters to the desired values according to: https://wallet.keplr.app/chains/osmosis/proposals/278 and its respective common wealth thread.

Brief Changelog

expedited proposal parameter migrations are implemented in the SDK fork
parameters are set to the desired values from the gov prop
the upgraded sdk change is integrated into Osmosis
e2e upgrade tests continue to pass

Testing and Verifying

This change is already covered by existing tests, such as the CI tests as well as tests written in gov/legacy/v4 module

  • Added unit test that validates params settings and storage.

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes / no)
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no)
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / Osmosis docs repo / not documented)

@xBalbinus xBalbinus marked this pull request as ready for review August 1, 2022 20:25
@xBalbinus xBalbinus requested a review from a team August 1, 2022 20:25
@xBalbinus xBalbinus marked this pull request as draft August 1, 2022 20:25
@xBalbinus xBalbinus changed the title migration to v4 [refactor] expedited proposals parameter migrations Aug 2, 2022
@xBalbinus xBalbinus changed the title [refactor] expedited proposals parameter migrations refactor: expedited proposals parameter migrations Aug 2, 2022
Copy link
Member

@p0mvn p0mvn left a comment

Choose a reason for hiding this comment

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

Great work, had some comments. Please take a look

@@ -0,0 +1,6 @@
package v4

var MinInitialDepositRatio = minInitialDepositRatio
Copy link
Member

Choose a reason for hiding this comment

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

let's group these vars and add whitespace at the end of the file please

Comment on lines 13 to 16
var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100))
var minExpeditedDeposit = sdk.NewCoins(sdk.NewCoin("osmo", sdk.NewInt(5000)))
var expeditedVotingPeriod = time.Duration(time.Hour * 24)
var expeditedThreshold = sdk.NewDec(2).Quo(sdk.NewDec(3))
Copy link
Member

Choose a reason for hiding this comment

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

please group the vars:

var (
...
)

var expeditedVotingPeriod = time.Duration(time.Hour * 24)
var expeditedThreshold = sdk.NewDec(2).Quo(sdk.NewDec(3))

// MigrateStore performs in-place store migrations for consensus version 3
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// MigrateStore performs in-place store migrations for consensus version 3
// MigrateStore performs in-place store migrations for consensus version 4

Comment on lines 20 to 22
// Please note that this is the first version that switches from using
// SDK versioning (v043 etc) for package names to consensus versioning
// of the gov module.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Please note that this is the first version that switches from using
// SDK versioning (v043 etc) for package names to consensus versioning
// of the gov module.

// of the gov module.
// The migration includes:
//
// - Setting the minimum deposit param in the paramstore.
Copy link
Member

Choose a reason for hiding this comment

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

Let's update the comment please


//Set depositParams
paramstore.Get(ctx, types.ParamStoreKeyDepositParams, &depositParams)
depositParams.MinInitialDepositRatio = minInitialDepositRatio
Copy link
Member

Choose a reason for hiding this comment

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

This should have been set during the previous migration (v3)

Suggested change
depositParams.MinInitialDepositRatio = minInitialDepositRatio

// increased to 5000 OSMO. The proposal will have 24 hours to achieve
// a two-thirds majority of all staked OSMO voting power voting YES.
var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100))
var minExpeditedDeposit = sdk.NewCoins(sdk.NewCoin("osmo", sdk.NewInt(5000)))
Copy link
Member

Choose a reason for hiding this comment

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

Hmm this is not ideal that we have this coupling in the sdk on osmosis by having to hardcode the osmo denom here.

This is a flaw in the original design though and regular deposits have the same problem. I think it's okay to hard code it here, just commenting to keep this issue in mind

// increased to 5000 OSMO. The proposal will have 24 hours to achieve
// a two-thirds majority of all staked OSMO voting power voting YES.
var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100))
var minExpeditedDeposit = sdk.NewCoins(sdk.NewCoin("osmo", sdk.NewInt(5000)))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var minExpeditedDeposit = sdk.NewCoins(sdk.NewCoin("osmo", sdk.NewInt(5000)))
var minExpeditedDeposit = sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(5000 * 1_000_000)))

// If expedited, the deposit to enter voting period will be
// increased to 5000 OSMO. The proposal will have 24 hours to achieve
// a two-thirds majority of all staked OSMO voting power voting YES.
var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var minInitialDepositRatio = sdk.NewDec(25).Quo(sdk.NewDec(100))


// We assume that all deposit params are set besides the MinInitialDepositRatio
originalDepositParams := types.DefaultDepositParams()
originalDepositParams.MinInitialDepositRatio = sdk.ZeroDec()
Copy link
Member

Choose a reason for hiding this comment

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

let's remove everything related to min initial deposit ratio please

@@ -25,3 +26,8 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error {
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v3.MigrateStore(ctx, m.keeper.paramSpace)
}

// Migrate2to3 migrates from version 3 to 4.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Migrate2to3 migrates from version 3 to 4.
// Migrate3to4 migrates from version 3 to 4.

Comment on lines 31 to 33
var depositParams types.DepositParams
var votingParams types.VotingParams
var tallyParams types.TallyParams
Copy link
Member

Choose a reason for hiding this comment

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

Let's group vars please

x/gov/legacy/v4/store.go Outdated Show resolved Hide resolved
x/gov/legacy/v4/store.go Outdated Show resolved Hide resolved
x/gov/legacy/v4/store.go Outdated Show resolved Hide resolved
@czarcas7ic czarcas7ic merged commit 02273b8 into osmosis-main Aug 8, 2022
@czarcas7ic czarcas7ic deleted the xiangan/refactor branch August 8, 2022 17:36
@czarcas7ic czarcas7ic restored the xiangan/refactor branch August 8, 2022 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

refactor(x/gov): expedited proposals parameter migrations
3 participants