Skip to content

Commit

Permalink
merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Apr 8, 2024
2 parents f030223 + 0583a63 commit c881cb9
Show file tree
Hide file tree
Showing 50 changed files with 2,677 additions and 3,444 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ jobs:
export VERSION=${{ needs.build_init.outputs.version }}
make build-release-zip
- name: Provenanced version
# TODO[1760]: github: Re-enable the build_osx provenanced version step.
if: false
run: build/provenanced version --long
- uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -105,12 +103,7 @@ jobs:
export VERSION=${{ needs.build_init.outputs.version }}
make build-release-zip
- name: Provenanced version
# TODO[1760]: github: Re-enable the build_linux provenanced version step.
if: false
run: build/provenanced version --long
- name: Compile Tests
# TODO[1760]: github: Delete this build_linux Compile Tests step.
run: go test -mod=readonly -timeout 30m -tags='norace ledger test_ledger_mock' -run='ZYX_NOT_A_REAL_TEST_XZY' ./...
- uses: actions/upload-artifact@v4
with:
name: linux-zip
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,25 @@ jobs:
build-tests:
# TODO[1760]: Delete this build-tests action once the tests reliably pass again.
needs: setup-tests
strategy:
fail-fast: false
matrix:
part: ["00", "01", "02", "03"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
if: needs.setup-tests.outputs.should-run
with:
go-version: ${{ needs.setup-tests.outputs.go-version }}
- uses: actions/download-artifact@v4
if: needs.setup-tests.outputs.should-run
with:
name: "${{ needs.setup-tests.outputs.file-prefix }}-pkgs.txt.part.${{ matrix.part }}"
- name: build tests
if: needs.setup-tests.outputs.should-run
run: |
make build-tests
cat pkgs.txt.part.${{ matrix.part }} | xargs go test -mod=readonly -timeout 30m -tags='norace ledger test_ledger_mock' -run='ZYX_NOPE_NOPE_XYZ'
# This action performs a code coverage assessment but filters out generated code from proto based types
# and grpc services
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,17 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Improvements

* Remove unsupported database types [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Update ibc and migrate params [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Replace ModuleBasics with BasicModuleManager [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Remove handlers from provenance modules [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Updated app.go to use RegisterStreamingServices on BaseApp [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Bump the SDK to `v0.50.5-pio-1` (from an earlier ephemeral version) [#1897](https://github.com/provenance-io/provenance/pull/1897).

### Dependencies

- Bump `github.com/cosmos/ibc-go/v8` from 8.0.0 to 8.2.0 ([#1910](https://github.com/provenance-io/provenance/pull/1910))
- Bump `google.golang.org/grpc` from 1.62.1 to 1.63.0 ([#1903](https://github.com/provenance-io/provenance/pull/1903))

---

## [v1.18.0](https://github.com/provenance-io/provenance/releases/tag/v1.18.0) - 2024-03-22
Expand Down
50 changes: 26 additions & 24 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ var (
// DefaultPowerReduction pio specific value for power reduction for TokensFromConsensusPower
DefaultPowerReduction = sdkmath.NewIntFromUint64(1_000_000_000)

<<<<<<< HEAD

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (03)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-linux

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / Build Linux

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / Build OSX

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected <<, expected name

Check failure on line 191 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected <<, expected name
// ModuleBasics defines the module BasicManager is in charge of setting up basic,
// non-dependant module elements, such as codec registration
// and genesis verification.
Expand Down Expand Up @@ -237,6 +238,8 @@ var (
exchangemodule.AppModuleBasic{},
)

=======

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (03)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (03)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-linux

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / build-tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / tests (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / Build Linux

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (03)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (02)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (00)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / Build OSX

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected ==, expected name

Check failure on line 241 in app/app.go

View workflow job for this annotation

GitHub Actions / test-race (01)

syntax error: unexpected ==, expected name
>>>>>>> main
// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
Expand Down Expand Up @@ -442,7 +445,7 @@ func New(
app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])

// set the BaseApp's parameter store
// TODO[1760]: Update upgrade handler

app.ConsensusParamsKeeper = consensusparamkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(keys[consensusparamtypes.StoreKey]),
Expand Down Expand Up @@ -827,25 +830,24 @@ func New(
icaModule,
)

// TODO[1760]: app-module: BasicModuleManager: Make sure that this setup has everything we need (it was just copied from the SDK).
// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
// non-dependant module elements, such as codec registration and genesis verification.
// By default it is composed of all the module from the module manager.
// Additionally, app module basics can be overwritten by passing them as argument.
/*
app.BasicModuleManager = module.NewBasicManagerFromManager(
app.mm,
map[string]module.AppModuleBasic{
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
govtypes.ModuleName: gov.NewAppModuleBasic(
[]govclient.ProposalHandler{
paramsclient.ProposalHandler,
},
app.BasicModuleManager = module.NewBasicManagerFromManager(
app.mm,
map[string]module.AppModuleBasic{
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
govtypes.ModuleName: gov.NewAppModuleBasic(
append(
[]govclient.ProposalHandler{},
paramsclient.ProposalHandler,
nameclient.RootNameProposalHandler,
),
})
app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino)
app.BasicModuleManager.RegisterInterfaces(interfaceRegistry)
*/
),
})
app.BasicModuleManager.RegisterLegacyAminoCodec(legacyAmino)
app.BasicModuleManager.RegisterInterfaces(interfaceRegistry)

// NOTE: upgrade module is required to be prioritized
app.mm.SetOrderPreBlockers(
Expand Down Expand Up @@ -1283,9 +1285,8 @@ func (app *App) InterfaceRegistry() types.InterfaceRegistry {
}

// DefaultGenesis returns a default genesis from the registered AppModuleBasic's.
func (a *App) DefaultGenesis() map[string]json.RawMessage {
// TODO[1760] This was changed to ModuleBasics, but it will be removed
return ModuleBasics.DefaultGenesis(a.appCodec)
func (app *App) DefaultGenesis() map[string]json.RawMessage {
return app.BasicModuleManager.DefaultGenesis(app.appCodec)
}

// GetKey returns the KVStoreKey for the provided store key.
Expand Down Expand Up @@ -1336,7 +1337,7 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig serverconfig.API
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// Register grpc-gateway routes for all modules.
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// register swagger API from root so that other applications can override easily
if apiConfig.Swagger {
Expand Down Expand Up @@ -1403,11 +1404,12 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
// register the key tables for legacy param subspaces
keyTable := ibcclienttypes.ParamKeyTable()
keyTable.RegisterParamSet(&ibcconnectiontypes.Params{})
paramsKeeper.Subspace(ibctransfertypes.ModuleName) // TODO[1760]: params: Migrate ibc-transfer params.
paramsKeeper.Subspace(ibcexported.ModuleName) // TODO[1760]: params: Migrate ibc-host params.
paramsKeeper.Subspace(icahosttypes.SubModuleName) // TODO[1760]: params: Migrate ica-host params.
paramsKeeper.Subspace(icqtypes.ModuleName) // TODO[1760]: params: Migrate icq params.
paramsKeeper.Subspace(ibchookstypes.ModuleName) // TODO[1760]: params: Migrate ibc-hooks params.
paramsKeeper.Subspace(ibcexported.ModuleName).WithKeyTable(keyTable)
paramsKeeper.Subspace(ibctransfertypes.ModuleName).WithKeyTable(ibctransfertypes.ParamKeyTable())
paramsKeeper.Subspace(icahosttypes.SubModuleName).WithKeyTable(icahosttypes.ParamKeyTable())

paramsKeeper.Subspace(icqtypes.ModuleName) // TODO[1760]: params: Migrate icq params.
paramsKeeper.Subspace(ibchookstypes.ModuleName) // TODO[1760]: params: Migrate ibc-hooks params.

return paramsKeeper
}
Expand Down
15 changes: 13 additions & 2 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,17 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) {
)
}

// finalize block so we have CheckTx state set
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
Height: 1,
})
require.NoError(t, err)

app.Commit()

// Making a new app object with the db, so that initchain hasn't been called
app2 := New(log.NewTestLogger(t), opts.DB, nil, true,
map[int64]bool{}, opts.HomePath, 0, opts.EncConfig, simtestutil.EmptyAppOptions{})
var err error
map[int64]bool{}, opts.HomePath, 0, MakeEncodingConfig(), simtestutil.EmptyAppOptions{})
require.NotPanics(t, func() {
_, err = app2.ExportAppStateAndValidators(false, nil, nil)
}, "exporting app state at current height")
Expand Down Expand Up @@ -144,6 +149,12 @@ func TestExportAppStateAndValidators(t *testing.T) {
allAccounts := app.AccountKeeper.GetAllAccounts(ctx)
logAccounts(t, allAccounts, "allAccounts")

// finalize block so we have CheckTx state set
_, err := app.FinalizeBlock(&abci.RequestFinalizeBlock{
Height: 1,
})
require.NoError(t, err)

app.Commit()

// Get an export
Expand Down
4 changes: 0 additions & 4 deletions app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package app

import (
"github.com/cosmos/cosmos-sdk/std"

"github.com/provenance-io/provenance/app/params"
)

Expand All @@ -14,8 +13,5 @@ func MakeEncodingConfig() params.EncodingConfig {
encodingConfig := params.MakeTestEncodingConfig()
std.RegisterLegacyAminoCodec(encodingConfig.Amino)
std.RegisterInterfaces(encodingConfig.InterfaceRegistry)

ModuleBasics.RegisterLegacyAminoCodec(encodingConfig.Amino)
ModuleBasics.RegisterInterfaces(encodingConfig.InterfaceRegistry)
return encodingConfig
}
7 changes: 0 additions & 7 deletions app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package app

import (
"encoding/json"

"github.com/cosmos/cosmos-sdk/codec"
)

// The genesis state of the blockchain is represented here as a map of raw json
Expand All @@ -14,8 +12,3 @@ import (
// the ModuleBasicManager which populates json from each BasicModule
// object provided to it during init.
type GenesisState map[string]json.RawMessage

// NewDefaultGenesisState generates the default state for the application.
func NewDefaultGenesisState(cdc codec.JSONCodec) GenesisState {
return ModuleBasics.DefaultGenesis(cdc)
}
8 changes: 4 additions & 4 deletions app/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func setup(t *testing.T, withGenesis bool, invCheckPeriod uint, chainID string)

app := New(loggerMaker(), db, nil, true, map[int64]bool{}, t.TempDir(), invCheckPeriod, encCdc, simtestutil.EmptyAppOptions{}, baseapp.SetChainID(chainID))
if withGenesis {
return app, NewDefaultGenesisState(encCdc.Marshaler)
return app, app.DefaultGenesis()
}
return app, GenesisState{}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ func NewAppWithCustomOptions(t *testing.T, isCheckTx bool, options SetupOptions)
}

app := New(options.Logger, options.DB, nil, true, options.SkipUpgradeHeights, options.HomePath, options.InvCheckPeriod, options.EncConfig, options.AppOpts)
genesisState := NewDefaultGenesisState(app.appCodec)
genesisState := app.DefaultGenesis()
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance)

if !isCheckTx {
Expand Down Expand Up @@ -223,7 +223,7 @@ func genesisStateWithValSet(t *testing.T,
bondAmt := sdk.DefaultPowerReduction

for _, val := range valSet.Validators {
pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey)
pk, err := cryptocodec.FromCmtPubKeyInterface(val.PubKey)
require.NoError(t, err)
pkAny, err := codectypes.NewAnyWithValue(pk)
require.NoError(t, err)
Expand Down Expand Up @@ -352,7 +352,7 @@ func GenesisStateWithSingleValidator(t *testing.T, app *App) GenesisState {
},
}

genesisState := NewDefaultGenesisState(app.appCodec)
genesisState := app.DefaultGenesis()
genesisState = genesisStateWithValSet(t, app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balances...)

return genesisState
Expand Down
75 changes: 72 additions & 3 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import (
storetypes "cosmossdk.io/store/types"
upgradetypes "cosmossdk.io/x/upgrade/types"

icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"

"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
icqtypes "github.com/cosmos/ibc-apps/modules/async-icq/v8/types"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
"github.com/cosmos/ibc-go/v8/modules/core/exported"

ibctmmigrations "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint/migrations"
"github.com/provenance-io/provenance/x/exchange"
"github.com/provenance-io/provenance/x/hold"
ibchookstypes "github.com/provenance-io/provenance/x/ibchooks/types"
Expand Down Expand Up @@ -168,11 +170,26 @@ var upgrades = map[string]appUpgrade{
Added: []string{crisistypes.ModuleName},
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error

if err := pruneIBCExpiredConsensusStates(ctx, app); err != nil {
return nil, err
}

err = migrateBaseappParams(ctx, app)
if err != nil {
return nil, err
}

vm, err = runModuleMigrations(ctx, app, vm)
if err != nil {
return nil, err
}

err = updateIBCClients(ctx, app)
if err != nil {
return nil, err
}

removeInactiveValidatorDelegations(ctx, app)

return vm, nil
Expand All @@ -182,11 +199,26 @@ var upgrades = map[string]appUpgrade{
Added: []string{crisistypes.ModuleName},
Handler: func(ctx sdk.Context, app *App, vm module.VersionMap) (module.VersionMap, error) {
var err error

if err := pruneIBCExpiredConsensusStates(ctx, app); err != nil {
return nil, err
}

err = migrateBaseappParams(ctx, app)
if err != nil {
return nil, err
}

vm, err = runModuleMigrations(ctx, app, vm)
if err != nil {
return nil, err
}

err = updateIBCClients(ctx, app)
if err != nil {
return nil, err
}

removeInactiveValidatorDelegations(ctx, app)

return vm, nil
Expand Down Expand Up @@ -447,6 +479,43 @@ func updateIbcMarkerDenomMetadata(ctx sdk.Context, app *App) {
ctx.Logger().Info("Done updating ibc marker denom metadata")
}

// pruneIBCExpiredConsensusStates prunes expired consensus states for IBC.
func pruneIBCExpiredConsensusStates(ctx sdk.Context, app *App) error {
ctx.Logger().Info("Pruning expired consensus states for IBC.")
_, err := ibctmmigrations.PruneExpiredConsensusStates(ctx, app.appCodec, app.IBCKeeper.ClientKeeper)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("unable to prune expired consensus states, error: %s.", err))
return err
}
ctx.Logger().Info("Done pruning expired consensus states for IBC.")
return nil
}

// updateIBCClients updates the allowed clients for IBC.
// TODO: Remove with the umber handlers.
func updateIBCClients(ctx sdk.Context, app *App) error {
ctx.Logger().Info("Updating IBC AllowedClients.")
params := app.IBCKeeper.ClientKeeper.GetParams(ctx)
params.AllowedClients = append(params.AllowedClients, exported.Localhost)
app.IBCKeeper.ClientKeeper.SetParams(ctx, params)
ctx.Logger().Info("Done updating IBC AllowedClients.")
return nil
}

// migrateBaseappParams migrates to new ConsensusParamsKeeper
// TODO: Remove with the umber handlers.
func migrateBaseappParams(ctx sdk.Context, app *App) error {
ctx.Logger().Info("Migrating legacy params.")
legacyBaseAppSubspace := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())
err := baseapp.MigrateParams(ctx, legacyBaseAppSubspace, app.ConsensusParamsKeeper.ParamsStore)
if err != nil {
ctx.Logger().Error(fmt.Sprintf("unable to migrate legacy params to ConsensusParamsKeeper, error: %s.", err))
return err
}
ctx.Logger().Info("Done migrating legacy params.")
return nil
}

// convertNavUnits iterates all the net asset values and updates their units if they are using usd.
// TODO: Remove with the tourmaline handlers.
func convertNavUnits(ctx sdk.Context, app *App) {
Expand Down
Loading

0 comments on commit c881cb9

Please sign in to comment.