The Provenance repository is built on the work of many open source projects including
the [Cosmos SDK]](https://github.com/cosmos/cosmos-sdk). The source code outside of the /x/
folder is largely based on a reference implementation of this SDK. The work inside the modules
folder represents the evolution of blockchain applications started at Figure Technologies in 2018.
This project would not be possible without the dedication and support of the Cosmos community.
Thank you for considering making contributions to the Provenance!
Contributing to this repo can mean many things such as participated in discussion or proposing code changes. To ensure a smooth workflow for all contributors, the 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 for 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
- For core developers working on
provenance-io
, to ensure a clear ownership of branches, branches must be named with the convention{moniker}/{issue#}-branch-name
- For core developers working on
- 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.
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 runningmake lint
. A convenience gitpre-commit
hook that runs the formatters automatically before each commit is available in thecontrib/githooks/
directory.
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.
Draft PRs can be used for preliminary feedback and to see the results of the GitHub action checks. They can also be used to better indicate that you are working on an issue.
Before a PR can be merged:
- All commits must be signed.
- It must be up-to-date with
main
. - It must be approved by two or more maintainers.
- It must pass all required GitHub action checks.
The following are encouraged and may sometimes be required:
- All GitHub action checks pass (even the non-required ones).
- New Unit and/or integration tests have been written.
- Documentation has been updated (in
/docs
orx/<module>/spec
). - Functions and variables have accurate
godoc
comments. - Test code coverage increases.
- Running
go mod tidy
should not causego.mod
orgo.sum
to change. - There should be at least one entry in the changelog. See: .changelog/README.md.
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.
Please note that Go requires code to live under absolute paths, which complicates forking.
While my fork lives at https://github.com/rigeyrigerige/provenance
,
the code should never exist at $GOPATH/src/github.com/rigeyrigerige/provenance
.
Instead, we use git remote
to add the fork as a new remote for the original repo,
$GOPATH/src/github.com/provenance-io/provenance
, and do all the work there.
For instance, to create a fork and work on a branch of it, I would:
- Create the fork on github, using the fork button.
- Go to the original repo checked out locally (i.e.
$GOPATH/src/github.com/provenance-io/provenance
) git remote rename origin upstream
git remote add origin git@github.com:rigeyrigerige/provenance.git
Now origin
refers to my fork and upstream
refers to the provenance-io
version.
So I can git push -u origin main
to update my fork, and make pull requests to provenance-io
from there.
Of course, replace rigeyrigerige
with your git handle.
To pull in updates from the origin repo, run
git fetch upstream
git rebase upstream/main
(or whatever branch you want)
Please don't make Pull Requests from a main
branch.
We use Go Modules to manage dependency versions.
Since most dependencies are not under our control, a third party may break our
build, in which case we can fall back on go mod tidy
.
We use Protocol Buffers along with gogoproto to generate code for use in Cosmos-SDK.
For determinstic behavior around Protobuf tooling, everything is containerized using Docker. Make sure to have Docker installed on your machine, or head to Docker's website to install it.
For updating the third_party
.proto
files, you can run make proto-update-deps
command.
For formatting code in .proto
files, you can run make proto-format
command.
For linting and checking breaking changes, we use buf. You can use the commands make proto-lint
and make proto-check-breaking
to respectively lint your proto files and check for breaking changes.
To generate the protobuf stubs, you can run make proto-gen
.
We also added the make proto-all
command to run all the above commands sequentially.
In order for imports to properly compile in your IDE, you may need to manually set your protobuf path in your IDE's workspace settings/config.
For example, in vscode your .vscode/settings.json
should look like:
{
"protoc": {
"options": [
"--proto_path=${workspaceRoot}/proto",
"--proto_path=${workspaceRoot}/third_party/proto"
]
}
}
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.
Always use a slice for the test table (never a map).
When iterating over the test cases, tc
as the variable that holds the current test, e.g. for _, tc := range tests
.
Each test case should be run as it's own sub-test, e.g. using t.Run
.
Messages should be provided for every assert
and require
.
A message should reference the value being tested in the assert/require as opposed to the general purpose of the test as a whole.
For example: err := DoThing()
, good: require.NoError(t, err, "DoThing")
, bad: require.NoError(t, err, "should not fail")
.
Provenance uses the trunk-based development branching model and semantic versioning (<major>.<minor>.<patch>
).
- The
major
version represents the version of the entire network. It will likely only change as part of a fork. - The
minor
version represents the features available. Changing to a newminor
version involves an upgrade governance proposal. - The
patch
version represents features or fixes that can be added without affecting state. - Release candidates include
-rc#
at the end where the numbering starts at 1 (e.g.-rc1
). Release candidates may not be state compatible with their predecessors.
Provenance uses the main
branch for new features and fixes.
It is not guaranteed that main
will be compatible with the current Provenance blockchain networks.
A .x
releases branch is made for each minor version. E.g. release/v1.12.x
.
A tag is created for each release. E.g. v1.12.0
.
To get a specific version, check it out by tag. E.g. git checkout v1.12.0 -b tag-v1.12.0
.
Some older repos still use master
instead of main
but the two are treated the same way.
The main
branch and all release/*
branches are protected and can only be updated via PR.
Branch protection might not be set up in all repos, but those branches should always be treated as if they were protected.
- The latest state of development is on
main
. - Using
--force
onto a protected branch is not allowed (except when reverting a broken commit, which should seldom happen). - Protected branches must not fail
make test test-race
. - Protected branches must not fail
make lint
. - Protected branches should not fail any GitHub action checks.
- In a main repo (e.g. provenance), the preferred branch name format is
<user>/<issue #>-<short description>
. - In forked repos under the
provenance-io
organization (e.g. provenance-io/cosmos-sdk), the preferred branch name format isprov/<user>/<issue #>-<short description>
.
All changes should target main
.
If a change is needed in a release branch, it should first be PRed to main
then be cherry-picked and re-PRed to the release branch.
- Assign the issue to yourself and mark it as "In Progress" in any projects the issue is assigned to.
- Checkout
main
and make sure it's up-to-date. E.g.git checkout main && git pull
. - Create a development branch for your work using the development branch name format defined above. E.g.
git checkout -b myuser/123-add-foo-feature
. - Make changes and commit them. The suggested commit message format is
[issue #]: <message>
. E.g.git commit -m "[123]: Update changelog."
. - Push up your changes.
- Make a PR (possibly as a draft).
- Repeat steps 4 and 5 as needed.
- Mark your PR as "Ready to Review" (unless it's already that way).
- Once the PR is ready (approved and all checks pass), it should be merged using the "Squash and Merge" strategy.
Definitions:
- A "major release" is one where the 1st number in the version string is increased.
It usually has minor and patch versions of
0
, but in some cases might not. - A "minor release" is one where the 2nd number in the version string is increased.
It usually has a patch version of
0
, but might not. - A "patch release" is one where the 3rd number in the version string is increased.
- A "release candidate" is one that has
-rc#
at the end of the version string. These are usually not used for patch releases, but can be. - A "full release" is a release that isn't a release candidate.
- A "
.x
branch" is a git branch with the formatrelease/v#.#.x
. - The primary Provenance Blockchain network is "
mainnet
". - The Provenance Blockchain network used for testing and integration is "
testnet
".
Git tags should only be used for releases.
A release is automatically created by GitHub when a tag is pushed that has the format v#.#.#
(where #
is a whole number of any length).
A release candidate is created if the tag has the format v#.#.#-rc#
.
As of v1.13.0
, release tags are created on the .x
branches. E.g. on release/v1.13.x
.
Prior to v1.13.0
, release tags were created on branches containing the full version string. E.g. release/v1.12.0
.
For releases of forked repos (e.g. provenance-io/cosmos-sdk),
the version should have the format <upstream version>-pio-#
where <upstream version>
is the version from the upstream repo that our version is based on.
The -pio-#
numbering should start at 1
and should restart when the <upstream version>
changes.
The release cycle generally follows this pattern:
- Create a new release candidate.
- Test it locally. Go back to step 1 if issues are found.
- Upgrade
testnet
to the release candidate. - Test using
testnet
. Go back to step 1 if issues are found. - Create the full release.
- Upgrade
mainnet
to the full release. - Release patch versions as needed.
In some cases, a release candidate is not created before creating a full version.
Either way, testnet
will be upgraded to the new version before mainnet
.
For patch version releases, no upgrades are required or preformed.
Once mainnet
has upgraded off of a version, that version is no longer supported.
Summary:
- Create a
.x
branch if needed. - Update changelog and release notes on the
.x
branch. - Create the new version tag.
- PR the
.x
branch back tomain
.
If a .x
branch does not yet exist for the desired minor version, one must be created now.
- In a main repo (e.g. provenance), the
.x
branch name format isrelease/v#.#.x
. - In forked repos under the
provenance-io
organization (e.g. provenance-io/cosmos-sdk), the.x
branch name format isrelease-pio/v#.#.x
.
- Start on
main
and make sure you're up-to-date, e.g.git checkout main && git pull
. - Create the new
.x
branch, e.g.git checkout -b release/v1.13.x
. - Push it to GitHub, e.g.
git push
.
You will need to create a new development branch for this and PR it back to the .x
branch.
The CHANGELOG.md
on the .x
branch must be updated to reflect the new release.
- Run
.changelog/prep-release.sh <version>
to create/updateRELEASE_CHANGELOG.md
, updateCHANGELOG.md
, and move things around in the.changelog/
folder. - Review the changes with extra attention on the new content of
CHANGELOG.md
andRELEASE_CHANGELOG.md
. - Stage and commit the changes.
- Push up your branch and create a PR for it to the
.x
branch. The PR title should be likeMark v1.13.0
. - Get the PR approved and merged.
Do the following locally.
- Navigate to your locally cloned repo.
- Make sure you've got up-to-date repo info. E.g.
git fetch
. - Checkout the
.x
branch and make sure it's up-to-date. E.g.git checkout release/v1.13.x && git pull
. - Create and sign the tag. E.g.
git tag -s v1.13.0 -m "Release v1.13.0"
. - Push the branch. E.g.
git push
. - Push the tag. E.g.
git push origin v1.13.0
.
You can then monitor the GitHub actions for the repo and also watch for the new release page to be created.
This PR should update the CHANGELOG.md
and contain any changes applied to the .x
branch that are not yet in main
.
It should NOT contain the RELEASE_CHANGELOG.md
file.
It also should NOT have the new version directory under .changelog/
(e.g. .changelog/v1.13.0
), but it SHOULD remove applicable entries from .changelog/unreleased
.
Do the following locally.
- Navigate to your locally cloned repo.
- Check out the
.x
branch and make sure it's up-to-date. E.g.git checkout release/v1.13.x && git pull
. - Check out the
main
branch and make sure it's up-to-date. E.g.git checkout main && git pull
. - Create a new development branch. E.g.
git checkout -b myuser/v1.13.0-back-to-main
. - Identify the commit that updated the changelog on the .x branch. E.g.
git log -5 --oneline release/v1.13.x
, then copy the commit hash. - Cherry-pick (without committing) that commit to your development branch. E.g.
git cherry-pick 5f57e13 --no-commit
. - Remove the
RELEASE_CHANGELOG.md
file. - Remove the new version directory under
.changelog
. - Stage the removals and finish the cherry-pick to commit the changes.
- Identify any other changes made to the
.x
branch that were not made tomain
(and should be); cherry-pick and commit them. - Create a PR from your branch targeting
main
. The PR title should be likeMark v1.13.0
.