github.com/decred/dcrlnd@v0.7.6/docs/code_contribution_guidelines.md (about)

     1  # Table of Contents
     2  1. [Overview](#overview)
     3  2. [Minimum Recommended Skillset](#minimum-recommended-skillset)
     4  3. [Required Reading](#required-reading)
     5  4. [Development Practices](#development-practices)
     6     1. [Share Early, Share Often](#share-early-share-often)
     7     1. [Testing](#testing)
     8     1. [Code Documentation and Commenting](#code-documentation-and-commenting)
     9     1. [Model Git Commit Messages](#model-git-commit-messages)
    10     1. [Ideal Git Commit Structure](#ideal-git-commit-structure)
    11     1. [Code Spacing](#code-spacing)
    12     1. [Protobuf Compilation](#protobuf-compilation)
    13     1. [Additional Style Constraints On Top of gofmt](#additional-style-constraints-on-top-of-gofmt)
    14     1. [Pointing to Remote Dependant Branches in Go Modules](#pointing-to-remote-dependant-branches-in-go-modules)
    15     1. [Use of Log Levels](#use-of-log-levels)
    16  5. [Code Approval Process](#code-approval-process)
    17     1. [Code Review](#code-review)
    18     1. [Rework Code (if needed)](#rework-code-if-needed)
    19     1. [Acceptance](#acceptance)
    20  6. [Contribution Standards](#contribution-standards)
    21     1. [Contribution Checklist](#contribution-checklist)
    22     1. [Licensing of Contributions](#licensing-of-contributions)
    23  
    24  # Overview
    25  
    26  Developing cryptocurrencies is an exciting endeavor that touches a wide variety
    27  of areas such as wire protocols, peer-to-peer networking, databases,
    28  cryptography, language interpretation (transaction scripts), adversarial
    29  threat-modeling, and RPC systems. They also represent a radical shift to the
    30  current monetary system and as a result provide an opportunity to help reshape
    31  the entire financial system. With the advent of the [Lightning Network
    32  (LN)](https://lightning.network/), new layers are being constructed upon the
    33  base blockchain layer which have the potential to alleviate many of the
    34  limitations and constraints inherent in the design of blockchains. There are
    35  few projects that offer this level of diversity and impact all in one code
    36  base.
    37  
    38  However, as exciting as it is, one must keep in mind that cryptocurrencies
    39  represent real money and introducing bugs and security vulnerabilities can have
    40  far more dire consequences than in typical projects where having a small bug is
    41  minimal by comparison.  In the world of cryptocurrencies, even the smallest bug
    42  in the wrong area can cost people a significant amount of money.  For this
    43  reason, the Lightning Network Daemon (`lnd`) has a formalized and rigorous
    44  development process (heavily inspired by
    45  [btcsuite](https://github.com/btcsuite)) which is outlined on this page.
    46  
    47  We highly encourage code contributions, however it is imperative that you adhere
    48  to the guidelines established on this page.
    49  
    50  # Minimum Recommended Skillset
    51  
    52  The following list is a set of core competencies that we recommend you possess
    53  before you really start attempting to contribute code to the project.  These are
    54  not hard requirements as we will gladly accept code contributions as long as
    55  they follow the guidelines set forth on this page.  That said, if you don't have
    56  the following basic qualifications you will likely find it quite difficult to
    57  contribute to the core layers of Lightning. However, there are still a number
    58  of low hanging fruit which can be tackled without having full competency in the
    59  areas mentioned below. 
    60  
    61  - A reasonable understanding of bitcoin at a high level (see the
    62    [Required Reading](#required-reading) section for the original white paper)
    63  - A reasonable understanding of the Lightning Network at a high level
    64  - Experience in some type of C-like language
    65  - An understanding of data structures and their performance implications
    66  - Familiarity with unit testing
    67  - Debugging experience
    68  - Ability to understand not only the area you are making a change in, but also
    69    the code your change relies on, and the code which relies on your changed code
    70  
    71  Building on top of those core competencies, the recommended skill set largely
    72  depends on the specific areas you are looking to contribute to.  For example,
    73  if you wish to contribute to the cryptography code, you should have a good
    74  understanding of the various aspects involved with cryptography such as the
    75  security and performance implications.
    76  
    77  # Required Reading
    78  
    79  - [Effective Go](http://golang.org/doc/effective_go.html) - The entire `dcrlnd`
    80    project follows the guidelines in this document.  For your code to be
    81    accepted, it must follow the guidelines therein.
    82  - [Original Satoshi Whitepaper](https://bitcoin.org/bitcoin.pdf) - This is the
    83    white paper that started it all.  Having a solid foundation to build on will
    84    make the code much more comprehensible.
    85  - [Lightning Network Whitepaper](https://lightning.network/lightning-network-paper.pdf) - This is
    86    the white paper that kicked off the Layer 2 revolution. Having a good grasp of
    87    the concepts of Lightning will make the core logic within the daemon much more
    88    comprehensible: Bitcoin Script, off-chain blockchain protocols, payment
    89    channels, bi-directional payment channels, relative and absolute time-locks
    90    and commitment state revocations.
    91      - The original LN was written for a rather narrow audience, the paper may be
    92        a bit unapproachable to many. Thanks to the Bitcoin community, there exist
    93        many easily accessible supplemental resources which can help one see how
    94        all the pieces fit together from double-spend protection all the way up to
    95        commitment state transitions and Hash Time Locked Contracts (HTLCs):
    96           - [Lightning Network Summary](https://lightning.network/lightning-network-summary.pdf)
    97          - [Understanding the Lightning Network 3-Part series](https://bitcoinmagazine.com/articles/understanding-the-lightning-network-part-building-a-bidirectional-payment-channel-1464710791)
    98          - [Deployable Lightning](https://github.com/ElementsProject/lightning/blob/master/doc/deployable-lightning.pdf)
    99  
   100  
   101  Note that the core design of the Lightning Network has shifted over time as
   102  concrete implementation and design has expanded our knowledge beyond the
   103  original white paper. Therefore, specific information outlined in the resources
   104  above may be a bit out of date. Many implementers are currently working on an
   105  initial [Lightning Network Specifications](https://github.com/lightningnetwork/lightning-rfc).
   106  Once the specification is finalized, it will be the most up-to-date
   107  comprehensive document explaining the Lightning Network. As a result, it will
   108  be recommended for newcomers to read first in order to get up to speed. 
   109  
   110  # Development Practices
   111  
   112  Developers are expected to work in their own trees and submit pull requests when
   113  they feel their feature or bug fix is ready for integration into the  master
   114  branch.
   115  
   116  ## Share Early, Share Often
   117  
   118  We firmly believe in the share early, share often approach.  The basic premise
   119  of the approach is to announce your plans **before** you start work, and once
   120  you have started working, craft your changes into a stream of small and easily
   121  reviewable commits.
   122  
   123  This approach has several benefits:
   124  
   125  - Announcing your plans to work on a feature **before** you begin work avoids
   126    duplicate work.
   127  - It permits discussions which can help you achieve your goals in a way that is
   128    consistent with the existing architecture.
   129  - It minimizes the chances of you spending time and energy on a change that
   130    might not fit with the consensus of the community or existing architecture and
   131    potentially be rejected as a result.
   132  - The quicker your changes are merged to master, the less time you will need to
   133    spend rebasing and otherwise trying to keep up with the main code base.
   134  
   135  ## Testing
   136  
   137  One of the major design goals of all of `dcrlnd`'s packages and the daemon
   138  itself is to aim for a high degree of test coverage.  This is financial software
   139  so bugs and regressions in the core logic can cost people real money.  For this
   140  reason every effort must be taken to ensure the code is as accurate and bug-free
   141  as possible. Thorough testing is a good way to help achieve that goal.
   142  
   143  Unless a new feature you submit is completely trivial, it will probably be
   144  rejected unless it is also accompanied by adequate test coverage for both
   145  positive and negative conditions.  That is to say, the tests must ensure your
   146  code works correctly when it is fed correct data as well as incorrect data
   147  (error paths).
   148  
   149  Go provides an excellent test framework that makes writing test code and
   150  checking coverage statistics straightforward.  For more information about the
   151  test coverage tools, see the [golang cover blog post](http://blog.golang.org/cover).
   152  
   153  A simple way to check the coverage of a package and all its functions is to call
   154  ```
   155  go test -coverprofile=cov.out; go tool cover -html=cov.out
   156  ```
   157  in the package directory.
   158  
   159  A quick summary of test practices follows:
   160  - All new code should be accompanied by tests that ensure the code behaves
   161    correctly when given expected values, and, perhaps even more importantly, that
   162    it handles errors gracefully.
   163  - When you fix a bug, it should be accompanied by tests which exercise the bug
   164    to both prove it has been resolved and to prevent future regressions.
   165  - Changes to publicly exported packages such as
   166    [brontide](https://github.com/decred/dcrlnd/tree/master/brontide)
   167    should be accompanied by unit tests exercising the new or changed behavior.
   168  - Changes to behavior within the daemon's interaction with the P2P protocol,
   169    or RPC's will need to be accompanied by integration tests which use the
   170    [`networkHarness`framework](https://github.com/decred/dcrlnd/blob/master/lntest/harness.go)
   171    contained within `dcrlnd`. For example integration tests, see
   172    [`lnd_test.go`](https://github.com/decred/dcrlnd/blob/master/lnd_test.go#L181).
   173  - The itest log files are automatically scanned for `[ERR]` lines. There
   174    shouldn't be any of those in the logs, see [Use of Log Levels](#use-of-log-levels).
   175  
   176  Throughout the process of contributing to `dcrlnd`, you'll likely also be
   177  extensively using the commands within our `Makefile`. As a result, we recommend
   178  [perusing the make file documentation](https://github.com/decred/dcrlnd/blob/master/docs/MAKEFILE.md).
   179  
   180  ## Code Documentation and Commenting
   181  
   182  - At a minimum every function must be commented with its intended purpose and
   183    any assumptions that it makes
   184    - Function comments must always begin with the name of the function per
   185      [Effective Go](http://golang.org/doc/effective_go.html).
   186    - Function comments should be complete sentences since they allow a wide
   187      variety of automated presentations such as [godoc.org](https://godoc.org).
   188    - The general rule of thumb is to look at it as if you were completely
   189      unfamiliar with the code and ask yourself, would this give me enough
   190  	information to understand what this function does and how I'd probably want
   191  	to use it?
   192  - Exported functions should also include detailed information the caller of the
   193    function will likely need to know and/or understand:<br /><br />
   194  
   195  **WRONG**
   196  ```go
   197  // generates a revocation key
   198  func DeriveRevocationPubkey(commitPubKey *secp256k1.PublicKey,
   199  	revokePreimage []byte) *secp256k1.PublicKey {
   200  ```
   201  **RIGHT**
   202  ```go
   203  // DeriveRevocationPubkey derives the revocation public key given the
   204  // counterparty's commitment key, and revocation preimage derived via a
   205  // pseudo-random-function. In the event that we (for some reason) broadcast a
   206  // revoked commitment transaction, then if the other party knows the revocation
   207  // preimage, then they'll be able to derive the corresponding private key to
   208  // this private key by exploiting the homomorphism in the elliptic curve group:
   209  //    * https://en.wikipedia.org/wiki/Group_homomorphism#Homomorphisms_of_abelian_groups
   210  //
   211  // The derivation is performed as follows:
   212  //
   213  //   revokeKey := commitKey + revokePoint
   214  //             := G*k + G*h
   215  //             := G * (k+h)
   216  //
   217  // Therefore, once we divulge the revocation preimage, the remote peer is able to
   218  // compute the proper private key for the revokeKey by computing:
   219  //   revokePriv := commitPriv + revokePreimge mod N
   220  //
   221  // Where N is the order of the sub-group.
   222  func DeriveRevocationPubkey(commitPubKey *secp256k1.PublicKey,
   223  	revokePreimage []byte) *secp256k1.PublicKey {
   224  ```
   225  - Comments in the body of the code are highly encouraged, but they should
   226    explain the intention of the code as opposed to just calling out the
   227    obvious<br /><br />
   228  
   229  **WRONG**
   230  ```Go
   231  // return err if amt is less than 546
   232  if amt < 546 {
   233  	return err
   234  }
   235  ```
   236  **RIGHT**
   237  ```go
   238  // Treat transactions with amounts less than the amount which is considered dust
   239  // as non-standard.
   240  if amt < 546 {
   241  	return err
   242  }
   243  ```
   244  **NOTE:** The above should really use a constant as opposed to a magic number,
   245  but it was left as a magic number to show how much of a difference a good
   246  comment can make.
   247  
   248  ## Model Git Commit Messages
   249  
   250  This project prefers to keep a clean commit history with well-formed commit
   251  messages.  This section illustrates a model commit message and provides a bit
   252  of background for it.  This content was originally created by Tim Pope and made
   253  available on his website, however that website is no longer active, so it is
   254  being provided here.
   255  
   256  Here’s a model Git commit message:
   257  
   258  ```
   259  prefix: Short (50 chars or less) summary of changes
   260  
   261  More detailed explanatory text, if necessary.  Wrap it to about 72
   262  characters or so.  In some contexts, the first line is treated as the
   263  subject of an email and the rest of the text as the body.  The blank
   264  line separating the summary from the body is critical (unless you omit
   265  the body entirely); tools like rebase can get confused if you run the
   266  two together.
   267  
   268  Write your commit message in the present tense: "Fix bug" and not "Fixed
   269  bug."  This convention matches up with commit messages generated by
   270  commands like git merge and git revert.
   271  
   272  Further paragraphs come after blank lines.
   273  
   274  - Bullet points are okay, too
   275  - Typically a hyphen or asterisk is used for the bullet, preceded by a
   276    single space, with blank lines in between, but conventions vary here
   277  - Use a hanging indent
   278  ```
   279  
   280  The commit prefix is always of the form `prefix: `. It is for the sole
   281  purpose of indicating which package or component was touched in a
   282  commit.
   283  
   284  Here is how the right prefix for a commit is chosen.
   285  - If a commit modifies a component in the main package
   286    (eg. `fundingmanager`) use the component name as the commit prefix.
   287  - If a commit modifies a component in any of the packages besides the main
   288    package use the package name as the commit prefix (eg. `autopilot`).
   289  - If a commit modifies components in multiple packages use the word `multi`
   290    as the commit prefix.
   291  
   292  Here are some of the reasons why wrapping your commit messages to 72 columns is
   293  a good thing.
   294  
   295  - git log doesn't do any special wrapping of the commit messages. With
   296    the default pager of less -S, this means your paragraphs flow far off the edge
   297    of the screen, making them difficult to read. On an 80 column terminal, if we
   298    subtract 4 columns for the indent on the left and 4 more for symmetry on the
   299    right, we’re left with 72 columns.
   300  - git format-patch --stdout converts a series of commits to a series of emails,
   301    using the messages for the message body.  Good email netiquette dictates we
   302    wrap our plain text emails such that there’s room for a few levels of nested
   303    reply indicators without overflow in an 80 column terminal.
   304  
   305  ## Ideal Git Commit Structure
   306  
   307  Within the project we prefer small, contained commits for a pull request over a
   308  single giant commit that touches several files/packages. Ideal commits build on
   309  their own, in order to facilitate easy usage of tools like `git bisect` to `git
   310  cherry-pick`. It's preferred that commits contain an isolated change in a
   311  single package. In this case, the commit header message should begin with the
   312  prefix of the modified package. For example, if a commit was made to modify the
   313  `lnwallet` package, it should start with `lnwallet: `. 
   314  
   315  In the case of changes that touch several packages, and can only compile with
   316  the change across several packages, a `multi: ` prefix should be used.
   317  
   318  Examples of common patterns w.r.t. commit structures within the project:
   319  
   320    * It is common that during the work on a PR, existing bugs are found and
   321      fixed. If they can be fixed in isolation, they should have their own
   322      commit. 
   323    * File restructuring like moving a function to another file or changing order
   324      of functions: with a separate commit because it is much easier to review
   325      the real changes that go on top of the restructuring.
   326    * Preparatory refactorings that are functionally equivalent: own commit.
   327    * Project or package wide file renamings should be in their own commit.
   328    * Ideally if a new package/struct/sub-system is added in a PR, there should
   329      be a single commit which adds the new functionality, with follow up
   330      individual commits that begin to integrate the functionality within the
   331      codebase.
   332  
   333  ## Code Spacing 
   334  
   335  Blocks of code within `dcrlnd` should be segmented into logical stanzas of
   336  operation. Such spacing makes the code easier to follow at a skim, and reduces
   337  unnecessary line noise. Coupled with the commenting scheme specified above,
   338  proper spacing allows readers to quickly scan code, extracting semantics
   339  quickly. Functions should _not_ just be laid out as a bare contiguous block of
   340  code.
   341  
   342  **WRONG**
   343  ```go
   344  	witness := make([][]byte, 4)
   345  	witness[0] = nil
   346  	if bytes.Compare(pubA, pubB) == -1 {
   347  		witness[1] = sigB
   348  		witness[2] = sigA
   349  	} else {
   350  		witness[1] = sigA
   351  		witness[2] = sigB
   352  	}
   353  	witness[3] = witnessScript
   354  	return witness
   355  ```
   356  **RIGHT**
   357  ```go
   358  	witness := make([][]byte, 4)
   359  
   360  	// When spending a p2wsh multi-sig script, rather than an OP_0, we add
   361  	// a nil stack element to eat the extra pop.
   362  	witness[0] = nil
   363  
   364  	// When initially generating the witnessScript, we sorted the serialized
   365  	// public keys in descending order. So we do a quick comparison in order
   366  	// to ensure the signatures appear on the Script Virtual Machine stack in
   367  	// the correct order.
   368  	if bytes.Compare(pubA, pubB) == -1 {
   369  		witness[1] = sigB
   370  		witness[2] = sigA
   371  	} else {
   372  		witness[1] = sigA
   373  		witness[2] = sigB
   374  	}
   375  
   376  	// Finally, add the preimage as the last witness element.
   377  	witness[3] = witnessScript
   378  
   379  	return witness
   380  ```
   381  
   382  Additionally, we favor spacing between stanzas within syntax like: switch case
   383  statements and select statements.
   384  
   385  **WRONG**   
   386  ```go
   387      switch {
   388          case a:
   389              <code block>
   390          case b:
   391              <code block>
   392          case c:
   393              <code block>
   394          case d:
   395              <code block>
   396          default:
   397              <code block>
   398      }
   399  ```
   400  **RIGHT** 
   401  ```go
   402      switch {
   403          // Brief comment detailing instances of this case (repeat below).
   404          case a:
   405              <code block>
   406  
   407          case b:
   408              <code block>
   409  
   410          case c:
   411              <code block>
   412  
   413          case d:
   414              <code block>
   415  
   416          default:
   417              <code block>
   418      }
   419  ```
   420  
   421  If one is forced to wrap lines of function arguments that exceed the 80
   422  character limit, then a new line should be inserted before the first stanza in
   423  the comment body.
   424  
   425  **WRONG**
   426  ```go
   427     func foo(a, b, c, 
   428         d, e) error {
   429         var a int 
   430     }
   431  ```
   432  **RIGHT**
   433  ```go
   434     func foo(a, b, c, 
   435         d, e) error {
   436  
   437         var a int 
   438     }
   439  ```
   440  
   441  ## Protobuf Compilation
   442  
   443  The `dcrlnd` project uses `protobuf`, and its extension [`gRPC`](www.grpc.io) in
   444  several areas and as the primary RPC interface. In order to ensure uniformity
   445  of all protos checked, in we require that all contributors pin against the
   446  _exact same_ version of `protoc`. As of the writing of this article, the `dcrlnd`
   447  project uses [v3.4.0](https://github.com/google/protobuf/releases/tag/v3.4.0)
   448  of `protoc`.
   449  
   450  The following two libraries must be installed with the exact commit hash as
   451  described in [lnrpc README](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/README.md)
   452  otherwise the CI pipeline on Travis will fail:
   453  - grpc-ecosystem/grpc-gateway
   454  - golang/protobuf
   455  
   456  For detailed instructions on how to compile modifications to `dcrlnd`'s `protobuf`
   457  definitions, check out the [lnrpc README](https://github.com/dcrlnd/lnd/blob/master/lnrpc/README.md).
   458  
   459  ## Additional Style Constraints On Top of `gofmt`
   460  
   461  Before a PR is submitted, the proposer should ensure that the file passes the
   462  set of linting scripts run by `make lint`. These include `gofmt`. In addition
   463  to `gofmt` we've opted to enforce the following style guidelines.
   464  
   465     * ALL columns (on a best effort basis) should be wrapped to 80 line columns.
   466       Editors should be set to treat a tab as 8 spaces.
   467     * When wrapping a line that contains a function call as the unwrapped line
   468       exceeds the column limit, the close paren should be placed on its own
   469       line. Additionally, all arguments should begin in a new line after the
   470       open paren.
   471  
   472       **WRONG**
   473       ```go
   474       value, err := bar(a,
   475          a, b, c)
   476       ```
   477  
   478       **RIGHT**
   479       ```go
   480       value, err := bar(
   481          a, a, b, c,
   482       )
   483       ```
   484  
   485  Note that the above guidelines don't apply to log messages. For log messages,
   486  committers should attempt to minimize the of number lines utilized, while still
   487  adhering to the 80-character column limit.
   488  
   489  ## Pointing to Remote Dependant Branches in Go Modules
   490  
   491  It's common that a developer may need to make a change in a dependent project
   492  of `lnd` such as `btcd`, `neutrino`, `btcwallet`, etc. In order to test changes
   493  without testing infrastructure, or simply make a PR into `lnd` that will build
   494  without any further work, the `go.mod` and `go.sum` files will need to be
   495  updated. Luckily, the `go mod` command has a handy tool to do this
   496  automatically so developers don't need to manually edit the `go.mod` file:
   497  ```
   498   go mod edit -replace=IMPORT-PATH-IN-LND@LND-VERSION=DEV-FORK-IMPORT-PATH@DEV-FORK-VERSION
   499  ```
   500  
   501  Here's an example replacing the `lightning-onion` version checked into `lnd` with a version in roasbeef's fork:
   502  ```
   503   go mod edit -replace=github.com/lightningnetwork/lightning-onion@v0.0.0-20180605012408-ac4d9da8f1d6=github.com/roasbeef/lightning-onion@2e5ae87696046298365ab43bcd1cf3a7a1d69695
   504  ```
   505  
   506  ## Use of Log Levels
   507  
   508  There are six log levels available: `trace`, `debug`, `info`, `warn`, `error` and `critical`.
   509  
   510  Only use `error` for internal errors that are never expected to happen during
   511  normal operation. No event triggered by external sources (rpc, chain backend,
   512  etc) should lead to an `error` log.
   513  
   514  # Code Approval Process
   515  
   516  This section describes the code approval process that is used for code
   517  contributions.  This is how to get your changes into `dcrlnd`.
   518  
   519  ## Code Review
   520  
   521  All code which is submitted will need to be reviewed before inclusion into the
   522  master branch.  This process is performed by the project maintainers and usually
   523  other committers who are interested in the area you are working in as well.
   524  
   525  ### Code Review Timeframe
   526  
   527  The timeframe for a code review will vary greatly depending on factors such as
   528  the number of other pull requests which need to be reviewed, the size and
   529  complexity of the contribution, how well you followed the guidelines presented
   530  on this page, and how easy it is for the reviewers to digest your commits.  For
   531  example, if you make one monolithic commit that makes sweeping changes to things
   532  in multiple subsystems, it will obviously take much longer to review.  You will
   533  also likely be asked to split the commit into several smaller, and hence more
   534  manageable, commits.
   535  
   536  Keeping the above in mind, most small changes will be reviewed within a few
   537  days, while large or far reaching changes may take weeks.  This is a good reason
   538  to stick with the [Share Early, Share Often](#share-early-share-often)
   539  development practice outlined above.
   540  
   541  ### What is the review looking for?
   542  
   543  The review is mainly ensuring the code follows the
   544  [Development Practices](#development-practices) and
   545  [Code Contribution Standards](#contribution-standards). However, there are a few
   546  other checks which are generally performed as follows:
   547  
   548  - The code is stable and has no stability or security concerns
   549  - The code is properly using existing APIs and generally fits well into the
   550    overall architecture
   551  - The change is not something which is deemed inappropriate by community
   552    consensus
   553  
   554  ## Rework Code (if needed)
   555  
   556  After the code review, the change will be accepted immediately if no issues are
   557  found.  If there are any concerns or questions, you will be provided with
   558  feedback along with the next steps needed to get your contribution merged with
   559  master.  In certain cases the code reviewer(s) or interested committers may help
   560  you rework the code, but generally you will simply be given feedback for you to
   561  make the necessary changes.
   562  
   563  During the process of responding to review comments, we prefer that changes be
   564  made with [fixup commits](https://robots.thoughtbot.com/autosquashing-git-commits).
   565  The reason for this is two fold: it makes it easier for the reviewer to see
   566  what changes have been made between versions (since Github doesn't easily show
   567  prior versions like Critique) and it makes it easier on the PR author as they
   568  can set it to auto squash the fix up commits on rebase.
   569  
   570  This process will continue until the code is finally accepted.
   571  
   572  ## Acceptance
   573  
   574  Once your code is accepted, it will be integrated with the master branch. After
   575  2+ (sometimes 1) LGTM's (approvals) are given on a PR, it's eligible to land in
   576  master. At this final phase, it may be necessary to rebase the PR in order to
   577  resolve any conflicts and also squash fix up commits. Ideally, the set of
   578  [commits by new contributors are PGP signed](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work), 
   579  although this isn't a strong requirement (but we prefer it!). In order to keep
   580  these signatures intact, we prefer using merge commits. PR proposers can use
   581  `git rebase --signoff` to sign and rebase at the same time as a final step.
   582  
   583  Rejoice as you will now be listed as a [contributor](https://github.com/decred/dcrlnd/graphs/contributors)!
   584  
   585  # Contribution Standards
   586  
   587  ## Contribution Checklist
   588  
   589  - [&nbsp;&nbsp;] All changes are Go version 1.12 compliant
   590  - [&nbsp;&nbsp;] The code being submitted is commented according to
   591    [Code Documentation and Commenting](#code-documentation-and-commenting)
   592  - [&nbsp;&nbsp;] For new code: Code is accompanied by tests which exercise both
   593    the positive and negative (error paths) conditions (if applicable)
   594  - [&nbsp;&nbsp;] For bug fixes: Code is accompanied by new tests which trigger
   595    the bug being fixed to prevent regressions
   596  - [&nbsp;&nbsp;] Any new logging statements use an appropriate subsystem and
   597    logging level
   598  - [&nbsp;&nbsp;] Code has been formatted with `go fmt`
   599  - [&nbsp;&nbsp;] For code and documentation: lines are wrapped at 80 characters
   600    (the tab character should be counted as 8 characters, not 4, as some IDEs do
   601    per default)
   602  - [&nbsp;&nbsp;] Running `make check` does not fail any tests
   603  - [&nbsp;&nbsp;] Running `go vet` does not report any issues
   604  - [&nbsp;&nbsp;] Running `make lint` does not report any **new** issues that
   605    did not already exist
   606  - [&nbsp;&nbsp;] All commits build properly and pass tests. Only in exceptional
   607    cases it can be justifiable to violate this condition. In that case, the
   608    reason should be stated in the commit message.
   609  - [&nbsp;&nbsp;] Commits have a logical structure according to
   610    [Ideal Git Commit Structure](#ideal-git-commit-structure).
   611  
   612  ## Licensing of Contributions
   613  ****
   614  All contributions must be licensed with the
   615  [MIT license](https://github.com/decred/dcrlnd/blob/master/LICENSE).  This is
   616  the same license as all of the code found within dcrlnd.
   617  
   618  
   619  # Acknowledgements
   620  This document was heavily inspired by a [similar document outlining the code
   621  contribution](https://github.com/btcsuite/btcd/blob/master/docs/code_contribution_guidelines.md)
   622  guidelines for btcd and is similar to the [one for dcrd](https://github.com/decred/dcrd/blob/master/docs/code_contribution_guidelines.md) as well.