Skip to content

Commit

Permalink
Merge branch 'main' into robert/nullbyte
Browse files Browse the repository at this point in the history
  • Loading branch information
toteki authored Jun 28, 2023
2 parents 2949e7d + 5561660 commit 66d3ec4
Show file tree
Hide file tree
Showing 31 changed files with 663 additions and 325 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
with:
fetch-depth: 0
# lint only changed files
- uses: tj-actions/changed-files@v36
- uses: tj-actions/changed-files@v37
id: changed-files
with:
files: "**/*.md"
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Features

- [2192](https://github.com/umee-network/umee/pull/2102) Add `MsgFastLiquidate` to `x/leverage`
- [2102](https://github.com/umee-network/umee/pull/2102) and [2106](https://github.com/umee-network/umee/pull/2106) Add `MsgLeveragedLiquidate` to `x/leverage`
- [2085](https://github.com/umee-network/umee/pull/2085) Add `inspect` query to leverage module, which msut be enabled on a node by running with `-l` liquidator query flag.
- [1952](https://github.com/umee-network/umee/pull/1952) Add `x/incentive` module.
- [2015](https://github.com/umee-network/umee/pull/2015), [2050](https://github.com/umee-network/umee/pull/2050) Add `x/ugov` module.
Expand Down
2 changes: 1 addition & 1 deletion app/wasm/query/handle_leverage.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@ func (q UmeeQuery) HandleMaxBorrow(
ctx context.Context,
qs lvtypes.QueryServer,
) (proto.Message, error) {
req := &lvtypes.QueryMaxBorrow{Address: q.MaxBorrow.Address, Denom: q.MaxBorrow.Address}
req := &lvtypes.QueryMaxBorrow{Address: q.MaxBorrow.Address, Denom: q.MaxBorrow.Denom}
return qs.MaxBorrow(ctx, req)
}
3 changes: 2 additions & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ type Client struct {
// Accounts are generated using the list of mnemonics. Each string must be a sequence of words,
// eg: `["w11 w12 w13", "w21 w22 w23"]`. Keyring names for created accounts will be: val1, val2....
func NewClient(
chainDataDir,
chainID,
tmrpcEndpoint,
grpcEndpoint string,
mnemonics map[string]string,
gasAdjustment float64,
encCfg sdkparams.EncodingConfig,
) (Client, error) {
c, err := sdkclient.NewClient(chainID, tmrpcEndpoint, grpcEndpoint, mnemonics, gasAdjustment, encCfg)
c, err := sdkclient.NewClient(chainDataDir, chainID, tmrpcEndpoint, grpcEndpoint, mnemonics, gasAdjustment, encCfg)
if err != nil {
return Client{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion contrib/images/umee.e2e.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN if [ "$EXPERIMENTAL" = "true" ] ; then echo "Installing experimental build";
RUN BUILD_TAGS=badgerdb make install

## Prepare the final clear binary
FROM ubuntu:rolling
FROM ubuntu:23.04
EXPOSE 26656 26657 1317 9090 7171
ENTRYPOINT ["umeed", "start"]

Expand Down
7 changes: 3 additions & 4 deletions contrib/images/umeed.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ RUN LEDGER_ENABLED=false BUILD_TAGS=badgerdb make install

# Stage-2: copy binary and required artifacts to a fresh image
# we need to use debian compatible system.
FROM ubuntu:rolling
FROM ubuntu:23.04
EXPOSE 26656 26657 1317 9090
CMD ["umeed"]
# Run umeed by default, omit entrypoint to ease using container with CLI
CMD ["umeed"]
STOPSIGNAL SIGTERM

RUN apt-get update && apt-get install ca-certificates -y \
&& addgroup --gid 1000 umee \
&& useradd -u 1000 -g umee -m umee
&& groupadd umee && useradd -g umee -m umee

COPY --from=builder /go/bin/umeed /usr/local/bin/
COPY --from=builder /go/pkg/mod/github.com/\!cosm\!wasm/wasmvm\@v*/internal/api/libwasmvm.*.so /usr/lib/
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
github.com/tendermint/tm-db v0.6.7
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1
google.golang.org/grpc v1.56.1
google.golang.org/protobuf v1.30.0
google.golang.org/protobuf v1.31.0
gopkg.in/yaml.v3 v3.0.1
gotest.tools/v3 v3.4.0
mvdan.cc/gofumpt v0.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2254,8 +2254,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
19 changes: 10 additions & 9 deletions proto/umee/leverage/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ service Msg {
// of the target's collateral.
rpc Liquidate(MsgLiquidate) returns (MsgLiquidateResponse);

// FastLiquidate allows a user to repay a different user's borrowed coins in exchange for some
// of the target's collateral. For flash liquidations, the tokens to repay are borrowed instead of
// LeveragedLiquidate allows a user to repay a different user's borrowed coins in exchange for some
// of the target's collateral. For leveraged liquidations, the tokens to repay are borrowed instead of
// being taken from the liquidator's wallet, and the reward is immediately collateralized. Borrow
// limit checks for the liquidator are deferred until after the reward is collateralized, allowing
// this initial borrow to exceed the liquidator's borrow limit as long as it is healthy by the end
// of the transaction. Repay amount is calculated automatically, so the liquidator only specifies
// repay and reward token denoms.
rpc FastLiquidate(MsgFastLiquidate) returns (MsgFastLiquidateResponse);
// repay and reward token denoms. For safety, the liquidator cannot exceed 80% of their borrow limit when
// executing this transaction, instead of the regular 100%.
rpc LeveragedLiquidate(MsgLeveragedLiquidate) returns (MsgLeveragedLiquidateResponse);

// SupplyCollateral combines the Supply and Collateralize actions.
rpc SupplyCollateral(MsgSupplyCollateral) returns (MsgSupplyCollateralResponse);
Expand Down Expand Up @@ -149,15 +150,15 @@ message MsgLiquidate {
string reward_denom = 4;
}

// MsgFastLiquidate is the request structure for the FastLiquidate RPC.
message MsgFastLiquidate {
// MsgLeveragedLiquidate is the request structure for the LeveragedLiquidate RPC.
message MsgLeveragedLiquidate {
// Liquidator is the account address performing a liquidation and the signer
// of the message.
string liquidator = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// Borrower is the account whose borrow is being repaid, and collateral consumed,
// by the liquidation. It does not sign the message.
string borrower = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// RepayDenom is the base token that the liquidator will borrow and repay on behalf of
// RepayDenom is the base token that the liquidator will borrow in order to repay on behalf of
// the borrower.
string repay_denom = 3;
// RewardDenom is the uToken denom that the liquidator will receive as a liquidation reward
Expand Down Expand Up @@ -226,8 +227,8 @@ message MsgLiquidateResponse {
cosmos.base.v1beta1.Coin reward = 3 [(gogoproto.nullable) = false];
}

// MsgFastLiquidateResponse defines the Msg/FastLiquidate response type.
message MsgFastLiquidateResponse {
// MsgLeveragedLiquidateResponse defines the Msg/LeveragedLiquidate response type.
message MsgLeveragedLiquidateResponse {
// Repaid is the amount of base tokens that the liquidator borrowed and repaid
// to the module on behalf of the borrower.
cosmos.base.v1beta1.Coin repaid = 1 [(gogoproto.nullable) = false];
Expand Down
3 changes: 2 additions & 1 deletion sdkclient/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Client struct {
}

func NewClient(
chainDataDir,
chainID,
tmrpcEndpoint,
grpcEndpoint string,
Expand All @@ -35,7 +36,7 @@ func NewClient(
if err != nil {
return Client{}, err
}
uc.Tx, err = tx.NewClient(chainID, tmrpcEndpoint, mnemonics, gasAdjustment, encCfg)
uc.Tx, err = tx.NewClient(chainDataDir, chainID, tmrpcEndpoint, mnemonics, gasAdjustment, encCfg)
return uc, err
}

Expand Down
7 changes: 4 additions & 3 deletions sdkclient/tx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ type Client struct {
}

// Initializes a cosmos sdk client context and transaction factory for
// signing and broadcasting transactions
// signing and broadcasting transactions by passing chainDataDir and remaining func arguments
// Note: For signing the transactions accounts are created by names like this val0, val1....
func NewClient(
chainID string,
chainDataDir,
chainID,
tmrpcEndpoint string,
mnemonics map[string]string,
gasAdjustment float64,
Expand All @@ -45,7 +46,7 @@ func NewClient(
encCfg: encCfg,
}

c.keyringKeyring, err = keyring.New(keyringAppName, keyring.BackendTest, "", nil, encCfg.Codec)
c.keyringKeyring, err = keyring.New(keyringAppName, keyring.BackendTest, chainDataDir, nil, encCfg.Codec)
if err != nil {
return nil, err
}
Expand Down
22 changes: 15 additions & 7 deletions tests/e2e/setup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ type E2ETestSuite struct {
GravityContractAddr string
Umee client.Client
cdc codec.Codec
MinNetwork bool // MinNetwork defines which runs only validator wihtout price-feeder, gaia and ibc-relayer

}

func (s *E2ETestSuite) SetupSuite() {
Expand Down Expand Up @@ -110,9 +112,13 @@ func (s *E2ETestSuite) SetupSuite() {
s.initGenesis()
s.initValidatorConfigs()
s.runValidators()
s.runPriceFeeder()
s.runGaiaNetwork()
s.runIBCRelayer()
if !s.MinNetwork {
s.runPriceFeeder()
s.runGaiaNetwork()
s.runIBCRelayer()
} else {
s.T().Log("running minimum network withut gaia,price-feeder and ibc-relayer")
}
// s.runContractDeployment()
// s.runOrchestrators()
s.initUmeeClient()
Expand All @@ -131,9 +137,11 @@ func (s *E2ETestSuite) TearDownSuite() {
s.T().Log("tearing down e2e integration test suite...")

// s.Require().NoError(s.DkrPool.Purge(s.ethResource))
s.Require().NoError(s.DkrPool.Purge(s.GaiaResource))
s.Require().NoError(s.DkrPool.Purge(s.HermesResource))
s.Require().NoError(s.DkrPool.Purge(s.priceFeederResource))
if !s.MinNetwork {
s.Require().NoError(s.DkrPool.Purge(s.GaiaResource))
s.Require().NoError(s.DkrPool.Purge(s.HermesResource))
s.Require().NoError(s.DkrPool.Purge(s.priceFeederResource))
}

for _, vc := range s.ValResources {
s.Require().NoError(s.DkrPool.Purge(vc))
Expand Down Expand Up @@ -1062,8 +1070,8 @@ func (s *E2ETestSuite) initUmeeClient() {
mnemonics[fmt.Sprintf("val%d", index)] = v.mnemonic
}
ecfg := app.MakeEncodingConfig()

s.Umee, err = client.NewClient(
s.Chain.dataDir,
s.Chain.ID,
"tcp://localhost:26657",
"tcp://localhost:9090",
Expand Down
13 changes: 0 additions & 13 deletions tests/qa/cw/config_example.yaml

This file was deleted.

34 changes: 13 additions & 21 deletions tests/qa/cw/cw_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ package cw
import (
"encoding/json"
"math/rand"
"os"
"strings"
"sync"
"testing"
"time"

"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdkparams "github.com/cosmos/cosmos-sdk/simapp/params"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/stretchr/testify/suite"
"gotest.tools/v3/assert"

"github.com/umee-network/umee/v5/app"
"github.com/umee-network/umee/v5/client"
cwutil "github.com/umee-network/umee/v5/tests/util"
)

Expand All @@ -33,28 +30,27 @@ var (
cwGroupMsgExecFunc func(name string, msg GroupExecMsg, wg *sync.WaitGroup, accSeq uint64)
)

func TestCWPlusGroup(t *testing.T) {
func TestQA(t *testing.T) {
t.Log("Running qa test...")
qaTest := new(QATest)
qaTest.MinNetwork = true
suite.Run(t, qaTest)
}

func (qaTest *QATest) TestCWPlusGroup() {
t := qaTest.T()
accAddrs := make([]sdk.AccAddress, 0)
for i := 0; i < TotalAccs; i++ {
privateKey := secp256k1.GenPrivKey()
pubKey := privateKey.PubKey()
accAddrs = append(accAddrs, sdk.AccAddress(pubKey.Address()))
}

// remove if old keyring exists for testing
os.RemoveAll("./keyring-test")
encConfig := app.MakeEncodingConfig()
cc, err := ReadConfig("./config_example.yaml")
assert.NilError(t, err)
// umee client
client, err := UmeeClient(cc, encConfig)
assert.NilError(t, err)

cw := cwutil.NewCosmwasmTestSuite(t, client)
cw := cwutil.NewCosmwasmTestSuite(qaTest.T(), qaTest.Umee)
cw.DeployWasmContract(cwGroupPath)

// sender is intital account
admin := client.Tx.SenderAddr()
admin := qaTest.Umee.Tx.SenderAddr()
// instantiate Contract
initMsg := GroupInitMsg{
Admin: admin.String(),
Expand Down Expand Up @@ -89,7 +85,7 @@ func TestCWPlusGroup(t *testing.T) {

// doing random txs to flood the cosmwasm network
wg := &sync.WaitGroup{}
accSeq, err := client.QueryAuthSeq(admin.String())
accSeq, err := qaTest.Umee.QueryAuthSeq(admin.String())
assert.NilError(t, err)
total := 0

Expand Down Expand Up @@ -160,7 +156,3 @@ func TestCWPlusGroup(t *testing.T) {
assert.NilError(t, err)
assert.Equal(t, updateAdmin.UpdateAdmin.Admin, adminQuery.Admin)
}

func UmeeClient(cc *ChainConfig, encConfig sdkparams.EncodingConfig) (client.Client, error) {
return client.NewClient(cc.ChainID, cc.RPC, cc.GRPC, cc.Mnemonics, 1.5, encConfig)
}
19 changes: 0 additions & 19 deletions tests/qa/cw/cw_utils.go

This file was deleted.

29 changes: 0 additions & 29 deletions tests/qa/cw/network_config.go

This file was deleted.

9 changes: 9 additions & 0 deletions tests/qa/cw/setup.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cw

import (
"github.com/umee-network/umee/v5/tests/e2e/setup"
)

type QATest struct {
setup.E2ETestSuite
}
4 changes: 2 additions & 2 deletions util/store/iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ func TestSumCoins(t *testing.T) {
}{
{"atom", 1},
{"umee", 8},
{"atom", 8}, // we overwrite
{"atom", 7}, // overwrite the previous value
{"ato", 2},
{"atoma", 3},
}
expected := sdk.NewCoins(
sdk.NewInt64Coin("ato", 2),
sdk.NewInt64Coin("atom", 8),
sdk.NewInt64Coin("atom", 7),
sdk.NewInt64Coin("atoma", 3),
sdk.NewInt64Coin("umee", 8))

Expand Down
Loading

0 comments on commit 66d3ec4

Please sign in to comment.