Skip to content

Commit

Permalink
Merge pull request cosmos#8 from cosmos/develop
Browse files Browse the repository at this point in the history
Sync fork
  • Loading branch information
dogemos committed Mar 15, 2019
2 parents 9401e91 + 1bc7716 commit 19cd8e9
Show file tree
Hide file tree
Showing 45 changed files with 1,038 additions and 666 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ v If a checkbox is n/a - please still include it but + a little note why
- [ ] Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
- [ ] Wrote tests
- [ ] Updated relevant documentation (`docs/`)
- [ ] Added entries in `PENDING.md` with issue #
- [ ] Added a relevant changelog entry: `sdkch add [section] [stanza] [message]`
- [ ] rereviewed `Files changed` in the github PR explorer

______
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3837 Fix `WithdrawValidatorCommission` to properly set the validator's remaining commission.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3813 New sdk.NewCoins safe constructor to replace bare sdk.Coins{} declarations.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3808 `gaiad` and `gaiacli` integration tests use ./build/ binaries.
7 changes: 7 additions & 0 deletions .pending/improvements/gaia/3819-Simulation-refa
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
\#3819 Simulation refactor, log output now stored in ~/.gaiad/simulation/
* Simulation moved to its own module (not a part of mock)
* Logger type instead of passing function variables everywhere
* Logger json output (for reloadable simulation running)
* Cleanup bank simulation messages / remove dup code in bank simulation
* Simulations saved in `~/.gaiad/simulations/`
* "Lean" simulation output option to exclude No-ops and !ok functions (`--SimulationLean` flag)
1 change: 1 addition & 0 deletions .pending/improvements/gaiacli/3841-Add-indent-to-J
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3841 Add indent to JSON of `gaiacli keys [add|show|list]`
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3859 Add newline to echo of `gaiacli keys ...`
1 change: 1 addition & 0 deletions .pending/improvements/sdk/3801-baseapp-safety-improvements
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3801 `baseapp` safety improvements
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3820 Make Coins.IsAllGT() more robust and consistent.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3828 New sdkch tool to maintain changelogs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#3864 Make Coins.IsAllGTE() more consistent.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,16 @@ update_dev_tools:
go get -u github.com/tendermint/lint/golint

devtools: devtools-stamp
devtools-clean: tools-clean
devtools-stamp: tools
@echo "--> Downloading linters (this may take awhile)"
$(GOPATH)/src/github.com/alecthomas/gometalinter/scripts/install.sh -b $(GOBIN)
go get github.com/tendermint/lint/golint
go install ./cmd/sdkch
touch $@

devtools-clean: tools-clean
rm -f devtools-stamp

vendor-deps: tools
@echo "--> Generating vendor directory via dep ensure"
@rm -rf .vendor-new
Expand Down
77 changes: 0 additions & 77 deletions PENDING.md

This file was deleted.

