bitbucket.org/number571/tendermint@v0.8.14/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://bitbucket.org/number571/tendermint/issues).
    14  [Search](https://bitbucket.org/number571/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://bitbucket.org/number571/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)
    30  in the Tendermint spec repo. Discussion
    31  at the RFC stage will build collective understanding of the dimensions
    32  of the problems and help structure conversations around trade-offs.
    33  
    34  When the problem is well understood but the solution leads to large structural
    35  changes to the code base, these changes should be proposed in the form of an
    36  [Architectural Decision Record (ADR)](./docs/architecture/). The ADR will help
    37  build consensus on an overall strategy to ensure the code base maintains
    38  coherence in the larger context. If you are not comfortable with writing an
    39  ADR, you can open a less-formal issue and the maintainers will help you turn it
    40  into an ADR.
    41  
    42  > How to pick a number for the ADR?
    43  
    44  Find the largest existing ADR number and bump it by 1.
    45  
    46  When the problem as well as proposed solution are well understood,
    47  changes should start with a [draft
    48  pull request](https://github.blog/2019-02-14-introducing-draft-pull-requests/)
    49  against master. The draft signals that work is underway. When the work
    50  is ready for feedback, hitting "Ready for Review" will signal to the
    51  maintainers to take a look.
    52  
    53  ![Contributing flow](./docs/imgs/contributing.png)
    54  
    55  Each stage of the process is aimed at creating feedback cycles which align contributors and maintainers to make sure:
    56  
    57  - Contributors don’t waste their time implementing/proposing features which won’t land in master.
    58  - Maintainers have the necessary context in order to support and review contributions.
    59  
    60  ## Forking
    61  
    62  Please note that Go requires code to live under absolute paths, which complicates forking.
    63  While my fork lives at `https://github.com/ebuchman/tendermint`,
    64  the code should never exist at `$GOPATH/src/github.com/ebuchman/tendermint`.
    65  Instead, we use `git remote` to add the fork as a new remote for the original repo,
    66  `$GOPATH/src/bitbucket.org/number571/tendermint`, and do all the work there.
    67  
    68  For instance, to create a fork and work on a branch of it, I would:
    69  
    70  - Create the fork on GitHub, using the fork button.
    71  - Go to the original repo checked out locally (i.e. `$GOPATH/src/bitbucket.org/number571/tendermint`)
    72  - `git remote rename origin upstream`
    73  - `git remote add origin git@github.com:ebuchman/basecoin.git`
    74  
    75  Now `origin` refers to my fork and `upstream` refers to the Tendermint version.
    76  So I can `git push -u origin master` to update my fork, and make pull requests to tendermint from there.
    77  Of course, replace `ebuchman` with your git handle.
    78  
    79  To pull in updates from the origin repo, run
    80  
    81  - `git fetch upstream`
    82  - `git rebase upstream/master` (or whatever branch you want)
    83  
    84  ## Dependencies
    85  
    86  We use [go modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
    87  
    88  That said, the master branch of every Tendermint repository should just build
    89  with `go get`, which means they should be kept up-to-date with their
    90  dependencies so we can get away with telling people they can just `go get` our
    91  software.
    92  
    93  Since some dependencies are not under our control, a third party may break our
    94  build, in which case we can fall back on `go mod tidy`. Even for dependencies under our control, go helps us to
    95  keep multiple repos in sync as they evolve. Anything with an executable, such
    96  as apps, tools, and the core, should use dep.
    97  
    98  Run `go list -u -m all` to get a list of dependencies that may not be
    99  up-to-date.
   100  
   101  When updating dependencies, please only update the particular dependencies you
   102  need. Instead of running `go get -u=patch`, which will update anything,
   103  specify exactly the dependency you want to update, eg.
   104  `GO111MODULE=on go get -u github.com/tendermint/go-amino@master`.
   105  
   106  ## Protobuf
   107  
   108  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.
   109  
   110  For linting, checking breaking changes and generating proto stubs, 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`.
   111  
   112  We use [Docker](https://www.docker.com/) to generate the protobuf stubs. To generate the stubs yourself, make sure docker is running then run `make proto-gen`.
   113  
   114  ### Visual Studio Code
   115  
   116  If you are a VS Code user, you may want to add the following to your `.vscode/settings.json`:
   117  
   118  ```json
   119  {
   120    "protoc": {
   121      "options": [
   122        "--proto_path=${workspaceRoot}/proto",
   123        "--proto_path=${workspaceRoot}/third_party/proto"
   124      ]
   125    }
   126  }
   127  ```
   128  
   129  ## Changelog
   130  
   131  Every fix, improvement, feature, or breaking change should be made in a
   132  pull-request that includes an update to the `CHANGELOG_PENDING.md` file.
   133  
   134  Changelog entries should be formatted as follows:
   135  
   136  ```md
   137  - [module] \#xxx Some description about the change (@contributor)
   138  ```
   139  
   140  Here, `module` is the part of the code that changed (typically a
   141  top-level Go package), `xxx` is the pull-request number, and `contributor`
   142  is the author/s of the change.
   143  
   144  It's also acceptable for `xxx` to refer to the relevant issue number, but pull-request
   145  numbers are preferred.
   146  Note this means pull-requests should be opened first so the changelog can then
   147  be updated with the pull-request's number.
   148  There is no need to include the full link, as this will be added
   149  automatically during release. But please include the backslash and pound, eg. `\#2313`.
   150  
   151  Changelog entries should be ordered alphabetically according to the
   152  `module`, and numerically according to the pull-request number.
   153  
   154  Changes with multiple classifications should be doubly included (eg. a bug fix
   155  that is also a breaking change should be recorded under both).
   156  
   157  Breaking changes are further subdivided according to the APIs/users they impact.
   158  Any change that effects multiple APIs/users should be recorded multiply - for
   159  instance, a change to the `Blockchain Protocol` that removes a field from the
   160  header should also be recorded under `CLI/RPC/Config` since the field will be
   161  removed from the header in RPC responses as well.
   162  
   163  ## Branching Model and Release
   164  
   165  The main development branch is master.
   166  
   167  Every release is maintained in a release branch named `vX.Y.Z`.
   168  
   169  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.
   170  
   171  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
   172  easy to reference the pull request where a change was introduced.
   173  
   174  ### Development Procedure
   175  
   176  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).
   177  
   178  To begin contributing, create a development branch either on `bitbucket.org/number571/tendermint`, or your fork (using `git remote add origin`).
   179  
   180  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!)
   181  
   182  Update the `UPGRADING.md` if the change you've made is breaking and the
   183  instructions should be in place for a user on how he/she can upgrade it's
   184  software (ABCI application, Tendermint-based blockchain, light client, wallet).
   185  
   186  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.
   187  
   188  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!)
   189  
   190  #### Merging Pull Requests
   191  
   192  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.
   193  
   194  Before merging a pull request:
   195  
   196  - Ensure pull branch is up-to-date with a recent `master` (GitHub won't let you merge without this!)
   197  - Run `make test` to ensure that all tests pass
   198  - [Squash](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git) merge pull request
   199  
   200  #### Pull Requests for Minor Releases
   201  
   202  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_.
   203  
   204  You can do this by cherry-picking your commit off master:
   205  
   206  ```sh
   207  $ git checkout rc1/v0.33.5
   208  $ git checkout -b {new branch name}
   209  $ git cherry-pick {commit SHA from master}
   210  # may need to fix conflicts, and then use git add and git cherry-pick --continue
   211  $ git push origin {new branch name}
   212  ```
   213  
   214  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.
   215  
   216  ### Git Commit Style
   217  
   218  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,
   219  
   220  ```sh
   221  cmd/debug: execute p.Signal only when p is not nil
   222  
   223  [potentially longer description in the body]
   224  
   225  Fixes #nnnn
   226  ```
   227  
   228  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!
   229  
   230  ### Release Procedure
   231  
   232  #### Major Release
   233  
   234  This major release process assumes that this release was preceded by release candidates.
   235  If there were no release candidates, and you'd like to cut a major release directly from master, see below.
   236  
   237  1. Start on the latest RC branch (`RCx/vX.X.0`).
   238  2. Run integration tests.
   239  3. Branch off of the RC branch (`git checkout -b release-prep`) and prepare the release:
   240     - "Squash" changes from the changelog entries for the RCs into a single entry,
   241        and add all changes included in `CHANGELOG_PENDING.md`.
   242        (Squashing includes both combining all entries, as well as removing or simplifying
   243        any intra-RC changes. It may also help to alphabetize the entries by package name.)
   244     - Run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for
   245       all PRs
   246     - Ensure that UPGRADING.md is up-to-date and includes notes on any breaking changes
   247        or other upgrading flows.
   248     - Bump TMVersionDefault version in  `version.go`
   249     - Bump P2P and block protocol versions in  `version.go`, if necessary
   250     - Bump ABCI protocol version in `version.go`, if necessary
   251     - Add any release notes you would like to be added to the body of the release to `release_notes.md`.
   252  4. Open a PR with these changes against the RC branch (`RCx/vX.X.0`).
   253  5. Once these changes are on the RC branch, branch off of the RC branch again to create a release branch:
   254     - `git checkout RCx/vX.X.0`
   255     - `git checkout -b release/vX.X.0`
   256  6. Push a tag with prepared release details. This will trigger the actual release `vX.X.0`.
   257     - `git tag -a vX.X.0 -m 'Release vX.X.0'`
   258     - `git push origin vX.X.0`
   259  7. Make sure that `master` is updated with the latest `CHANGELOG.md`, `CHANGELOG_PENDING.md`, and `UPGRADING.md`.
   260  8. Create the long-lived minor release branch `RC0/vX.X.1` for the next point release on this
   261     new major release series.
   262  
   263  ##### Major Release (from `master`)
   264  
   265  1. Start on `master`
   266  2. Run integration tests (see `test_integrations` in Makefile)
   267  3. Prepare release in a pull request against `master` (to be squash merged):
   268     - Copy `CHANGELOG_PENDING.md` to top of `CHANGELOG.md`; if this release
   269        had release candidates, squash all the RC updates into one
   270     - Run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for
   271       all issues
   272     - Run `bash ./scripts/authors.sh` to get a list of authors since the latest
   273       release, and add the github aliases of external contributors to the top of
   274       the changelog. To lookup an alias from an email, try `bash ./scripts/authors.sh <email>`
   275     - Reset the `CHANGELOG_PENDING.md`
   276     - Bump TMVersionDefault version in  `version.go`
   277     - Bump P2P and block protocol versions in  `version.go`, if necessary
   278     - Bump ABCI protocol version in `version.go`, if necessary
   279     - Make sure all significant breaking changes are covered in `UPGRADING.md`
   280     - Add any release notes you would like to be added to the body of the release to `release_notes.md`.
   281  4. Push a tag with prepared release details (this will trigger the release `vX.X.0`)
   282     - `git tag -a vX.X.x -m 'Release vX.X.x'`
   283     - `git push origin vX.X.x`
   284  5. Update the `CHANGELOG.md` file on master with the releases changelog.
   285  6. Delete any RC branches and tags for this release (if applicable)
   286  
   287  #### Minor Release (Point Releases)
   288  
   289  Minor releases are done differently from major releases: They are built off of long-lived backport branches, rather than from master.
   290  Each release "line" (e.g. 0.34 or 0.33) has its own long-lived backport branch, and
   291  the backport branches have names like `v0.34.x` or `v0.33.x` (literally, `x`; it is not a placeholder in this case).
   292  
   293  As non-breaking changes land on `master`, they should also be backported (cherry-picked) to these backport branches.
   294  
   295  We use Mergify's [backport feature](https://mergify.io/features/backports) to automatically backport to the needed branch. Depending on which backport branch you need to backport to there will be labels for them. To notify the bot to backport a pull request, mark the pull request with the label `backport-to-<backport_branch>`. Once the original pull request is merged, the bot will try to cherry-pick the pull request to the backport branch. If the bot fails to backport, it will open a pull request. The author of the original pull request is responsible for solving the conflicts and merging the pull request.
   296  
   297  Minor releases don't have release candidates by default, although any tricky changes may merit a release candidate.
   298  
   299  To create a minor release:
   300  
   301  1. Checkout the long-lived backport branch: `git checkout vX.X.x`
   302  2. Run integration tests: `make test_integrations`
   303  3. Check out a new branch and prepare the release:
   304     - Copy `CHANGELOG_PENDING.md` to top of `CHANGELOG.md`
   305     - Run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for all issues
   306     - 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>`
   307     - Reset the `CHANGELOG_PENDING.md`
   308     - Bump the ABCI version number, if necessary.
   309       (Note that ABCI follows semver, and that ABCI versions are the only versions
   310       which can change during minor releases, and only field additions are valid minor changes.)
   311     - Add any release notes you would like to be added to the body of the release to `release_notes.md`.
   312  4. Open a PR with these changes that will land them back on `vX.X.x`
   313  5. Once this change has landed on the backport branch, make sure to pull it locally, then push a tag.
   314     - `git tag -a vX.X.x -m 'Release vX.X.x'`
   315     - `git push origin vX.X.x`
   316  6. Create a pull request back to master with the CHANGELOG & version changes from the latest release.
   317     - Remove all `R:minor` labels from the pull requests that were included in the release.
   318     - Do not merge the backport branch into master.
   319  
   320  #### Release Candidates
   321  
   322  Before creating an official release, especially a major release, we may want to create a
   323  release candidate (RC) for our friends and partners to test out. We use git tags to
   324  create RCs, and we build them off of RC branches. RC branches typically have names formatted
   325  like `RCX/vX.X.X` (or, concretely, `RC0/v0.34.0`), while the tags themselves follow
   326  the "standard" release naming conventions, with `-rcX` at the end (`vX.X.X-rcX`).
   327  
   328  (Note that branches and tags _cannot_ have the same names, so it's important that these branches
   329  have distinct names from the tags/release names.)
   330  
   331  1. Start from the RC branch (e.g. `RC0/v0.34.0`).
   332  2. Create the new tag, specifying a name and a tag "message":
   333     `git tag -a v0.34.0-rc0 -m "Release Candidate v0.34.0-rc0`
   334  3. Push the tag back up to origin:
   335     `git push origin v0.34.0-rc4`
   336     Now the tag should be available on the repo's releases page.
   337  4. Create a new release candidate branch for any possible updates to the RC:
   338     `git checkout -b RC1/v0.34.0; git push origin RC1/v0.34.0`
   339  
   340  ## Testing
   341  
   342  ### Unit tests
   343  
   344  Unit tests are located in `_test.go` files as directed by [the Go testing
   345  package](https://golang.org/pkg/testing/). If you're adding or removing a
   346  function, please check there's a `TestType_Method` test for it.
   347  
   348  Run: `make test`
   349  
   350  ### Integration tests
   351  
   352  Integration tests are also located in `_test.go` files. What differentiates
   353  them is a more complicated setup, which usually involves setting up two or more
   354  components.
   355  
   356  Run: `make test_integrations`
   357  
   358  ### End-to-end tests
   359  
   360  End-to-end tests are used to verify a fully integrated Tendermint network.
   361  
   362  See [README](./test/e2e/README.md) for details.
   363  
   364  Run:
   365  
   366  ```sh
   367  cd test/e2e && \
   368    make && \
   369    ./build/runner -f networks/ci.toml
   370  ```
   371  
   372  ### Model-based tests (ADVANCED)
   373  
   374  *NOTE: if you're just submitting your first PR, you won't need to touch these
   375  most probably (99.9%)*.
   376  
   377  For components, that have been [formally
   378  verified](https://en.wikipedia.org/wiki/Formal_verification) using
   379  [TLA+](https://en.wikipedia.org/wiki/TLA%2B), it may be possible to generate
   380  tests using a combination of the [Apalache Model
   381  Checker](https://apalache.informal.systems/) and [tendermint-rs testgen
   382  util](https://github.com/informalsystems/tendermint-rs/tree/master/testgen).
   383  
   384  Now, I know there's a lot to take in. If you want to learn more, check out [
   385  this video](https://www.youtube.com/watch?v=aveoIMphzW8) by Andrey Kupriyanov
   386  & Igor Konnov.
   387  
   388  At the moment, we have model-based tests for the light client, located in the
   389  `./light/mbt` directory.
   390  
   391  Run: `cd light/mbt && go test`
   392  
   393  ### Fuzz tests (ADVANCED)
   394  
   395  *NOTE: if you're just submitting your first PR, you won't need to touch these
   396  most probably (99.9%)*.
   397  
   398  [Fuzz tests](https://en.wikipedia.org/wiki/Fuzzing) can be found inside the
   399  `./test/fuzz` directory. See [README.md](./test/fuzz/README.md) for details.
   400  
   401  Run: `cd test/fuzz && make fuzz-{PACKAGE-COMPONENT}`
   402  
   403  ### Jepsen tests (ADVANCED)
   404  
   405  *NOTE: if you're just submitting your first PR, you won't need to touch these
   406  most probably (99.9%)*.
   407  
   408  [Jepsen](http://jepsen.io/) tests are used to verify the
   409  [linearizability](https://jepsen.io/consistency/models/linearizable) property
   410  of the Tendermint consensus. They are located in a separate repository
   411  -> <https://github.com/tendermint/jepsen>. Please refer to its README for more
   412  information.
   413  
   414  ### RPC Testing
   415  
   416  **If you contribute to the RPC endpoints it's important to document your
   417  changes in the [Openapi file](./rpc/openapi/openapi.yaml)**.
   418  
   419  To test your changes you must install `nodejs` and run:
   420  
   421  ```bash
   422  npm i -g dredd
   423  make build-linux build-contract-tests-hooks
   424  make contract-tests
   425  ```
   426  
   427  **WARNING: these are currently broken due to <https://github.com/apiaryio/dredd>
   428  not supporting complete OpenAPI 3**.
   429  
   430  This command will popup a network and check every endpoint against what has
   431  been documented.