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

Add public and private plan creation #11

Merged
merged 45 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
17fb505
add proposal proto for public proposal plan messages
jaybxyz Jul 19, 2021
fdc9b93
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 19, 2021
b694ba1
update proto files
jaybxyz Jul 19, 2021
f557438
temp
jaybxyz Jul 19, 2021
13fcc46
change method name to prevent from duplicate
jaybxyz Jul 19, 2021
b47f8e3
WIP: designing what args to accept for adding plan proposal...
jaybxyz Jul 19, 2021
b0a61c8
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 20, 2021
3d230f3
change binary name to farmingd
jaybxyz Jul 20, 2021
25e83e8
change proposal design
jaybxyz Jul 20, 2021
edd2090
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 21, 2021
7ad06bd
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 24, 2021
ddf5eec
add private plans and public plans are work in progress
jaybxyz Jul 24, 2021
1cd663c
update cli commands for private plans
jaybxyz Jul 26, 2021
a5bb036
add tests for private farming plan command line interfaces
jaybxyz Jul 26, 2021
ed0520f
add public plan proposal
jaybxyz Jul 26, 2021
2edf4f7
add nolint:errcheck for now
jaybxyz Jul 26, 2021
6dbf2bb
fix golint by adding return value for sdkerrors.Wrapf
jaybxyz Jul 26, 2021
2eafadd
add name filed in both create fixed amount plan and ratio plan messages
jaybxyz Jul 27, 2021
e26e4cc
apply feedback
jaybxyz Jul 27, 2021
ac0d515
add validation and fix public ratio plan creation logic
jaybxyz Jul 27, 2021
af70b8e
remove empty name field and use the one from the passed argument
jaybxyz Jul 27, 2021
5ad0c33
remove unused rest code
jaybxyz Jul 27, 2021
7c56ea7
move the name field inside the AddRequestProposal
jaybxyz Jul 27, 2021
195ae66
add description on PublicPlanProposal message
jaybxyz Jul 27, 2021
ce77054
fix typo and add 09_proposal.md
jaybxyz Jul 27, 2021
e8b2924
add name field in update plan proposal
jaybxyz Jul 28, 2021
c40d32f
make indentation consistent and change variable name
jaybxyz Jul 28, 2021
adf7f92
reformat json
jaybxyz Jul 28, 2021
1dea61b
fix broken app
jaybxyz Jul 28, 2021
132026e
use three ifs instead of switch case and use else if to prevent from …
jaybxyz Jul 28, 2021
154b903
add detailed validation logics for AddRequestProposal, UpdateRequestP…
jaybxyz Jul 28, 2021
672bb5a
re: add detailed validation logics for AddRequestProposal, UpdateRequ…
jaybxyz Jul 28, 2021
e6a004b
add skeleton for docs #21
jaybxyz Jul 28, 2021
e6aadfc
add How-To farming_plans.md
jaybxyz Jul 28, 2021
adc1b61
update comment
jaybxyz Jul 28, 2021
95044e1
add validation for duplicate plan name
jaybxyz Jul 28, 2021
dd77f21
update date time format to RFC3339
jaybxyz Jul 29, 2021
ee1cf1b
feat: update public plan proposal
jaybxyz Jul 29, 2021
0a48a98
feat: adding validation logic for an epoch ratio must not exceed 1 wi…
jaybxyz Jul 29, 2021
bfe2ece
feat: add validation logic for overflow epoch ratio
jaybxyz Jul 30, 2021
876f696
Merge branch 'master' into kogisin/add-public-plan
jaybxyz Jul 30, 2021
8c79779
fix: add another if statement to check when both epoch amount and rat…
jaybxyz Aug 2, 2021
1f57a89
Merge commit '639a96bb38ab9bda41ab15cc74534f520bf4302b' into kogisin/…
jaybxyz Aug 2, 2021
f3abdf7
chore: update public plan proposal logics
jaybxyz Aug 2, 2021
d707cfd
docs: add command-line interfaces and update context
jaybxyz Aug 2, 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
2 changes: 2 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import (

farmingparams "github.com/tendermint/farming/app/params"
"github.com/tendermint/farming/x/farming"
farmingclient "github.com/tendermint/farming/x/farming/client"
farmingkeeper "github.com/tendermint/farming/x/farming/keeper"
farmingtypes "github.com/tendermint/farming/x/farming/types"

Expand All @@ -114,6 +115,7 @@ var (
distr.AppModuleBasic{},
gov.NewAppModuleBasic(
paramsclient.ProposalHandler, distrclient.ProposalHandler, upgradeclient.ProposalHandler, upgradeclient.CancelProposalHandler,
farmingclient.ProposalHandler,
// todo: farming proposal handler
),
params.AppModuleBasic{},
Expand Down
1 change: 0 additions & 1 deletion contrib/devtools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ENV GOLANG_PROTOBUF_VERSION=1.3.5 \
GOGO_PROTOBUF_VERSION=1.3.2 \
GRPC_GATEWAY_VERSION=1.14.7


RUN GO111MODULE=on go get \
github.com/golang/protobuf/protoc-gen-go@v${GOLANG_PROTOBUF_VERSION} \
github.com/gogo/protobuf/protoc-gen-gogo@v${GOGO_PROTOBUF_VERSION} \
Expand Down
11 changes: 11 additions & 0 deletions docs/Explanation/ADR/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Architecture Decision Records (ADR)

Use this location to record all high-level architecture decisions in the farming module

## Definitions

## Rationale

## Creating new ADR

## ADR Table of Contents
Empty file added docs/How-To/README.md
Empty file.
243 changes: 243 additions & 0 deletions docs/How-To/farming_plans.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
# Farming Plans

There are two different types of farming plans in the farming module. Where as a public farming plan can only be created through governance proposal, a private farming plan can be created with any account. The plan creator's account is used as distributing account FarmingPoolAddress that will be distributed to farmers automatically.

In this documentation, there are sample data provided in JSON structure that are needed to test the functionality by using farming command line interfaces.

## Table of Contetns

- [Bootstrap Local Network](#Boostrap)
- [Public Farming Plan](#Public-Farming-Plan)
* [AddPublicFarmingFixedAmountPlan](#AddPublicFarmingFixedAmountPlan)
* [AddPublicFarmingRatioPlan](#AddPublicFarmingRatioPlan)
* [AddMultiplePublicPlans](#AddMultiplePublicPlans)
* [UpdatePublicFarmingFixedAmountPlan](#UpdatePublicFarmingFixedAmountPlan)
* [DeletePublicFarmingFixedAmountPlan](#DeletePublicFarmingFixedAmountPlan)
- [Private Farming Plan](#Private-Farming-Plan)
* [PrivateFarmingFixedAmountPlan](#PrivateFarmingFixedAmountPlan)
* [PrivateFarmingRatioPlan](#PrivateFarmingRatioPlan)

# Bootstrap

```bash
# Clone the project
git clone https://github.com/tendermint/farming.git
cd cosmos-sdk
make install

# Configure variables
export BINARY=farmingd
export HOME_1=$HOME/.farmingapp
export CHAIN_ID=localnet
export VALIDATOR_1="struggle panic room apology luggage game screen wing want lazy famous eight robot picture wrap act uphold grab away proud music danger naive opinion"
export USER_1="guard cream sadness conduct invite crumble clock pudding hole grit liar hotel maid produce squeeze return argue turtle know drive eight casino maze host"
export GENESIS_COINS=10000000000stake,10000000000uatom,10000000000uusd

# Boostrap
$BINARY init $CHAIN_ID --chain-id $CHAIN_ID
echo $VALIDATOR_1 | $BINARY keys add val1 --keyring-backend test --recover
echo $USER_1 | $BINARY keys add user1 --keyring-backend test --recover
$BINARY add-genesis-account $($BINARY keys show val1 --keyring-backend test -a) $GENESIS_COINS
$BINARY add-genesis-account $($BINARY keys show user1 --keyring-backend test -a) $GENESIS_COINS
$BINARY gentx val1 100000000stake --chain-id $CHAIN_ID --keyring-backend test
$BINARY collect-gentxs

# Modify app.toml
sed -i '' 's/enable = false/enable = true/g' $HOME_1/config/app.toml
sed -i '' 's/swagger = false/swagger = true/g' $HOME_1/config/app.toml

# Modify governance proposal for testing purpose
sed -i '' 's%"amount": "10000000"%"amount": "1"%g' $HOME_1/config/genesis.json
sed -i '' 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_1/config/genesis.json
sed -i '' 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_1/config/genesis.json
sed -i '' 's%"voting_period": "172800s"%"voting_period": "60s"%g' $HOME_1/config/genesis.json

# Start
$BINARY start
```

# Public Farming Plan

## AddPublicFarmingFixedAmountPlan

```json
{
"title": "Public Farming Plan",
"description": "Are you ready to farm?",
"add_request_proposals": [
{
"name": "First Public Farming Plan",
"farming_pool_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v",
"termination_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v",
"staking_coin_weights": [
{
"denom": "PoolCoinDenom",
"amount": "1.000000000000000000"
}
],
"start_time": "2021-07-15T08:41:21.662422Z",
"end_time": "2022-07-16T08:41:21.662422Z",
"epoch_amount": [
{
"denom": "uatom",
"amount": "1"
}
]
}
]
}
```

## AddPublicFarmingRatioPlan

```json
{
"title": "Public Farming Plan",
"description": "Are you ready to farm?",
"add_request_proposals": [
{
"name": "First Public Farming Plan",
"farming_pool_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v",
"termination_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v",
"staking_coin_weights": [
{
"denom": "PoolCoinDenom",
"amount": "1.000000000000000000"
}
],
"start_time": "2021-07-15T08:41:21.662422Z",
"end_time": "2022-07-16T08:41:21.662422Z",
"epoch_ratio": "1.000000000000000000"
}
]
}
```

## AddMultiplePublicPlans

```json
{
"title": "Public Farming Plan",
"description": "Are you ready to farm?",
"add_request_proposals": [
{
"name": "First Public Farming Plan",
"farming_pool_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v",
"termination_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v",
"staking_coin_weights": [
{
"denom": "PoolCoinDenom",
"amount": "1.000000000000000000"
}
],
"start_time": "2021-07-15T08:41:21.662422Z",
"end_time": "2022-07-16T08:41:21.662422Z",
"epoch_amount": [
{
"denom": "uatom",
"amount": "1"
}
]
},
{
"name": "First Public Farming Plan",
"farming_pool_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v",
"termination_address": "cosmos1zaavvzxez0elundtn32qnk9lkm8kmcszzsv80v",
"staking_coin_weights": [
{
"denom": "PoolCoinDenom",
"amount": "1.000000000000000000"
}
],
"start_time": "2021-07-15T08:41:21.662422Z",
"end_time": "2022-07-16T08:41:21.662422Z",
"epoch_ratio": "1.000000000000000000"
}
]
}
```

## UpdatePublicFarmingFixedAmountPlan

```json
{
"title": "Let's Update the Farming Plan 1",
"description": "FarmingPoolAddress needs to be changed",
"update_request_proposals": [
{
"plan_id": 1,
"farming_pool_address": "cosmos13w4ueuk80d3kmwk7ntlhp84fk0arlm3mqf0w08",
"termination_address": "cosmos13w4ueuk80d3kmwk7ntlhp84fk0arlm3mqf0w08",
"staking_coin_weights": [
{
"denom": "uatom",
"amount": "1.000000000000000000"
}
],
"start_time": "2021-07-15T08:41:21.662422Z",
"end_time": "2022-07-16T08:41:21.662422Z",
"epoch_amount": [
{
"denom": "uatom",
"amount": "1"
}
]
}
]
}
```

## DeletePublicFarmingFixedAmountPlan

```json
{
"title": "Delete Public Farming Plan 1",
"description": "This plan is no longer needed",
"delete_request_proposals": [
{
"plan_id": 1
}
]
}
```

# Private Farming Plan

## PrivateFarmingFixedAmountPlan

```json
{
"name": "This Farming Plan intends to incentivize ATOM HODLERS!",
"staking_coin_weights": [
{
"denom": "uatom",
"amount": "1.000000000000000000"
}
],
"start_time": "2021-07-15T08:41:21.662422Z",
"end_time": "2022-07-16T08:41:21.662422Z",
"epoch_amount": [
{
"denom": "uatom",
"amount": "1"
}
]
}
```

## PrivateFarmingRatioPlan

```json
{
"name": "This Farming Plan intends to incentivize ATOM HODLERS!",
"staking_coin_weights": [
{
"denom": "uatom",
"amount": "1.000000000000000000"
}
],
"start_time": "2021-07-15T08:41:21.662422Z",
"end_time": "2022-07-16T08:41:21.662422Z",
"epoch_ratio":"1.000000000000000000"
}
```
jaybxyz marked this conversation as resolved.
Show resolved Hide resolved
9 changes: 9 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Farming Module Documentation

## Get Started

## References

## Other Resources

## Contribute
1 change: 1 addition & 0 deletions docs/Tutorials/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
## Tutorials
17 changes: 10 additions & 7 deletions proto/tendermint/farming/v1beta1/farming.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,36 +51,39 @@ message BasePlan {
// id specifies index of the farming plan
uint64 id = 1;

// name specifies the name for the base plan
string name = 2;

// type specifies the plan type; type 0 is public and 1 is private
// public plan must be created through governance proposal and private plan is
// created by account
PlanType type = 2;
PlanType type = 3;

// farming_pool_address defines the bech32-encoded address of the farming pool
string farming_pool_address = 3 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""];
string farming_pool_address = 4 [(gogoproto.moretags) = "yaml:\"farming_pool_address\""];

// reward_pool_address defines the bech32-encoded address that distributes
// reward amount of coins to farmers
string reward_pool_address = 4 [(gogoproto.moretags) = "yaml:\"reward_pool_address\""];
string reward_pool_address = 5 [(gogoproto.moretags) = "yaml:\"reward_pool_address\""];

// termination_address defines the bech32-encoded address that terminates plan
// when the plan ends after the end time, the balance of farming pool address
// is transferred to the termination address
string termination_address = 5 [(gogoproto.moretags) = "yaml:\"termination_address\""];
string termination_address = 6 [(gogoproto.moretags) = "yaml:\"termination_address\""];

// staking_coin_weights specifies coin weights for the plan
repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 6 [
repeated cosmos.base.v1beta1.DecCoin staking_coin_weights = 7 [
(gogoproto.moretags) = "yaml:\"staking_coin_weights\"",
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.DecCoins",
(gogoproto.nullable) = false
];

// start_time specifies the start time of the plan
google.protobuf.Timestamp start_time = 7
google.protobuf.Timestamp start_time = 8
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\""];

// end_time specifies the end time of the plan
google.protobuf.Timestamp end_time = 8
google.protobuf.Timestamp end_time = 9
[(gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"end_time\""];
}

Expand Down
Loading