Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2373e27

Browse files
authoredApr 25, 2023
Update contributing guidelines (celestiaorg#740)
After recent discussions, it has become apparent that some facets of our contribution process haven't been clear enough - for example our preferred size of pull requests, or preferred approach when contributors/core team members submit larger changes. This PR updates those guidelines. 📖 [Rendered](https://github.com/cometbft/cometbft/blob/thane/contributing/CONTRIBUTING.md) I also took this opportunity to update the contributing workflow diagram, which was pretty out of date, and replaced it with a Mermaid diagram since GitHub has pretty decent support for such diagrams now. --- #### PR checklist - [ ] Tests written/updated - [ ] Changelog entry added in `.changelog` (we use [unclog](https://github.com/informalsystems/unclog) to manage our changelog) - [ ] Updated relevant documentation (`docs/` or `spec/`) and code comments
1 parent b8187b0 commit 2373e27

File tree

2 files changed

+198
-99
lines changed

2 files changed

+198
-99
lines changed
 

‎CONTRIBUTING.md

+198-99
Original file line numberDiff line numberDiff line change
@@ -5,82 +5,182 @@ may be helpful to understand the goal of the project. The goal of CometBFT is to
55
develop a BFT consensus engine robust enough to support permissionless
66
value-carrying networks. While all contributions are welcome, contributors
77
should bear this goal in mind in deciding if they should target the main
8-
CometBFT project or a potential fork. When targeting the main CometBFT project,
9-
the following process leads to the best chance of landing changes in `main`.
10-
11-
All work on the code base should be motivated by a [GitHub
12-
Issue](https://github.com/cometbft/cometbft/issues).
13-
[Search](https://github.com/cometbft/cometbft/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
14-
is a good place to start when looking for places to contribute. If you would
15-
like to work on an issue which already exists, please indicate so by leaving a
16-
comment.
17-
18-
All new contributions should start with a [GitHub
19-
Issue](https://github.com/cometbft/cometbft/issues/new/choose). The issue helps
20-
capture the problem you're trying to solve and allows for early feedback. Once
21-
the issue is created the process can proceed in different directions depending
22-
on how well defined the problem and potential solution are. If the change is
23-
simple and well understood, maintainers will indicate their support with a
24-
heartfelt emoji.
8+
CometBFT project or a potential fork.
9+
10+
## Overview
11+
12+
When targeting the main CometBFT project, following the processes outlined in
13+
this document will lead to the best chance of landing changes in a release.
14+
15+
### Core team responsibility
16+
17+
The CometBFT core team is responsible for stewarding this
18+
project over time. This means that the core team needs to understand the nature
19+
of, and agree to maintain, all of the changes that land on `main` or a backport
20+
branch. It may cost a few days/weeks' worth of time to _submit_ a
21+
particular change, but _maintaining_ that change over the years has a
22+
much higher cost that the core team will bear.
23+
24+
### Ease of reviewing
25+
26+
The fact that the core team needs to be able to deeply understand the short-,
27+
medium- and long-term consequences of incoming changes means that changes need
28+
to be **easily reviewed**.
29+
30+
What makes a change easy to review, and more likely to land in an upcoming
31+
release?
32+
33+
1. **Each pull request must do _one thing_**. It must be very clear what that
34+
one thing is when looking at the pull request title, description, and linked
35+
issues. It must also be very clear what value it ultimately aims to deliver,
36+
and to which user(s). A single pull request that does multiple things, or
37+
without a clear articulation of the problem it attempts to solve, may be
38+
rejected immediately.
39+
40+
2. **Each pull request must be at most 300 lines of code changes**. Larger
41+
changes must be structured as a series of pull requests of at most 300 lines
42+
of code changes each, each building upon the previous one, all ideally
43+
tracked in a tracking issue.
44+
45+
If a single PR absolutely has to be larger, it _must_ be structured such that
46+
it can be reviewed commit by commit, with each commit doing _one logical
47+
thing_ (with a good description of what it aims to achieve in the Git
48+
commit), and each commit ideally being no larger than 300 lines of code
49+
changes. Poorly structured pull requests may be rejected immediately with a
50+
request to restructure them.
51+
52+
This does not necessarily apply to documentation-related changes or
53+
automatically generated code (e.g. generated from Protobuf definitions). But
54+
automatically generated code changes should occur within separate commits, so
55+
they are easily distinguishable from manual code changes.
56+
57+
## Workflow
58+
59+
The following diagram summarizes the general workflow used by the core team to
60+
make changes, with a full description of the workflow below the diagram.
61+
Exceptions to this process will naturally occur (e.g. in the case of urgent
62+
security fixes), but this is rare.
63+
64+
Each stage of the process is aimed at creating feedback cycles which align
65+
contributors and maintainers to make sure:
66+
67+
- Contributors don’t waste their time implementing/proposing features which
68+
won't land in `main`.
69+
- Maintainers have the necessary context in order to support and review
70+
contributions.
71+
72+
```mermaid
73+
flowchart LR
74+
complexity{Problem\ncomplexity}
75+
issue("New issue\n(Problem articulation\nfor discussion)")
76+
clarity{"Problem +\nsolution clarity"}
77+
rfc("RFC pull request(s)")
78+
rfc_merge("Merge RFC to main")
79+
risk{"Solution\ncomplexity/risk"}
80+
adr("ADR + PoC\npull request(s)")
81+
adr_merge("Merge ADR to main\nand create tracking issue")
82+
pr("Solution\npull request(s)")
83+
merge("Merge to main/backport\nor feature branch")
84+
85+
complexity --"Low/Moderate/High"--> issue
86+
complexity --Trivial--> pr
87+
issue --> clarity
88+
clarity --High--> risk
89+
clarity --Low--> rfc
90+
rfc --Approved--> rfc_merge
91+
risk --"Moderate/High"--> adr
92+
adr --"ADR accepted by core team"--> adr_merge
93+
adr_merge --> pr
94+
risk --Low--> pr
95+
pr --Approved--> merge
96+
```
97+
98+
### GitHub issues
99+
100+
All non-trivial work on the code base should be motivated by a [GitHub
101+
Issue][gh-issues]. [Search][search-issues] is a good place to start when looking
102+
for places to contribute. If you would like to work on an issue which already
103+
exists, please indicate so by leaving a comment. If someone else is already
104+
assigned to that issue and you would like to contribute to it or take it over,
105+
please coordinate with the existing assignee(s) and only start work on it once
106+
you have been assigned to it. Unsolicited pull requests relating to issues
107+
assigned to other users may be rejected immediately.
108+
109+
All new contributions should start with a [GitHub Issue][new-gh-issue]. The
110+
issue helps capture the **problem** being solved and allows for early feedback.
111+
Problems must be captured in terms of the **impact** that they have on specific
112+
users. Once the issue is created the process can proceed in different directions
113+
depending on how well defined the problem and potential solution are. If the
114+
change is simple and well understood, maintainers will indicate their support
115+
with a heartfelt emoji.
116+
117+
### Request for comments (RFCs)
25118

26119
If the issue would benefit from thorough discussion, maintainers may request
27-
that you create a [Request For
28-
Comment](https://github.com/cometbft/cometbft/tree/main/docs/rfc) in the
29-
CometBFT repo. Discussion at the RFC stage will build collective
30-
understanding of the dimensions of the problems and help structure conversations
31-
around trade-offs.
120+
that you create a [Request For Comment][rfcs] in the CometBFT repo. Discussion
121+
at the RFC stage will build collective understanding of the dimensions of the
122+
problems and help structure conversations around trade-offs.
123+
124+
### Architecture decision records (ADRs)
32125

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 ADR,
38-
you can open a less-formal issue and the maintainers will help you turn it into
39-
an ADR.
126+
When the problem is well understood but the solution leads to
127+
large/complex/risky structural changes to the code base, these changes should be
128+
proposed in the form of an [Architectural Decision Record
129+
(ADR)](./docs/architecture/). The ADR will help build consensus on an overall
130+
strategy to ensure the code base maintains coherence in the larger context. If
131+
you are not comfortable with writing an ADR, you can open a less-formal issue
132+
and the maintainers will help you turn it into an ADR. Sometimes the best way to
133+
demonstrate the value of an ADR is to build a proof-of-concept (PoC) along with
134+
the ADR - in this case, link to the PoC from the ADR PR.
40135

41-
> How to pick a number for the ADR?
136+
**How does one pick a number for an new ADR?**
42137

43-
Find the largest existing ADR number and bump it by 1.
138+
Find the largest existing ADR number (between those in `./docs/architecture/`
139+
and those that may be open as issues or pull requests) and bump it by 1.
44140

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 `main`. The draft signals that work is underway and is not ready for
49-
review. Only users that are familiar with the issue, or those that the author explicitly requested a review from
50-
are expected to write comments at this point. When the work is ready for feedback,
51-
hitting "Ready for Review" will signal to the maintainers to take a look, and to
52-
the rest of the community that feedback is welcome.
141+
### Pull requests
53142

54-
**The team may opt to ignore unsolicited comments/feedback on draft PRs**, as having to
55-
respond to feedback on work that is not marked as "Ready for Review" interferes with the
56-
process of getting the work to the point that it is ready to review.
143+
When the problem as well as proposed solution are well understood and low-risk,
144+
changes should start with a **pull request**.
57145

58-
![Contributing flow](./docs/imgs/contributing.png)
146+
Please adhere to the guidelines in the [Ease of reviewing](#ease-of-reviewing)
147+
section above when submitting pull requests.
59148

60-
Each stage of the process is aimed at creating feedback cycles which align contributors and maintainers to make sure:
149+
### Draft pull requests
61150

62-
- Contributors don’t waste their time implementing/proposing features which won’t land in `main`.
63-
- Maintainers have the necessary context in order to support and review contributions.
151+
One can optionally submit a [draft pull request][gh-draft-prs] against `main`,
152+
in which case this signals that work is underway and is not ready for review.
153+
Only users that are familiar with the issue, or those that the author explicitly
154+
requested a review from are expected to write comments at this point. When the
155+
work is ready for feedback, hitting "Ready for Review" will signal to the
156+
maintainers to take a look, and to the rest of the community that feedback is
157+
welcome.
64158

159+
**The team may opt to ignore unsolicited comments/feedback on draft PRs**, as
160+
having to respond to feedback on work that is not marked as "Ready for Review"
161+
interferes with the process of getting the work to the point that it is ready to
162+
review.
65163

66164
## Forking
67165

68-
Please note that Go requires code to live under absolute paths, which complicates forking.
69-
While my fork lives at `https://github.com/ebuchman/cometbft`,
70-
the code should never exist at `$GOPATH/src/github.com/ebuchman/cometbft`.
71-
Instead, we use `git remote` to add the fork as a new remote for the original repo,
166+
Please note that Go requires code to live under absolute paths, which
167+
complicates forking. While my fork lives at
168+
`https://github.com/ebuchman/cometbft`, the code should never exist at
169+
`$GOPATH/src/github.com/ebuchman/cometbft`. Instead, we use `git remote` to add
170+
the fork as a new remote for the original repo,
72171
`$GOPATH/src/github.com/cometbft/cometbft`, and do all the work there.
73172

74173
For instance, to create a fork and work on a branch of it, I would:
75174

76175
- Create the fork on GitHub, using the fork button.
77-
- Go to the original repo checked out locally (i.e. `$GOPATH/src/github.com/cometbft/cometbft`)
176+
- Go to the original repo checked out locally (i.e.
177+
`$GOPATH/src/github.com/cometbft/cometbft`)
78178
- `git remote rename origin upstream`
79179
- `git remote add origin git@github.com:ebuchman/basecoin.git`
80180

81-
Now `origin` refers to my fork and `upstream` refers to the CometBFT version.
82-
So I can `git push -u origin main` to update my fork, and make pull requests to CometBFT from there.
83-
Of course, replace `ebuchman` with your git handle.
181+
Now `origin` refers to my fork and `upstream` refers to the CometBFT version. So
182+
I can `git push -u origin main` to update my fork, and make pull requests to
183+
CometBFT from there. Of course, replace `ebuchman` with your git handle.
84184

85185
To pull in updates from the origin repo, run
86186

@@ -89,34 +189,32 @@ To pull in updates from the origin repo, run
89189

90190
## Dependencies
91191

92-
We use [go modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.
192+
We use [Go modules] to manage dependencies.
93193

94-
That said, the `main` branch of every CometBFT repository should just build
95-
with `go get`, which means they should be kept up-to-date with their
96-
dependencies so we can get away with telling people they can just `go get` our
97-
software.
194+
That said, the `main` branch of every CometBFT repository should just build with
195+
`go get`, which means they should be kept up-to-date with their dependencies so
196+
we can get away with telling people they can just `go get` our software.
98197

99198
Since some dependencies are not under our control, a third party may break our
100-
build, in which case we can fall back on `go mod tidy`. Even for dependencies under our control, go helps us to
101-
keep multiple repos in sync as they evolve. Anything with an executable, such
102-
as apps, tools, and the core, should use dep.
199+
build, in which case we can fall back on `go mod tidy`. Even for dependencies
200+
under our control, go helps us to keep multiple repos in sync as they evolve.
201+
Anything with an executable, such as apps, tools, and the core, should use dep.
103202

104203
Run `go list -u -m all` to get a list of dependencies that may not be
105204
up-to-date.
106205

107206
When updating dependencies, please only update the particular dependencies you
108-
need. Instead of running `go get -u=patch`, which will update anything,
109-
specify exactly the dependency you want to update.
207+
need. Instead of running `go get -u=patch`, which will update anything, specify
208+
exactly the dependency you want to update.
110209

111210
## Protobuf
112211

113-
We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along
114-
with [`gogoproto`](https://github.com/cosmos/gogoproto) to generate code for use
212+
We use [Protocol Buffers] along with [`gogoproto`] to generate code for use
115213
across CometBFT.
116214

117215
To generate proto stubs, lint, and check protos for breaking changes, you will
118-
need to install [buf](https://buf.build/) and `gogoproto`. Then, from the root
119-
of the repository, run:
216+
need to install [buf] and `gogoproto`. Then, from the root of the repository,
217+
run:
120218

121219
```bash
122220
# Lint all of the .proto files
@@ -130,17 +228,17 @@ make proto-check-breaking
130228
make proto-gen
131229
```
132230

133-
To automatically format `.proto` files, you will need
134-
[`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) installed. Once
135-
installed, you can run:
231+
To automatically format `.proto` files, you will need [`clang-format`]
232+
installed. Once installed, you can run:
136233

137234
```bash
138235
make proto-format
139236
```
140237

141238
### Visual Studio Code
142239

143-
If you are a VS Code user, you may want to add the following to your `.vscode/settings.json`:
240+
If you are a VS Code user, you may want to add the following to your
241+
`.vscode/settings.json`:
144242

145243
```json
146244
{
@@ -154,12 +252,13 @@ If you are a VS Code user, you may want to add the following to your `.vscode/se
154252

155253
## Changelog
156254

157-
To manage and generate our changelog, we currently use [unclog](https://github.com/informalsystems/unclog).
255+
To manage and generate our changelog, we currently use [unclog].
158256

159257
Every fix, improvement, feature, or breaking change should be made in a
160258
pull-request that includes a file
161259
`.changelog/unreleased/${category}/${issue-or-pr-number}-${description}.md`,
162260
where:
261+
163262
- `category` is one of `improvements`, `breaking-changes`, `bug-fixes`,
164263
`features` and if multiple apply, create multiple files;
165264
- `description` is a short (4 to 6 word), hyphen separated description of the
@@ -293,8 +392,7 @@ Before merging a pull request:
293392
- Ensure pull branch is up-to-date with a recent `main` (GitHub won't let you
294393
merge without this!)
295394
- Run `make test` to ensure that all tests pass
296-
- [Squash](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git)
297-
merge pull request
395+
- [Squash][git-squash] merge pull request
298396

299397
#### Pull Requests for Minor Releases
300398

@@ -317,8 +415,7 @@ conflicts so that reviewers can be sure to take a thorough look.
317415

318416
### Git Commit Style
319417

320-
We follow the [Go style guide on commit
321-
messages](https://tip.golang.org/doc/contribute.html#commit_messages). Write
418+
We follow the [Go style guide on commit messages][go-git-commit-style]. Write
322419
concise commits that start with the package name and have a description that
323420
finishes the sentence "This change modifies CometBFT to...". For example,
324421

@@ -339,15 +436,15 @@ message, though!
339436
### Unit tests
340437

341438
Unit tests are located in `_test.go` files as directed by [the Go testing
342-
package](https://golang.org/pkg/testing/). If you're adding or removing a
343-
function, please check there's a `TestType_Method` test for it.
439+
package][go-testing]. If you're adding or removing a function, please check
440+
there's a `TestType_Method` test for it.
344441

345442
Run: `make test`
346443

347444
### Integration tests
348445

349-
Integration tests are also located in `_test.go` files. What differentiates
350-
them is a more complicated setup, which usually involves setting up two or more
446+
Integration tests are also located in `_test.go` files. What differentiates them
447+
is a more complicated setup, which usually involves setting up two or more
351448
components.
352449

353450
Run: `make test_integrations`
@@ -371,26 +468,28 @@ cd test/e2e && \
371468
*NOTE: if you're just submitting your first PR, you won't need to touch these
372469
most probably (99.9%)*.
373470

374-
[Fuzz tests](https://en.wikipedia.org/wiki/Fuzzing) can be found inside the
375-
`./test/fuzz` directory. See [README.md](./test/fuzz/README.md) for details.
471+
[Fuzz tests] can be found inside the `./test/fuzz` directory. See
472+
[README.md](./test/fuzz/README.md) for details.
376473

377474
Run: `cd test/fuzz && make fuzz-{PACKAGE-COMPONENT}`
378475

379476
### RPC Testing
380477

381-
**If you contribute to the RPC endpoints it's important to document your
382-
changes in the [Openapi file](./rpc/openapi/openapi.yaml)**.
383-
384-
To test your changes you must install `nodejs` and run:
385-
386-
```bash
387-
npm i -g dredd
388-
make build-linux build-contract-tests-hooks
389-
make contract-tests
390-
```
391-
392-
**WARNING: these are currently broken due to <https://github.com/apiaryio/dredd>
393-
not supporting complete OpenAPI 3**.
394-
395-
This command will popup a network and check every endpoint against what has
396-
been documented.
478+
**If you contribute to the RPC endpoints it's important to document your changes
479+
in the [OpenAPI file](./rpc/openapi/openapi.yaml)**.
480+
481+
[gh-issues]: https://github.com/cometbft/cometbft/issues
482+
[search-issues]: https://github.com/cometbft/cometbft/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22
483+
[new-gh-issue]: https://github.com/cometbft/cometbft/issues/new/choose
484+
[rfcs]: https://github.com/cometbft/cometbft/tree/main/docs/rfc
485+
[gh-draft-prs]: https://github.blog/2019-02-14-introducing-draft-pull-requests/
486+
[Go modules]: https://github.com/golang/go/wiki/Modules
487+
[Protocol Buffers]: https://protobuf.dev/
488+
[`gogoproto`]: https://github.com/cosmos/gogoproto
489+
[buf]: https://buf.build/
490+
[`clang-format`]: https://clang.llvm.org/docs/ClangFormat.html
491+
[unclog]: https://github.com/informalsystems/unclog
492+
[git-squash]: https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git
493+
[go-git-commit-style]: https://tip.golang.org/doc/contribute.html#commit_messages
494+
[go-testing]: https://golang.org/pkg/testing/
495+
[Fuzz tests]: https://en.wikipedia.org/wiki/Fuzzing

‎docs/imgs/contributing.png

-31 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.