Skip to content

Commit

Permalink
feat: upgrade to v0.52.0-beta.1
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Oct 3, 2024
1 parent 4628e03 commit 35ee601
Show file tree
Hide file tree
Showing 13 changed files with 483 additions and 708 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/[email protected]
with:
go-version: "1.21"
go-version: "1.23"
check-latest: true
env:
GOOS: ${{ matrix.targetos }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.23"
check-latest: true
cache: true
cache-dependency-path: go.sum
Expand Down
54 changes: 18 additions & 36 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,24 @@ import (
_ "embed"
"io"

dbm "github.com/cosmos/cosmos-db"

"cosmossdk.io/core/appconfig"
"cosmossdk.io/core/registry"
corestore "cosmossdk.io/core/store"
"cosmossdk.io/depinject"
"cosmossdk.io/depinject/appconfig"
"cosmossdk.io/log"
storetypes "cosmossdk.io/store/types"

_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
clienthelpers "cosmossdk.io/client/v2/helpers"
_ "cosmossdk.io/x/accounts" // import for side-effects
_ "cosmossdk.io/x/bank" // import for side-effects
_ "cosmossdk.io/x/consensus" // import for side-effects
_ "cosmossdk.io/x/distribution" // import for side-effects
distrkeeper "cosmossdk.io/x/distribution/keeper"
_ "cosmossdk.io/x/mint" // import for side-effects
_ "cosmossdk.io/x/staking" // import for side-effects
stakingkeeper "cosmossdk.io/x/staking/keeper"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -22,23 +32,8 @@ import (
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
"github.com/cosmos/cosmos-sdk/types/module"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
consensuskeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/auth" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/auth/tx/config" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/bank" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/consensus" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/distribution" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/mint" // import for side-effects
_ "github.com/cosmos/cosmos-sdk/x/staking" // import for side-effects
)

// DefaultNodeHome default home directories for the application daemon
Expand All @@ -57,17 +52,14 @@ var (
// capabilities aren't needed for testing.
type MiniApp struct {
*runtime.App
legacyAmino *codec.LegacyAmino
legacyAmino registry.AminoRegistrar
appCodec codec.Codec
txConfig client.TxConfig
interfaceRegistry codectypes.InterfaceRegistry

// keepers
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
DistrKeeper distrkeeper.Keeper
ConsensusParamsKeeper consensuskeeper.Keeper
StakingKeeper *stakingkeeper.Keeper
DistrKeeper distrkeeper.Keeper

// simulation manager
sm *module.SimulationManager
Expand All @@ -86,20 +78,13 @@ func init() {
func AppConfig() depinject.Config {
return depinject.Configs(
appconfig.LoadYAML(AppConfigYAML),
depinject.Supply(
&appv1alpha1.Config{}, // hack until https://github.com/cosmos/cosmos-sdk/pull/21042
// supply custom module basics
map[string]module.AppModuleBasic{
genutiltypes.ModuleName: genutil.NewAppModuleBasic(genutiltypes.DefaultMessageValidator),
},
),
)
}

// NewMiniApp returns a reference to an initialized MiniApp.
func NewMiniApp(
logger log.Logger,
db dbm.DB,
db corestore.KVStoreWithBatch,
traceStore io.Writer,
loadLatest bool,
appOpts servertypes.AppOptions,
Expand All @@ -123,11 +108,8 @@ func NewMiniApp(
&app.legacyAmino,
&app.txConfig,
&app.interfaceRegistry,
&app.AccountKeeper,
&app.BankKeeper,
&app.StakingKeeper,
&app.DistrKeeper,
&app.ConsensusParamsKeeper,
); err != nil {
return nil, err
}
Expand All @@ -154,7 +136,7 @@ func NewMiniApp(
}

// LegacyAmino returns MiniApp's amino codec.
func (app *MiniApp) LegacyAmino() *codec.LegacyAmino {
func (app *MiniApp) LegacyAmino() registry.AminoRegistrar {
return app.legacyAmino
}

Expand Down
8 changes: 7 additions & 1 deletion app/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ modules:
end_blockers: [staking]
# NOTE: The genutils module must occur after staking so that pools are properly initialized with tokens from genesis accounts.
# NOTE: The genutils module must also occur after auth so that it can access the params from auth.
init_genesis: [auth, bank, distribution, staking, genutil]
init_genesis:
[consensus, accounts, auth, bank, distribution, staking, genutil]
override_store_keys:
- module_name: auth
kv_store_key: acc
- module_name: accounts
kv_store_key: _accounts
- name: accounts
config:
"@type": cosmos.accounts.module.v1.Module
- name: auth
config:
"@type": cosmos.auth.module.v1.Module
Expand Down
42 changes: 2 additions & 40 deletions app/params/config.go → app/config.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
package params
package app

import (
"cosmossdk.io/errors"
"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/address"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

const (
CoinUnit = "mini"

DefaultBondDenom = CoinUnit

// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address.
Bech32PrefixAccAddr = "mini"
)
Expand All @@ -32,38 +23,9 @@ var (
)

func init() {
SetAddressPrefixes()
RegisterDenoms()
}

func RegisterDenoms() {
err := sdk.RegisterDenom(CoinUnit, math.LegacyOneDec())
if err != nil {
panic(err)
}
}

func SetAddressPrefixes() {
config := sdk.GetConfig()
config.SetBech32PrefixForAccount(Bech32PrefixAccAddr, Bech32PrefixAccPub)
config.SetBech32PrefixForValidator(Bech32PrefixValAddr, Bech32PrefixValPub)
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)

// This is copied from the cosmos sdk v0.43.0-beta1
// source: https://github.com/cosmos/cosmos-sdk/blob/v0.43.0-beta1/types/address.go#L141
config.SetAddressVerifier(func(bytes []byte) error {
if len(bytes) == 0 {
return errors.Wrap(sdkerrors.ErrUnknownAddress, "addresses cannot be empty")
}

if len(bytes) > address.MaxAddrLen {
return errors.Wrapf(sdkerrors.ErrUnknownAddress, "address max length is %d, got %d", address.MaxAddrLen, len(bytes))
}

if len(bytes) != 20 && len(bytes) != 32 {
return errors.Wrapf(sdkerrors.ErrUnknownAddress, "address length must be 20 or 32 bytes, got %d", len(bytes))
}

return nil
})
config.Seal()
}
Loading

0 comments on commit 35ee601

Please sign in to comment.