github.com/Finschia/finschia-sdk@v0.48.1/CONTRIBUTING.md (about)

     1  # Contributing
     2  
     3  - [Contributing](#contributing)
     4    - [Pull Requests](#pull-requests)
     5      - [Process for reviewing PRs](#process-for-reviewing-prs)
     6      - [Updating Documentation](#updating-documentation)
     7    - [Forking](#forking)
     8    - [Dependencies](#dependencies)
     9    - [Protobuf](#protobuf)
    10    - [Testing](#testing)
    11    - [Branching Model and Release](#branching-model-and-release)
    12      - [PR Targeting](#pr-targeting)
    13      - [Development Procedure](#development-procedure)
    14      - [Pull Merge Procedure](#pull-merge-procedure)
    15      - [Release Procedure](#release-procedure)
    16      - [Point Release Procedure](#point-release-procedure)
    17    - [Code Owner Membership](#code-owner-membership)
    18  
    19  Thank you for considering making contributions to finschia-sdk and related
    20  repositories!
    21  
    22  Contributing to this repo can mean many things such as participating in
    23  discussion or proposing code changes. To ensure a smooth workflow for all
    24  contributors, the general procedure for contributing has been established:
    25  
    26  1. Either [open](https://github.com/Finschia/finschia-sdk/issues/new/choose) or
    27     [find](https://github.com/Finschia/finschia-sdk/issues) an issue you'd like to help with
    28  2. Participate in thoughtful discussion on that issue
    29  3. If you would like to contribute:
    30     1. If the issue is a proposal, ensure that the proposal has been accepted
    31     2. Ensure that nobody else has already begun working on this issue. If they have,
    32        make sure to contact them to collaborate
    33     3. If nobody has been assigned for the issue and you would like to work on it,
    34        make a comment on the issue to inform the community of your intentions
    35        to begin work
    36     4. Follow standard Github best practices: fork the repo, branch from the
    37        HEAD of `main`, make some commits, and submit a PR to `main`
    38        - For core developers working within the finschia-sdk repo, to ensure a clear
    39          ownership of branches, branches must be named with the convention
    40          `{moniker}/{issue#}-branch-name`
    41     5. Be sure to submit the PR in `Draft` mode submit your PR early, even if
    42        it's incomplete as this indicates to the community you're working on
    43        something and allows them to provide comments early in the development process
    44     6. When the code is complete it can be marked `Ready for Review`
    45     7. Be sure to include a relevant change log entry in the `Unreleased` section
    46        of `CHANGELOG.md` (see file for log format)
    47  
    48  Note that for very small or blatantly obvious problems (such as typos) it is
    49  not required to an open issue to submit a PR, but be aware that for more complex
    50  problems/features, if a PR is opened before an adequate design discussion has
    51  taken place in a github issue, that PR runs a high likelihood of being rejected.
    52  
    53  Other notes:
    54  
    55  - Please make sure to run `make format` before every commit - the easiest way
    56    to do this is have your editor run it for you upon saving a file. Additionally
    57    please ensure that your code is lint compliant by running `golangci-lint run`.
    58    A convenience git `pre-commit` hook that runs the formatters automatically
    59    before each commit is available in the `contrib/githooks/` directory.
    60  
    61  ## Commit Convention
    62  All commits pushed to `finschia-sdk` are classified according to the rules below.
    63  Therefore, it cannot be included in the release notes unless you properly assign the prefix to the commit. For example, you can write commit message like `feat: this is new feature`. However, if you want to clarify the scope of the commit, you can write it as follows `feat(x/token): this is new feature`.
    64  - `chore` : a commit of the type chore makes trivial changes. If you don't want to include specific commit in the release note, add this prefix.
    65  - `feat` : a commit of the type feat introduces a new feature to the codebase
    66  - `fix` : a commit of the type fix patches a bug in your codebase
    67  - `refactor` : A code change that neither fixes a bug nor adds a feature
    68  - `BREAKING CHANGE` : a commit of the type breaking changes to the codebase. This changes breaks down the backward compatibility
    69  - `perf` : A code change that improves performance
    70  - `test`: Adding missing tests or correcting existing tests
    71  - `docs`: Documentation only changes
    72  - `build`: Changes that affect the build system or external dependencies
    73  - `ci`: Changes to our CI configuration files and scripts
    74  
    75  ## Pull Requests
    76  
    77  To accommodate review process we suggest that PRs are categorically broken up.
    78  Ideally each PR addresses only a single issue. Additionally, as much as possible
    79  code refactoring and cleanup should be submitted as a separate PRs from bugfixes/feature-additions.
    80  
    81  ### Process for reviewing PRs
    82  
    83  All PRs require two Reviews before merge (except docs changes, or variable name-changes which only require one). When reviewing PRs please use the following review explanations:
    84  
    85  - `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.
    86  - `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:
    87    - You must also think through anything which ought to be included but is not
    88    - You must think through whether any added code could be partially combined (DRYed) with existing code
    89    - You must think through any potential security issues or incentive-compatibility flaws introduced by the changes
    90    - Naming must be consistent with conventions and the rest of the codebase
    91    - 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).
    92    - if you approve of the PR, you are responsible for fixing any of the issues mentioned here and more
    93  - If you sat down with the PR submitter and did a pairing review please note that in the `Approval`, or your PR comments.
    94  - If you are only making "surface level" reviews, submit any notes as `Comments` without adding a review.
    95  
    96  ### Updating Documentation
    97  
    98  If you open a PR on the LBM SDK, it is mandatory to update the relevant documentation in /docs.
    99  
   100  - If your change relates to the core SDK (baseapp, store, ...), please update the `docs/basics/`, `docs/core/` and/or `docs/building-modules/` folders.
   101  - If your changes relate to the core of the CLI (not specifically to module's CLI/Rest), please modify the `docs/run-node/` folder.
   102  - If your changes relate to a module, please update the module's spec in `x/moduleName/docs/spec/`.
   103  
   104  ## Forking
   105  
   106  Please note that Go requires code to live under absolute paths, which complicates forking.
   107  While my fork lives at `https://github.com/someone/finschia-sdk`,
   108  the code should never exist at `$GOPATH/src/github.com/someone/finschia-sdk`.
   109  Instead, we use `git remote` to add the fork as a new remote for the original repo,
   110  `$GOPATH/src/github.com/Finschia/finschia-sdk`, and do all the work there.
   111  
   112  For instance, to create a fork and work on a branch of it, I would:
   113  
   114  - Create the fork on github, using the fork button.
   115  - Go to the original repo checked out locally (i.e. `$GOPATH/src/github.com/Finschia/finschia-sdk`)
   116  - `git remote rename origin upstream`
   117  - `git remote add origin git@github.com:someone/finschia-sdk.git`
   118  
   119  Now `origin` refers to my fork and `upstream` refers to the finschia-sdk version.
   120  So I can `git push -u origin main` to update my fork, and make pull requests to finschia-sdk from there.
   121  Of course, replace `someone` with your git handle.
   122  
   123  To pull in updates from the origin repo, run
   124  
   125  - `git fetch upstream`
   126  - `git rebase upstream/main` (or whatever branch you want)
   127  
   128  Please don't make Pull Requests from `main`.
   129  
   130  ## Dependencies
   131  
   132  We use [Go 1.20 Modules](https://github.com/golang/go/wiki/Modules) to manage
   133  dependency versions.
   134  
   135  The `main` branch of every LBM repository should just build with `go get`,
   136  which means they should be kept up-to-date with their dependencies, so we can
   137  get away with telling people they can just `go get` our software.
   138  
   139  Since some dependencies are not under our control, a third party may break our
   140  build, in which case we can fall back on `go mod tidy -v`.
   141  
   142  ## Protobuf
   143  
   144  We use [Protocol Buffers](https://developers.google.com/protocol-buffers) along with [gogoproto](https://github.com/gogo/protobuf) to generate code for use in finschia-sdk.
   145  
   146  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](https://docs.docker.com/get-docker/) to install it.
   147  
   148  For formatting code in `.proto` files, you can run `make proto-format` command.
   149  
   150  For linting and checking breaking changes, we use [buf](https://buf.build/). You can use the commands `make proto-lint` and `make proto-check-breaking` to respectively lint your proto files and check for breaking changes.
   151  
   152  To generate the protobuf stubs, you can run `make proto-gen`.
   153  
   154  We also added the `make proto-all` command to run all the above commands sequentially.
   155  
   156  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.
   157  
   158  For example, in vscode your `.vscode/settings.json` should look like:
   159  
   160  ```
   161  {
   162      "protoc": {
   163          "options": [
   164          "--proto_path=${workspaceRoot}/proto",
   165          "--proto_path=${workspaceRoot}/third_party/proto"
   166          ]
   167      }
   168  }
   169  ```
   170  
   171  ## Testing
   172  
   173  Tests can be ran by running `make test` at the top level of the SDK repository. 
   174  
   175  We expect tests to use `require` or `assert` rather than `t.Skip` or `t.Fail`,
   176  unless there is a reason to do otherwise.
   177  When testing a function under a variety of different inputs, we prefer to use
   178  [table driven tests](https://github.com/golang/go/wiki/TableDrivenTests).
   179  Table driven test error messages should follow the following format
   180  `<desc>, tc #<index>, i #<index>`.
   181  `<desc>` is an optional short description of whats failing, `tc` is the
   182  index within the table of the testcase that is failing, and `i` is when there
   183  is a loop, exactly which iteration of the loop failed.
   184  The idea is you should be able to see the
   185  error message and figure out exactly what failed.
   186  Here is an example check:
   187  
   188  ```go
   189  <some table>
   190  for tcIndex, tc := range cases {
   191    <some code>
   192    for i := 0; i < tc.numTxsToTest; i++ {
   193        <some code>
   194  			require.Equal(t, expectedTx[:32], calculatedTx[:32],
   195  				"First 32 bytes of the txs differed. tc #%d, i #%d", tcIndex, i)
   196  ```
   197  
   198  ## Branching Model and Release
   199  
   200  User-facing repos should adhere to the trunk based development branching model: https://trunkbaseddevelopment.com/.
   201  
   202  Libraries need not follow the model strictly, but would be wise to.
   203  
   204  The SDK utilizes [semantic versioning](https://semver.org/).
   205  
   206  ### PR Targeting
   207  
   208  Ensure that you base and target your PR on the `main` branch.
   209  
   210  All feature additions should be targeted against `main`. Bug fixes for an outstanding release candidate
   211  should be targeted against the release candidate branch.
   212  
   213  ### Development Procedure
   214  
   215  - the latest state of development is on `main`
   216  - `main` must never fail `make lint test test-race`
   217  - `main` should not fail `make lint`
   218  - no `--force` onto `main` (except when reverting a broken commit, which should seldom happen)
   219  - create a development branch either on github.com/Finschia/finschia-sdk, or your fork (using `git remote add origin`)
   220  - before submitting a pull request, begin `git rebase` on top of `main`
   221  
   222  ### Pull Merge Procedure
   223  
   224  - ensure pull branch is rebased on `main`
   225  - run `make test` to ensure that all tests pass
   226  - merge pull request (We are using `squash and merge` for small features)
   227  
   228  ### Release Procedure
   229  
   230  - Start on `main`
   231  - Create the release candidate branch `rc/v*` (going forward known as **RC**)
   232    and ensure it's protected against pushing from anyone except the release
   233    manager/coordinator
   234    - **no PRs targeting this branch should be merged unless exceptional circumstances arise**
   235  - On the `RC` branch, prepare a new version section in the `CHANGELOG.md`
   236    - All links must be link-ified: `$ python ./scripts/linkify_changelog.py CHANGELOG.md`
   237    - Copy the entries into a `RELEASE_CHANGELOG.md`, this is needed so the bot knows which entries to add to the release page on github.
   238  - Kick off a large round of simulation testing (e.g. 400 seeds for 2k blocks)
   239  - If errors are found during the simulation testing, commit the fixes to `main`
   240    and create a new `RC` branch (making sure to increment the `rcN`)
   241  - After simulation has successfully completed, create the release branch
   242    (`release/vX.XX.X`) from the `RC` branch
   243  - Create a PR to `main` to incorporate the `CHANGELOG.md` updates
   244  - Tag the release (use `git tag -a`) and create a release in Github
   245  - Delete the `RC` branches
   246