Skip to content

Commit

Permalink
Merge pull request #158 from crescent-network/158-backport-v4.2.0
Browse files Browse the repository at this point in the history
build!: backport from v4.x.x (#154 #155 #157)
  • Loading branch information
crypin authored Jun 16, 2023
2 parents 40f6beb + 4e10c2a commit da9d012
Show file tree
Hide file tree
Showing 22 changed files with 725 additions and 104 deletions.
28 changes: 20 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,6 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

## [v5.0.0] - 2023-02

### State Machine Breaking

- (deps) [\#147](https://github.com/crescent-network/crescent/pull/147) feat!: bump cosmos-sdk to `v1.2.0-sdk-0.45.10` to use `MinInitialDepositRatio` as 0.5 for proposal submission

### Features

- (x/marker) [\#145](https://github.com/crescent-network/crescent/pull/145) Add marker module
Expand All @@ -57,6 +51,22 @@ Ref: https://keepachangelog.com/en/1.0.0/

- (x/liquidity) [\#144](https://github.com/crescent-network/crescent/pull/144) Change `mm-order` tx cmd

## [v4.2.0] - 2023-06-09

### State Machine Breaking

- (deps) [\#157](https://github.com/crescent-network/crescent/pull/157) build!: bump cosmos-sdk to v1.1.5-sdk-0.45.10 for barberry

## [v4.1.1] - 2023-05-26

- (ibc) [\#155](https://github.com/crescent-network/crescent/pull/155) build: bump ibc-go to v3.4.0-crescent-v4-3 for huckleberry

## [v4.1.0] - 2023-05-16

### State Machine Breaking

- (x/lpfarm) [\#154](https://github.com/crescent-network/crescent/pull/154) feat!: add MsgTerminatePrivatePlan

## [v4.0.0] - 2023-01-05

### State Machine Breaking
Expand Down Expand Up @@ -204,7 +214,7 @@ Running a full node will encounter wrong app hash issue if it doesn't upgrade to
- `x/vesting` feat: periodic vesting msg
- `x/bank` feat: Add dynamic blockedAddrs

[unreleased]: https://github.com/crescent-network/crescent/compare/v5.0.0...HEAD
[unreleased]: https://github.com/crescent-network/crescent/compare/v4.2.0...HEAD
[v1.0.0]: https://github.com/crescent-network/crescent/releases/tag/v1.0.0
[v1.1.0]: https://github.com/crescent-network/crescent/releases/tag/v1.1.0
[v2.1.0]: https://github.com/crescent-network/crescent/releases/tag/v2.1.0
Expand All @@ -213,4 +223,6 @@ Running a full node will encounter wrong app hash issue if it doesn't upgrade to
[v2.3.0]: https://github.com/crescent-network/crescent/releases/tag/v2.3.0
[v3.0.0]: https://github.com/crescent-network/crescent/releases/tag/v3.0.0
[v4.0.0]: https://github.com/crescent-network/crescent/releases/tag/v4.0.0
[v5.0.0]: https://github.com/crescent-network/crescent/releases/tag/v5.0.0
[v4.1.0]: https://github.com/crescent-network/crescent/releases/tag/v4.1.0
[v4.1.1]: https://github.com/crescent-network/crescent/releases/tag/v4.1.1
[v4.2.0]: https://github.com/crescent-network/crescent/releases/tag/v4.2.0
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ Crescent core uses a fork of [cosmos-sdk](https://github.com/crescent-network/co

| Requirement | Notes |
|---------------------|----------------------|
| cosmos-sdk (forked) | v1.2.0-sdk-0.45.10 |
| ibc-go (forked) | v3.4.0-crescent-v4-2 |
| cosmos-sdk (forked) | v1.1.5-sdk-0.45.10 |
| ibc-go (forked) | v3.4.0-crescent-v4-3 |

## Documentation

The documentation is available in [docs](docs) directory. If you are a developer interested in technical specification, go to each `x/{module}`'s `spec` directory.

* [Crescent Official Docs](https://docs.crescent.network/)
* [Swagger API Docs](https://app.swaggerhub.com/apis-docs/crescent/crescent)
* [Swagger API Docs](https://app.swaggerhub.com/apis-docs/crescent/crescent/2.0.0)

<!-- markdown-link-check-disable -->

## Community

Expand Down
17 changes: 17 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Security Policy

## Reporting a Vulnerability

Privately and confidentially send us a description of the vulnerability that you have discovered. Our contact information is given below.

In your report, please include as much information as you can, including:

* a description of the vulnerability and how it could be exploited
* its potential impact (e.g. theft of funds, denial of service)
* steps or code for reproducing it
* a proposed patch for remedying it

## How to Contact Us

[email protected]
[email protected]
2 changes: 1 addition & 1 deletion docs/cli/claim.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work

## Synopsis

This document provides a high-level overview of how the command line (CLI) interface works for the `claim` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/welcome/install) to install it. Run this command under the project root directory `$ ignite chain serve -c config-test.yml`.
This document provides a high-level overview of how the command line (CLI) interface works for the `claim` module.

Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document.

Expand Down
2 changes: 1 addition & 1 deletion docs/cli/farming.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work

## Synopsis

This document provides a high-level overview of how the command line (CLI) interface works for the `farming` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/welcome/install) to install it. Run this command under the project root directory `$ ignite chain serve -c config-test.yml`.
This document provides a high-level overview of how the command line (CLI) interface works for the `farming` module.

Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document.

Expand Down
5 changes: 1 addition & 4 deletions docs/cli/liquidfarming.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ Description: A high-level overview of how the command-line interfaces (CLI) work
## Synopsis

This document provides a high-level overview of how the command line (CLI) interface works for the `liquidfarming` module.
To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/).
If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/welcome/install) to install it.
Run this command under the project root directory `$ ignite chain serve -c config-test.yml`.

Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document.

Expand Down Expand Up @@ -359,4 +356,4 @@ Example

```bash
crescentd query liquidfarming exchange-rate 1 -o json | jq
```
```
2 changes: 1 addition & 1 deletion docs/cli/liquidity.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work

## Synopsis

This document provides a high-level overview of how the command line (CLI) interface works for the `liquidity` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/welcome/install) to install it. Run this command under the project root directory `$ ignite chain serve -c config-test.yml`.
This document provides a high-level overview of how the command line (CLI) interface works for the `liquidity` module.

Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document.

Expand Down
4 changes: 2 additions & 2 deletions docs/cli/liquidstaking.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work

## Synopsis

This document provides a high-level overview of how the command line (CLI) interface works for the `liquidstaking` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/welcome/install) to install it. Run this command under the project root directory `$ ignite chain serve -c config-test.yml`.
This document provides a high-level overview of how the command line (CLI) interface works for the `liquidstaking` module.

Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document.

Expand Down Expand Up @@ -167,4 +167,4 @@ Example

```bash
crescentd query liquidstaking voting-power cre1mzgucqnfr2l8cj5apvdpllhzt4zeuh2c5l33n3 -o json | jq
```
```
10 changes: 1 addition & 9 deletions docs/cli/lpfarm.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work
## Synopsis

This document provides a high-level overview of how the command line (CLI)
interface works for the `lpfarm` module. To set up a local testing environment, it requires the latest
[Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine,
see [this guide](https://docs.ignite.com/welcome/install) to install it. Run this command under the project root
directory
`$ ignite chain serve -v -c config-test.yml`.
interface works for the `lpfarm` module.

Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout
the document.
Expand Down Expand Up @@ -220,10 +216,6 @@ Example:

```bash
crescentd q lpfarm plans -o json | jq
crescentd q lpfarm plans --farming-pool-addr cre1gkvhlzmpxarqwk4jh7k7yemf60r50y55n8ax9kxcx8t28hm0e7cqk52jh9 -o json | jq
crescentd q lpfarm plans --termination-addr cre1mzgucqnfr2l8cj5apvdpllhzt4zeuh2c5l33n3 -o json | jq
crescentd q lpfarm plans --is-private true -o json | jq
crescentd q lpfarm plans --is-terminated false -o json | jq
```

#### Plan
Expand Down
2 changes: 1 addition & 1 deletion docs/cli/marketmaker.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Description: A high-level overview of how the command-line interfaces (CLI) work

## Synopsis

This document provides a high-level overview of how the command line (CLI) interface works for the `marketmaker` module. To set up a local testing environment, it requires 0.24.1 or lower versions of [Ignite CLI](https://docs.ignite.com/). If you don't have Ignite CLI set up in your local machine, see [this guide](https://docs.ignite.com/welcome/install) to install it. Run this command under the project root directory `$ ignite chain serve -v -c config-test.yml`.
This document provides a high-level overview of how the command line (CLI) interface works for the `marketmaker` module.

Note that [jq](https://stedolan.github.io/jq/) is recommended to be installed as it is used to process JSON throughout the document.

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ require (
github.com/uudashr/gocognit v1.0.6 // indirect
github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.2.0 // indirect
github.com/zondax/hid v0.9.1 // indirect
github.com/zondax/hid v0.9.0 // indirect
gitlab.com/bosi/decorder v0.2.3 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.uber.org/atomic v1.10.0 // indirect
Expand Down Expand Up @@ -261,8 +261,8 @@ require (

replace (
github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 // dragonberry security patch
github.com/cosmos/cosmos-sdk => github.com/crescent-network/cosmos-sdk v1.2.0-sdk-0.45.10
github.com/cosmos/ibc-go/v3 => github.com/crescent-network/ibc-go/v3 v3.4.0-crescent-v4-2
github.com/cosmos/cosmos-sdk => github.com/crescent-network/cosmos-sdk v1.1.5-sdk-0.45.10 // barberry security patch, customized
github.com/cosmos/ibc-go/v3 => github.com/crescent-network/ibc-go/v3 v3.4.0-crescent-v4-3 // huckleberry security patch
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
// github.com/keybase/go-keychain => github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4
google.golang.org/grpc => google.golang.org/grpc v1.33.2
Expand Down
11 changes: 5 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6V
github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crescent-network/cosmos-sdk v1.2.0-sdk-0.45.10 h1:nl/ZwPvXJCxUdYlUEe+PVUNb3ifVvaqJw5XVXnNbwIM=
github.com/crescent-network/cosmos-sdk v1.2.0-sdk-0.45.10/go.mod h1:CbfWNs4PuxxsvRD/snQuSBDwIhtsD7rIDTVQyYMKTa0=
github.com/crescent-network/ibc-go/v3 v3.4.0-crescent-v4-2 h1:ibh/OH30EtvlORD8gUoOz30+7Wl4NTbt/kL6IjDPwTU=
github.com/crescent-network/ibc-go/v3 v3.4.0-crescent-v4-2/go.mod h1:nI//NgRwnCGKFEkMn62rSW8/fQ1KprbUKFfxp5AbSZk=
github.com/crescent-network/cosmos-sdk v1.1.5-sdk-0.45.10 h1:jf8mc04DO8EVBIfQUAtz43Owfg8uJDv/WYcPnOOG7Uo=
github.com/crescent-network/cosmos-sdk v1.1.5-sdk-0.45.10/go.mod h1:CbfWNs4PuxxsvRD/snQuSBDwIhtsD7rIDTVQyYMKTa0=
github.com/crescent-network/ibc-go/v3 v3.4.0-crescent-v4-3 h1:eBQwupfSDLTDmjFuUefWFel//BCWMPEPouWWWoANLNI=
github.com/crescent-network/ibc-go/v3 v3.4.0-crescent-v4-3/go.mod h1:tR2qrfrmeZqKiZh2tlTotpq3FDaXLD4omi3sBpaq21w=
github.com/cristalhq/acmd v0.8.1/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ=
github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo=
github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc=
Expand Down Expand Up @@ -1067,9 +1067,8 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8=
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo=
github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
gitlab.com/bosi/decorder v0.2.3 h1:gX4/RgK16ijY8V+BRQHAySfQAb354T7/xQpDB2n10P0=
gitlab.com/bosi/decorder v0.2.3/go.mod h1:9K1RB5+VPNQYtXtTDAzd2OEftsZb1oV0IrJrzChSdGE=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
Expand Down
8 changes: 8 additions & 0 deletions proto/crescent/lpfarm/v1beta1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ option (gogoproto.goproto_getters_all) = false;

service Msg {
rpc CreatePrivatePlan(MsgCreatePrivatePlan) returns (MsgCreatePrivatePlanResponse);
rpc TerminatePrivatePlan(MsgTerminatePrivatePlan) returns (MsgTerminatePrivatePlanResponse);
rpc Farm(MsgFarm) returns (MsgFarmResponse);
rpc Unfarm(MsgUnfarm) returns (MsgUnfarmResponse);
rpc Harvest(MsgHarvest) returns (MsgHarvestResponse);
Expand All @@ -30,6 +31,13 @@ message MsgCreatePrivatePlanResponse {
string farming_pool_address = 2;
}

message MsgTerminatePrivatePlan {
string creator = 1;
uint64 plan_id = 2;
}

message MsgTerminatePrivatePlanResponse {}

message MsgFarm {
string farmer = 1;
cosmos.base.v1beta1.Coin coin = 2 [(gogoproto.nullable) = false];
Expand Down
37 changes: 37 additions & 0 deletions x/lpfarm/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func GetTxCmd() *cobra.Command {

cmd.AddCommand(
NewCreatePrivatePlanCmd(),
NewTerminatePrivatePlanCmd(),
NewFarmCmd(),
NewUnfarmCmd(),
NewHarvestCmd(),
Expand Down Expand Up @@ -117,6 +118,42 @@ $ %s tx %s create-private-plan "New Farming Plan" 2022-01-01T00:00:00Z 2023-01-0
return cmd
}

func NewTerminatePrivatePlanCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "terminate-private-plan [plan-id]",
Args: cobra.ExactArgs(1),
Short: "Terminate a private farming plan",
Long: strings.TrimSpace(
fmt.Sprintf(`Terminate a private farming plan.
The plan's termination address must be same with the message sender(original plan creator).
Example:
$ %s tx %s terminate-private-plan 1 --from mykey
`,
version.AppName, types.ModuleName,
),
),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

planId, err := strconv.ParseUint(args[0], 10, 64)
if err != nil {
return fmt.Errorf("invalid plan id: %w", err)
}

msg := types.NewMsgTerminatePrivatePlan(clientCtx.GetFromAddress(), planId)
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

func NewFarmCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "farm [coin]",
Expand Down
3 changes: 3 additions & 0 deletions x/lpfarm/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler {
case *types.MsgCreatePrivatePlan:
res, err := msgServer.CreatePrivatePlan(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgTerminatePrivatePlan:
res, err := msgServer.TerminatePrivatePlan(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
case *types.MsgFarm:
res, err := msgServer.Farm(sdk.WrapSDKContext(ctx), msg)
return sdk.WrapServiceResult(ctx, res, err)
Expand Down
25 changes: 25 additions & 0 deletions x/lpfarm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

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

"github.com/crescent-network/crescent/v5/x/lpfarm/types"
)
Expand Down Expand Up @@ -41,6 +42,30 @@ func (k msgServer) CreatePrivatePlan(goCtx context.Context, msg *types.MsgCreate
}, nil
}

// TerminatePrivatePlan defines a method to terminate a private plan.
func (k msgServer) TerminatePrivatePlan(goCtx context.Context, msg *types.MsgTerminatePrivatePlan) (*types.MsgTerminatePrivatePlanResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)

plan, found := k.GetPlan(ctx, msg.PlanId)
if !found {
return nil, sdkerrors.Wrapf(sdkerrors.ErrNotFound, "plan not found: %d", msg.PlanId)
}
if !plan.IsPrivate {
return nil, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "cannot terminate public plan")
}
if plan.TerminationAddress != msg.Creator {
return nil, sdkerrors.Wrapf(
sdkerrors.ErrUnauthorized,
"plan's termination address must be same with the sender's address")
}

if err := k.Keeper.TerminatePlan(ctx, plan); err != nil {
return nil, err
}

return &types.MsgTerminatePrivatePlanResponse{}, nil
}

// Farm defines a method for farming coins.
func (k msgServer) Farm(goCtx context.Context, msg *types.MsgFarm) (*types.MsgFarmResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
Expand Down
Loading

0 comments on commit da9d012

Please sign in to comment.