Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
## [Unreleased]

### Features

- [1555](https://github.com/umee-network/umee/pull/1555) Updates IBC to v5.1.0 that adds adds optional memo field to `FungibleTokenPacketData` and `MsgTransfer`.
- [1577](https://github.com/umee-network/umee/pull/1577) Removes LIQUIDATOR build flag and adds `--enable-liquidator-query` or `-l` runtime flag to `umeed start`.

### State Machine Breaking

Expand Down
7 changes: 1 addition & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ TM_VERSION := $(shell go list -m github.com/tendermint/tendermint | sed 's:.
DOCKER := $(shell which docker)
PROJECT_NAME := umee
HTTPS_GIT := https://github.com/umee-network/umee.git
LIQUIDATOR := $(if $(LIQUIDATOR),true,false)

###############################################################################
## Version ##
Expand Down Expand Up @@ -70,8 +69,7 @@ ldflags = -X github.com/cosmos/cosmos-sdk/version.Name=umee \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X "github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep)" \
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION) \
-X github.com/umee-network/umee/v3/x/leverage/keeper.EnableLiquidator=$(LIQUIDATOR)
-X github.com/tendermint/tendermint/version.TMCoreSemVer=$(TM_VERSION)

ifeq ($(LINK_STATICALLY),true)
ldflags += -linkmode=external -extldflags "-Wl,-z,muldefs -static"
Expand All @@ -97,9 +95,6 @@ build-no_cgo:
build-linux: go.sum
LEDGER_ENABLED=false GOOS=linux GOARCH=amd64 $(MAKE) build

build-liquidator:
LIQUIDATOR=true $(MAKE) build

install: go.sum
@echo "--> Installing..."
go install -mod=readonly $(BUILD_FLAGS) ./...
Expand Down
6 changes: 4 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -442,13 +442,15 @@ func New(
distrtypes.ModuleName,
)
var err error
enableLiquidatorQuery := cast.ToBool(appOpts.Get(leveragetypes.FlagEnableLiquidatorQuery))
app.LeverageKeeper, err = leveragekeeper.NewKeeper(
appCodec,
keys[leveragetypes.ModuleName],
app.GetSubspace(leveragetypes.ModuleName),
app.BankKeeper,
app.OracleKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
enableLiquidatorQuery,
)
if err != nil {
panic(err)
Expand Down Expand Up @@ -750,8 +752,8 @@ func New(
}

func (app *UmeeApp) setAnteHandler(txConfig client.TxConfig,
wasmConfig *wasmtypes.WasmConfig, wasmStoreKey *storetypes.KVStoreKey) {

wasmConfig *wasmtypes.WasmConfig, wasmStoreKey *storetypes.KVStoreKey,
) {
anteHandler, err := customante.NewAnteHandler(
customante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
Expand Down
2 changes: 2 additions & 0 deletions cmd/umeed/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

umeeapp "github.com/umee-network/umee/v3/app"
appparams "github.com/umee-network/umee/v3/app/params"
"github.com/umee-network/umee/v3/x/leverage"
)

// NewRootCmd returns the root command handler for the Umee daemon.
Expand Down Expand Up @@ -187,6 +188,7 @@ func initRootCmd(rootCmd *cobra.Command, a appCreator) {

func addModuleInitFlags(startCmd *cobra.Command) {
crisis.AddModuleInitFlags(startCmd)
leverage.AddModuleInitFlags(startCmd)
}

func queryCommand(ac appCreator) *cobra.Command {
Expand Down
13 changes: 13 additions & 0 deletions x/leverage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,19 @@ Similarly, `AdjustedTotalBorrowed` is never set independently during regular ope

See [leverage query proto](https://github.com/umee-network/umee/blob/main/proto/umee/leverage/v1/query.proto) for list of supported queries.

Additionally, the query `liquidation-targets` is only enabled if the node is started with a flag:

```bash
# Enabled
umeed start --enable-liquidator-query

# Enabled
umeed start -l

# Disabled
umeed start
```

## Messages

See [leverage tx proto](https://github.com/umee-network/umee/blob/main/proto/umee/leverage/v1/tx.proto#L11) for list of supported messages.
Expand Down
6 changes: 1 addition & 5 deletions x/leverage/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package keeper

import (
"context"
"strings"

sdk "github.com/cosmos/cosmos-sdk/types"
"google.golang.org/grpc/codes"
Expand All @@ -11,9 +10,6 @@ import (
"github.com/umee-network/umee/v3/x/leverage/types"
)

// EnableLiquidator must be set to "true" at compile time to enable QueryLiquidationTargets
var EnableLiquidator = ""

var _ types.QueryServer = Querier{}

// Querier implements a QueryServer for the x/leverage module.
Expand Down Expand Up @@ -241,7 +237,7 @@ func (q Querier) LiquidationTargets(
return nil, status.Error(codes.InvalidArgument, "empty request")
}

if strings.ToLower(EnableLiquidator) != "true" {
if !q.Keeper.liquidatorQueryEnabled {
return nil, types.ErrNotLiquidatorNode
}

Expand Down
8 changes: 0 additions & 8 deletions x/leverage/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/umee-network/umee/v3/x/leverage/fixtures"
"github.com/umee-network/umee/v3/x/leverage/keeper"
"github.com/umee-network/umee/v3/x/leverage/types"
)

Expand Down Expand Up @@ -120,13 +119,6 @@ func (s *IntegrationTestSuite) TestQuerier_AccountSummary() {
func (s *IntegrationTestSuite) TestQuerier_LiquidationTargets() {
ctx, require := s.ctx, s.Require()

keeper.EnableLiquidator = "false"

_, err := s.queryClient.LiquidationTargets(ctx.Context(), &types.QueryLiquidationTargets{})
require.ErrorIs(err, types.ErrNotLiquidatorNode)

keeper.EnableLiquidator = "true"

resp, err := s.queryClient.LiquidationTargets(ctx.Context(), &types.QueryLiquidationTargets{})
require.NoError(err)

Expand Down
2 changes: 2 additions & 0 deletions x/leverage/keeper/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func NewTestKeeper(
bk types.BankKeeper,
ok types.OracleKeeper,
authority string,
enableLiquidatorQuery bool,
) (Keeper, TestKeeper) {
k, err := NewKeeper(
cdc,
Expand All @@ -35,6 +36,7 @@ func NewTestKeeper(
bk,
ok,
authority,
enableLiquidatorQuery,
)
require.NoError(err)
return k, TestKeeper{&k}
Expand Down
29 changes: 16 additions & 13 deletions x/leverage/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import (
)

type Keeper struct {
cdc codec.Codec
storeKey storetypes.StoreKey
paramSpace paramtypes.Subspace
hooks types.Hooks
bankKeeper types.BankKeeper
oracleKeeper types.OracleKeeper
authority string // the gov module account
cdc codec.Codec
storeKey storetypes.StoreKey
paramSpace paramtypes.Subspace
hooks types.Hooks
bankKeeper types.BankKeeper
oracleKeeper types.OracleKeeper
authority string // the gov module account
liquidatorQueryEnabled bool
}

func NewKeeper(
Expand All @@ -31,19 +32,21 @@ func NewKeeper(
bk types.BankKeeper,
ok types.OracleKeeper,
authority string,
enableLiquidatorQuery bool,
) (Keeper, error) {
// set KeyTable if it has not already been set
if !paramSpace.HasKeyTable() {
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
}

return Keeper{
cdc: cdc,
storeKey: storeKey,
paramSpace: paramSpace,
bankKeeper: bk,
oracleKeeper: ok,
authority: authority,
cdc: cdc,
storeKey: storeKey,
paramSpace: paramSpace,
bankKeeper: bk,
oracleKeeper: ok,
authority: authority,
liquidatorQueryEnabled: enableLiquidatorQuery,
}, nil
}

Expand Down
4 changes: 1 addition & 3 deletions x/leverage/keeper/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ func (s *IntegrationTestSuite) SetupTest() {
Time: time.Unix(0, 0),
})

// Enable liquidation queries for testing
keeper.EnableLiquidator = "true"

// we only override the Leverage keeper so we can supply a custom mock oracle
k, tk := keeper.NewTestKeeper(
s.Require(),
Expand All @@ -65,6 +62,7 @@ func (s *IntegrationTestSuite) SetupTest() {
app.BankKeeper,
newMockOracleKeeper(),
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
true,
)

s.tk = tk
Expand Down
5 changes: 5 additions & 0 deletions x/leverage/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,8 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp
simState.AppParams, simState.Cdc, am.accountKeeper, am.bankKeeper, am.keeper,
)
}

// AddModuleInitFlags implements servertypes.ModuleInitFlags interface.
func AddModuleInitFlags(startCmd *cobra.Command) {
startCmd.Flags().BoolP(types.FlagEnableLiquidatorQuery, "l", false, "enable liquidator query")
}
3 changes: 3 additions & 0 deletions x/leverage/types/flag.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package types

const FlagEnableLiquidatorQuery = "enable-liquidator-query"