Skip to content

Commit

Permalink
Added testnet command and localnet targets
Browse files Browse the repository at this point in the history
Finished testnet command and introduced localnet targets in Makefile, together with gaiadnode Docker image

Fixed function parameter list - now starts with ctx

Separated GenTxConfig into a server/config package so both the server package and the mock package can use it

Adding server/config to app package

gaiadnode Docker image

Separated GenTxConfig into a server/config package so both the server package and the mock package can use it

Adding server/config to app package

Fixes requested by Rigel

Removed commented code

Global flag fixes
  • Loading branch information
greg-szabo committed Jun 12, 2018
1 parent 1b20adc commit 4c5e536
Show file tree
Hide file tree
Showing 15 changed files with 630 additions and 179 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.swp
*.swo
.vscode
.idea

# Build
vendor
Expand All @@ -15,6 +16,7 @@ docs/_build
examples/basecoin/app/data
baseapp/data/*
client/lcd/keys/*
mytestnet

# Testing
coverage.txt
Expand Down
93 changes: 36 additions & 57 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
# Changelog

## Pending

BREAKING CHANGES
* msg.GetSignBytes() now returns bech32-encoded addresses in all cases
* [lcd] REST end-points now include gas
* [cli] rearranged commands under subcommands
* [stake] remove Tick and add EndBlocker

FEATURES

IMPROVEMENTS
* export command now writes current validator set for Tendermint
* [tests] Application module tests now use a mock application
* [gaiacli] Fix error message when account isn't found when running gaiacli account
* [lcd] refactored to eliminate use of global variables, and interdependent tests
* bank module uses go-wire codec instead of 'encoding/json'
* auth module uses go-wire codec instead of 'encoding/json'
* revised use of endblock and beginblock
* added testnet command
* added localnet commands to Makefile (docker-based local testnet)

FIXES
* [lcd] Switch to bech32 for addresses on all human readable inputs and outputs
* [lcd] fixed tx indexing/querying
* [cli] Added `--gas` flag to specify transaction gas limit
* [cli] fixed cli-bash tests
* [ci] added cli-bash tests
* [basecoin] updated basecoin for stake and slashing

## 0.18.1

BREAKING CHANGES

* [x/auth] move stuff specific to auth anteHandler to the auth module rather than the types folder. This includes:
* StdTx (and its related stuff i.e. StdSignDoc, etc)
* StdFee
* StdSignature
* Account interface
* Related to this organization, I also:
* [x/auth] got rid of AccountMapper interface (in favor of the struct already in auth module)
* [x/auth] removed the FeeHandler function from the AnteHandler, Replaced with FeeKeeper
* [x/auth] Removed GetSignatures() from Tx interface (as different Tx styles might use something different than StdSignature)
* [store] Removed SubspaceIterator and ReverseSubspaceIterator from KVStore interface and replaced them with helper functions in /types
* Switch to bech32cosmos on all human readable inputs and outputs

BUG FIXES

* auto-sequencing transactions correctly
* query sequence via account store
* fixed duplicate pub_key in stake.Validator

## 0.18.0

_2018-06-05_
_TBD_

BREAKING CHANGES

Expand All @@ -38,20 +63,6 @@ BREAKING CHANGES
* Introduction of Unbonding fields, lowlevel logic throughout (not fully implemented with queue)
* Introduction of PoolShares type within validators,
replaces three rational fields (BondedShares, UnbondingShares, UnbondedShares
* [x/auth] move stuff specific to auth anteHandler to the auth module rather than the types folder. This includes:
* StdTx (and its related stuff i.e. StdSignDoc, etc)
* StdFee
* StdSignature
* Account interface
* Related to this organization, I also:
* [x/auth] got rid of AccountMapper interface (in favor of the struct already in auth module)
* [x/auth] removed the FeeHandler function from the AnteHandler, Replaced with FeeKeeper
* [x/auth] Removed GetSignatures() from Tx interface (as different Tx styles might use something different than StdSignature)
* [store] Removed SubspaceIterator and ReverseSubspaceIterator from KVStore interface and replaced them with helper functions in /types
* [cli] rearranged commands under subcommands
* [stake] remove Tick and add EndBlocker
* Switch to bech32cosmos on all human readable inputs and outputs


FEATURES

Expand All @@ -68,41 +79,12 @@ FEATURES
* [stake] Added REST API
* [Makefile] Added terraform/ansible playbooks to easily create remote testnets on Digital Ocean


BUG FIXES

* Auto-sequencing now works correctly
* [stake] staking delegator shares exchange rate now relative to equivalent-bonded-tokens the validator has instead of bonded tokens
^ this is important for unbonded validators in the power store!
* [cli] fixed cli-bash tests
* [ci] added cli-bash tests
* [basecoin] updated basecoin for stake and slashing
* [docs] fixed references to old cli commands
* [docs] Downgraded Swagger to v2 for downstream compatibility
* auto-sequencing transactions correctly
* query sequence via account store
* fixed duplicate pub_key in stake.Validator
* Auto-sequencing now works correctly



## 0.17.5

*June 5, 2018*

Update to Tendermint v0.19.9 (Fix evidence reactor, mempool deadlock, WAL panic,
memory leak)

## 0.17.4

*May 31, 2018*

Update to Tendermint v0.19.7 (WAL fixes and more)

## 0.17.3

*May 29, 2018*

Update to Tendermint v0.19.6 (fix fast-sync halt)

## 0.17.2

Expand Down Expand Up @@ -142,7 +124,6 @@ BUG FIXES

* Auto-sequencing now works correctly


## 0.16.0 (May 14th, 2018)

BREAKING CHANGES
Expand Down Expand Up @@ -177,14 +158,12 @@ BUG FIXES

* Gaia now uses stake, ported from github.com/cosmos/gaia


## 0.15.1 (April 29, 2018)

IMPROVEMENTS:

* Update Tendermint to v0.19.1 (includes many rpc fixes)


## 0.15.0 (April 29, 2018)

NOTE: v0.15.0 is a large breaking change that updates the encoding scheme to use
Expand Down
19 changes: 17 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,27 @@ devdoc_update:


########################################
### Remote validator nodes using terraform and ansible
### Local validator nodes using docker and docker-compose

# Build linux binary
build-linux:
GOOS=linux GOARCH=amd64 $(MAKE) build

build-docker-gaiadnode:
$(MAKE) -C networks/local

# Run a 4-node testnet locally
localnet-start: localnet-stop
@if ! [ -f build/node0/gaiad/config/genesis.json ]; then docker run --rm -v $(CURDIR)/build:/gaiad:Z tendermint/gaiadnode testnet --v 4 --o . --starting-ip-address 192.168.10.2 ; fi
docker-compose up

# Stop testnet
localnet-stop:
docker-compose down

########################################
### Remote validator nodes using terraform and ansible

TESTNET_NAME?=remotenet
SERVERS?=4
BINARY=$(CURDIR)/build/gaiad
Expand All @@ -157,4 +172,4 @@ remotenet-status:
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build build_examples install install_examples dist check_tools get_tools get_vendor_deps draw_deps test test_cli test_unit test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update remotenet-start remotenet-stop remotenet-status
.PHONY: build build_examples install install_examples dist check_tools get_tools get_vendor_deps draw_deps test test_cli test_unit test_cover test_lint benchmark devdoc_init devdoc devdoc_save devdoc_update build-linux build-docker-gaiadnode localnet-start localnet-stop remotenet-start remotenet-stop remotenet-status
42 changes: 15 additions & 27 deletions cmd/gaia/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ package app
import (
"encoding/json"
"errors"

"github.com/spf13/pflag"
"github.com/spf13/viper"
crypto "github.com/tendermint/go-crypto"
tmtypes "github.com/tendermint/tendermint/types"

"github.com/cosmos/cosmos-sdk/server"
gc "github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/wire"
"github.com/cosmos/cosmos-sdk/x/auth"
Expand Down Expand Up @@ -50,25 +49,15 @@ func (ga *GenesisAccount) ToAccount() (acc *auth.BaseAccount) {
}
}

var (
flagName = "name"
flagClientHome = "home-client"
flagOWK = "owk"

// bonded tokens given to genesis validators/accounts
freeFermionVal = int64(100)
freeFermionsAcc = int64(50)
)

// get app init parameters for server init command
func GaiaAppInit() server.AppInit {
fsAppGenState := pflag.NewFlagSet("", pflag.ContinueOnError)

fsAppGenTx := pflag.NewFlagSet("", pflag.ContinueOnError)
fsAppGenTx.String(flagName, "", "validator moniker, required")
fsAppGenTx.String(flagClientHome, DefaultCLIHome,
fsAppGenTx.String(server.FlagName, "", "validator moniker, required")
fsAppGenTx.String(server.FlagClientHome, DefaultCLIHome,
"home directory for the client, used for key generation")
fsAppGenTx.Bool(flagOWK, false, "overwrite the accounts created")
fsAppGenTx.Bool(server.FlagOWK, false, "overwrite the accounts created")

return server.AppInit{
FlagsAppGenState: fsAppGenState,
Expand All @@ -86,18 +75,15 @@ type GaiaGenTx struct {
}

// Generate a gaia genesis transaction with flags
func GaiaAppGenTx(cdc *wire.Codec, pk crypto.PubKey) (
func GaiaAppGenTx(cdc *wire.Codec, pk crypto.PubKey, genTxConfig gc.GenTxConfig) (
appGenTx, cliPrint json.RawMessage, validator tmtypes.GenesisValidator, err error) {
clientRoot := viper.GetString(flagClientHome)
overwrite := viper.GetBool(flagOWK)
name := viper.GetString(flagName)
if name == "" {
if genTxConfig.Name == "" {
return nil, nil, tmtypes.GenesisValidator{}, errors.New("Must specify --name (validator moniker)")
}

var addr sdk.Address
var secret string
addr, secret, err = server.GenerateSaveCoinKey(clientRoot, name, "1234567890", overwrite)
addr, secret, err = server.GenerateSaveCoinKey(genTxConfig.CliRoot, genTxConfig.Name, "1234567890", genTxConfig.Overwrite)
if err != nil {
return
}
Expand All @@ -107,8 +93,10 @@ func GaiaAppGenTx(cdc *wire.Codec, pk crypto.PubKey) (
if err != nil {
return
}

cliPrint = json.RawMessage(bz)
return GaiaAppGenTxNF(cdc, pk, addr, name, overwrite)
appGenTx, _, validator, err = GaiaAppGenTxNF(cdc, pk, addr, genTxConfig.Name, genTxConfig.Overwrite)
return
}

// Generate a gaia genesis transaction without flags
Expand All @@ -129,7 +117,7 @@ func GaiaAppGenTxNF(cdc *wire.Codec, pk crypto.PubKey, addr sdk.Address, name st

validator = tmtypes.GenesisValidator{
PubKey: pk,
Power: freeFermionVal,
Power: server.FreeFermionVal,
}
return
}
Expand Down Expand Up @@ -160,21 +148,21 @@ func GaiaAppGenState(cdc *wire.Codec, appGenTxs []json.RawMessage) (genesisState
accAuth := auth.NewBaseAccountWithAddress(genTx.Address)
accAuth.Coins = sdk.Coins{
{genTx.Name + "Token", 1000},
{"steak", freeFermionsAcc},
{"steak", server.FreeFermionsAcc},
}
acc := NewGenesisAccount(&accAuth)
genaccs[i] = acc
stakeData.Pool.LooseUnbondedTokens += freeFermionsAcc // increase the supply
stakeData.Pool.LooseUnbondedTokens += server.FreeFermionsAcc // increase the supply

// add the validator
if len(genTx.Name) > 0 {
desc := stake.NewDescription(genTx.Name, "", "", "")
validator := stake.NewValidator(genTx.Address, genTx.PubKey, desc)
validator.PoolShares = stake.NewBondedShares(sdk.NewRat(freeFermionVal))
validator.PoolShares = stake.NewBondedShares(sdk.NewRat(server.FreeFermionVal))
stakeData.Validators = append(stakeData.Validators, validator)

// pool logic
stakeData.Pool.BondedTokens += freeFermionVal
stakeData.Pool.BondedTokens += server.FreeFermionVal
stakeData.Pool.BondedShares = sdk.NewRat(stakeData.Pool.BondedTokens)
}
}
Expand Down
68 changes: 68 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
version: '3'

services:
node0:
container_name: node0
image: "tendermint/gaiadnode"
ports:
- "46656-46657:46656-46657"
environment:
- ID=0
- LOG=$${LOG:-gaiad.log}
volumes:
- ./build:/gaiad:Z
networks:
localnet:
ipv4_address: 192.168.10.2

node1:
container_name: node1
image: "tendermint/gaiadnode"
ports:
- "46659-46660:46656-46657"
environment:
- ID=1
- LOG=$${LOG:-gaiad.log}
volumes:
- ./build:/gaiad:Z
networks:
localnet:
ipv4_address: 192.168.10.3

node2:
container_name: node2
image: "tendermint/gaiadnode"
environment:
- ID=2
- LOG=$${LOG:-gaiad.log}
ports:
- "46661-46662:46656-46657"
volumes:
- ./build:/gaiad:Z
networks:
localnet:
ipv4_address: 192.168.10.4

node3:
container_name: node3
image: "tendermint/gaiadnode"
environment:
- ID=3
- LOG=$${LOG:-gaiad.log}
ports:
- "46663-46664:46656-46657"
volumes:
- ./build:/gaiad:Z
networks:
localnet:
ipv4_address: 192.168.10.5

networks:
localnet:
driver: bridge
ipam:
driver: default
config:
-
subnet: 192.168.10.0/16

7 changes: 7 additions & 0 deletions networks/local/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Makefile for the "gaiadnode" docker image.

all:
docker build --tag tendermint/gaiadnode gaiadnode

.PHONY: all

Loading

0 comments on commit 4c5e536

Please sign in to comment.