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

upgrade: convert denom "anom" to "ono" #191

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import (
v1_1_6 "github.com/onomyprotocol/onomy/app/upgrades/v1.1.6"
v2_0_0 "github.com/onomyprotocol/onomy/app/upgrades/v2.0.0"
v2_1_0 "github.com/onomyprotocol/onomy/app/upgrades/v2.1.0"

v2_2_0 "github.com/onomyprotocol/onomy/app/upgrades/v2.2.0"
"github.com/onomyprotocol/onomy/docs"
)

Expand Down Expand Up @@ -463,6 +463,7 @@ func (app *OnomyApp) setupUpgradeHandlers() {
app.UpgradeKeeper.SetUpgradeHandler(v1_1_6.Name, v1_1_6.UpgradeHandler)
app.UpgradeKeeper.SetUpgradeHandler(v2_0_0.Name, v2_0_0.CreateUpgradeHandler(app.mm, app.configurator, &app.AppKeepers))
app.UpgradeKeeper.SetUpgradeHandler(v2_1_0.Name, v2_1_0.CreateUpgradeHandler(app.mm, app.configurator, &app.AppKeepers))
app.UpgradeKeeper.SetUpgradeHandler(v2_2_0.Name, v2_2_0.CreateUpgradeHandler(app.mm, app.configurator, &app.AppKeepers))

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion app/upgrades/v1.1.6/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package v1_1_6 //nolint:revive,stylecheck // app version

import (
"context"
// sdk "github.com/cosmos/cosmos-sdk/types"

// sdk "github.com/cosmos/cosmos-sdk/types".
upgradetypes "cosmossdk.io/x/upgrade/types"
"github.com/cosmos/cosmos-sdk/types/module"
)
Expand Down
17 changes: 7 additions & 10 deletions app/upgrades/v2.0.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ func CreateUpgradeHandler(
configurator module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {

return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)

Expand All @@ -46,7 +45,7 @@ func CreateUpgradeHandler(

err = initializeConsensusParamVersion(ctx, keepers.ConsensusParamsKeeper)
if err != nil {
// don't hard fail here, as this is not critical for the upgrade to succeed
// don't hard fail here, as this is not critical for the upgrade to succeed.
ctx.Logger().Error("Error initializing ConsensusParam Version:", "message", err.Error())
}

Expand Down Expand Up @@ -74,7 +73,7 @@ func initializeConsensusParamVersion(ctx sdk.Context, consensusKeeper consensusp
// # inflation_max: "0.200000000000000000"
// # inflation_min: "0.070000000000000000"
// # inflation_rate_change: "0.130000000000000000"
// # mint_denom: anom
// # mint_denom: anom.
func collectionsInitializeMintParam(ctx sdk.Context, mintKeeper mintkeeper.Keeper) error {
params, err := mintKeeper.Params.Get(ctx)
if err != nil {
Expand All @@ -97,7 +96,7 @@ func unbondNow(ctx sdk.Context, keepers *keepers.AppKeepers, ubfs []UnbondingFai
continue
}

// ensure accuracy
// ensure accuracy.
if u.Delegator == ubd.DelegatorAddress && u.Validator == ubd.ValidatorAddress && ubd.Entries[u.Index].Balance.Equal(u.Balance) {
ubd.Entries[u.Index].UnbondingId = u.UnbondingId
ubd.Entries[u.Index].CompletionTime = ctx.BlockHeader().Time.Add(-1 * time.Hour)
Expand All @@ -106,28 +105,27 @@ func unbondNow(ctx sdk.Context, keepers *keepers.AppKeepers, ubfs []UnbondingFai
err := keepers.StakingKeeper.SetUnbondingDelegation(ctx, ubd)
if err != nil {
return err

}
err = keepers.StakingKeeper.UnbondingCanComplete(ctx, u.UnbondingId)
if err != nil {
return err
}
// index ubd update
// index ubd update.
indexUpdate(u.Delegator, u.Validator, u.Index, ubfs)
}
}

return nil
}

// getInfoUnbondingFail Get info UnbondingFail
// getInfoUnbondingFail Get info UnbondingFail.
func getInfoUnbondingFail(ctx sdk.Context, keepers *keepers.AppKeepers) (ubf []UnbondingFail, err error) {
// ubdID errors: 3500-3700 (3599-3678)
// ubdID errors: 3500-3700 (3599-3678).
for i := 3500; i < 3700; i++ {
id := uint64(i)
ubd, err := keepers.StakingKeeper.GetUnbondingDelegationByUnbondingID(ctx, id)
if err != nil {
continue // not found ubd for id
continue // not found ubd for id.
}

for idx, entry := range ubd.Entries {
Expand All @@ -141,7 +139,6 @@ func getInfoUnbondingFail(ctx sdk.Context, keepers *keepers.AppKeepers) (ubf []U
})
break
}

}
}

Expand Down
3 changes: 1 addition & 2 deletions app/upgrades/v2.1.0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,13 @@ func CreateUpgradeHandler(
configurator module.Configurator,
keepers *keepers.AppKeepers,
) upgradetypes.UpgradeHandler {

return func(c context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx := sdk.UnwrapSDKContext(c)
baseAppLegacySS := keepers.ParamsKeeper.Subspace(baseapp.Paramspace).
WithKeyTable(paramstypes.ConsensusParamsKeyTable())
baseapp.MigrateParams(ctx, baseAppLegacySS, &keepers.ConsensusParamsKeeper.ParamsStore)

// onomy1vwr8z00ty7mqnk4dtchr9mn9j96nuh6wrlww93
// onomy1vwr8z00ty7mqnk4dtchr9mn9j96nuh6wrlww93.
addrTreasury := sdk.MustAccAddressFromBech32("onomy1vwr8z00ty7mqnk4dtchr9mn9j96nuh6wrlww93")
treasuryTokens := keepers.BankKeeper.GetAllBalances(ctx, addrTreasury)
err := keepers.DistrKeeper.FundCommunityPool(ctx, treasuryTokens, addrTreasury)
Expand Down
Loading
Loading