From 8f453eaa04bc7fe06527a2a60b720d3998a6dc41 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 16 Jul 2018 17:43:10 +0100 Subject: [PATCH 1/5] update params for x/gov and default config --- CHANGELOG.md | 16 ++++++++++++++++ server/util.go | 17 +++++++++++------ x/gov/keeper.go | 6 +++--- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2915450c2..3690f5b74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Changelog +## 0.22.0 + +*July 16th, 2018* + +BREAKING CHANGES +* [x/gov] Increase VotingPeriod, DepositPeriod, and MinDeposit + +IMPROVEMENTS +* [gaiad] Default config updates: + - `timeout_commit=5000` so blocks only made every 5s + - `prof_listen_addr=localhost:6060` so profile server is on by default + - `p2p.send_rate` and `p2p.recv_rate` increases 10x (~5MB/s) + +BUG FIXES +* [server] Fix to actually overwrite default tendermint config + ## 0.21.1 *July 14th, 2018* diff --git a/server/util.go b/server/util.go index 1e6ed06c9..51547d116 100644 --- a/server/util.go +++ b/server/util.go @@ -77,16 +77,21 @@ func interceptLoadConfig() (conf *cfg.Config, err error) { rootDir := tmpConf.RootDir configFilePath := filepath.Join(rootDir, "config/config.toml") // Intercept only if the file doesn't already exist + if _, err := os.Stat(configFilePath); os.IsNotExist(err) { // the following parse config is needed to create directories - sdkDefaultConfig, _ := tcmd.ParseConfig() - sdkDefaultConfig.ProfListenAddress = "prof_laddr=localhost:6060" - sdkDefaultConfig.P2P.RecvRate = 5120000 - sdkDefaultConfig.P2P.SendRate = 5120000 - cfg.WriteConfigFile(configFilePath, sdkDefaultConfig) + conf, _ = tcmd.ParseConfig() + conf.ProfListenAddress = "localhost:6060" + conf.P2P.RecvRate = 5120000 + conf.P2P.SendRate = 5120000 + conf.Consensus.TimeoutCommit = 5000 + cfg.WriteConfigFile(configFilePath, conf) // Fall through, just so that its parsed into memory. } - conf, err = tcmd.ParseConfig() + + if conf == nil { + conf, err = tcmd.ParseConfig() + } return } diff --git a/x/gov/keeper.go b/x/gov/keeper.go index b60404b8c..ea3b47b96 100644 --- a/x/gov/keeper.go +++ b/x/gov/keeper.go @@ -131,15 +131,15 @@ func (keeper Keeper) activateVotingPeriod(ctx sdk.Context, proposal Proposal) { // Gets procedure from store. TODO: move to global param store and allow for updating of this func (keeper Keeper) GetDepositProcedure() DepositProcedure { return DepositProcedure{ - MinDeposit: sdk.Coins{sdk.NewCoin("steak", 10)}, - MaxDepositPeriod: 200, + MinDeposit: sdk.Coins{sdk.NewCoin("steak", 100)}, + MaxDepositPeriod: 10000, } } // Gets procedure from store. TODO: move to global param store and allow for updating of this func (keeper Keeper) GetVotingProcedure() VotingProcedure { return VotingProcedure{ - VotingPeriod: 200, + VotingPeriod: 10000, } } From 2cbe5662d02ddd3395d7aadb05463a6bd2648c7b Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 16 Jul 2018 18:08:22 +0100 Subject: [PATCH 2/5] fix tests --- x/gov/keeper.go | 12 +++++++++--- x/gov/keeper_test.go | 7 +++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/x/gov/keeper.go b/x/gov/keeper.go index ea3b47b96..4569743ef 100644 --- a/x/gov/keeper.go +++ b/x/gov/keeper.go @@ -128,18 +128,24 @@ func (keeper Keeper) activateVotingPeriod(ctx sdk.Context, proposal Proposal) { // ===================================================== // Procedures +var ( + defaultMinDeposit int64 = 100 + defaultMaxDepositPeriod int64 = 10000 + defaultVotingPeriod int64 = 10000 +) + // Gets procedure from store. TODO: move to global param store and allow for updating of this func (keeper Keeper) GetDepositProcedure() DepositProcedure { return DepositProcedure{ - MinDeposit: sdk.Coins{sdk.NewCoin("steak", 100)}, - MaxDepositPeriod: 10000, + MinDeposit: sdk.Coins{sdk.NewCoin("steak", defaultMinDeposit)}, + MaxDepositPeriod: defaultMaxDepositPeriod, } } // Gets procedure from store. TODO: move to global param store and allow for updating of this func (keeper Keeper) GetVotingProcedure() VotingProcedure { return VotingProcedure{ - VotingPeriod: 10000, + VotingPeriod: defaultVotingPeriod, } } diff --git a/x/gov/keeper_test.go b/x/gov/keeper_test.go index 786953fd3..988a8a6a7 100644 --- a/x/gov/keeper_test.go +++ b/x/gov/keeper_test.go @@ -10,6 +10,13 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) +// overwrite defaults for testing +func init() { + defaultMinDeposit = 10 + defaultMaxDepositPeriod = 200 + defaultVotingPeriod = 200 +} + func TestGetSetProposal(t *testing.T) { mapp, keeper, _, _, _, _ := getMockApp(t, 0) mapp.BeginBlock(abci.RequestBeginBlock{}) From 566bf8e3bdade8fc3124d27c990e04c14d7da6cc Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Mon, 16 Jul 2018 20:25:20 +0200 Subject: [PATCH 3/5] Governance CLI test fixes --- x/gov/keeper.go | 2 +- x/gov/proposals.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x/gov/keeper.go b/x/gov/keeper.go index 4569743ef..572c5388e 100644 --- a/x/gov/keeper.go +++ b/x/gov/keeper.go @@ -129,7 +129,7 @@ func (keeper Keeper) activateVotingPeriod(ctx sdk.Context, proposal Proposal) { // Procedures var ( - defaultMinDeposit int64 = 100 + defaultMinDeposit int64 = 10 defaultMaxDepositPeriod int64 = 10000 defaultVotingPeriod int64 = 10000 ) diff --git a/x/gov/proposals.go b/x/gov/proposals.go index 64ffe6bfa..bb6b0aed4 100644 --- a/x/gov/proposals.go +++ b/x/gov/proposals.go @@ -60,7 +60,7 @@ type TextProposal struct { Description string `json:"description"` // Description of the proposal ProposalType ProposalKind `json:"proposal_type"` // Type of proposal. Initial set {PlainTextProposal, SoftwareUpgradeProposal} - Status ProposalStatus `json:"string"` // Status of the Proposal {Pending, Active, Passed, Rejected} + Status ProposalStatus `json:"proposal_status"` // Status of the Proposal {Pending, Active, Passed, Rejected} SubmitBlock int64 `json:"submit_block"` // Height of the block where TxGovSubmitProposal was included TotalDeposit sdk.Coins `json:"total_deposit"` // Current deposit on this proposal. Initial value is set at InitialDeposit @@ -184,7 +184,7 @@ func (pt ProposalKind) Format(s fmt.State, verb rune) { case 's': s.Write([]byte(fmt.Sprintf("%s", pt.String()))) default: - s.Write([]byte(fmt.Sprintf("%v", pt))) + s.Write([]byte(fmt.Sprintf("%v", byte(pt)))) } } @@ -283,6 +283,6 @@ func (status ProposalStatus) Format(s fmt.State, verb rune) { case 's': s.Write([]byte(fmt.Sprintf("%s", status.String()))) default: - s.Write([]byte(fmt.Sprintf("%v", status))) + s.Write([]byte(fmt.Sprintf("%v", byte(status)))) } } From 4b688992bac15e5740be1fa5f784de1cf7aa86a2 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 16 Jul 2018 11:42:28 -0700 Subject: [PATCH 4/5] Merge pull request #1691: Table driven test indexes * types: Switch table driven test error messages to new format Make table driven tests in /types follow the format described in #1664 * typos / lower case errors * lower case, not sentences * lower case, not sentences --- types/coin_test.go | 44 ++++++++++++++++----------------- types/rational.go | 2 +- types/rational_test.go | 56 ++++++++++++++++++++++-------------------- types/utils_test.go | 4 +-- 4 files changed, 54 insertions(+), 52 deletions(-) diff --git a/types/coin_test.go b/types/coin_test.go index c7ccc5746..da52b4849 100644 --- a/types/coin_test.go +++ b/types/coin_test.go @@ -17,9 +17,9 @@ func TestIsPositiveCoin(t *testing.T) { {NewCoin("a", -1), false}, } - for _, tc := range cases { + for tcIndex, tc := range cases { res := tc.inputOne.IsPositive() - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "%s positivity is incorrect, tc #%d", tc.inputOne.String(), tcIndex) } } @@ -33,9 +33,9 @@ func TestIsNotNegativeCoin(t *testing.T) { {NewCoin("a", -1), false}, } - for _, tc := range cases { + for tcIndex, tc := range cases { res := tc.inputOne.IsNotNegative() - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "%s not-negativity is incorrect, tc #%d", tc.inputOne.String(), tcIndex) } } @@ -52,9 +52,9 @@ func TestSameDenomAsCoin(t *testing.T) { {NewCoin("steak", -11), NewCoin("steak", 10), true}, } - for _, tc := range cases { + for tcIndex, tc := range cases { res := tc.inputOne.SameDenomAs(tc.inputTwo) - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "coin denominations didn't match, tc #%d", tcIndex) } } @@ -70,9 +70,9 @@ func TestIsGTECoin(t *testing.T) { {NewCoin("a", 1), NewCoin("b", 1), false}, } - for _, tc := range cases { + for tcIndex, tc := range cases { res := tc.inputOne.IsGTE(tc.inputTwo) - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "coin GTE relation is incorrect, tc #%d", tcIndex) } } @@ -89,9 +89,9 @@ func TestIsEqualCoin(t *testing.T) { {NewCoin("steak", -11), NewCoin("steak", 10), false}, } - for _, tc := range cases { + for tcIndex, tc := range cases { res := tc.inputOne.IsEqual(tc.inputTwo) - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "coin equality relation is incorrect, tc #%d", tcIndex) } } @@ -106,9 +106,9 @@ func TestPlusCoin(t *testing.T) { {NewCoin("asdf", -4), NewCoin("asdf", 5), NewCoin("asdf", 1)}, } - for _, tc := range cases { + for tcIndex, tc := range cases { res := tc.inputOne.Plus(tc.inputTwo) - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", tcIndex) } tc := struct { @@ -132,9 +132,9 @@ func TestMinusCoin(t *testing.T) { {NewCoin("asdf", 10), NewCoin("asdf", 1), NewCoin("asdf", 9)}, } - for _, tc := range cases { + for tcIndex, tc := range cases { res := tc.inputOne.Minus(tc.inputTwo) - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "difference of coins is incorrect, tc #%d", tcIndex) } tc := struct { @@ -212,10 +212,10 @@ func TestPlusCoins(t *testing.T) { {Coins{{"A", negone}, {"B", zero}}, Coins{{"A", zero}, {"B", zero}}, Coins{{"A", negone}}}, } - for _, tc := range cases { + for tcIndex, tc := range cases { res := tc.inputOne.Plus(tc.inputTwo) assert.True(t, res.IsValid()) - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "sum of coins is incorrect, tc #%d", tcIndex) } } @@ -242,12 +242,12 @@ func TestParse(t *testing.T) { {"5foo-bar", false, nil}, // once more, only letters in coin name } - for _, tc := range cases { + for tcIndex, tc := range cases { res, err := ParseCoins(tc.input) if !tc.valid { - require.NotNil(t, err, "%s: %#v", tc.input, res) + require.NotNil(t, err, "%s: %#v. tc #%d", tc.input, res, tcIndex) } else if assert.Nil(t, err, "%s: %+v", tc.input, err) { - require.Equal(t, tc.expected, res) + require.Equal(t, tc.expected, res, "coin parsing was incorrect, tc #%d", tcIndex) } } @@ -296,10 +296,10 @@ func TestSortCoins(t *testing.T) { {dup, false, false}, } - for _, tc := range cases { - require.Equal(t, tc.before, tc.coins.IsValid()) + for tcIndex, tc := range cases { + require.Equal(t, tc.before, tc.coins.IsValid(), "coin validity is incorrect before sorting, tc #%d", tcIndex) tc.coins.Sort() - require.Equal(t, tc.after, tc.coins.IsValid()) + require.Equal(t, tc.after, tc.coins.IsValid(), "coin validity is incorrect after sorting, tc #%d", tcIndex) } } diff --git a/types/rational.go b/types/rational.go index cb07bf543..89cc76968 100644 --- a/types/rational.go +++ b/types/rational.go @@ -234,7 +234,7 @@ func (r *Rat) UnmarshalAmino(text string) (err error) { //___________________________________________________________________________________ // helpers -// test if two rat arrays are the equal +// test if two rat arrays are equal func RatsEqual(r1s, r2s []Rat) bool { if len(r1s) != len(r2s) { return false diff --git a/types/rational_test.go b/types/rational_test.go index ecbc09e88..5ca1ac9c6 100644 --- a/types/rational_test.go +++ b/types/rational_test.go @@ -48,22 +48,22 @@ func TestNewFromDecimal(t *testing.T) { {"0.foobar.", true, Rat{}}, } - for _, tc := range tests { + for tcIndex, tc := range tests { res, err := NewRatFromDecimal(tc.decimalStr, 4) if tc.expErr { - require.NotNil(t, err, tc.decimalStr) + require.NotNil(t, err, tc.decimalStr, "error expected, tc #%d", tcIndex) } else { - require.Nil(t, err, tc.decimalStr) - require.True(t, res.Equal(tc.exp), tc.decimalStr) + require.Nil(t, err, tc.decimalStr, "unexpected error, tc #%d", tcIndex) + require.True(t, res.Equal(tc.exp), tc.decimalStr, "equality was incorrect, tc #%d", tcIndex) } // negative tc res, err = NewRatFromDecimal("-"+tc.decimalStr, 4) if tc.expErr { - require.NotNil(t, err, tc.decimalStr) + require.NotNil(t, err, tc.decimalStr, "error expected (negative case), tc #%d", tcIndex) } else { - require.Nil(t, err, tc.decimalStr) - require.True(t, res.Equal(tc.exp.Mul(NewRat(-1))), tc.decimalStr) + require.Nil(t, err, tc.decimalStr, "unexpected error (negative case), tc #%d", tcIndex) + require.True(t, res.Equal(tc.exp.Mul(NewRat(-1))), tc.decimalStr, "equality was incorrect (negative case), tc #%d", tcIndex) } } } @@ -99,10 +99,10 @@ func TestEqualities(t *testing.T) { {NewRat(-1, 7), NewRat(-3, 7), true, false, false}, } - for _, tc := range tests { - require.Equal(t, tc.gt, tc.r1.GT(tc.r2)) - require.Equal(t, tc.lt, tc.r1.LT(tc.r2)) - require.Equal(t, tc.eq, tc.r1.Equal(tc.r2)) + for tcIndex, tc := range tests { + require.Equal(t, tc.gt, tc.r1.GT(tc.r2), "GT result is incorrect, tc #%d", tcIndex) + require.Equal(t, tc.lt, tc.r1.LT(tc.r2), "LT result is incorrect, tc #%d", tcIndex) + require.Equal(t, tc.eq, tc.r1.Equal(tc.r2), "equality result is incorrect, tc #%d", tcIndex) } } @@ -135,15 +135,15 @@ func TestArithmetic(t *testing.T) { {NewRat(100), NewRat(1, 7), NewRat(100, 7), NewRat(700), NewRat(701, 7), NewRat(699, 7)}, } - for _, tc := range tests { - require.True(t, tc.resMul.Equal(tc.r1.Mul(tc.r2)), "r1 %v, r2 %v", tc.r1.Rat, tc.r2.Rat) - require.True(t, tc.resAdd.Equal(tc.r1.Add(tc.r2)), "r1 %v, r2 %v", tc.r1.Rat, tc.r2.Rat) - require.True(t, tc.resSub.Equal(tc.r1.Sub(tc.r2)), "r1 %v, r2 %v", tc.r1.Rat, tc.r2.Rat) + for tcIndex, tc := range tests { + require.True(t, tc.resMul.Equal(tc.r1.Mul(tc.r2)), "r1 %v, r2 %v. tc #%d", tc.r1.Rat, tc.r2.Rat, tcIndex) + require.True(t, tc.resAdd.Equal(tc.r1.Add(tc.r2)), "r1 %v, r2 %v. tc #%d", tc.r1.Rat, tc.r2.Rat, tcIndex) + require.True(t, tc.resSub.Equal(tc.r1.Sub(tc.r2)), "r1 %v, r2 %v. tc #%d", tc.r1.Rat, tc.r2.Rat, tcIndex) if tc.r2.Num().IsZero() { // panic for divide by zero require.Panics(t, func() { tc.r1.Quo(tc.r2) }) } else { - require.True(t, tc.resDiv.Equal(tc.r1.Quo(tc.r2)), "r1 %v, r2 %v", tc.r1.Rat, tc.r2.Rat) + require.True(t, tc.resDiv.Equal(tc.r1.Quo(tc.r2)), "r1 %v, r2 %v. tc #%d", tc.r1.Rat, tc.r2.Rat, tcIndex) } } } @@ -168,9 +168,9 @@ func TestEvaluate(t *testing.T) { {NewRat(113, 12), 9}, } - for _, tc := range tests { - require.Equal(t, tc.res, tc.r1.RoundInt64(), "%v", tc.r1) - require.Equal(t, tc.res*-1, tc.r1.Mul(NewRat(-1)).RoundInt64(), "%v", tc.r1.Mul(NewRat(-1))) + for tcIndex, tc := range tests { + require.Equal(t, tc.res, tc.r1.RoundInt64(), "%v. tc #%d", tc.r1, tcIndex) + require.Equal(t, tc.res*-1, tc.r1.Mul(NewRat(-1)).RoundInt64(), "%v. tc #%d", tc.r1.Mul(NewRat(-1)), tcIndex) } } @@ -192,10 +192,10 @@ func TestRound(t *testing.T) { {NewRat(1, 2), NewRat(1, 2), 1000}, } - for _, tc := range tests { - require.Equal(t, tc.res, tc.r.Round(tc.precFactor), "%v", tc.r) + for tcIndex, tc := range tests { + require.Equal(t, tc.res, tc.r.Round(tc.precFactor), "%v", tc.r, "incorrect rounding, tc #%d", tcIndex) negR1, negRes := tc.r.Mul(NewRat(-1)), tc.res.Mul(NewRat(-1)) - require.Equal(t, negRes, negR1.Round(tc.precFactor), "%v", negR1) + require.Equal(t, negRes, negR1.Round(tc.precFactor), "%v", negR1, "incorrect rounding (negative case), tc #%d", tcIndex) } } @@ -211,8 +211,8 @@ func TestToLeftPadded(t *testing.T) { {NewRat(1000, 3), 8, "00000333"}, {NewRat(1000, 3), 12, "000000000333"}, } - for _, tc := range tests { - require.Equal(t, tc.res, tc.rat.ToLeftPadded(tc.digits)) + for tcIndex, tc := range tests { + require.Equal(t, tc.res, tc.rat.ToLeftPadded(tc.digits), "incorrect left padding, tc #%d", tcIndex) } } @@ -296,11 +296,13 @@ func TestRatsEqual(t *testing.T) { {[]Rat{NewRat(1), NewRat(0)}, []Rat{NewRat(1), NewRat(0)}, true}, {[]Rat{NewRat(1), NewRat(0)}, []Rat{NewRat(0), NewRat(1)}, false}, {[]Rat{NewRat(1), NewRat(0)}, []Rat{NewRat(1)}, false}, + {[]Rat{NewRat(1), NewRat(2)}, []Rat{NewRat(2), NewRat(4)}, false}, + {[]Rat{NewRat(3), NewRat(18)}, []Rat{NewRat(1), NewRat(6)}, false}, } - for _, tc := range tests { - require.Equal(t, tc.eq, RatsEqual(tc.r1s, tc.r2s)) - require.Equal(t, tc.eq, RatsEqual(tc.r2s, tc.r1s)) + for tcIndex, tc := range tests { + require.Equal(t, tc.eq, RatsEqual(tc.r1s, tc.r2s), "equality of rational arrays is incorrect, tc #%d", tcIndex) + require.Equal(t, tc.eq, RatsEqual(tc.r2s, tc.r1s), "equality of rational arrays is incorrect (converse), tc #%d", tcIndex) } } diff --git a/types/utils_test.go b/types/utils_test.go index 8c84e2ace..af22f2db6 100644 --- a/types/utils_test.go +++ b/types/utils_test.go @@ -29,10 +29,10 @@ func TestSortJSON(t *testing.T) { wantErr: false}, } - for _, tc := range cases { + for tcIndex, tc := range cases { got, err := SortJSON([]byte(tc.unsortedJSON)) if tc.wantErr != (err != nil) { - t.Fatalf("got %t, want: %t, err=%s", err != nil, tc.wantErr, err) + t.Fatalf("got %t, want: %t, tc #%d, err=%s", err != nil, tc.wantErr, tcIndex, err) } require.Equal(t, string(got), tc.want) } From 9f2b83cbe9e1b35b350703366b5e7f5806c5547e Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 16 Jul 2018 20:01:54 +0100 Subject: [PATCH 5/5] version bump --- version/version.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/version/version.go b/version/version.go index 0c1574e48..c6361dd50 100644 --- a/version/version.go +++ b/version/version.go @@ -2,10 +2,10 @@ package version const Maj = "0" -const Min = "21" -const Fix = "1" +const Min = "22" +const Fix = "0" -const Version = "0.21.1" +const Version = "0.22.0" // GitCommit set by build flags var GitCommit = ""