2 changes: 1 addition & 1 deletion client/lcd/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1744,7 +1744,7 @@ definitions:
properties:
denom:
type: string
example: steak
example: stake
amount:
type: string
example: "50"
Expand Down
2 changes: 1 addition & 1 deletion client/lcd/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func InitClientHome(t *testing.T, dir string) string {
// TODO: Make InitializeTestLCD safe to call in multiple tests at the same time
// InitializeTestLCD starts Tendermint and the LCD in process, listening on
// their respective sockets where nValidators is the total number of validators
// and initAddrs are the accounts to initialize with some steak tokens. It
// and initAddrs are the accounts to initialize with some stake tokens. It
// returns a cleanup function, a set of validator public keys, and a port.
func InitializeTestLCD(t *testing.T, nValidators int, initAddrs []sdk.AccAddress, minting bool) (
cleanup func(), valConsPubKeys []crypto.PubKey, valOperAddrs []sdk.ValAddress, port string) {
Expand Down
86 changes: 33 additions & 53 deletions cmd/gaia/app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govsim "github.com/cosmos/cosmos-sdk/x/gov/simulation"
"github.com/cosmos/cosmos-sdk/x/mint"
"github.com/cosmos/cosmos-sdk/x/mock/simulation"
"github.com/cosmos/cosmos-sdk/x/simulation"
"github.com/cosmos/cosmos-sdk/x/slashing"
slashingsim "github.com/cosmos/cosmos-sdk/x/slashing/simulation"
"github.com/cosmos/cosmos-sdk/x/staking"
Expand All @@ -43,19 +43,30 @@ var (
blockSize int
enabled bool
verbose bool
lean bool
commit bool
period int
)

func init() {
flag.StringVar(&genesisFile, "SimulationGenesis", "", "Custom simulation genesis file")
flag.Int64Var(&seed, "SimulationSeed", 42, "Simulation random seed")
flag.IntVar(&numBlocks, "SimulationNumBlocks", 500, "Number of blocks")
flag.IntVar(&blockSize, "SimulationBlockSize", 200, "Operations per block")
flag.BoolVar(&enabled, "SimulationEnabled", false, "Enable the simulation")
flag.BoolVar(&verbose, "SimulationVerbose", false, "Verbose log output")
flag.BoolVar(&commit, "SimulationCommit", false, "Have the simulation commit")
flag.IntVar(&period, "SimulationPeriod", 1, "Run slow invariants only once every period assertions")
flag.StringVar(&genesisFile, "SimulationGenesis", "", "custom simulation genesis file")
flag.Int64Var(&seed, "SimulationSeed", 42, "simulation random seed")
flag.IntVar(&numBlocks, "SimulationNumBlocks", 500, "number of blocks")
flag.IntVar(&blockSize, "SimulationBlockSize", 200, "operations per block")
flag.BoolVar(&enabled, "SimulationEnabled", false, "enable the simulation")
flag.BoolVar(&verbose, "SimulationVerbose", false, "verbose log output")
flag.BoolVar(&lean, "SimulationLean", false, "lean simulation log output")
flag.BoolVar(&commit, "SimulationCommit", false, "have the simulation commit")
flag.IntVar(&period, "SimulationPeriod", 1, "run slow invariants only once every period assertions")
}

// helper function for populating input for SimulateFromSeed
func getSimulateFromSeedInput(tb testing.TB, app *GaiaApp) (
testing.TB, *baseapp.BaseApp, simulation.AppStateFn, int64,
simulation.WeightedOperations, sdk.Invariants, int, int, bool, bool) {

return tb, app.BaseApp, appStateFn, seed,
testAndRunTxs(app), invariants(app), numBlocks, blockSize, commit, lean
}

func appStateFromGenesisFileFn(r *rand.Rand, accs []simulation.Account, genesisTimestamp time.Time) (json.RawMessage, []simulation.Account, string) {
Expand Down Expand Up @@ -92,7 +103,7 @@ func appStateRandomizedFn(r *rand.Rand, accs []simulation.Account, genesisTimest
numInitiallyBonded = numAccs
}
fmt.Printf("Selected randomly generated parameters for simulated genesis:\n"+
"\t{amount of steak per account: %v, initially bonded validators: %v}\n",
"\t{amount of stake per account: %v, initially bonded validators: %v}\n",
amount, numInitiallyBonded)

// randomly generate some genesis accounts
Expand Down Expand Up @@ -265,8 +276,8 @@ func randIntBetween(r *rand.Rand, min, max int) int {
func testAndRunTxs(app *GaiaApp) []simulation.WeightedOperation {
return []simulation.WeightedOperation{
{5, authsim.SimulateDeductFee(app.accountKeeper, app.feeCollectionKeeper)},
{100, banksim.SendMsg(app.accountKeeper, app.bankKeeper)},
{10, banksim.SingleInputMsgMultiSend(app.accountKeeper, app.bankKeeper)},
{100, banksim.SimulateMsgSend(app.accountKeeper, app.bankKeeper)},
{10, banksim.SimulateSingleInputMsgMultiSend(app.accountKeeper, app.bankKeeper)},
{50, distrsim.SimulateMsgSetWithdrawAddress(app.accountKeeper, app.distrKeeper)},
{50, distrsim.SimulateMsgWithdrawDelegatorReward(app.accountKeeper, app.distrKeeper)},
{50, distrsim.SimulateMsgWithdrawValidatorCommission(app.accountKeeper, app.distrKeeper)},
Expand Down Expand Up @@ -314,14 +325,7 @@ func BenchmarkFullGaiaSimulation(b *testing.B) {

// Run randomized simulation
// TODO parameterize numbers, save for a later PR
_, err := simulation.SimulateFromSeed(
b, app.BaseApp, appStateFn, seed,
testAndRunTxs(app),
invariants(app), // these shouldn't get ran
numBlocks,
blockSize,
commit,
)
_, err := simulation.SimulateFromSeed(getSimulateFromSeedInput(b, app))
if err != nil {
fmt.Println(err)
b.Fail()
Expand Down Expand Up @@ -356,14 +360,7 @@ func TestFullGaiaSimulation(t *testing.T) {
require.Equal(t, "GaiaApp", app.Name())

// Run randomized simulation
_, err := simulation.SimulateFromSeed(
t, app.BaseApp, appStateFn, seed,
testAndRunTxs(app),
invariants(app),
numBlocks,
blockSize,
commit,
)
_, err := simulation.SimulateFromSeed(getSimulateFromSeedInput(t, app))
if commit {
// for memdb:
// fmt.Println("Database Size", db.Stats()["database.size"])
Expand Down Expand Up @@ -397,14 +394,8 @@ func TestGaiaImportExport(t *testing.T) {
require.Equal(t, "GaiaApp", app.Name())

// Run randomized simulation
_, err := simulation.SimulateFromSeed(
t, app.BaseApp, appStateFn, seed,
testAndRunTxs(app),
invariants(app),
numBlocks,
blockSize,
commit,
)
_, err := simulation.SimulateFromSeed(getSimulateFromSeedInput(t, app))

if commit {
// for memdb:
// fmt.Println("Database Size", db.Stats()["database.size"])
Expand Down Expand Up @@ -446,7 +437,8 @@ func TestGaiaImportExport(t *testing.T) {
storeKeysPrefixes := []StoreKeysPrefixes{
{app.keyMain, newApp.keyMain, [][]byte{}},
{app.keyAccount, newApp.keyAccount, [][]byte{}},
{app.keyStaking, newApp.keyStaking, [][]byte{staking.UnbondingQueueKey, staking.RedelegationQueueKey, staking.ValidatorQueueKey}}, // ordering may change but it doesn't matter
{app.keyStaking, newApp.keyStaking, [][]byte{staking.UnbondingQueueKey,
staking.RedelegationQueueKey, staking.ValidatorQueueKey}}, // ordering may change but it doesn't matter
{app.keySlashing, newApp.keySlashing, [][]byte{}},
{app.keyMint, newApp.keyMint, [][]byte{}},
{app.keyDistr, newApp.keyDistr, [][]byte{}},
Expand Down Expand Up @@ -492,14 +484,8 @@ func TestGaiaSimulationAfterImport(t *testing.T) {
require.Equal(t, "GaiaApp", app.Name())

// Run randomized simulation
stopEarly, err := simulation.SimulateFromSeed(
t, app.BaseApp, appStateFn, seed,
testAndRunTxs(app),
invariants(app),
numBlocks,
blockSize,
commit,
)
stopEarly, err := simulation.SimulateFromSeed(getSimulateFromSeedInput(t, app))

if commit {
// for memdb:
// fmt.Println("Database Size", db.Stats()["database.size"])
Expand Down Expand Up @@ -537,14 +523,7 @@ func TestGaiaSimulationAfterImport(t *testing.T) {
})

// Run randomized simulation on imported app
_, err = simulation.SimulateFromSeed(
t, newApp.BaseApp, appStateFn, seed,
testAndRunTxs(newApp),
invariants(newApp),
numBlocks,
blockSize,
commit,
)
_, err = simulation.SimulateFromSeed(getSimulateFromSeedInput(t, newApp))
require.Nil(t, err)

}
Expand Down Expand Up @@ -575,6 +554,7 @@ func TestAppStateDeterminism(t *testing.T) {
50,
100,
true,
false,
)
appHash := app.LastCommitID().Hash
appHashList[j] = appHash
Expand Down
50 changes: 50 additions & 0 deletions cmd/sdkch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# sdkch
Simple tool to maintain modular changelogs

# Usage

```
$ sdkch -help
usage: sdkch [-d directory] [-prune] command
Maintain unreleased changelog entries in a modular fashion.
Commands:
add section stanza [message] Add an entry file.
If message is empty, start the editor to edit
the message.
generate [version] Generate a changelog in Markdown format and print
it to STDOUT. version defaults to UNRELEASED.
Sections Stanzas
--- ---
breaking gaia
features gaiacli
improvements gaiarest
bugfixes sdk
tendermint
Flags:
-d string
entry files directory (default "/home/alessio/work/tendermint/src/github.com/cosmos/cosmos-sdk/.pending")
-prune
prune old entries after changelog generation
```

## Add a new entry

You can either drop a text file in the appropriate directory or use the `add` command:

```bash
$ sdkch add features gaiacli '#3452 New cool gaiacli command'
```

If no message is provided, a new entry file is opened in an editor is started

## Generate the full changelog

```bash
$ sdkch generate v0.30.0
```

The `-prune` flag would remove the old entry files after the changelog is generated.
Loading

0 comments on commit 19cd8e9

Please sign in to comment.