github.com/Finschia/ostracon@v1.1.5/CONTRIBUTING.md (about)

     1  # Contributing
     2  
     3  Thank you for your interest in contributing to Ostracon! Before
     4  contributing, it may be helpful to understand the goal of the project. The goal
     5  of Ostracon 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 Ostracon project or a potential fork. When targeting the
     9  main Ostracon project, the following process leads to the best chance of
    10  landing changes in `main`.
    11  
    12  All work on the code base should be motivated by a [Github
    13  Issue](https://github.com/Finschia/ostracon/issues).
    14  [Search](https://github.com/Finschia/ostracon/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/Finschia/ostracon/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  > How to pick a number for the ADR?
    28  
    29  Find the largest existing ADR number and bump it by 1.
    30  
    31  When the problem as well as proposed solution are well understood,
    32  changes should start with a [draft
    33  pull request](https://github.blog/2019-02-14-introducing-draft-pull-requests/)
    34  against `main`. The draft signals that work is underway. When the work
    35  is ready for feedback, hitting "Ready for Review" will signal to the
    36  maintainers to take a look.
    37  
    38  Each stage of the process is aimed at creating feedback cycles which align contributors and maintainers to make sure:
    39  
    40  - Contributors don’t waste their time implementing/proposing features which won’t land in `main`.
    41  - Maintainers have the necessary context in order to support and review contributions.
    42  
    43  ## Forking
    44  
    45  Please note that Go requires code to live under absolute paths, which complicates forking.
    46  While my fork lives at `https://github.com/ebuchman/ostracon`,
    47  the code should never exist at `$GOPATH/src/github.com/ebuchman/ostracon`.
    48  Instead, we use `git remote` to add the fork as a new remote for the original repo,
    49  `$GOPATH/src/github.com/Finschia/ostracon`, and do all the work there.
    50  
    51  For instance, to create a fork and work on a branch of it, I would:
    52  
    53  - Create the fork on GitHub, using the fork button.
    54  - Go to the original repo checked out locally (i.e. `$GOPATH/src/github.com/Finschia/ostracon`)
    55  - `git remote rename origin upstream`
    56  - `git remote add origin git@github.com:ebuchman/basecoin.git`
    57  
    58  Now `origin` refers to my fork and `upstream` refers to the Ostracon version.
    59  So I can `git push -u origin main` to update my fork, and make pull requests to ostracon from there.
    60  Of course, replace `ebuchman` with your git handle.
    61  
    62  To pull in updates from the origin repo, run
    63  
    64  - `git fetch upstream`
    65  - `git rebase upstream/main` (or whatever branch you want)
    66  
    67  ## Dependencies
    68  
    69  We use [go modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
    70  
    71  That said, the `main` branch of every Ostracon repository should just build
    72  with `go get`, which means they should be kept up-to-date with their
    73  dependencies so we can get away with telling people they can just `go get` our
    74  software.
    75  
    76  Since some dependencies are not under our control, a third party may break our
    77  build, in which case we can fall back on `go mod tidy`. Even for dependencies under our control, go helps us to
    78  keep multiple repos in sync as they evolve. Anything with an executable, such
    79  as apps, tools, and the core, should use dep.
    80  
    81  Run `go list -u -m all` to get a list of dependencies that may not be
    82  up-to-date.
    83  
    84  When updating dependencies, please only update the particular dependencies you
    85  need. Instead of running `go get -u=patch`, which will update anything,
    86  specify exactly the dependency you want to update, eg.
    87  `GO111MODULE=on go get -u github.com/tendermint/tm-db@master`.
    88  
    89  ## Protobuf
    90  
    91  We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use across Ostracon Core.
    92  
    93  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`.
    94  
    95  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`.
    96  
    97  ## Changelog
    98  
    99  Every fix, improvement, feature, or breaking change should be made in a
   100  pull-request that includes an update to the `CHANGELOG_PENDING.md` file.
   101  
   102  Changelog entries should be formatted as follows:
   103  
   104  ```md
   105  - [module] \#xxx Some description about the change (@contributor)
   106  ```
   107  
   108  Here, `module` is the part of the code that changed (typically a
   109  top-level Go package), `xxx` is the pull-request number, and `contributor`
   110  is the author/s of the change.
   111  
   112  It's also acceptable for `xxx` to refer to the relevant issue number, but pull-request
   113  numbers are preferred.
   114  Note this means pull-requests should be opened first so the changelog can then
   115  be updated with the pull-request's number.
   116  There is no need to include the full link, as this will be added
   117  automatically during release. But please include the backslash and pound, eg. `\#2313`.
   118  
   119  Changelog entries should be ordered alphabetically according to the
   120  `module`, and numerically according to the pull-request number.
   121  
   122  Changes with multiple classifications should be doubly included (eg. a bug fix
   123  that is also a breaking change should be recorded under both).
   124  
   125  Breaking changes are further subdivided according to the APIs/users they impact.
   126  Any change that effects multiple APIs/users should be recorded multiply - for
   127  instance, a change to the `Blockchain Protocol` that removes a field from the
   128  header should also be recorded under `CLI/RPC/Config` since the field will be
   129  removed from the header in RPC responses as well.
   130  
   131  ## Branching Model and Release
   132  
   133  User-facing repos should adhere to the trunk based development branching model: https://trunkbaseddevelopment.com/.
   134  
   135  Libraries need not follow the model strictly, but would be wise to.
   136  
   137  The SDK utilizes [semantic versioning](https://semver.org/).
   138  
   139  The main development branch is `main`.
   140  
   141  Every release is maintained in a release branch named `vX.Y.Z`.
   142  
   143  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 `main`.
   144  
   145  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
   146  easy to reference the pull request where a change was introduced.
   147  
   148  ### Development Procedure
   149  
   150  The latest state of development is on `main`, which must never fail `make test`. _Never_ force push `main`, unless fixing broken git history (which we rarely do anyways).
   151  
   152  To begin contributing, create a development branch either on `github.com/Finschia/ostracon`, or your fork (using `git remote add origin`).
   153  
   154  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 `main`. (Since pull requests are squash-merged, either is fine!)
   155  
   156  Update the `UPGRADING.md` if the change you've made is breaking and the
   157  instructions should be in place for a user on how he/she can upgrade it's
   158  software (ABCI application, Ostracon-based blockchain, light client, wallet).
   159  
   160  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.
   161  
   162  Sometimes (often!) pull requests get out-of-date with `main`, as other people merge different pull requests to `main`. It is our convention that pull request authors are responsible for updating their branches with `main`. (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!)
   163  
   164  #### PR Targeting
   165  
   166  Ensure that you base and target your PR on the `main` branch.
   167  
   168  All feature additions should be targeted against `main`. Bug fixes for an outstanding release candidate
   169  should be targeted against the release candidate branch.
   170  
   171  #### Merging Pull Requests
   172  
   173  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.
   174  
   175  Before merging a pull request:
   176  
   177  - Ensure pull branch is up-to-date with a recent `main` (GitHub won't let you merge without this!)
   178  - Run `make test` to ensure that all tests pass
   179  - [Squash](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git) merge pull request
   180  
   181  #### Pull Requests for Minor Releases
   182  
   183  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 `main`_.
   184  
   185  You can do this by cherry-picking your commit off `main`:
   186  
   187  ```sh
   188  $ git checkout rc1/v0.33.5
   189  $ git checkout -b {new branch name}
   190  $ git cherry-pick {commit SHA from `main`}
   191  # may need to fix conflicts, and then use git add and git cherry-pick --continue
   192  $ git push origin {new branch name}
   193  ```
   194  
   195  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.
   196  
   197  ### Git Commit Style
   198  
   199  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 Ostracon to...". For example,
   200  
   201  ```sh
   202  cmd/debug: execute p.Signal only when p is not nil
   203  
   204  [potentially longer description in the body]
   205  
   206  Fixes #nnnn
   207  ```
   208  
   209  Each PR should have one commit once it lands on `main`; this can be accomplished by using the "squash and merge" button on Github. Be sure to edit your commit message, though!
   210  
   211  ### Release Procedure
   212  
   213  #### Major Release
   214  
   215  1. Start on `main`
   216  2. Run integration tests (see `test_integrations` in Makefile)
   217  3. Prepare release in a pull request against `main` (to be squash merged):
   218     - Copy `CHANGELOG_PENDING.md` to top of `CHANGELOG.md`; if this release
   219        had release candidates, squash all the RC updates into one
   220     - Run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for
   221       all issues
   222     - run `bash ./scripts/authors.sh` to get a list of authors since the latest
   223       release, and add the github aliases of external contributors to the top of
   224       the changelog. To lookup an alias from an email, try `bash ./scripts/authors.sh <email>`
   225     - Reset the `CHANGELOG_PENDING.md`
   226     - Bump P2P and block protocol versions in  `version.go`, if necessary
   227     - Bump ABCI protocol version in `version.go`, if necessary
   228     - Make sure all significant breaking changes are covered in `UPGRADING.md`
   229     - Add any release notes you would like to be added to the body of the release to `release_notes.md`.
   230  4. Push a tag with prepared release details (this will trigger the release `vX.X.0`)
   231     - `git tag -a vX.X.x -m 'Release vX.X.x'`
   232     - `git push origin vX.X.x`
   233  5. Update the changelog.md file on `main` with the releases changelog.
   234  6. Delete any RC branches and tags for this release (if applicable)
   235  
   236  #### Minor Release
   237  
   238  Minor releases are done differently from major releases: They are built off of long-lived release candidate branches, rather than from `main`.
   239  
   240  1. Checkout the long-lived release candidate branch: `git checkout rcX/vX.X.X`
   241  2. Run integration tests: `make test_integrations`
   242  3. Prepare the release:
   243     - copy `CHANGELOG_PENDING.md` to top of `CHANGELOG.md`
   244     - run `python ./scripts/linkify_changelog.py CHANGELOG.md` to add links for all issues
   245     - 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>`
   246     - reset the `CHANGELOG_PENDING.md`
   247     - bump P2P and block protocol versions in  `version.go`, if necessary
   248     - bump ABCI protocol version in `version.go`, if necessary
   249     - make sure all significant breaking changes are covered in `UPGRADING.md`
   250     - Add any release notes you would like to be added to the body of the release to `release_notes.md`.
   251  4. Create a release branch `release/vX.X.x` off the release candidate branch:
   252     - `git checkout -b release/vX.X.x`
   253     - `git push -u origin release/vX.X.x`
   254     - Note that all branches prefixed with `release` are protected once pushed. You will need admin help to make any changes to the branch.
   255  5. Once the release branch has been approved, make sure to pull it locally, then push a tag.
   256     - `git tag -a vX.X.x -m 'Release vX.X.x'`
   257     - `git push origin vX.X.x`
   258  6. Create a pull request back to `main` with the CHANGELOG & version changes from the latest release.
   259     - Remove all `R:minor` labels from the pull requests that were included in the release.
   260     - Do not merge the release branch into `main`.
   261  7. Delete the former long lived release candidate branch once the release has been made.
   262  8. Create a new release candidate branch to be used for the next release.
   263  
   264  #### Backport Release
   265  
   266  1. start from the existing release branch you want to backport changes to (e.g. v0.30)
   267     Branch to a release/vX.X.X branch locally (e.g. release/v0.30.7)
   268  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)
   269  3. Follow steps 2 and 3 from [Major Release](#major-release)
   270  4. Push changes to release/vX.X.X branch
   271  5. Open a PR against the existing vX.X branch
   272  
   273  #### Release Candidates
   274  
   275  Before creating an official release, especially a major release, we may want to create a
   276  release candidate (RC) for our friends and partners to test out. We use git tags to
   277  create RCs, and we build them off of RC branches. RC branches typically have names formatted
   278  like `RCX/vX.X.X` (or, concretely, `RC0/v0.34.0`), while the tags themselves follow
   279  the "standard" release naming conventions, with `-rcX` at the end (`vX.X.X-rcX`).
   280  
   281  (Note that branches and tags _cannot_ have the same names, so it's important that these branches
   282  have distinct names from the tags/release names.)
   283  
   284  1. Start from the RC branch (e.g. `RC0/v0.34.0`).
   285  2. Create the new tag, specifying a name and a tag "message":
   286     `git tag -a v0.34.0-rc0 -m "Release Candidate v0.34.0-rc0`
   287  3. Push the tag back up to origin:
   288     `git push origin v0.34.0-rc4`
   289     Now the tag should be available on the repo's releases page.
   290  4. Create a new release candidate branch for any possible updates to the RC:
   291     `git checkout -b RC1/v0.34.0; git push origin RC1/v0.34.0`
   292  
   293  ## Testing
   294  
   295  ### Unit tests
   296  
   297  Unit tests are located in `_test.go` files as directed by [the Go testing
   298  package](https://golang.org/pkg/testing/). If you're adding or removing a
   299  function, please check there's a `TestType_Method` test for it.
   300  
   301  Run: `make test`
   302  
   303  ### Integration tests
   304  
   305  Integration tests are also located in `_test.go` files. What differentiates
   306  them is a more complicated setup, which usually involves setting up two or more
   307  components.
   308  
   309  Run: `make test_integrations`
   310  
   311  ### End-to-end tests
   312  
   313  End-to-end tests are used to verify a fully integrated Ostracon network.
   314  
   315  See [README](./test/e2e/README.md) for details.
   316  
   317  Run:
   318  
   319  ```sh
   320  cd test/e2e && \
   321    make && \
   322    ./build/runner -f networks/ci.toml
   323  ```
   324  
   325  ### Maverick
   326  
   327  **If you're changing the code in `consensus` package or `node` package, please make sure to
   328  replicate all the changes in `./test/maverick/consensus`** and `./test/maverick/node`**. Maverick is a
   329  byzantine node used to assert that the validator gets punished for malicious
   330  behavior.
   331  
   332  See [README](./test/maverick/README.md) for details.
   333  
   334  ### Model-based tests (ADVANCED)
   335  
   336  *NOTE: if you're just submitting your first PR, you won't need to touch these
   337  most probably (99.9%)*.
   338  
   339  For components, that have been [formally
   340  verified](https://en.wikipedia.org/wiki/Formal_verification) using
   341  [TLA+](https://en.wikipedia.org/wiki/TLA%2B), it may be possible to generate
   342  tests using a combination of the [Apalache Model
   343  Checker](https://apalache.informal.systems/) and [tendermint-rs testgen
   344  util](https://github.com/informalsystems/tendermint-rs/tree/master/testgen).
   345  
   346  At the moment, we have model-based tests for the light client, located in the
   347  `./light/mbt` directory.
   348  
   349  Run: `cd light/mbt && go test`
   350  
   351  ### Fuzz tests (ADVANCED)
   352  
   353  *NOTE: if you're just submitting your first PR, you won't need to touch these
   354  most probably (99.9%)*.
   355  
   356  [Fuzz tests](https://en.wikipedia.org/wiki/Fuzzing) can be found inside the
   357  `./test/fuzz` directory. See [README.md](./test/fuzz/README.md) for details.
   358  
   359  Run: `cd test/fuzz && make fuzz-{PACKAGE-COMPONENT}`
   360  
   361  ### Jepsen tests (ADVANCED)
   362  
   363  *NOTE: if you're just submitting your first PR, you won't need to touch these
   364  most probably (99.9%)*.
   365  
   366  [Jepsen](http://jepsen.io/) tests are used to verify the
   367  [linearizability](https://jepsen.io/consistency/models/linearizable) property
   368  of the Ostracon consensus. They are located in a separate repository
   369  -> <https://github.com/tendermint/jepsen>. Please refer to its README for more
   370  information.
   371  
   372  ### RPC Testing
   373  
   374  If you contribute to the RPC endpoints it's important to document your changes in the [Openapi file](./rpc/openapi/openapi.yaml)
   375  To test your changes you should install `nodejs` and run:
   376  
   377  ```bash
   378  npm i -g dredd
   379  make build-contract-tests-hooks
   380  make contract-tests
   381  ```
   382  
   383  **WARNING: these are currently broken due to <https://github.com/apiaryio/dredd>
   384  not supporting complete OpenAPI 3**.
   385  
   386  This command will popup a network and check every endpoint against what has
   387  been documented.