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

feat: add starport for better development environment #231

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,8 @@ test-sim-after-import
### Localnet ###
###############################################################################

# Run a single testnet locally
localnet:
./scripts/localnet.sh
starport c serve

.PHONY: localnet

Expand Down Expand Up @@ -220,14 +219,10 @@ containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer)
proto-all: proto-format proto-lint proto-gen proto-swagger-gen update-swagger-docs

proto-gen:
@echo "Generating Protobuf files"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protocgen.sh; fi
starport g proto-go

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
@if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \
sh ./scripts/protoc-swagger-gen.sh; fi
starport g openapi

proto-format:
@echo "Formatting Protobuf files"
Expand Down
13 changes: 13 additions & 0 deletions TECHNICAL-SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,16 @@ Run `make test-all` command to run tests.

> 💡 you can also use the default `go` command to build the project, check the content of the [Makefile](https://github.com/tendermint/farming/blob/main/Makefile#L145) for reference

## Getting Started

The farming module uses [Starport](https://docs.starport.network/guide/). You can install it by simply running the following command. If you want to know more about the installation, you can go to the [official docs](https://docs.starport.network/guide/install.html).

```bash
curl https://get.starport.network/starport! | bash
```

`serve` command installs dependencies, builds, initializes, and starts your blockchain in development.

```bash
starport chain serve
```
28 changes: 28 additions & 0 deletions config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
accounts:
- name: alice
coins: ["10000000000stake", "10000000uatom"]
- name: bob
coins: ["10000000000stake", "10000000uatom"]
validator:
name: alice
staked: "100000000stake"
client:
openapi:
path: "docs/static/openapi.yml"
vuex:
path: "vue/src/store"
faucet:
name: bob
coins: ["10000000stake","10000000uatom"]
genesis:
app_state:
gov:
deposit_params:
min_deposit:
- denom: "stake"
amount: "1"
voting_params:
voting_period: "1s"
tally_params:
quorum: "0.000000000000000001"
threshold: "0.000000000000000001"
56 changes: 37 additions & 19 deletions docs/Tutorials/localnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,26 @@ Title: Localnet
Description: A tutorial of how to build `farmingd` and bootstrap local network.
---

### Get farming module source code
## Get farming module source code

```bash
# Use git to clone farming module source code and install `farmingd`
git clone https://github.com/tendermint/farming.git
cd farming
make install
```

### Boostrap
## Start a blockchain with Starport

The following script is prepared to bootstrap a single chain with a single validator in your local machine. Copy the script and run them in your terminal.
Use [Starport CLI](https://docs.starport.network/cli/#starport-chain-serve) to start a local blockchain with automatic reloading. You can configure custom settings in [config.yml](../../../config.yml).

```bash
starport chain serve
```

## Start a blockchain with commands

The following commands are used to bootstrap a single chain with a single validator in your local machine. Copy the commands and run them in your terminal.

```bash
# Configure variables
Expand All @@ -27,7 +36,7 @@ export VALIDATOR_1_GENESIS_COINS=10000000000stake,10000000000uatom,10000000000uu
export USER_1_GENESIS_COINS=10000000000stake,10000000000uatom,10000000000uusd
export USER_2_GENESIS_COINS=10000000000stake,10000000000poolD35A0CC16EE598F90B044CE296A405BA9C381E38837599D96F2F70C2F02A23A4

# Bootstrap
# Initialize chain and craete gentx for a single validator
$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
Expand All @@ -38,21 +47,30 @@ $BINARY add-genesis-account $($BINARY keys show user2 --keyring-backend test -a)
$BINARY gentx val1 100000000stake --chain-id $CHAIN_ID --keyring-backend test
$BINARY collect-gentxs

# Check OS for sed -i option value
export SED_I=""
if [[ "$OSTYPE" == "darwin"* ]]; then
export SED_I="''"
fi

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

# (Optional) Modify governance proposal for testing public plan proposal
sed -i $SED_I 's%"amount": "10000000"%"amount": "1"%g' $HOME_FARMINGAPP/config/genesis.json
sed -i $SED_I 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_FARMINGAPP/config/genesis.json
sed -i $SED_I 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_FARMINGAPP/config/genesis.json
sed -i $SED_I 's%"voting_period": "172800s"%"voting_period": "60s"%g' $HOME_FARMINGAPP/config/genesis.json
# Check platform
platform='unknown'
unamestr=`uname`
if [ "$unamestr" = 'Linux' ]; then
platform='linux'
fi

if [ $platform = 'linux' ]; then
sed -i 's/enable = false/enable = true/g' $HOME_BUDGETAPP/config/app.toml
sed -i 's/swagger = false/swagger = true/g' $HOME_BUDGETAPP/config/app.toml
sed -i 's%"amount": "10000000"%"amount": "1"%g' $HOME_BUDGETAPP/config/genesis.json
# (Optional) Modify governance proposal for testing public plan proposal
sed -i 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json
sed -i 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json
sed -i 's%"voting_period": "172800s"%"voting_period": "30s"%g' $HOME_BUDGETAPP/config/genesis.json
else
sed -i '' 's/enable = false/enable = true/g' $HOME_BUDGETAPP/config/app.toml
sed -i '' 's/swagger = false/swagger = true/g' $HOME_BUDGETAPP/config/app.toml
sed -i '' 's%"amount": "10000000"%"amount": "1"%g' $HOME_BUDGETAPP/config/genesis.json
# (Optional) Modify governance proposal for testing public plan proposal
sed -i '' 's%"quorum": "0.334000000000000000",%"quorum": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json
sed -i '' 's%"threshold": "0.500000000000000000",%"threshold": "0.000000000000000001",%g' $HOME_BUDGETAPP/config/genesis.json
sed -i '' 's%"voting_period": "172800s"%"voting_period": "30s"%g' $HOME_BUDGETAPP/config/genesis.json
fi

# Start
$BINARY start
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/gorilla/mux v1.8.0
github.com/gravity-devs/liquidity v1.4.2
github.com/grpc-ecosystem/grpc-gateway v1.16.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.6.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/spf13/cast v1.3.1
Expand All @@ -20,8 +20,8 @@ require (
github.com/tendermint/budget v1.0.0-rc1
github.com/tendermint/tendermint v0.34.14
github.com/tendermint/tm-db v0.6.4
google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83
google.golang.org/grpc v1.40.0
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1
google.golang.org/grpc v1.42.0
google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
Loading