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

build: Upgrade to 0.43-beta1 and integrate x/authz & x/feegrant into stable #349

Merged
merged 36 commits into from
May 19, 2021
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e3c41cc
integrate x/authz and x/feegrant into stable
likhita-809 May 13, 2021
a0a072d
small fixes for build
likhita-809 May 13, 2021
f2e345c
fix lint issues
likhita-809 May 13, 2021
97f6d46
fix failing tests
likhita-809 May 13, 2021
9d0f263
Fixes in orm module
likhita-809 May 14, 2021
a4acd96
Cleanup ServiceMsg
aleem1314 May 14, 2021
9468d2a
move authz & feegrant into stable build
aleem1314 May 14, 2021
69d39c8
fix: build error
aleem1314 May 14, 2021
269d4df
wip
likhita-809 May 14, 2021
8f1a543
wip
likhita-809 May 14, 2021
e3264ce
fix: failing tests
aleem1314 May 14, 2021
ab8a0fe
Merge branch 'likhita/authz-and-feegrant-integration' of https://gith…
aleem1314 May 14, 2021
b049c52
feat: add upgrade handler
aleem1314 May 14, 2021
9530b5c
define AddrLen in app module
likhita-809 May 14, 2021
2078316
Merge branch 'likhita/authz-and-feegrant-integration' of https://gith…
likhita-809 May 14, 2021
1a63aa2
fix failed tests
likhita-809 May 14, 2021
5d10293
feat: minor refactor
aleem1314 May 14, 2021
e96c473
add IBCMockKeeper
likhita-809 May 14, 2021
4948418
remove commented code on wasm
likhita-809 May 14, 2021
0d7008d
small fix
likhita-809 May 14, 2021
e700956
remove commented code
aleem1314 May 14, 2021
87f618f
feat: regen app updates
aleem1314 May 17, 2021
702b17e
feat: add ConsensusVersion() to regen modules
aleem1314 May 17, 2021
76f3e17
fix: review changes
aleem1314 May 17, 2021
5882749
fix: review changes
aleem1314 May 17, 2021
41de9e0
Merge branch 'master' into likhita/authz-and-feegrant-integration
aleem1314 May 17, 2021
01f3a7e
Update app/addr_prefixes.go
aleem1314 May 17, 2021
028ffd8
Update app/experimental_appconfig.go
aleem1314 May 17, 2021
dc433c7
Update app/regen/cmd/genaccounts.go
aleem1314 May 17, 2021
6c87f89
remove commented code
aleem1314 May 17, 2021
804edaf
fix: build error
aleem1314 May 17, 2021
459e377
remove wasm comments
likhita-809 May 18, 2021
00cd84b
remove unused const in x/group/server/testsuite
likhita-809 May 18, 2021
974e987
fix: review changes
likhita-809 May 18, 2021
7f42e21
fix: review changes
likhita-809 May 19, 2021
de937f7
remove DefaultPowerReduction from app.go
likhita-809 May 19, 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
9 changes: 4 additions & 5 deletions app/addr_prefixes.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package app

