github.com/adoriasoft/tendermint@v0.34.0-dev1.0.20200722151356-96d84601a75a/CONTRIBUTING.md (about) 1 # Contributing 2 3 Thank you for your interest in contributing to Tendermint! Before 4 contributing, it may be helpful to understand the goal of the project. The goal 5 of Tendermint is to develop a BFT consensus engine robust enough to 6 support permissionless value-carrying networks. While all contributions are 7 welcome, contributors should bear this goal in mind in deciding if they should 8 target the main Tendermint project or a potential fork. When targeting the 9 main Tendermint project, the following process leads to the best chance of 10 landing changes in master. 11 12 All work on the code base should be motivated by a [Github 13 Issue](https://github.com/tendermint/tendermint/issues). 14 [Search](https://github.com/tendermint/tendermint/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) 15 is a good place start when looking for places to contribute. If you 16 would like to work on an issue which already exists, please indicate so 17 by leaving a comment. 18 19 All new contributions should start with a [Github 20 Issue](https://github.com/tendermint/tendermint/issues/new/choose). The 21 issue helps capture the problem you're trying to solve and allows for 22 early feedback. Once the issue is created the process can proceed in different 23 directions depending on how well defined the problem and potential 24 solution are. If the change is simple and well understood, maintainers 25 will indicate their support with a heartfelt emoji. 26 27 If the issue would benefit from thorough discussion, maintainers may 28 request that you create a [Request For 29 Comment](https://github.com/tendermint/spec/tree/master/rfc). Discussion 30 at the RFC stage will build collective understanding of the dimensions 31 of the problems and help structure conversations around trade-offs. 32 33 When the problem is well understood but the solution leads to large 34 structural changes to the code base, these changes should be proposed in 35 the form of an [Architectural Decision Record 36 (ADR)](./docs/architecture/). The ADR will help build consensus on an 37 overall strategy to ensure the code base maintains coherence 38 in the larger context. If you are not comfortable with writing an ADR, 39 you can open a less-formal issue and the maintainers will help you 40 turn it into an ADR. ADR numbers can be registered [here](https://github.com/tendermint/tendermint/issues/2313). 41 42 When the problem as well as proposed solution are well understood, 43 changes should start with a [draft 44 pull request](https://github.blog/2019-02-14-introducing-draft-pull-requests/) 45 against master. The draft signals that work is underway. When the work 46 is ready for feedback, hitting "Ready for Review" will signal to the 47 maintainers to take a look. 48 49 ![Contributing flow](./docs/imgs/contributing.png) 50 51 Each stage of the process is aimed at creating feedback cycles which align contributors and maintainers to make sure: 52 53 - Contributors don’t waste their time implementing/proposing features which won’t land in master. 54 - Maintainers have the necessary context in order to support and review contributions. 55 56 ## Forking 57 58 Please note that Go requires code to live under absolute paths, which complicates forking. 59 While my fork lives at `https://github.com/ebuchman/tendermint`, 60 the code should never exist at `$GOPATH/src/github.com/ebuchman/tendermint`. 61 Instead, we use `git remote` to add the fork as a new remote for the original repo, 62 `$GOPATH/src/github.com/tendermint/tendermint`, and do all the work there. 63 64 For instance, to create a fork and work on a branch of it, I would: 65 66 - Create the fork on GitHub, using the fork button. 67 - Go to the original repo checked out locally (i.e. `$GOPATH/src/github.com/tendermint/tendermint`) 68 - `git remote rename origin upstream` 69 - `git remote add origin git@github.com:ebuchman/basecoin.git` 70 71 Now `origin` refers to my fork and `upstream` refers to the Tendermint version. 72 So I can `git push -u origin master` to update my fork, and make pull requests to tendermint from there. 73 Of course, replace `ebuchman` with your git handle. 74 75 To pull in updates from the origin repo, run 76 77 - `git fetch upstream` 78 - `git rebase upstream/master` (or whatever branch you want) 79 80 ## Dependencies 81 82 We use [go modules](https://github.com/golang/go/wiki/Modules) to manage dependencies. 83 84 That said, the master branch of every Tendermint repository should just build 85 with `go get`, which means they should be kept up-to-date with their 86 dependencies so we can get away with telling people they can just `go get` our 87 software. 88 89 Since some dependencies are not under our control, a third party may break our 90 build, in which case we can fall back on `go mod tidy`. Even for dependencies under our control, go helps us to 91 keep multiple repos in sync as they evolve. Anything with an executable, such 92 as apps, tools, and the core, should use dep. 93 94 Run `go list -u -m all` to get a list of dependencies that may not be 95 up-to-date. 96 97 When updating dependencies, please only update the particular dependencies you 98 need. Instead of running `go get -u=patch`, which will update anything, 99 specify exactly the dependency you want to update, eg. 100 `GO111MODULE=on go get -u github.com/tendermint/go-amino@master`. 101 102 ## Protobuf 103 104 We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use across Tendermint Core. 105 106 For linting and checking breaking changes, we use [buf](https://buf.build/). If you would like to run linting and check if the changes you have made are breaking then you will need to have docker running locally. Then the linting cmd will be `make proto-lint` and the breaking changes check will be `make proto-check-breaking`. 107 108 There are two ways to generate your proto stubs. 109 110 1. Use Docker, pull an image that will generate your proto stubs with no need to install anything. `make proto-gen-docker` 111 2. Run `make proto-gen` after installing `protoc` and gogoproto, you can do this by running `make protobuf`. 112 113 ### Installation Instructions 114 115 To install `protoc`, download an appropriate release (https://github.com/protocolbuffers/protobuf) and then move the provided binaries into your PATH (follow instructions in README included with the download). 116 117 To install `gogoproto`, do the following: 118 119 ``` 120 $ go get github.com/gogo/protobuf/gogoproto 121 $ cd $GOPATH/pkg/mod/github.com/gogo/protobuf@v1.3.1 # or wherever go get installs things 122 $ make install 123 ``` 124 125 You should now be able to run `make proto-gen` from inside the root Tendermint directory to generate new files from proto files. 126 127 ## Vagrant 128 129 If you are a [Vagrant](https://www.vagrantup.com/) user, you can get started 130 hacking Tendermint with the commands below. 131 132 NOTE: In case you installed Vagrant in 2017, you might need to run 133 `vagrant box update` to upgrade to the latest `ubuntu/xenial64`. 134 135 ``` 136 vagrant up 137 vagrant ssh 138 make test 139 ``` 140 141 ## Changelog 142 143 Every fix, improvement, feature, or breaking change should be made in a 144 pull-request that includes an update to the `CHANGELOG_PENDING.md` file. 145 146 Changelog entries should be formatted as follows: 147 148 ```md 149 - [module] \#xxx Some description about the change (@contributor) 150 ``` 151 152 Here, `module` is the part of the code that changed (typically a 153 top-level Go package), `xxx` is the pull-request number, and `contributor` 154 is the author/s of the change. 155 156 It's also acceptable for `xxx` to refer to the relevant issue number, but pull-request 157 numbers are preferred. 158 Note this means pull-requests should be opened first so the changelog can then 159 be updated with the pull-request's number. 160 There is no need to include the full link, as this will be added 161 automatically during release. But please include the backslash and pound, eg. `\#2313`. 162 163 Changelog entries should be ordered alphabetically according to the 164 `module`, and numerically according to the pull-request number. 165 166 Changes with multiple classifications should be doubly included (eg. a bug fix 167 that is also a breaking change should be recorded under both). 168 169 Breaking changes are further subdivided according to the APIs/users they impact. 170 Any change that effects multiple APIs/users should be recorded multiply - for 171 instance, a change to the `Blockchain Protocol` that removes a field from the 172 header should also be recorded under `CLI/RPC/Config` since the field will be 173 removed from the header in RPC responses as well. 174 175 ## Branching Model and Release 176 177 The main development branch is master. 178 179 Every release is maintained in a release branch named `vX.Y.Z`. 180 181 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. 182 183 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 184 easy to reference the pull request where a change was introduced. 185 186 ### Development Procedure 187 188 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). 189 190 To begin contributing, create a development branch either on `github.com/tendermint/tendermint`, or your fork (using `git remote add origin`). 191 192 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!) 193 194 Update the `UPGRADING.md` if the change you've made is breaking and the 195 instructions should be in place for a user on how he/she can upgrade it's 196 software (ABCI application, Tendermint-based blockchain, light client, wallet). 197 198 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. 199 200 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!) 201 202 #### Merging Pull Requests 203 204 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. 205 206 Before merging a pull request: 207 208 - Ensure pull branch is up-to-date with a recent `master` (GitHub won't let you merge without this!) 209 - Run `make test` to ensure that all tests pass 210 - [Squash](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git) merge pull request 211 212 #### Pull Requests for Minor Releases 213 214 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_. 215 216 You can do this by cherry-picking your commit off master: 217 218 ``` 219 $ git checkout rc1/v0.33.5 220 $ git checkout -b {new branch name} 221 $ git cherry-pick {commit SHA from master} 222 # may need to fix conflicts, and then use git add and git cherry-pick --continue 223 $ git push origin {new branch name} 224 ``` 225 226 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. 227 228 ### Git Commit Style 229 230 We follow the [Go style guide on commit messages](https://tip.golang.org/doc/contribute.html#commit_messages). Write concise commits that start with the package name and have a description that finishes the sentence "This change modifies Tendermint to...". For example, 231 232 ``` 233 cmd/debug: execute p.Signal only when p is not nil 234 235 [potentially longer description in the body] 236 237 Fixes #nnnn 238 ``` 239 240 Each PR should have one commit once it lands on `master`; this can be accomplished by using the "squash and merge" button on Github. Be sure to edit your commit message, though! 241 242 ### Release Procedure 243 244 #### Major Release 245 246 1. start on `master` 247 2. run integration tests (see `test_integrations` in Makefile) 248 3. prepare release in a pull request against `master` (to be squash merged): 249 - copy `CHANGELOG_PENDING.md` to top of `CHANGELOG.md` 250 - run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for 251 all issues 252 - run `bash ./scripts/authors.sh` to get a list of authors since the latest 253 release, and add the github aliases of external contributors to the top of 254 the changelog. To lookup an alias from an email, try `bash ./scripts/authors.sh <email>` 255 - reset the `CHANGELOG_PENDING.md` 256 - bump Tendermint version in `version.go` 257 - bump P2P and block protocol versions in `version.go`, if necessary 258 - bump ABCI protocol version in `version.go`, if necessary 259 - make sure all significant breaking changes are covered in `UPGRADING.md` 260 4. push your changes with prepared release details to `vX.X` (this will trigger the release `vX.X.0`) 261 5. merge back to master (don't squash merge!) 262 263 #### Minor Release 264 265 Minor releases are done differently from major releases: They are built off of long-lived release candidate branches, rather than from master. 266 267 1. Checkout the long-lived release candidate branch: `git checkout rcX/vX.X.X` 268 2. Run integration tests: `make test_integrations` 269 3. Prepare the release: 270 - copy `CHANGELOG_PENDING.md` to top of `CHANGELOG.md` 271 - run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for all issues 272 - 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>` 273 - reset the `CHANGELOG_PENDING.md` 274 - bump Tendermint version in `version.go` 275 - bump P2P and block protocol versions in `version.go`, if necessary 276 - bump ABCI protocol version in `version.go`, if necessary 277 - make sure all significant breaking changes are covered in `UPGRADING.md` 278 4. Create a release branch `release/vX.X.x` off the release candidate branch: 279 - `git checkout -b release/vX.X.x` 280 - `git push -u origin release/vX.X.x` 281 - Note that all branches prefixed with `release` are protected once pushed. You will need admin help to make any changes to the branch. 282 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. 283 6. Create a pull request back to master with the CHANGELOG & version changes from the latest release. 284 - Remove all `R:minor` labels from the pull requests that were included in the release. 285 - Do not merge the release branch into master. 286 287 #### Backport Release 288 289 1. start from the existing release branch you want to backport changes to (e.g. v0.30) 290 Branch to a release/vX.X.X branch locally (e.g. release/v0.30.7) 291 2. cherry pick the commit(s) that contain the changes you want to backport (usually these commits are from squash-merged PRs which were already reviewed) 292 3. steps 2 and 3 from [Major Release](#major-release) 293 4. push changes to release/vX.X.X branch 294 5. open a PR against the existing vX.X branch 295 296 ## Testing 297 298 All repos should be hooked up to [CircleCI](https://circleci.com/). 299 300 If they have `.go` files in the root directory, they will be automatically 301 tested by circle using `go test -v -race ./...`. If not, they will need a 302 `circle.yml`. Ideally, every repo has a `Makefile` that defines `make test` and 303 includes its continuous integration status using a badge in the `README.md`. 304 305 ### RPC Testing 306 307 If you contribute to the RPC endpoints it's important to document your changes in the [Swagger file](./rpc/swagger/swagger.yaml) 308 To test your changes you should install `nodejs` and run: 309 310 ```bash 311 npm i -g dredd 312 make build-linux build-contract-tests-hooks 313 make contract-tests 314 ``` 315 316 This command will popup a network and check every endpoint against what has been documented