@@ -13,8 +13,10 @@ permalink: /contribute/
13
13
4.2. [ Testing] ( #Testing ) <br />
14
14
4.3. [ Code Documentation and Commenting] ( #CodeDocumentation ) <br />
15
15
4.4. [ Model Git Commit Messages] ( #ModelGitCommitMessages ) <br />
16
- 4.5. [ Code Spacing] ( #CodeSpacing ) <br />
17
- 4.6. [ Protobuf Compilation] ( #Protobuf ) <br />
16
+ 4.5. [ Ideal Git Commit Structure] ( #IdealGitCommitStructure ) <br />
17
+ 4.6. [ Code Spacing] ( #CodeSpacing ) <br />
18
+ 4.7. [ Protobuf Compilation] ( #Protobuf ) <br />
19
+ 4.8. [ Additional Style Constraints On Top of gofmt] ( ExtraGoFmtStyle ) <br />
18
20
5 . [ Code Approval Process] ( #CodeApproval ) <br />
19
21
5.1. [ Code Review] ( #CodeReview ) <br />
20
22
5.2. [ Rework Code (if needed)] ( #CodeRework ) <br />
@@ -44,8 +46,8 @@ represent real money and introducing bugs and security vulnerabilities can have
44
46
far more dire consequences than in typical projects where having a small bug is
45
47
minimal by comparison. In the world of cryptocurrencies, even the smallest bug
46
48
in the wrong area can cost people a significant amount of money. For this
47
- reason, the Lightning Network Daemon (lnd) has a formalized and rigorous
48
- development process (heavily insipred by
49
+ reason, the Lightning Network Daemon (` lnd ` ) has a formalized and rigorous
50
+ development process (heavily inspired by
49
51
[ btcsuite] ( https://github.com/btcsuite ) ) which is outlined on this page.
50
52
51
53
We highly encourage code contributions, however it is imperative that you adhere
@@ -84,7 +86,7 @@ security and performance implications.
84
86
85
87
### 3. Required Reading
86
88
87
- - [ Effective Go] ( http://golang.org/doc/effective_go.html ) - The entire lnd
89
+ - [ Effective Go] ( http://golang.org/doc/effective_go.html ) - The entire ` lnd `
88
90
project follows the guidelines in this document. For your code to be accepted,
89
91
it must follow the guidelines therein.
90
92
- [ Original Satoshi Whitepaper] ( https://bitcoin.org/bitcoin.pdf ) - This is the white paper that started it all. Having a solid
@@ -100,10 +102,10 @@ Note that the core design of the Lightning Network has shifted over time as
100
102
concrete implementation and design has expanded our knowledge beyond the
101
103
original white paper. Therefore, specific information outlined in the resources
102
104
above may be a bit out of date. Many implementers are currently working on an
103
- initial [ Version 1 Specification ] ( https://medium .com/@ lightningnetwork/lightning-network-meeting-on-interoperability-and-specifications-ea49e47696a4 ) .
105
+ initial [ Lightning Network Specifications ] ( https://github .com/lightningnetwork/lightning-rfc ) .
104
106
Once the specification is finalized, it will be the most up-to-date
105
107
comprehensive document explaining the Lightning Network. As a result, it will
106
- be recommened for newcomers to read first in order to get up to speed.
108
+ be recommended for newcomers to read first in order to get up to speed.
107
109
108
110
<a name =" DevelopmentPractices " />
109
111
@@ -138,7 +140,7 @@ This approach has several benefits:
138
140
139
141
#### 4.2. Testing
140
142
141
- One of the major design goals of all of lnd's packages and the daemon itself is
143
+ One of the major design goals of all of ` lnd ` 's packages and the daemon itself is
142
144
to aim for a high degree of test coverage. This is financial software so bugs
143
145
and regressions in the core logic can cost people real money. For this reason
144
146
every effort must be taken to ensure the code is as accurate and bug-free as
@@ -166,10 +168,14 @@ A quick summary of test practices follows:
166
168
be accompanied by unit tests exercising the new or changed behavior.
167
169
- Changes to behavior within the daemon's interaction with the P2P protocol,
168
170
or RPC's will need to be accompanied by integration tests which use the
169
- [ ` networkHarness ` framework] ( https://github.com/lightningnetwork/lnd/blob/master/networktest .go )
171
+ [ ` networkHarness ` framework] ( https://github.com/lightningnetwork/lnd/blob/master/lntest/harness .go )
170
172
contained within ` lnd ` . For example integration tests, see
171
173
[ ` lnd_test.go ` ] ( https://github.com/lightningnetwork/lnd/blob/master/lnd_test.go#L181 ) .
172
174
175
+ Throughout the process of contributing to ` lnd ` , you'll likely also be
176
+ extensively using the commands within our ` Makefile ` . As a result, we recommend
177
+ [ perusing the make file documentation] ( https://github.com/lightningnetwork/lnd/blob/master/docs/MAKEFILE.md ) .
178
+
173
179
<a name =" CodeDocumentation " />
174
180
175
181
#### 4.3. Code Documentation and Commenting
@@ -277,7 +283,7 @@ Further paragraphs come after blank lines.
277
283
Here are some of the reasons why wrapping your commit messages to 72 columns is
278
284
a good thing.
279
285
280
- - git log doesn’ t do any special wrapping of the commit messages. With
286
+ - git log doesn' t do any special wrapping of the commit messages. With
281
287
the default pager of less -S, this means your paragraphs flow far off the edge
282
288
of the screen, making them difficult to read. On an 80 column terminal, if we
283
289
subtract 4 columns for the indent on the left and 4 more for symmetry on the
@@ -292,19 +298,39 @@ all short-[commit messages are to be prefixed according to the convention
292
298
outlined in the Go project](https://golang.org/doc/contribute.html#change). All
293
299
commits should begin with the subsystem or package primarily affected by the
294
300
change. In the case of a widespread change, the packages are to be delimited by
295
- either a '+' or a ','. This prefix seems minor but can be extremly helpful in
301
+ either a '+' or a ','. This prefix seems minor but can be extremely helpful in
296
302
determining the scope of a commit at a glance, or when bug hunting to find a
297
303
commit which introduced a bug or regression.
298
304
305
+ <a name="IdealGitCommitStructure" />
306
+
307
+ #### 4.5. Ideal Git Commit Structure
308
+
309
+ Within the project we prefer small, contained commits for a pull request over a
310
+ single giant commit that touches several files/packages. Ideal commits build on
311
+ their own, in order to facilitate easy usage of tools like ` git bisect` to ` git
312
+ cherry-pick` . It's preferred that commits contain an isolated change in a
313
+ single package. In this case, the commit header message should begin with the
314
+ prefix of the modified package. For example, if a commit was made to modify the
315
+ ` lnwallet` package, it should start with ` lnwallet: ` .
316
+
317
+ In the case of changes that only build in tandem with changes made in other
318
+ packages, it is permitted for a single commit to be made which contains several
319
+ prefixes such as: ` lnwallet+htlcswitch` . This prefix structure along with the
320
+ requirement for atomic contained commits (when possible) make things like
321
+ scanning the set of commits and debugging easier. In the case of a change that
322
+ touches several packages, and can only compile with the change across several
323
+ packages, a ` multi: ` prefix should be used.
324
+
299
325
<a name="CodeSpacing" />
300
326
301
- #### 4.5 . Code Spacing
327
+ #### 4.6 . Code Spacing
302
328
303
- Blocks of code within lnd should be segmented into logical stanzas of
329
+ Blocks of code within ` lnd` should be segmented into logical stanzas of
304
330
operation. Such spacing makes the code easier to follow at a skim, and reduces
305
331
unnecessary line noise. Coupled with the commenting scheme specified above,
306
332
proper spacing allows readers to quickly scan code, extracting semantics quickly.
307
- Functions should _not_ just be layed out as a bare contiguous block of code.
333
+ Functions should _not_ just be laid out as a bare contiguous block of code.
308
334
309
335
**WRONG**
310
336
` ` ` go
@@ -348,15 +374,23 @@ Functions should _not_ just be layed out as a bare contiguous block of code.
348
374
349
375
<a name="Protobuf" />
350
376
351
- #### 4.5.6 . Protobuf Compilation
377
+ #### 4.7 . Protobuf Compilation
352
378
353
379
The ` lnd` project uses ` protobuf` , and its extension [` gRPC` ](www.grpc.io) in
354
380
several areas and as the primary RPC interface. In order to ensure uniformity
355
381
of all protos checked, in we require that all contributors pin against the
356
382
_exact same_ version of ` protoc` . As of the writing of this article, the ` lnd`
357
- project uses [v3.2 .0](https://github.com/google/protobuf/releases/tag/v3.2 .0)
383
+ project uses [v3.4 .0](https://github.com/google/protobuf/releases/tag/v3.4 .0)
358
384
of ` protoc` .
359
385
386
+ The following commit hashes of related projects are also required in order to
387
+ generate identical compiled protos and related files:
388
+ * grpc-ecosystem/grpc-gateway: ` f2862b476edcef83412c7af8687c9cd8e4097c0f`
389
+ * golang/protobuf: ` ab9f9a6dab164b7d1246e0e688b0ab7b94d8553e`
390
+
391
+ For detailed instructions on how to compile modifications to ` lnd` 's ` protobuf`
392
+ definitions, check out the [lnrpc README](https://github.com/lightningnetwork/lnd/blob/master/lnrpc/README.md).
393
+
360
394
Additionally, in order to maintain a uniform display of the RPC responses
361
395
rendered by ` lncli` , all added or modified ` protof` definitions, _must_ attach
362
396
the proper ` json_name` option for all fields. An example of such an option can
@@ -373,12 +407,40 @@ Notice how the `json_name` field option corresponds with the name of the field
373
407
itself, and uses a ` snake_case` style of name formatting. All added or modified
374
408
` proto` fields should adhere to the format above.
375
409
410
+ <a name="ExtraGoFmtStyle" />
411
+
412
+ #### 4.8. Additional Style Constraints On Top of ` gofmt`
413
+
414
+ Before a PR is submitted, the proposer should ensure that the file passes the
415
+ set of linting scripts run by ` make lint` . These include ` gofmt` . In addition
416
+ to ` gofmt` we've opted to enforce the following style guidelines.
417
+
418
+ * ALL columns (on a best effort basis) should be wrapped to 80 line columns.
419
+ Editors should be set to treat a tab as 4 spaces.
420
+ * When wrapping a line that contains a function call as the unwrapped line
421
+ exceeds the column limit, the close paren should be placed on its own
422
+ line. Additionally, all arguments should begin in a new line after the
423
+ open paren.
424
+
425
+ **WRONG**
426
+ ` ` ` go
427
+ value , err := bar (a
428
+ a, b, c)
429
+ ` ` `
430
+
431
+ **RIGHT**
432
+ ` ` ` go
433
+ value , err := bar (
434
+ a, a, b, c,
435
+ )
436
+ ` ` `
437
+
376
438
<a name="CodeApproval" />
377
439
378
440
### 5. Code Approval Process
379
441
380
442
This section describes the code approval process that is used for code
381
- contributions. This is how to get your changes into lnd.
443
+ contributions. This is how to get your changes into ` lnd` .
382
444
383
445
<a name="CodeReview" />
384
446
@@ -427,17 +489,27 @@ master. In certain cases the code reviewer(s) or interested committers may help
427
489
you rework the code, but generally you will simply be given feedback for you to
428
490
make the necessary changes.
429
491
492
+ During the process of responding to review comments, we prefer that changes be
493
+ made with [fixup commits](https://robots.thoughtbot.com/autosquashing-git-commits).
494
+ The reason for this is two fold: it makes it easier for the reviewer to see
495
+ what changes have been made between versions (since Github doesn't easily show
496
+ prior versions like Critique) and it makes it easier on the PR author as they
497
+ can set it to auto squash the fix up commits on rebase.
498
+
430
499
This process will continue until the code is finally accepted.
431
500
432
501
<a name="CodeAcceptance" />
433
502
434
503
#### 5.3. Acceptance
435
504
436
- Once your code is accepted, it will be integrated with the master branch.
437
- Typically it will be rebased and fast-forward merged to master as we prefer to
438
- keep a clean commit history over a tangled weave of merge commits. However,
439
- regardless of the specific merge method used, the code will be integrated with
440
- the master branch and the pull request will be closed.
505
+ Once your code is accepted, it will be integrated with the master branch. After
506
+ 2+ (sometimes 1) LGTM's (approvals) are given on a PR, it's eligible to land in
507
+ master. At this final phase, it may be necessary to rebase the PR in order to
508
+ resolve any conflicts and also squash fix up commits. Ideally, the set of
509
+ [commits by new contributors are PGP signed](https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work),
510
+ although this isn't a strong requirement (but we prefer it!). In order to keep
511
+ these signatures intact, we prefer using merge commits. PR proposers can use
512
+ ` git rebase --signoff` to sign and rebase at the same time as a final step.
441
513
442
514
Rejoice as you will now be listed as a [contributor](https://github.com/lightningnetwork/lnd/graphs/contributors)!
443
515
@@ -449,7 +521,7 @@ Rejoice as you will now be listed as a [contributor](https://github.com/lightnin
449
521
450
522
#### 6.1. Contribution Checklist
451
523
452
- - [ ] All changes are Go version 1.5 compliant
524
+ - [ ] All changes are Go version 1.11 compliant
453
525
- [ ] The code being submitted is commented according to the
454
526
[Code Documentation and Commenting](#CodeDocumentation) section
455
527
- [ ] For new code: Code is accompanied by tests which exercise both
@@ -459,10 +531,13 @@ Rejoice as you will now be listed as a [contributor](https://github.com/lightnin
459
531
- [ ] Any new logging statements use an appropriate subsystem and
460
532
logging level
461
533
- [ ] Code has been formatted with ` go fmt`
462
- - [ ] Running ` go test` does not fail any tests
534
+ - [ ] For code and documentation: lines are wrapped at 80 characters
535
+ (the tab character should be counted as 8 characters, not 4, as some IDEs do
536
+ per default)
537
+ - [ ] Running ` make unit` and ` make itest` do not fail any tests
463
538
- [ ] Running ` go vet` does not report any issues
464
- - [ ] Running [golint](https://github.com/golang/ lint) does not
465
- report any **new** issues that did not already exist
539
+ - [ ] Running ` make lint` does not report any **new** issues that
540
+ did not already exist
466
541
467
542
<a name="Licensing" />
468
543
0 commit comments