-
Notifications
You must be signed in to change notification settings - Fork 608
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move fork and upgrade logic into sub-directory structure (#680)
* Move fork logic into sub-directory structure * Move upgrade handlers into sub-directories * Move upgrade logic to end of keeper initialization * Add v4 migration test
- Loading branch information
1 parent
4da4013
commit 66637c3
Showing
20 changed files
with
470 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Osmosis Upgrades | ||
|
||
This folder contains logic for every osmosis upgrade. (Both state migrations, and hard forks) | ||
|
||
* v1 - Initial version | ||
* v3 - short blurb on prop19 and the fork | ||
* v4 - Berylium State Migration | ||
* v5 - Boron State migration | ||
* v6 - hard fork for IBC bug fix | ||
|
||
## TODO: Make a fork-upgrade struct and a state-migration upgrade struct |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# TODO Write stuff | ||
|
||
Should include description about this version, compatibility with v1 until height {...}, and fork code here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package v3 | ||
|
||
const UpgradeName = "v3" | ||
const UpgradeHeight = 712000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package v3 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" | ||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" | ||
) | ||
|
||
func RunForkLogic(ctx sdk.Context, gov *govkeeper.Keeper, staking *stakingkeeper.Keeper) { | ||
ctx.Logger().Info("Applying Osmosis v3 upgrade." + | ||
" Fixing governance deposit so proposals can be voted upon," + | ||
" and fixing validator min commission rate.") | ||
FixMinDepositDenom(ctx, gov) | ||
FixMinCommisionRate(ctx, staking) | ||
} | ||
|
||
// Fixes an error where minimum deposit was set to "500 osmo" | ||
// This denom does not exist, which makes it impossible for a proposal to go to a vote | ||
func FixMinDepositDenom(ctx sdk.Context, gov *govkeeper.Keeper) { | ||
var params = gov.GetDepositParams(ctx) | ||
params.MinDeposit = sdk.NewCoins(sdk.NewCoin("uosmo", sdk.NewInt(500000000))) | ||
gov.SetDepositParams(ctx, params) | ||
} | ||
|
||
// Fixes an error where validators can be created with a commission rate | ||
// less than the network minimum rate. | ||
func FixMinCommisionRate(ctx sdk.Context, staking *stakingkeeper.Keeper) { | ||
// Upgrade every validators min-commission rate | ||
validators := staking.GetAllValidators(ctx) | ||
minCommissionRate := staking.GetParams(ctx).MinCommissionRate | ||
for _, v := range validators { | ||
if v.Commission.Rate.LT(minCommissionRate) { | ||
comm, err := staking.MustUpdateValidatorCommission( | ||
ctx, v, minCommissionRate) | ||
if err != nil { | ||
panic(err) | ||
} | ||
v.Commission = comm | ||
|
||
// call the before-modification hook since we're about to update the commission | ||
staking.BeforeValidatorModified(ctx, v.GetOperator()) | ||
|
||
staking.SetValidator(ctx, v) | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package v4 | ||
|
||
const UpgradeName = "v4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package app | ||
package v4 | ||
|
||
import ( | ||
"encoding/csv" | ||
|
Oops, something went wrong.