Skip to content

Latest commit

 

History

History
323 lines (230 loc) · 18.6 KB

CONTRIBUTING.md

File metadata and controls

323 lines (230 loc) · 18.6 KB

Contributing

Thank you for considering making contributions to the Interchain Security (ICS) repository! 🎉👍

Overview

Contributing to this repo can mean many things such as participating in discussion or proposing code changes. Following the processes outlined in this document will lead to the best chance of landing changes in a release.

Stewarding team responsibility

ICS has many stakeholders contributing and shaping the project. The ICS stewarding team is composed of Informal Systems developers and is responsible for stewarding this project over time. This means that the stewarding team needs to understand the nature of, and agree to maintain, all of the changes that land on main or a backport branch. It may cost a few days/weeks' worth of time to submit a particular change, but maintaining that change over the years has a much higher cost that the stewarding team will bear.

Ease of reviewing

The fact that the stewarding team needs to be able to deeply understand the short-, medium- and long-term consequences of incoming changes means that changes need to be easily reviewed.

What makes a change easy to review, and more likely to land in an upcoming release?

  1. Each pull request must do one thing. It must be very clear what that one thing is when looking at the pull request title, description, and linked issues. It must also be very clear what value it ultimately aims to deliver, and to which user(s). A single pull request that does multiple things, or without a clear articulation of the problem it attempts to solve, may be rejected immediately.

  2. Each pull request must be manageable in size. Self-contained pull requests that are manageable in size may target main directly. Larger contributions though must be structured as a series of smaller pull requests each building upon the previous one, all ideally tracked in a tracking issue (i.e., an EPIC). These pull requests must target a long-lived feature branch. For details, see the development procedure guidelines. Poorly structured pull requests may be rejected immediately with a request to restructure them.

    Note: This does not necessarily apply to documentation-related changes or automatically generated code (e.g. generated from Protobuf definitions). But automatically generated code changes should occur within separate commits, so they are easily distinguishable from manual code changes.

Workflow

To ensure a smooth workflow for all contributors, a general workflow for contributing has been established.

  1. Start by browsing existing issues and discussions. If you are looking for something interesting or if you have something in your mind, there is a chance it had been discussed.
  2. Determine whether a GitHub issue or discussion is more appropriate for your needs:
    1. If you want to propose something new that requires specification or an additional design, or you would like to change a process, start with a new discussion. With discussions, we can better handle the design process using discussion threads. A discussion usually leads to one or more issues.
    2. If the issue you want addressed is a specific proposal or a bug, then open a new issue.
    3. Review existing issues to find an issue you'd like to help with.
  3. Participate in thoughtful discussion on that issue.
  4. If you would like to contribute:
    1. Ensure that the proposal has been accepted.
    2. Ensure that nobody else has already begun working on this issue. If they have, make sure to contact them to collaborate.
    3. 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 and please wait for an acknowledgement from the stewarding team.
  5. To submit your work as a contribution to the repository, follow standard GitHub best practices. See development procedure guidelines below.

Note: For very small or trivial issues such as typos, you are not required to open an issue before submitting a PR. For complex problems or features, please make sure to open an issue and provide context and problem description. PRs opened before adequate design discussion has taken place in a GitHub issue have a high likelihood of being rejected without review.

Project Board

We use self-organizing principles to coordinate and collaborate across organizations in structured "EPIC" that focuses on specific problem domains or architectural components of ICS. For details, see the GitHub Project board.

The developers work in sprints, which are available in a GitHub Project.

Architecture Decision Records (ADR)

When proposing an architecture decision for ICS, please start by opening an issue or a discussion with a summary of the proposal. Once the proposal has been discussed and there is rough alignment on a high-level approach to the design, you may either start development, or write an ADR.

If your architecture decision is a simple change, you may contribute directly without writing an ADR. However, if you are proposing a significant change, please include a corresponding ADR.

In certain circumstances, the architecture decision may require changes to the ICS spec. Note that the spec is responsible for defining language-agnostic, implementation-agnostic behaviors for the ICS protocol. Whereas ADRs are responsible for communicating implementation decisions contained within this repo.

To create an ADR, follow the template and doc. If you would like to see examples of how these are written, please refer to the current ADRs.

ADR Proposals

Architecture Decision Records (ADRs) may be proposed by any contributors or maintainers of ICS. ADRs are intended to be iterative, and may be merged into main while still in a Proposed status

Development Procedure

main must be stable, include only completed features and never fail make lint, make test, or make build/install.

Depending on the scope of the work, we differentiate between self-contained pull requests and long-lived contributions (features).

