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

ints: stricter numbers #4939

Merged
merged 8 commits into from Jun 4, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG_PENDING.md
Expand Up @@ -12,6 +12,14 @@ Friendly reminder, we have a [bug bounty program](https://hackerone.com/tendermi

- [evidence] \#4725 Remove `Pubkey` from DuplicateVoteEvidence
- [rpc] [\#4792](https://github.com/tendermint/tendermint/pull/4792) `/validators` are now sorted by voting power (@melekes)
- [types] \#4382 `SignedMsgType` has moved to a Protobuf enum types
- [types] \#4382 `Total` has been changed from a `int` to a `uint32`
- [types] \#4582 Vote: `ValidatorIndex` & `Round` are now int32
- [types] \#4582 Proposal: `POLRound` & `Round` are now int32
- [types] \#4582 Block: `Round` is now int32
- [consensus] \#4582 RoundState: `Round`, `LockedRound` & `CommitRound` are now int32
- [consensus] \#4582 HeightVoteSet: `round` is now int32
- [privval] \#4582 `round` in private_validator_state.json is no longer a string in json it is now a number.
- [crypto] \#4941 Remove suffixes from all keys.
- ed25519: type `PrivKeyEd25519` is now `PrivKey`
- ed25519: type `PubKeyEd25519` is now `PubKey`
Expand Down
46 changes: 23 additions & 23 deletions CONTRIBUTING.md
Expand Up @@ -116,7 +116,7 @@ To install `protoc`, download an appropriate release (https://github.com/protoco

To install `gogoproto`, do the following:

```sh
```
$ go get github.com/gogo/protobuf/gogoproto
$ cd $GOPATH/pkg/mod/github.com/gogo/protobuf@v1.3.1 # or wherever go get installs things
$ make install
Expand Down Expand Up @@ -178,34 +178,34 @@ The main development branch is master.

Every release is maintained in a release branch named `vX.Y.Z`.

Pending minor releases have long-lived release candidate ("RC") branches. Minor release changes should be merged to these long-lived RC branches at the same time that the changes are merged to master.
Pending minor releases have long-lived release candidate ("RC") branches. Minor release changes should be merged to these long-lived RC branches at the same time that the changes are merged to master.

Note all pull requests should be squash merged except for merging to a release branch (named `vX.Y`). This keeps the commit history clean and makes it
easy to reference the pull request where a change was introduced.

### Development Procedure

The latest state of development is on `master`, which must never fail `make test`. _Never_ force push `master`, unless fixing broken git history (which we rarely do anyways).
The latest state of development is on `master`, which must never fail `make test`. _Never_ force push `master`, unless fixing broken git history (which we rarely do anyways).

To begin contributing, create a development branch either on github.com/tendermint/tendermint, or your fork (using `git remote add origin`).
To begin contributing, create a development branch either on github.com/tendermint/tendermint, or your fork (using `git remote add origin`).

Make changes, and before submitting a pull request, update the `CHANGELOG_PENDING.md` to record your change. Also, run either `git rebase` or `git merge` on top of the latest `master`. (Since pull requests are squash-merged, either is fine!)

Once you have submitted a pull request label the pull request with either `R:minor`, if the change should be included in the next minor release, or `R:major`, if the change is meant for a major release.

Sometimes (often!) pull requests get out-of-date with master, as other people merge different pull requests to master. It is our convention that pull request authors are responsible for updating their branches with master. (This also means that you shouldn't update someone else's branch for them; even if it seems like you're doing them a favor, you may be interfering with their git flow in some way!)
Sometimes (often!) pull requests get out-of-date with master, as other people merge different pull requests to master. It is our convention that pull request authors are responsible for updating their branches with master. (This also means that you shouldn't update someone else's branch for them; even if it seems like you're doing them a favor, you may be interfering with their git flow in some way!)

#### Merging Pull Requests
#### Merging Pull Requests

It is also our convention that authors merge their own pull requests, when possible. External contributors may not have the necessary permissions to do this, in which case, a member of the core team will merge the pull request once it's been approved.
It is also our convention that authors merge their own pull requests, when possible. External contributors may not have the necessary permissions to do this, in which case, a member of the core team will merge the pull request once it's been approved.

Before merging a pull request:
Before merging a pull request:

- Ensure pull branch is up-to-date with a recent `master` (GitHub won't let you merge without this!)
- Ensure pull branch is up-to-date with a recent `master` (GitHub won't let you merge without this!)
- Run `make test` to ensure that all tests pass
- [Squash](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git) merge pull request

#### Pull Requests for Minor Releases
#### Pull Requests for Minor Releases

If your change should be included in a minor release, please also open a PR against the long-lived minor release candidate branch (e.g., `rc1/v0.33.5`) _immediately after your change has been merged to master_.

Expand All @@ -214,12 +214,12 @@ You can do this by cherry-picking your commit off master:
```
$ git checkout rc1/v0.33.5
$ git checkout -b {new branch name}
$ git cherry-pick {commit SHA from master}
$ git cherry-pick {commit SHA from master}
# may need to fix conflicts, and then use git add and git cherry-pick --continue
$ git push origin {new branch name}
```

After this, you can open a PR. Please note in the PR body if there were merge conflicts so that reviewers can be sure to take a thorough look.
After this, you can open a PR. Please note in the PR body if there were merge conflicts so that reviewers can be sure to take a thorough look.

### Git Commit Style

Expand Down Expand Up @@ -255,22 +255,22 @@ Each PR should have one commit once it lands on `master`; this can be accomplish

#### Minor Release

Minor releases are done differently from major releases: They are built off of long-lived release candidate branches, rather than from master.
Minor releases are done differently from major releases: They are built off of long-lived release candidate branches, rather than from master.

1. Checkout the long-lived release candidate branch: `git checkout rcX/vX.X.X`
2. Run integration tests: `make test_integrations`
1. Checkout the long-lived release candidate branch: `git checkout rcX/vX.X.X`
2. Run integration tests: `make test_integrations`
3. Prepare the release:
- Copy `CHANGELOG_PENDING.md` to top of `CHANGELOG.md`
- Run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for all issues
- Run `bash ./scripts/authors.sh` to get a list of authors since the latest release, and add the GitHub aliases of external contributors to the top of the CHANGELOG. To lookup an alias from an email, try `bash ./scripts/authors.sh <email>`
- Reset the `CHANGELOG_PENDING.md`
- Bump the appropriate versions in `version.go`
5. Create a release branch `release/vX.X.x` off the release candidate branch:
- Copy `CHANGELOG_PENDING.md` to top of `CHANGELOG.md`
- Run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for all issues
- Run `bash ./scripts/authors.sh` to get a list of authors since the latest release, and add the GitHub aliases of external contributors to the top of the CHANGELOG. To lookup an alias from an email, try `bash ./scripts/authors.sh <email>`
- Reset the `CHANGELOG_PENDING.md`
- Bump the appropriate versions in `version.go`
4. Create a release branch `release/vX.X.x` off the release candidate branch:
- `git checkout -b release/vX.X.x`
- `git push -u origin release/vX.X.x`
- Note that all branches prefixed with `release` are protected once pushed. You will need admin help to make any changes to the branch.
6. Open a pull request of the new minor release branch onto the latest major release branch `vX.X` and then rebase to merge. This will start the release process.
7. Create a pull request back to master with the CHANGELOG & version changes from the latest release.
5. Open a pull request of the new minor release branch onto the latest major release branch `vX.X` and then rebase to merge. This will start the release process.
6. Create a pull request back to master with the CHANGELOG & version changes from the latest release.
- Remove all `R:minor` labels from the pull requests that were included in the release.
- Do not merge the release branch into master.

Expand Down
3 changes: 2 additions & 1 deletion blockchain/v1/reactor_test.go
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/tendermint/tendermint/libs/log"
"github.com/tendermint/tendermint/mempool/mock"
"github.com/tendermint/tendermint/p2p"
tmproto "github.com/tendermint/tendermint/proto/types"
"github.com/tendermint/tendermint/proxy"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/store"
Expand Down Expand Up @@ -64,7 +65,7 @@ func makeVote(
Height: header.Height,
Round: 1,
Timestamp: tmtime.Now(),
Type: types.PrecommitType,
Type: tmproto.PrecommitType,
BlockID: blockID,
}

Expand Down
6 changes: 3 additions & 3 deletions config/config.go
Expand Up @@ -870,21 +870,21 @@ func (cfg *ConsensusConfig) WaitForTxs() bool {
}

// Propose returns the amount of time to wait for a proposal
func (cfg *ConsensusConfig) Propose(round int) time.Duration {
func (cfg *ConsensusConfig) Propose(round int32) time.Duration {
return time.Duration(
cfg.TimeoutPropose.Nanoseconds()+cfg.TimeoutProposeDelta.Nanoseconds()*int64(round),
) * time.Nanosecond
}

// Prevote returns the amount of time to wait for straggler votes after receiving any +2/3 prevotes
func (cfg *ConsensusConfig) Prevote(round int) time.Duration {
func (cfg *ConsensusConfig) Prevote(round int32) time.Duration {
return time.Duration(
cfg.TimeoutPrevote.Nanoseconds()+cfg.TimeoutPrevoteDelta.Nanoseconds()*int64(round),
) * time.Nanosecond
}

// Precommit returns the amount of time to wait for straggler votes after receiving any +2/3 precommits
func (cfg *ConsensusConfig) Precommit(round int) time.Duration {
func (cfg *ConsensusConfig) Precommit(round int32) time.Duration {
return time.Duration(
cfg.TimeoutPrecommit.Nanoseconds()+cfg.TimeoutPrecommitDelta.Nanoseconds()*int64(round),
) * time.Nanosecond
Expand Down
2 changes: 1 addition & 1 deletion config/toml.go
Expand Up @@ -500,6 +500,6 @@ var testPrivValidatorKey = `{

var testPrivValidatorState = `{
"height": "0",
"round": "0",
"round": 0,
"step": 0
}`
19 changes: 10 additions & 9 deletions consensus/byzantine_test.go
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/tendermint/tendermint/libs/service"
"github.com/tendermint/tendermint/p2p"
tmproto "github.com/tendermint/tendermint/proto/types"
sm "github.com/tendermint/tendermint/state"
"github.com/tendermint/tendermint/types"
)
Expand Down Expand Up @@ -56,12 +57,12 @@ func TestByzantine(t *testing.T) {
// NOTE: Now, test validators are MockPV, which by default doesn't
// do any safety checks.
css[i].privValidator.(types.MockPV).DisableChecks()
css[i].decideProposal = func(j int) func(int64, int) {
return func(height int64, round int) {
css[i].decideProposal = func(j int32) func(int64, int32) {
return func(height int64, round int32) {
byzantineDecideProposalFunc(t, height, round, css[j], switches[j])
}
}(i)
css[i].doPrevote = func(height int64, round int) {}
}(int32(i))
css[i].doPrevote = func(height int64, round int32) {}
}

eventBus := css[i].eventBus
Expand Down Expand Up @@ -172,7 +173,7 @@ func TestByzantine(t *testing.T) {
//-------------------------------
// byzantine consensus functions

func byzantineDecideProposalFunc(t *testing.T, height int64, round int, cs *State, sw *p2p.Switch) {
func byzantineDecideProposalFunc(t *testing.T, height int64, round int32, cs *State, sw *p2p.Switch) {
// byzantine user should create two proposals and try to split the vote.
// Avoid sending on internalMsgQueue and running consensus state.

Expand Down Expand Up @@ -209,7 +210,7 @@ func byzantineDecideProposalFunc(t *testing.T, height int64, round int, cs *Stat

func sendProposalAndParts(
height int64,
round int,
round int32,
cs *State,
peer p2p.Peer,
proposal *types.Proposal,
Expand All @@ -221,7 +222,7 @@ func sendProposalAndParts(
peer.Send(DataChannel, cdc.MustMarshalBinaryBare(msg))

// parts
for i := 0; i < parts.Total(); i++ {
for i := 0; i < int(parts.Total()); i++ {
part := parts.GetPart(i)
msg := &BlockPartMessage{
Height: height, // This tells peer that this part applies to us.
Expand All @@ -233,8 +234,8 @@ func sendProposalAndParts(

// votes
cs.mtx.Lock()
prevote, _ := cs.signVote(types.PrevoteType, blockHash, parts.Header())
precommit, _ := cs.signVote(types.PrecommitType, blockHash, parts.Header())
prevote, _ := cs.signVote(tmproto.PrevoteType, blockHash, parts.Header())
precommit, _ := cs.signVote(tmproto.PrecommitType, blockHash, parts.Header())
cs.mtx.Unlock()

peer.Send(VoteChannel, cdc.MustMarshalBinaryBare(&VoteMessage{prevote}))
Expand Down