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

chore: Cosmos SDK 0.44.* series upgrade for Osmosis #538

Merged
merged 42 commits into from
Nov 21, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9f5afdc
Workflow testing for state sync
faddat Aug 23, 2021
03ae62b
Mod fixed
faddat Oct 6, 2021
6b3c1d1
Incomplete: Update to 0.44.1
faddat Oct 6, 2021
a12b818
Merge https://github.com/osmosis-labs/osmosis into zerofourfourone
faddat Oct 14, 2021
ec530fb
Merge branch 'faddat/sdk-0441' of https://github.com/osmosis-labs/osm…
faddat Oct 14, 2021
123621e
fix bug (#531)
catShaark Oct 15, 2021
fe3c44f
Merge https://github.com/osmosis-labs/osmosis into faddat/sdk-0441
faddat Oct 17, 2021
0b6ef9a
go fmt
faddat Oct 17, 2021
6716d9a
tidy the tidy
faddat Oct 17, 2021
8cab4ef
Fixed mod and sum....
faddat Oct 17, 2021
fffe165
Got the correct branch in faddat/basecoin. Fully up to date with ups…
faddat Oct 17, 2021
547665a
fixed epoch tests
faddat Oct 17, 2021
e335e48
Marshaler -> Codec for tests
faddat Oct 17, 2021
40c3c1d
Update CHANGELOG.md
faddat Oct 18, 2021
48df7c5
Removed faddat/basecoin replace line
faddat Oct 18, 2021
9eca141
Merge remote-tracking branch 'origin/main' into faddat/sdk-0441
faddat Oct 18, 2021
face727
Merge branch 'main' of https://github.com/osmosis-labs/osmosis into f…
faddat Oct 18, 2021
1eec774
Merge branch 'faddat/sdk-0441' of https://github.com/osmosis-labs/osm…
faddat Oct 18, 2021
fe9e83f
Merge branch 'main' into faddat/sdk-0441
faddat Nov 19, 2021
0dd0f60
Update per my comments
ValarDragon Nov 19, 2021
8b8c4d2
Merge branch 'main' into faddat/sdk-0441
ValarDragon Nov 19, 2021
b2ca6cb
Fix more build / merge issues
ValarDragon Nov 19, 2021
ecd176a
Merge branch 'main' into faddat/sdk-0441
ValarDragon Nov 19, 2021
119a246
Add upgradekeeper definition
ValarDragon Nov 20, 2021
a745468
Update root command
ValarDragon Nov 20, 2021
f900989
Fix all remaining SetBalance/AddCoins -> FundAccount errors
ValarDragon Nov 20, 2021
bf50b9b
Fix NewMnemonic break
ValarDragon Nov 20, 2021
361c57a
More test fixes
ValarDragon Nov 21, 2021
09d8f07
More test fixes
ValarDragon Nov 21, 2021
18b305c
Fix gamm cli test cases setting incorrect expectErr
ValarDragon Nov 21, 2021
de6cabe
Fix claims test
ValarDragon Nov 21, 2021
c03353c
Try more fixes
ValarDragon Nov 21, 2021
291ecbc
Fix setup logic
ValarDragon Nov 21, 2021
6dacae5
Split simulation into its own test
ValarDragon Nov 21, 2021
5303fb0
comment out v4 upgrade fully, delete prop12 test
ValarDragon Nov 21, 2021
e6c0915
Restore paramproposal key
ValarDragon Nov 21, 2021
9121ab2
Fix simulation
ValarDragon Nov 21, 2021
5c7ab65
Fix hooks comments
ValarDragon Nov 21, 2021
081e533
Reverse ante handler decorator order
ValarDragon Nov 21, 2021
3f6afdd
Move app.Seal to where it is gaia/regen
ValarDragon Nov 21, 2021
41378a9
Delete sealed comment
ValarDragon Nov 21, 2021
eac2618
Restore the prior usage of blocked addrs
ValarDragon Nov 21, 2021
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
5 changes: 4 additions & 1 deletion .github/workflows/statesync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: State Sync
# or API.
on: [workflow_dispatch]

# This workflow tests state sync against the Notional archive server.
# This workflow tests state sync against the Notional archive server.
# To decentralize this workflow, add additional nodes to scripts/statesync.sh

jobs:
Expand All @@ -15,6 +15,9 @@ jobs:
name: osmosis state sync
steps:
- uses: actions/checkout@v2
- uses: actions/[email protected]
with:
go-version: '^1.17'

- name: state sync
run: bash scripts/statesync.sh
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

* Upgraded Osmosis to Cosmos-sdk 0.44.2
* Store block height in epochs module for debugging
* Allow zero-weight pool-incentive distribution records
* Fix bug in incentives epoch distribution events, used to use raw address, now uses bech32 addr
Expand Down
117 changes: 64 additions & 53 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ import (
"os"
"path/filepath"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"

abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
tmos "github.com/tendermint/tendermint/libs/os"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
dbm "github.com/tendermint/tm-db"

ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client"
paramproposal "github.com/cosmos/cosmos-sdk/x/params/types/proposal"
ibcclient "github.com/cosmos/ibc-go/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -62,13 +59,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
transfer "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer"
ibctransferkeeper "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/keeper"
ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc/applications/transfer/types"
ibc "github.com/cosmos/cosmos-sdk/x/ibc/core"
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/core/05-port/types"
ibchost "github.com/cosmos/cosmos-sdk/x/ibc/core/24-host"
ibckeeper "github.com/cosmos/cosmos-sdk/x/ibc/core/keeper"
"github.com/cosmos/cosmos-sdk/x/params"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
Expand All @@ -83,6 +73,15 @@ import (
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
transfer "github.com/cosmos/ibc-go/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/modules/core"
ibcclientclient "github.com/cosmos/ibc-go/modules/core/02-client/client"
porttypes "github.com/cosmos/ibc-go/modules/core/05-port/types"
ibchost "github.com/cosmos/ibc-go/modules/core/24-host"
ibckeeper "github.com/cosmos/ibc-go/modules/core/keeper"
"github.com/gorilla/mux"

appparams "github.com/osmosis-labs/osmosis/app/params"
_ "github.com/osmosis-labs/osmosis/client/docs/statik"
Expand Down Expand Up @@ -133,6 +132,7 @@ var (
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
poolincentivesclient.UpdatePoolIncentivesHandler,
ibcclientclient.UpdateClientProposalHandler, ibcclientclient.UpgradeProposalHandler,
),
params.AppModuleBasic{},
crisis.AppModuleBasic{},
Expand Down Expand Up @@ -183,7 +183,7 @@ var _ App = (*OsmosisApp)(nil)
type OsmosisApp struct {
*baseapp.BaseApp
cdc *codec.LegacyAmino
appCodec codec.Marshaler
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry

invCheckPeriod uint
Expand Down Expand Up @@ -248,7 +248,7 @@ func NewOsmosisApp(

bApp := baseapp.NewBaseApp(appName, logger, db, encodingConfig.TxConfig.TxDecoder(), baseAppOptions...)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetAppVersion(version.Version)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)

keys := sdk.NewKVStoreKeys(
Expand Down Expand Up @@ -288,8 +288,13 @@ func NewOsmosisApp(
appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms,
)
app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.BlockedAddrs(),
appCodec,
keys[banktypes.StoreKey],
app.AccountKeeper,
app.GetSubspace(banktypes.ModuleName),
app.ModuleAccountAddrs(),
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
)

stakingKeeper := stakingkeeper.NewKeeper(
appCodec, keys[stakingtypes.StoreKey], app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName),
)
Expand All @@ -304,32 +309,34 @@ func NewOsmosisApp(
app.CrisisKeeper = crisiskeeper.NewKeeper(
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath)

// this configures a no-op upgrade handler for the v2 upgrade,
// which improves the lockup module's store management.
app.UpgradeKeeper.SetUpgradeHandler(
"v4", func(ctx sdk.Context, plan upgradetypes.Plan) {
// Upgrade all of the lock storages
locks, err := app.LockupKeeper.GetLegacyPeriodLocks(ctx)
if err != nil {
panic(err)
}
// clear all lockup module locking / unlocking queue items
app.LockupKeeper.ClearAllLockRefKeys(ctx)
app.LockupKeeper.ClearAllAccumulationStores(ctx)
/*
// this configures a no-op upgrade handler for the v2 upgrade,
// which improves the lockup module's store management.
app.UpgradeKeeper.SetUpgradeHandler(
"v4", func(ctx sdk.Context, plan upgradetypes.Plan) {
// Upgrade all of the lock storages
locks, err := app.LockupKeeper.GetLegacyPeriodLocks(ctx)
if err != nil {
panic(err)
}
// clear all lockup module locking / unlocking queue items
app.LockupKeeper.ClearAllLockRefKeys(ctx)
app.LockupKeeper.ClearAllAccumulationStores(ctx)

// reset all lock and references
if err := app.LockupKeeper.ResetAllLocks(ctx, locks); err != nil {
panic(err)
}
// reset all lock and references
if err := app.LockupKeeper.ResetAllLocks(ctx, locks); err != nil {
panic(err)
}
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved

// configure upgrade for gamm module's pool creation fee param add
app.GAMMKeeper.SetParams(ctx, gammtypes.NewParams(sdk.Coins{sdk.NewInt64Coin("uosmo", 1)})) // 1 uOSMO
// configure upgrade for gamm module's pool creation fee param add
app.GAMMKeeper.SetParams(ctx, gammtypes.NewParams(sdk.Coins{sdk.NewInt64Coin("uosmo", 1)})) // 1 uOSMO

prop12(ctx, app)
prop12(ctx, app)

})
})

*/

app.UpgradeKeeper.SetUpgradeHandler("v5", func(ctx sdk.Context, plan upgradetypes.Plan) {
totalLiquidity := app.GAMMKeeper.GetLegacyTotalLiquidity(ctx)
Expand All @@ -339,8 +346,7 @@ func NewOsmosisApp(

// Create IBC Keeper
app.IBCKeeper = ibckeeper.NewKeeper(
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), &stakingKeeper, scopedIBCKeeper,
)
appCodec, keys[ibchost.StoreKey], app.GetSubspace(ibchost.ModuleName), app.StakingKeeper, app.UpgradeKeeper, scopedIBCKeeper)

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
Expand Down Expand Up @@ -395,10 +401,11 @@ func NewOsmosisApp(
// register the proposal types
govRouter := govtypes.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(paramstypes.QuerierRoute, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientUpdateProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(poolincentivestypes.RouterKey, poolincentives.NewPoolIncentivesProposalHandler(app.PoolIncentivesKeeper))

govKeeper := govkeeper.NewKeeper(
Expand Down Expand Up @@ -528,7 +535,7 @@ func NewOsmosisApp(

app.mm.RegisterInvariants(&app.CrisisKeeper)
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.mm.RegisterServices(module.NewConfigurator(app.MsgServiceRouter(), app.GRPCQueryRouter()))
app.mm.RegisterServices(module.NewConfigurator(app.AppCodec(), app.MsgServiceRouter(), app.GRPCQueryRouter()))

// create the simulation manager and define the order of the modules for deterministic simulations
//
Expand Down Expand Up @@ -568,14 +575,18 @@ func NewOsmosisApp(
// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
app.SetAnteHandler(
NewAnteHandler(
app.AccountKeeper, app.BankKeeper,
app.TxFeesKeeper, app.GAMMKeeper,
ante.DefaultSigVerificationGasConsumer,
encodingConfig.TxConfig.SignModeHandler(),
),
anteHandler, err := ante.NewAnteHandler(
ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
)
if err != nil {
panic(err)
}
app.SetAnteHandler(anteHandler)
app.SetEndBlocker(app.EndBlocker)

if loadLatest {
Expand All @@ -590,8 +601,8 @@ func NewOsmosisApp(
// that in-memory capabilities get regenerated on app restart.
// Note that since this reads from the store, we can only perform it when
// `loadLatest` is set to true.
ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{})
app.CapabilityKeeper.InitializeAndSeal(ctx)
// ctx := app.BaseApp.NewUncachedContext(true, tmproto.Header{})
app.CapabilityKeeper.Seal()
ValarDragon marked this conversation as resolved.
Show resolved Hide resolved
}

app.ScopedIBCKeeper = scopedIBCKeeper
Expand All @@ -603,7 +614,7 @@ func NewOsmosisApp(
// MakeCodecs constructs the *std.Codec and *codec.LegacyAmino instances used by
// simapp. It is useful for tests and clients who do not want to construct the
// full simapp
func MakeCodecs() (codec.Marshaler, *codec.LegacyAmino) {
func MakeCodecs() (codec.Codec, *codec.LegacyAmino) {
config := MakeEncodingConfig()
return config.Marshaler, config.Amino
}
Expand Down Expand Up @@ -669,7 +680,7 @@ func (app *OsmosisApp) LegacyAmino() *codec.LegacyAmino {
//
// NOTE: This is solely to be used for testing purposes as it may be desirable
// for modules to register their own custom testing types.
func (app *OsmosisApp) AppCodec() codec.Marshaler {
func (app *OsmosisApp) AppCodec() codec.Codec {
return app.appCodec
}

Expand Down Expand Up @@ -766,7 +777,7 @@ func GetMaccPerms() map[string][]string {
}

// initParamsKeeper init params keeper and its subspaces
func initParamsKeeper(appCodec codec.BinaryMarshaler, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper {
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)

paramsKeeper.Subspace(authtypes.ModuleName)
Expand Down
6 changes: 3 additions & 3 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func DefaultConfig() network.Config {
NumValidators: 1,
BondDenom: sdk.DefaultBondDenom,
MinGasPrices: fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom),
AccountTokens: sdk.TokensFromConsensusPower(1000),
StakingTokens: sdk.TokensFromConsensusPower(500),
BondedTokens: sdk.TokensFromConsensusPower(100),
AccountTokens: sdk.TokensFromConsensusPower(1000, sdk.NewIntFromUint64(1)),
StakingTokens: sdk.TokensFromConsensusPower(500, sdk.NewIntFromUint64(1)),
BondedTokens: sdk.TokensFromConsensusPower(100, sdk.NewIntFromUint64(1)),
PruningStrategy: storetypes.PruningOptionNothing,
CleanupDir: true,
SigningAlgo: string(hd.Secp256k1Type),
Expand Down
2 changes: 1 addition & 1 deletion app/params/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// This is provided for compatibility between protobuf and amino implementations.
type EncodingConfig struct {
InterfaceRegistry types.InterfaceRegistry
Marshaler codec.Marshaler
Marshaler codec.Codec
TxConfig client.TxConfig
Amino *codec.LegacyAmino
}
Loading