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