github.com/ari-anchor/sei-tendermint@v0.0.0-20230519144642-dc826b7b56bb/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) 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/github.com/tendermint/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/github.com/tendermint/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 109 with [`gogoproto`](https://github.com/gogo/protobuf) to generate code for use 110 across Tendermint Core. 111 112 To generate proto stubs, lint, and check protos for breaking changes, you will 113 need to install [buf](https://buf.build/) and `gogoproto`. Then, from the root 114 of the repository, run: 115 116 ```bash 117 # Lint all of the .proto files in proto/tendermint 118 make proto-lint 119 120 # Check if any of your local changes (prior to committing to the Git repository) 121 # are breaking 122 make proto-check-breaking 123 124 # Generate Go code from the .proto files in proto/tendermint 125 make proto-gen 126 ``` 127 128 To automatically format `.proto` files, you will need 129 [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) installed. Once 130 installed, you can run: 131 132 ```bash 133 make proto-format 134 ``` 135 136 ### Visual Studio Code 137 138 If you are a VS Code user, you may want to add the following to your `.vscode/settings.json`: 139 140 ```json 141 { 142 "protoc": { 143 "options": [ 144 "--proto_path=${workspaceRoot}/proto", 145 "--proto_path=${workspaceRoot}/third_party/proto" 146 ] 147 } 148 } 149 ``` 150 151 ## Changelog 152 153 Every fix, improvement, feature, or breaking change should be made in a 154 pull-request that includes an update to the `CHANGELOG_PENDING.md` file. 155 156 Changelog entries should be formatted as follows: 157 158 ```md 159 - [module] \#xxx Some description about the change (@contributor) 160 ``` 161 162 Here, `module` is the part of the code that changed (typically a 163 top-level Go package), `xxx` is the pull-request number, and `contributor` 164 is the author/s of the change. 165 166 It's also acceptable for `xxx` to refer to the relevant issue number, but pull-request 167 numbers are preferred. 168 Note this means pull-requests should be opened first so the changelog can then 169 be updated with the pull-request's number. 170 There is no need to include the full link, as this will be added 171 automatically during release. But please include the backslash and pound, eg. `\#2313`. 172 173 Changelog entries should be ordered alphabetically according to the 174 `module`, and numerically according to the pull-request number. 175 176 Changes with multiple classifications should be doubly included (eg. a bug fix 177 that is also a breaking change should be recorded under both). 178 179 Breaking changes are further subdivided according to the APIs/users they impact. 180 Any change that effects multiple APIs/users should be recorded multiply - for 181 instance, a change to the `Blockchain Protocol` that removes a field from the 182 header should also be recorded under `CLI/RPC/Config` since the field will be 183 removed from the header in RPC responses as well. 184 185 ## Branching Model and Release 186 187 The main development branch is master. 188 189 Every release is maintained in a release branch named `vX.Y.Z`. 190 191 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. 192 193 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 194 easy to reference the pull request where a change was introduced. 195 196 ### Development Procedure 197 198 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). 199 200 To begin contributing, create a development branch either on `github.com/tendermint/tendermint`, or your fork (using `git remote add origin`). 201 202 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!) 203 204 Update the `UPGRADING.md` if the change you've made is breaking and the 205 instructions should be in place for a user on how he/she can upgrade it's 206 software (ABCI application, Tendermint-based blockchain, light client, wallet). 207 208 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. 209 210 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!) 211 212 #### Merging Pull Requests 213 214 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. 215 216 Before merging a pull request: 217 218 - Ensure pull branch is up-to-date with a recent `master` (GitHub won't let you merge without this!) 219 - Run `make test` to ensure that all tests pass 220 - [Squash](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git) merge pull request 221 222 #### Pull Requests for Minor Releases 223 224 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_. 225 226 You can do this by cherry-picking your commit off master: 227 228 ```sh 229 $ git checkout rc1/v0.33.5 230 $ git checkout -b {new branch name} 231 $ git cherry-pick {commit SHA from master} 232 # may need to fix conflicts, and then use git add and git cherry-pick --continue 233 $ git push origin {new branch name} 234 ``` 235 236 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. 237 238 ### Git Commit Style 239 240 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, 241 242 ```sh 243 cmd/debug: execute p.Signal only when p is not nil 244 245 [potentially longer description in the body] 246 247 Fixes #nnnn 248 ``` 249 250 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! 251 252 ## Testing 253 254 ### Unit tests 255 256 Unit tests are located in `_test.go` files as directed by [the Go testing 257 package](https://golang.org/pkg/testing/). If you're adding or removing a 258 function, please check there's a `TestType_Method` test for it. 259 260 Run: `make test` 261 262 ### Integration tests 263 264 Integration tests are also located in `_test.go` files. What differentiates 265 them is a more complicated setup, which usually involves setting up two or more 266 components. 267 268 Run: `make test_integrations` 269 270 ### End-to-end tests 271 272 End-to-end tests are used to verify a fully integrated Tendermint network. 273 274 See [README](./test/e2e/README.md) for details. 275 276 Run: 277 278 ```sh 279 cd test/e2e && \ 280 make && \ 281 ./build/runner -f networks/ci.toml 282 ``` 283 284 ### Model-based tests (ADVANCED) 285 286 *NOTE: if you're just submitting your first PR, you won't need to touch these 287 most probably (99.9%)*. 288 289 For components, that have been [formally 290 verified](https://en.wikipedia.org/wiki/Formal_verification) using 291 [TLA+](https://en.wikipedia.org/wiki/TLA%2B), it may be possible to generate 292 tests using a combination of the [Apalache Model 293 Checker](https://apalache.informal.systems/) and [tendermint-rs testgen 294 util](https://github.com/informalsystems/tendermint-rs/tree/master/testgen). 295 296 Now, I know there's a lot to take in. If you want to learn more, check out [ 297 this video](https://www.youtube.com/watch?v=aveoIMphzW8) by Andrey Kupriyanov 298 & Igor Konnov. 299 300 At the moment, we have model-based tests for the light client, located in the 301 `./light/mbt` directory. 302 303 Run: `cd light/mbt && go test` 304 305 ### Fuzz tests (ADVANCED) 306 307 *NOTE: if you're just submitting your first PR, you won't need to touch these 308 most probably (99.9%)*. 309 310 [Fuzz tests](https://en.wikipedia.org/wiki/Fuzzing) can be found inside the 311 `./test/fuzz` directory. See [README.md](./test/fuzz/README.md) for details. 312 313 Run: `cd test/fuzz && make fuzz-{PACKAGE-COMPONENT}` 314 315 ### Jepsen tests (ADVANCED) 316 317 *NOTE: if you're just submitting your first PR, you won't need to touch these 318 most probably (99.9%)*. 319 320 [Jepsen](http://jepsen.io/) tests are used to verify the 321 [linearizability](https://jepsen.io/consistency/models/linearizable) property 322 of the Tendermint consensus. They are located in a separate repository 323 -> <https://github.com/tendermint/jepsen>. Please refer to its README for more 324 information. 325 326 ### RPC Testing 327 328 **If you contribute to the RPC endpoints it's important to document your 329 changes in the [Openapi file](./rpc/openapi/openapi.yaml)**. 330 331 To test your changes you must install `nodejs` and run: 332 333 ```bash 334 npm i -g dredd 335 make build-linux build-contract-tests-hooks 336 make contract-tests 337 ``` 338 339 **WARNING: these are currently broken due to <https://github.com/apiaryio/dredd> 340 not supporting complete OpenAPI 3**. 341 342 This command will popup a network and check every endpoint against what has 343 been documented.