Skip to content

Commit

Permalink
Wire up paramauthority (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin authored Jan 18, 2023
1 parent aa7e5bd commit eb375f0
Show file tree
Hide file tree
Showing 36 changed files with 1,063 additions and 503 deletions.
31 changes: 22 additions & 9 deletions .github/workflows/docker-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ jobs:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v1
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
id: go

- name: checkout chain
Expand All @@ -76,10 +76,10 @@ jobs:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.18
uses: actions/setup-go@v1
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.18
go-version: 1.19
id: go

- name: checkout chain
Expand All @@ -89,6 +89,19 @@ jobs:
env:
BRANCH_CI: ${{needs.build-and-push-image.outputs.branchTag}}




test-param-authority:
runs-on: ubuntu-latest
needs: build-and-push-image
steps:
- name: Set up Go 1.19
uses: actions/setup-go@v3
with:
go-version: 1.19
id: go

- name: checkout chain
uses: actions/checkout@v2

- run: make ibctest-paramauthority
env:
BRANCH_CI: ${{needs.build-and-push-image.outputs.branchTag}}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.18-alpine as BUILD
FROM --platform=$BUILDPLATFORM golang:1.19-alpine as BUILD

WORKDIR /noble

Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ ibctest-tkn-factory:
ibctest-packet-forward:
cd ibctest && go test -race -v -run TestPacketForwardMiddleware .

ibctest-paramauthority:
cd ibctest && go test -race -v -run TestNobleParamAuthority .


###############################################################################
### Build Image ###
Expand Down
18 changes: 9 additions & 9 deletions app/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ import (

type HandlerOptions struct {
ante.HandlerOptions
tokenfactorykeeper tokenfactory.Keeper
tokenFactoryKeeper *tokenfactory.Keeper
IBCKeeper *ibckeeper.Keeper
ConsumerKeeper ibcconsumerkeeper.Keeper
}

type IsPausedDecorator struct {
tokenfactory tokenfactory.Keeper
tokenfactory *tokenfactory.Keeper
}

func NewIsPausedDecorator(tk tokenfactory.Keeper) IsPausedDecorator {
func NewIsPausedDecorator(tk *tokenfactory.Keeper) IsPausedDecorator {
return IsPausedDecorator{
tokenfactory: tk,
}
Expand All @@ -49,10 +49,10 @@ func (ad IsPausedDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool
}

type IsBlacklistedDecorator struct {
tokenfactory tokenfactory.Keeper
tokenfactory *tokenfactory.Keeper
}

func NewIsBlacklistedDecorator(tk tokenfactory.Keeper) IsBlacklistedDecorator {
func NewIsBlacklistedDecorator(tk *tokenfactory.Keeper) IsBlacklistedDecorator {
return IsBlacklistedDecorator{
tokenfactory: tk,
}
Expand Down Expand Up @@ -125,8 +125,8 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {
anteDecorators := []sdk.AnteDecorator{
ante.NewSetUpContextDecorator(), // outermost AnteDecorator. SetUpContext must be called first
ante.NewRejectExtensionOptionsDecorator(),
NewIsBlacklistedDecorator(options.tokenfactorykeeper),
NewIsPausedDecorator(options.tokenfactorykeeper),
NewIsBlacklistedDecorator(options.tokenFactoryKeeper),
NewIsPausedDecorator(options.tokenFactoryKeeper),
// temporarily disabled so that chain can be tested locally without the provider chain running
// consumerante.NewMsgFilterDecorator(options.ConsumerKeeper),
consumerante.NewDisabledModulesDecorator("/cosmos.evidence", "/cosmos.slashing"),
Expand All @@ -147,7 +147,7 @@ func NewAnteHandler(options HandlerOptions) (sdk.AnteHandler, error) {

}

func checkIfMintedAsset(ctx sdk.Context, denom string, k tokenfactory.Keeper) bool {
mintingDenom := tokenfactory.Keeper.GetMintingDenom(k, ctx)
func checkIfMintedAsset(ctx sdk.Context, denom string, k *tokenfactory.Keeper) bool {
mintingDenom := k.GetMintingDenom(ctx)
return mintingDenom.Denom == denom
}
40 changes: 22 additions & 18 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,11 @@ import (
"github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/params"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
"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"
ica "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host"
Expand All @@ -76,6 +73,11 @@ import (
packetforward "github.com/strangelove-ventures/packet-forward-middleware/v3/router"
packetforwardkeeper "github.com/strangelove-ventures/packet-forward-middleware/v3/router/keeper"
packetforwardtypes "github.com/strangelove-ventures/packet-forward-middleware/v3/router/types"
paramauthority "github.com/strangelove-ventures/paramauthority/x/params"
paramauthoritykeeper "github.com/strangelove-ventures/paramauthority/x/params/keeper"
paramauthorityupgrade "github.com/strangelove-ventures/paramauthority/x/upgrade"
paramauthorityupgradekeeper "github.com/strangelove-ventures/paramauthority/x/upgrade/keeper"

abci "github.com/tendermint/tendermint/abci/types"
tmjson "github.com/tendermint/tendermint/libs/json"
"github.com/tendermint/tendermint/libs/log"
Expand Down Expand Up @@ -109,12 +111,12 @@ var (
authzmodule.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
params.AppModuleBasic{},
paramauthority.AppModuleBasic{},
crisis.AppModuleBasic{},
slashing.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
ibc.AppModuleBasic{},
upgrade.AppModuleBasic{},
paramauthorityupgrade.AppModuleBasic{},
evidence.AppModuleBasic{},
transfer.AppModuleBasic{},
ica.AppModuleBasic{},
Expand Down Expand Up @@ -177,8 +179,8 @@ type App struct {
CapabilityKeeper *capabilitykeeper.Keeper
SlashingKeeper slashingkeeper.Keeper
CrisisKeeper crisiskeeper.Keeper
UpgradeKeeper upgradekeeper.Keeper
ParamsKeeper paramskeeper.Keeper
UpgradeKeeper paramauthorityupgradekeeper.Keeper
ParamsKeeper paramauthoritykeeper.Keeper
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
Expand All @@ -193,7 +195,7 @@ type App struct {
ScopedICAHostKeeper capabilitykeeper.ScopedKeeper
ScopedCCVConsumerKeeper capabilitykeeper.ScopedKeeper

TokenfactoryKeeper tokenfactorymodulekeeper.Keeper
TokenFactoryKeeper *tokenfactorymodulekeeper.Keeper

// this line is used by starport scaffolding # stargate/app/keeperDeclaration

Expand Down Expand Up @@ -315,12 +317,13 @@ func New(
app.AccountKeeper,
)

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

// ... other modules keepers
Expand Down Expand Up @@ -405,14 +408,14 @@ func New(
app.ConsumerKeeper = *app.ConsumerKeeper.SetHooks(app.SlashingKeeper.Hooks())
consumerModule := ccvconsumer.NewAppModule(app.ConsumerKeeper)

app.TokenfactoryKeeper = *tokenfactorymodulekeeper.NewKeeper(
app.TokenFactoryKeeper = tokenfactorymodulekeeper.NewKeeper(
appCodec,
keys[tokenfactorymoduletypes.StoreKey],
app.GetSubspace(tokenfactorymoduletypes.ModuleName),

app.BankKeeper,
)
tokenfactoryModule := tokenfactorymodule.NewAppModule(appCodec, app.TokenfactoryKeeper, app.AccountKeeper, app.BankKeeper)
tokenfactoryModule := tokenfactorymodule.NewAppModule(appCodec, app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper)

var transferStack ibcporttypes.IBCModule
transferStack = transfer.NewIBCModule(app.TransferKeeper)
Expand All @@ -423,7 +426,7 @@ func New(
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp,
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp,
)
transferStack = tokenfactorymodule.NewIBCMiddleware(transferStack, app.TokenfactoryKeeper)
transferStack = tokenfactorymodule.NewIBCMiddleware(transferStack, app.TokenFactoryKeeper)

// Create static IBC router, add transfer route, then set and seal it
ibcRouter := ibcporttypes.NewRouter()
Expand Down Expand Up @@ -451,10 +454,10 @@ func New(
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper),
upgrade.NewAppModule(app.UpgradeKeeper),
paramauthorityupgrade.NewAppModule(app.UpgradeKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
paramauthority.NewAppModule(app.ParamsKeeper),
transferModule,
icaModule,
consumerModule,
Expand Down Expand Up @@ -553,7 +556,7 @@ func New(
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.ConsumerKeeper),
params.NewAppModule(app.ParamsKeeper),
paramauthority.NewAppModule(app.ParamsKeeper),
evidence.NewAppModule(app.EvidenceKeeper),
ibc.NewAppModule(app.IBCKeeper),
transferModule,
Expand All @@ -580,7 +583,7 @@ func New(
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
tokenfactorykeeper: app.TokenfactoryKeeper,
tokenFactoryKeeper: app.TokenFactoryKeeper,
IBCKeeper: app.IBCKeeper,
ConsumerKeeper: app.ConsumerKeeper,
},
Expand Down Expand Up @@ -746,8 +749,8 @@ func GetMaccPerms() map[string][]string {
}

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

paramsKeeper.Subspace(authtypes.ModuleName)
paramsKeeper.Subspace(banktypes.ModuleName)
Expand All @@ -759,6 +762,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(icahosttypes.SubModuleName)
paramsKeeper.Subspace(ccvconsumertypes.ModuleName)
paramsKeeper.Subspace(tokenfactorymoduletypes.ModuleName)
paramsKeeper.Subspace(upgradetypes.ModuleName)
// this line is used by starport scaffolding # stargate/app/paramSubspace

return paramsKeeper
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func NewRootCmd(

rootCmd := &cobra.Command{
Use: appName + "d",
Short: "Stargate CosmosHub App",
Short: "Noble App",
PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {
// set the default command outputs
cmd.SetOut(cmd.OutOrStdout())
Expand Down
13 changes: 7 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ require (
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/strangelove-ventures/packet-forward-middleware/v3 v3.1.1
github.com/strangelove-ventures/paramauthority v0.0.0-20230118074850-b40c4c394865
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.24
github.com/tendermint/tm-db v0.6.7
google.golang.org/genproto v0.0.0-20221114212237-e4508ebdbee1
google.golang.org/grpc v1.50.1
google.golang.org/genproto v0.0.0-20230113154510-dbe35b8444a5
google.golang.org/grpc v1.52.0
gopkg.in/yaml.v2 v2.4.0

)
Expand Down Expand Up @@ -120,10 +121,10 @@ require (
go.etcd.io/bbolt v1.3.6 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect
golang.org/x/net v0.2.0 // indirect
golang.org/x/sys v0.2.0 // indirect
golang.org/x/term v0.2.0 // indirect
golang.org/x/text v0.4.0 // indirect
golang.org/x/net v0.4.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/term v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
google.golang.org/protobuf v1.28.2-0.20220831092852-f930b1dc76e8 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
Loading

0 comments on commit eb375f0

Please sign in to comment.