import (
"encoding/binary"
"fmt"

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

const (
// AddrLen defines the length of an account's address
AddrLen = 20
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
// Bech32PrefixAccAddr defines the Bech32 prefix of an account's address
Bech32PrefixAccAddr = "regen"
// Bech32PrefixAccPub defines the Bech32 prefix of an account's public key
Expand All @@ -29,10 +31,7 @@ func init() {
config.SetBech32PrefixForConsensusNode(Bech32PrefixConsAddr, Bech32PrefixConsPub)
config.SetAddressVerifier(func(bytes []byte) error {
n := len(bytes)
if n == sdk.AddrLen {
return nil
}
if n <= binary.MaxVarintLen64+1 {
if (n != 0) && (n < address.MaxAddrLen) {
aleem1314 marked this conversation as resolved.
Show resolved Hide resolved
return nil
}
return fmt.Errorf("unexpected address length %d", n)
Expand Down
83 changes: 49 additions & 34 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"os"

"github.com/CosmWasm/wasmd/x/wasm"
// "github.com/CosmWasm/wasmd/x/wasm"
"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
Expand All @@ -29,6 +29,7 @@ import (
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
"github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
Expand All @@ -44,20 +45,12 @@ import (
"github.com/cosmos/cosmos-sdk/x/evidence"
evidencekeeper "github.com/cosmos/cosmos-sdk/x/evidence/keeper"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
"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"
"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"
ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/core/02-client"
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"
ibcmock "github.com/cosmos/cosmos-sdk/x/ibc/testing/mock"
"github.com/cosmos/cosmos-sdk/x/mint"
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
Expand All @@ -74,6 +67,14 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"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"
ibcclient "github.com/cosmos/ibc-go/modules/core/02-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"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
Expand Down Expand Up @@ -136,14 +137,15 @@ func init() {

// this changes the power reduction from 10e6 to 10e2 for the regen-test-1001 testnet which will give
// every validator 10,000 times more voting power than they currently have
sdk.PowerReduction = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(2), nil))
sdk.DefaultPowerReduction = sdk.NewIntFromBigInt(new(big.Int).Exp(big.NewInt(10), big.NewInt(2), nil))
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved

}

// Extended ABCI application
type RegenApp struct {
*baseapp.BaseApp
cdc *codec.LegacyAmino
appCodec codec.Marshaler
appCodec codec.Codec
interfaceRegistry types.InterfaceRegistry

invCheckPeriod uint
Expand All @@ -167,13 +169,15 @@ type RegenApp struct {
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
EvidenceKeeper evidencekeeper.Keeper
TransferKeeper ibctransferkeeper.Keeper
//nolint
wasmKeeper wasm.Keeper // only used in experimental builds
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper

// wasmKeeper wasm.Keeper // only used in experimental builds
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
ScopedTransferKeeper capabilitykeeper.ScopedKeeper
ScopedIBCMockKeeper capabilitykeeper.ScopedKeeper
// ScopedIBCMockKeeper capabilitykeeper.ScopedKeeper
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved

// the module manager
mm *module.Manager
Expand All @@ -187,6 +191,9 @@ type RegenApp struct {
// use ADR 33 approach without the need for removing their keepers
// and a larger refactoring.
smm *server.Manager

// module configurator
configurator module.Configurator
}

// NewRegenApp returns a reference to an initialized RegenApp.
Expand All @@ -201,7 +208,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest

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 @@ -238,7 +245,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName)
// NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do
// note replicate if you do not need to test core IBC or light clients.
scopedIBCMockKeeper := app.CapabilityKeeper.ScopeToModule(ibcmock.ModuleName)
// scopedIBCMockKeeper := app.CapabilityKeeper.ScopeToModule(ibcmock.ModuleName)

// add keepers
app.AccountKeeper = authkeeper.NewAccountKeeper(
Expand All @@ -265,7 +272,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName,
)

app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
app.registerUpgradeHandlers()

// register the staking hooks
Expand All @@ -276,7 +283,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest

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

// register the proposal types
Expand All @@ -285,7 +292,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
AddRoute(ibchost.RouterKey, ibcclient.NewClientUpdateProposalHandler(app.IBCKeeper.ClientKeeper))
AddRoute(ibchost.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper))

// Create Transfer Keepers
app.TransferKeeper = ibctransferkeeper.NewKeeper(
Expand All @@ -297,12 +304,12 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest

// NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do
// note replicate if you do not need to test core IBC or light clients.
mockModule := ibcmock.NewAppModule(scopedIBCMockKeeper)
// mockModule := ibcmock.NewAppModule(scopedIBCMockKeeper)
likhita-809 marked this conversation as resolved.
Show resolved Hide resolved

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := porttypes.NewRouter()
ibcRouter.AddRoute(ibctransfertypes.ModuleName, transferModule)
ibcRouter.AddRoute(ibcmock.ModuleName, mockModule)
// ibcRouter.AddRoute(ibcmock.ModuleName, mockModule)
app.IBCKeeper.SetRouter(ibcRouter)

// create evidence keeper with router
Expand Down Expand Up @@ -358,7 +365,6 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
evidencetypes.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
)
app.mm.SetOrderEndBlockers(crisistypes.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName)

// NOTE: The genutils module must occur after staking so that pools are
// properly initialized with tokens from genesis accounts.
// NOTE: Capability module must occur first so that it can initialize any capabilities
Expand All @@ -374,8 +380,8 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest

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

app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.configurator)
// create the simulation manager and define the order of the modules for deterministic simulations
//
// NOTE: this is not required apps that don't use the simulator for fuzz testing
Expand Down Expand Up @@ -407,12 +413,21 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
// initialize BaseApp
app.SetInitChainer(app.InitChainer)
app.SetBeginBlocker(app.BeginBlocker)
app.SetAnteHandler(
ante.NewAnteHandler(
app.AccountKeeper, app.BankKeeper, ante.DefaultSigVerificationGasConsumer,
encodingConfig.TxConfig.SignModeHandler(),
),
anteHandler, err := ante.NewAnteHandler(
ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
FeegrantKeeper: app.FeeGrantKeeper,
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
)
if err != nil {
panic(err)
}

app.SetAnteHandler(anteHandler)

app.SetEndBlocker(app.EndBlocker)

if loadLatest {
Expand All @@ -436,15 +451,15 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest

// NOTE: the IBC mock keeper and application module is used only for testing core IBC. Do
// note replicate if you do not need to test core IBC or light clients.
app.ScopedIBCMockKeeper = scopedIBCMockKeeper
// app.ScopedIBCMockKeeper = scopedIBCMockKeeper

return app
}

// MakeCodecs constructs the *std.Codec and *codec.LegacyAmino instances used by
// Regenapp. It is useful for tests and clients who do not want to construct the
// full Regenapp
func MakeCodecs() (codec.Marshaler, *codec.LegacyAmino) {
func MakeCodecs() (codec.Codec, *codec.LegacyAmino) {
config := MakeEncodingConfig()
return config.Marshaler, config.Amino
}
Expand Down Expand Up @@ -497,7 +512,7 @@ func (app *RegenApp) 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 *RegenApp) AppCodec() codec.Marshaler {
func (app *RegenApp) AppCodec() codec.Codec {
return app.appCodec
}

Expand Down Expand Up @@ -591,7 +606,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
Loading