Thank you for considering making contributions!
Contributing to this repo can mean many things such as participating in discussion or proposing code changes. To ensure a smooth workflow for all contributors, a general procedure for contributing has been established:
- Either open or find an issue you'd like to help with
- Participate in thoughtful discussion on that issue
- If you would like to contribute:
- If the issue is a proposal, ensure that the proposal has been accepted
- Ensure that nobody else has already begun working on this issue, if they have make sure to contact them to collaborate
- If nobody has been assigned the issue and you would like to work on it make a comment on the issue to inform the community of your intentions to begin work
- Follow standard Github best practices: fork the repo, branch from the
HEAD of
main
, make some commits, and submit a PR tomain
- Be sure to submit the PR in
Draft
mode. Submit your PR early, even if it's incomplete as this indicates to the community you're working on something and allows them to provide comments early in the development process - When the code is complete it can be marked
Ready for Review
- Be sure to include a relevant change log entry in the
Unreleased
section ofCHANGELOG.md
(see file for log format)
Note that for very small or blatantly obvious problems (such as typos) it is not required to an open issue to submit a PR, but be aware that for more complex problems/features, if a PR is opened before an adequate design discussion has taken place in a github issue, that PR runs a high likelihood of being rejected.
Take a peek at our coding repo for
overall information on repository workflow and standards. Note, we use make tools
for installing the linting tools.
Other notes:
- Looking for a good place to start contributing? How about checking out some good first issues
- Please make sure to run
make format
before every commit - the easiest way to do this is have your editor run it for you upon saving a file. Additionally please ensure that your code is lint compliant by runninggolangci-lint run
. A convenience gitpre-commit
hook that runs the formatters automatically before each commit is available in thecontrib/githooks/
directory.
Generally, when structuring a submission for the Cosmos ecosystem, the submission might span multiple layers of the technology stack, including the Cosmos SDK and Tendermint dependencies.
To accommodate review process we suggest that PRs are categorically broken up. Ideally each PR addresses only a single issue. Additionally, as much as possible code refactoring and cleanup should be submitted as a separate PRs from bugfixes/feature-additions.
In order to simplify reviewing large changes, submissions should have a created an issue with a description of the submission, a description tracking the changes and relevant discussions, and a checklist of changes and tasks to be done.
The issue can then be used to develop multiple well-scoped PRs that are easy to review.
The following PR structuring checklist can be used when submitting changes to the repository for review:
- Proto files: PR updating proto files. As a suggested next step, don't regenerate updated protobuf
implementations using
protgen
, since this will break existing code. - Broken code: If
protogen
is run, a PR disabling broken code - Validation: PR with validation of types
- Functionality: PR integrating supporting functionality
- Servers: PR for
msgserver
andqueryserver
- CLI: PR for CLI commands
- Orchestrators: PR for any orchestrators
- Genesis: PR for genesis
- Upgrades: PR for upgrades
All PRs require at least one review before merge (except docs changes, or variable name-changes which only require one). When reviewing PRs please use the following review explanations:
LGTM
without an explicit approval means that the changes look good, but you haven't pulled down the code, run tests locally and thoroughly reviewed it.Approval
through the GH UI means that you understand the code, documentation/spec is updated in the right places, you have pulled down and tested the code locally. In addition:- You must also think through anything which ought to be included but is not
- You must think through whether any added code could be partially combined (DRYed) with existing code
- You must think through any potential security issues or incentive-compatibility flaws introduced by the changes
- Naming must be consistent with conventions and the rest of the codebase
- Code must live in a reasonable location, considering dependency structures (e.g. not importing testing modules in production code, or including example code modules in production code).
- if you approve of the PR, you are responsible for fixing any of the issues mentioned here and more
- If you sat down with the PR submitter and did a pairing review please note that in the
Approval
, or your PR comments. - If you are only making "surface level" reviews, submit any notes as
Comments
without adding a review.
We use Go Modules to manage dependency versions.
The main branch of every Cosmos repository should just build with go get
,
which means they should be kept up-to-date with their dependencies so we can
get away with telling people they can just go get
our software.
When dependencies in go.mod
are changed, it is generally accepted practice
to delete go.sum
and then run go mod tidy
.
Since some dependencies are not under our control, a third party may break our
build, in which case we can fall back on go mod tidy -v
.
All repos should be hooked up to CircleCI.
If they have .go
files in the root directory, they will be automatically
tested by circle using go test -v -race ./...
. If not, they will need a
circle.yml
. Ideally, every repo has a Makefile
that defines make test
and
includes its continuous integration status using a badge in the README.md
.
We expect tests to use require
or assert
rather than t.Skip
or t.Fail
,
unless there is a reason to do otherwise.
When testing a function under a variety of different inputs, we prefer to use
table driven tests.
Table driven test error messages should follow the following format
<desc>, tc #<index>, i #<index>
.
<desc>
is an optional short description of whats failing, tc
is the
index within the table of the testcase that is failing, and i
is when there
is a loop, exactly which iteration of the loop failed.
The idea is you should be able to see the
error message and figure out exactly what failed.
Here is an example check:
<some table>
for tcIndex, tc := range cases {
<some code>
for i := 0; i < tc.numTxsToTest; i++ {
<some code>
require.Equal(t, expectedTx[:32], calculatedTx[:32],
"First 32 bytes of the txs differed. tc #%d, i #%d", tcIndex, i)
User-facing repos should adhere to the trunk based development branching model.
Libraries need not follow the model strictly, but would be wise to.
We utilize semantic versioning.
Ensure that you base and target your PR on the main
branch.
All feature additions should be targeted against main
. Bug fixes for an outstanding release candidate
should be targeted against the release candidate branch. Release candidate branches themselves should be the
only pull requests targeted directly against main.
- the latest state of development is on
main
main
must never failmake test
ormake test_cli
main
should not failmake lint
- no
--force
ontomain
(except when reverting a broken commit, which should seldom happen) - create a development branch either on
https://github.com/cosmos/kitools
, or your fork (usinggit remote add origin
) - before submitting a pull request, begin
git rebase
on top ofmain
- ensure pull branch is rebased on
main
- run
make test
andmake test_cli
to ensure that all tests pass - merge pull request