Self-contained pull requests:

  • Fork the repo (core developers must create a branch directly in the ICS repo), branch from the HEAD of main, make some commits, and submit a PR to main.
  • For core developers working within the interchain-security repo, follow branch name conventions to ensure clear ownership of branches: {moniker}/{issue#}-branch-name.
  • See Branching Model for more details.

Large contributions:

  • Make sure that a feature branch in created in the repo. This will be created by the stewarding team after design discussions. The name convention for the feature branch must be feat/{issue#}-branch-name. Note that (similar to main) all feature branches have branch protection rules and they run the CI. Unlike main, feature branch may intermittently fail to make lint, make test, make build/install.
  • Fork the repo (core developers must create a branch directly in the ICS repo), branch from the HEAD of the feature branch, make some commits, and submit a PR to the feature branch. All PRs targeting a feature branch should follow the same guidelines in this document.
  • Once the feature is completed, submit a PR from the feature branch targeting main.

Be 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 (most of the editors will do it anyway using a pre-configured setup of the programming language mode).

Note: Exceptions to the above guidelines are possible, but only after prior discussions with the stewarding team.

Testing

Appropriate tests should be written with a new feature, and all existing tests should pass. See docs/testing.md for more information.

Pull Requests

Before submitting a pull request:

  • synchronize your branch with the latest base branch (i.e., main or feature branch) and resolve any arising conflicts, e.g.,
    • either git fetch origin/main && git merge origin/main
    • or git fetch origin/main && git rebase -i origin/main
  • run make lint, make test, make build/install to ensure that all checks and tests pass.

Then:

  1. If you have something to show, start with a Draft PR. It's good to have early validation of your work and we highly recommend this practice. A Draft PR also indicates to the community that the work is in progress. Draft PRs also help the stewarding team provide early feedback and ensure the work is in the right direction.
  2. When the code is complete, change your PR from Draft to Ready for Review.
  3. Go through the actions for each checkbox present in the PR template description. The PR actions are automatically provided for each new PR.
  4. Be sure to include a relevant changelog entry in the Unreleased section of CHANGELOG.md (see file for log format). The entry should be on top of all others changes in the section.

PRs must have a category prefix that is based on the type of changes being made (for example, fix, feat, refactor, docs, and so on). The type must be included in the PR title as a prefix (for example, fix: <description>). This convention ensures that all changes that are committed to the base branch follow the Conventional Commits specification. Additionally, each PR should only address a single issue.

Note: When merging, GitHub will squash commits and rebase on top of the base branch.

Pull Request Templates

There are three PR templates. The default template contains links to the three templates. Please go the the Preview tab and select the appropriate sub-template:

Requesting Reviews

In order to accommodate the review process, the author of the PR must complete the author checklist (from the pull request template) to the best of their abilities before marking the PR as "Ready for Review". If you would like to receive early feedback on the PR, open the PR as a "Draft" and leave a comment in the PR indicating that you would like early feedback and tagging whoever you would like to receive feedback from.

Codeowners are marked automatically as the reviewers.

All PRs require at least two review approvals before they can be merged (one review might be acceptable in the case of minor changes to docs or others changes that do not affect production code). Each PR template has a reviewers checklist that must be completed before the PR can be merged. Each reviewer is responsible for all checked items unless they have indicated otherwise by leaving their handle next to specific items. In addition, use the following review explanations:

  • LGTM without an explicit approval means that the changes look good, but you haven't thoroughly reviewed the reviewer checklist items.
  • Approval means that you have completed some or all of the reviewer checklist items. If you only reviewed selected items, you must add your handle next to the items that you have reviewed. In addition, follow these guidelines:
    • 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 (for example, not importing testing modules in production code, or including example code modules in production code).
    • If you approve the PR, you are responsible for any issues mentioned here and any issues that should have been addressed after thoroughly reviewing the reviewer checklist items in the pull request template.
  • If you sat down with the PR submitter and did a pairing review, add this information in the Approval or your PR comments.
  • If you are only making "surface level" reviews, submit notes as a comment review.

Updating Documentation

If you open a PR in ICS, it is mandatory to update the relevant documentation in /docs.

Changelog

To manage and generate our changelog, we currently use unclog.

Every PR with types fix, feat, deps, and refactor should include a file .changelog/unreleased/${section}/[${component}/]${pr-number}-${short-description}.md, where:

  • section is one of dependencies, improvements, features, bug-fixes, state-breaking, api-breaking, and if multiple apply, create multiple files, not necessarily with the same short-description or content;
  • pr-number is the PR number;
  • short-description is a short (4 to 6 word), hyphen separated description of the change;
  • component is used for changes that affect one of the components defined in the config, e.g., provider, consumer.

For examples, see the .changelog folder.

Use unclog to add a changelog entry in .changelog (check the requirements first):

# add a general entry
unclog add \
   -i "${pr-number}-${short-description}" \
   -p "${pr-number}" \
   -s "${section}" \
   -m "${description}" \

# add a entry to a component 
unclog add 
   -i "${pr-number}-${short-description}" \
   -p "${pr-number}" \
   -c "${component}" \
   -s "${section}" \
   -m "${description}" \

where ${description} is a detailed description of the changelog entry.

For example,

# add an entry for bumping IBC to v7.2.0
unclog add -i "1196-bump-ibc" -p 1196 -s dependencies -m "Bump [ibc-go](https://github.com/cosmos/ibc-go) to [v7.2.0](https://github.com/cosmos/ibc-go/releases/tag/v7.2.0)" 

# add an entry for changing the consumer module;
# note that the entry is added to both state-breaking and features sections
unclog add -i "1024-jail-throttling-v2" -p 1024 -c consumer -s state-breaking -m "Add the consumer-side changes for jail throttling with retries (cf. ADR 008)." 
unclog add -i "1024-jail-throttling-v2" -p 1024 -c consumer -s features -m "Add the consumer-side changes for jail throttling with retries (cf. ADR 008)." 

Note: unclog add requires an editor. This can be set either by configuring an $EDITOR environment variable or by manually specify an editor binary path via the --editor flag.

Note: Changelog entries should answer the question: "what is important about this change for users to know?" or "what problem does this solve for users?". It should not simply be a reiteration of the title of the associated PR, unless the title of the PR very clearly explains the benefit of a change to a user.

Dependencies

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 ICS's 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.

Protobuf

We use Protocol Buffers along with buf to generate code for use in ICS.

For deterministic 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.

To generate the protobuf stubs, you can run make proto-gen.

Branching Model and Release

ICS adheres to the trunk based development branching model. User branches should start with a user name, example: {moniker}/{issue#}-branch-name.

PR Targeting

Ensure that you base and target your PRs on either main or a feature branch.

All complete features and all bug fixes must be targeted against main. Exception is for bug fixes which are only related to a released version. In that case, the related bug fix PRs must target against the release branch.

If needed, we will backport a commit from main to a release branch with appropriate consideration of versioning.