Check typos in CI #1654

pull storopoli wants to merge 6 commits into bitcoin:master from storopoli:master changing 8 files +71 −6
  1. storopoli commented at 7:29 pm on July 25, 2024: contributor

    typos is a powerful source code spell checker.

    • Adds a CI job that runs on every PR and push to master (but can also be run manually with workflow_dispatch) that checks for typos.

    • Adds a config file .typos.toml that deals with false positives and only checks for top-level/one-level .mediawiki and .md files. This config can be extended quite easily with actual terms or regexes to whitelist (false-positives)

    • Fixes some typos in several BIPs that were flagged locally by typos.

  2. in .github/workflows/typos.yml:19 in 9652bacaef outdated
    14+      uses: actions/checkout@v4
    15+
    16+    - name: Check spelling
    17+      uses: crate-ci/typos@master
    18+      with:
    19+        files: ./*.mediawiki
    


    jonatack commented at 7:37 pm on July 25, 2024:
    Markdown files are also acceptable and present; can this cover those too?

    storopoli commented at 12:00 pm on July 26, 2024:
    Done in ff3f94de63a8385e18aae0ab6688c4686dde71d1
  3. jonatack commented at 7:38 pm on July 25, 2024: member
    Concept ACK
  4. storopoli force-pushed on Jul 26, 2024
  5. storopoli requested review from jonatack on Jul 26, 2024
  6. in .github/workflows/typos.yml:5 in dbc1a9922f outdated
    0@@ -0,0 +1,19 @@
    1+name: Check Typos
    2+on:
    3+  push:
    4+    branches:
    5+      - master
    


    jonatack commented at 2:18 pm on July 26, 2024:
    Can it run on pull requests? E.g. in github-actions-check.yml: on: [push, pull_request]

    storopoli commented at 2:35 pm on July 26, 2024:
    That’s exactly what this does one line below. Your suggestion will make it run twice on a PR. Once for the PR and another since it is a commit (to a branch different from master)
  7. jonatack commented at 2:23 pm on July 26, 2024: member

    (but can also be run manually with workflow_dispatch)

    Can you provide a cross-platform command to run this check manually?

  8. storopoli commented at 2:38 pm on July 26, 2024: contributor

    (but can also be run manually with workflow_dispatch)

    Can you provide the cross-platform command to run this check manually? (I tried with macOS)

    Install typos and then run from the root dir:

    0typos ./*.mediawiki ./*.md ./**/*.mediawiki ./**/*.md
    

    EDIT: add a typo to any md or mediawiki file and see it being flagged

  9. jonatack commented at 3:17 pm on July 26, 2024: member

    Thanks! Tested.

    Install typos and then run from the root dir:

    0typos ./*.mediawiki ./*.md ./**/*.mediawiki ./**/*.md
    
    • Would you please update the PR description with that documentation? (Separate from this PR, it may be a good idea to add a CONTRIBUTING file, or a section to the readme, that documents how to run the CI checks manually.)

    • Would it make sense to add this task into github-action-checks.yml, and/or make the CI output more like the other tasks:

     0@@ -1,4 +1,4 @@
     1-name: Check Typos
     2+name: GitHub Actions Check
     3 on:
     4   push:
     5     branches:
     6@@ -8,6 +8,7 @@ on:
     7 
     8 jobs:
     9   typos:
    10+    name: "Spelling Checks"
    11     runs-on: ubuntu-latest
    12     steps:
    13     - name: Checkout Actions Repository
    
  10. in bip-0075.mediawiki:222 in dbc1a9922f outdated
    218@@ -219,7 +219,7 @@ message EncryptedProtocolMessage {
    219 ==Payment Protocol Process with InvoiceRequests==
    220 The full process overview for using '''InvoiceRequests''' in the Payment Protocol is defined below. 
    221 <br/><br/>
    222-All Payment Protocol messages MUST be encapsulated in either a [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProcotolMessage|EncryptedProtocolMessage]]. Once the process begins using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] messages, all subsequent communications MUST use [[#EncryptedProtocolMessage|EncryptedProtocolMessages]]. 
    223+All Payment Protocol messages MUST be encapsulated in either a [[#ProtocolMessage|ProtocolMessage]] or [[#EncryptedProtocolMessage|EncryptedProtocolMessage]]. Once the process begins using [[#EncryptedProtocolMessage|EncryptedProtocolMessage]] messages, all subsequent communications MUST use [[#EncryptedProtocolMessage|EncryptedProtocolMessages]].
    


    jonatack commented at 6:32 pm on July 26, 2024:
    Needs rebase, as the EOL extra space here was removed by merged #1653.

    storopoli commented at 2:02 am on July 28, 2024:
    Rebased
  11. storopoli closed this on Jul 28, 2024

  12. storopoli force-pushed on Jul 28, 2024
  13. storopoli reopened this on Jul 28, 2024

  14. storopoli force-pushed on Jul 28, 2024
  15. storopoli force-pushed on Jul 28, 2024
  16. storopoli commented at 2:03 am on July 28, 2024: contributor
    • Would you please update the PR description with that documentation? (Separate from this PR, it may be a good idea to add a CONTRIBUTING file, or a section to the readme, that documents how to run the CI checks manually.)

    Done, added a CONTRIBUTING.md in ce4351d6bf5cca5e19efe577fdcc74b953a70e21.

    • Would it make sense to add this task into github-action-checks.yml, and/or make the CI output more like the other tasks:

    Good idea! I’ve removed the new typos.yml and added the job in the already existing github-action-checks.yml in ce4351d6bf5cca5e19efe577fdcc74b953a70e21.

  17. storopoli requested review from jonatack on Jul 28, 2024
  18. in bip-0152.mediawiki:212 in c46d6b8750 outdated
    208@@ -209,7 +209,7 @@ There are several design goals for the Short ID calculation:
    209 * '''Space''' cmpctblock messages are never optional in this protocol, and contain a short ID for each non-prefilled transaction in the block. Thus, the size of short IDs is directly proportional to the maximum bandwidth savings possible.
    210 * '''Collision resistance''' It should be hard for network participants to create transactions that cause collisions. If an attacker were able to cause such collisions, filling mempools (and, thus, blocks) with them would cause poor network propagation of new (or non-attacker, in the case of a miner) blocks.
    211 
    212-SipHash is a secure, fast, and simple 64-bit MAC designed for network traffic authentication and collision-resistant hash tables. We truncate the output from SipHash-2-4 to 48 bits (see next section) in order to minimize space. The resulting 48-bit hash is certainly not large enough to avoid intentionally created individual collisons, but by using the block hash as a key to SipHash, an attacker cannot predict what keys will be used once their transactions are actually included in a relayed block. We mix in a per-connection 64-bit nonce to obtain independent short IDs on every connection, so that even block creators cannot control where collisions occur, and random collisions only ever affect a small number of connections at any given time. The mixing is done using SHA256(block_header || nonce), which is slow compared to SipHash, but only done once per block. It also adds the ability for nodes to choose the nonce in a better than random way to minimize collisions, though that is not necessary for correct behaviour. Conversely, nodes can also abuse this ability to increase their ability to introduce collisions in the blocks they relay themselves. However, they can already cause more problems by simply refusing to relay blocks. That is inevitable, and this design only seeks to prevent network-wide misbehavior.
    213+SipHash is a secure, fast, and simple 64-bit MAC designed for network traffic authentication and collision-resistant hash tables. We truncate the output from SipHash-2-4 to 48 bits (see next section) in order to minimize space. The resulting 48-bit hash is certainly not large enough to avoid intentionally created individual collisions, but by using the block hash as a key to SipHash, an attacker cannot predict what keys will be used once their transactions are actually included in a relayed block. We mix in a per-connection 64-bit nonce to obtain independent short IDs on every connection, so that even block creators cannot control where collisions occur, and random collisions only ever affect a small number of connections at any given time. The mixing is done using SHA256(block_header || nonce), which is slow compared to SipHash, but only done once per block. It also adds the ability for nodes to choose the nonce in a better than random way to minimize collisions, though that is not necessary for correct behaviour. Conversely, nodes can also abuse this ability to increase their ability to introduce collisions in the blocks they relay themselves. However, they can already cause more problems by simply refusing to relay blocks. That is inevitable, and this design only seeks to prevent network-wide misbehavior.
    


    murchandamus commented at 6:16 pm on July 29, 2024:
    The typo was “collisons” ⇒ “collisions” in the second sentence.

    storopoli commented at 7:00 pm on July 29, 2024:
    Yeah github wasn’t helpful with the diff.
  19. murchandamus commented at 6:18 pm on July 29, 2024: contributor
    Looks good to me, thank you for proposing this and putting in the work!
  20. murchandamus commented at 8:37 pm on July 31, 2024: contributor
    @jonatack: could you take another look whether your change requests have been satisfactorily addressed? I’m not particularly familiar with CI stuff, so please feel free to merge if you feel confident that it’s ready.
  21. jonatack commented at 5:06 pm on August 7, 2024: member

    WDYT about simplifying running the linter with something like the following:

     0diff --git a/.github/workflows/github-action-checks.yml b/.github/workflows/github-action-checks.yml
     1index 3f1fce9..17f19c1 100644
     2--- a/.github/workflows/github-action-checks.yml
     3+++ b/.github/workflows/github-action-checks.yml
     4@@ -29,5 +29,3 @@ jobs:
     5     - name: Check spelling
     6       uses: crate-ci/typos@master
     7-      with:
     8-        files: ./*.mediawiki ./*.md ./**/*.mediawiki ./**/*.md
     9diff --git a/.typos.toml b/.typos.toml
    10index e645929..e81f41c 100644
    11--- a/.typos.toml
    12+++ b/.typos.toml
    13@@ -27,3 +27,5 @@ Atack = "Atack"
    14 Meni = "Meni"
    15 
    16+[files]
    17+extend-exclude = ["/*/*.csv", "/*.d*", "/*/*.d*", "/*/*.go", "/*/*.json", "/*/*/*.json", "/*/*.mod", "/*/*.proto", "scripts", "/*/*.s*", "/*/*.t*"]
    18diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
    19index 506a295..df6d947 100644
    20--- a/CONTRIBUTING.md
    21+++ b/CONTRIBUTING.md
    22@@ -8,5 +8,5 @@ install [`typos`](https://github.com/crate-ci/typos)
    23 and then run in the root directory:
    24 
    25-typos ./*.mediawiki ./*.md ./**/*.mediawiki ./**/*.md
    26+typos
    

    This seems to work better for me locally and it also allows debugging the linter with its built-in options like typos --files.

    Edit: about the commit order, it seems best to fix the typos before adding the linter, or in the same commit, as otherwise the commits after adding the linter are non-hygienic.

  22. bip-46: fix typo b6bf97ba9e
  23. bip-75: fix typo c25032a3ff
  24. bip-119: fix typo da1e3ad545
  25. bip-152: fix typo 498668026e
  26. bip-352: fix typo b87b21e7c1
  27. storopoli force-pushed on Aug 7, 2024
  28. storopoli commented at 10:08 pm on August 7, 2024: contributor
    Great suggestions! Thanks! I incorporated them all. I also took the liberty of adding .py files since we are not typo checking the scripts for now.
  29. storopoli requested review from jonatack on Aug 7, 2024
  30. in .typos.toml:43 in 24d9b19a68 outdated
    38+    "/*/*/*.json",
    39+    "/*/*.mod",
    40+    "/*/*.proto",
    41+    "scripts",
    42+    "/*/*.s*",
    43+    "/*/*.t*"
    


    jonatack commented at 3:10 pm on August 8, 2024:
    0    "/*/*.t*",
    

    storopoli commented at 5:33 pm on August 12, 2024:
    Done in 52fdb00b6d5844f48cb30b5c39b6fe23708281e4
  31. in .typos.toml:27 in 24d9b19a68 outdated
    23+ser = "ser"
    24+anc = "anc"
    25+# Names
    26+Atack = "Atack"
    27+Ono = "Ono"
    28+Meni = "Meni"
    


    jonatack commented at 3:13 pm on August 8, 2024:

    sort

     0 [default.extend-words]
     1 # NOTE: use here for false-positives
     2+anc = "anc"
     3 PSBT = "PSBT"
     4 ser = "ser"
     5-anc = "anc"
     6 # Names
     7 Atack = "Atack"
     8-Ono = "Ono"
     9 Meni = "Meni"
    10+Ono = "Ono"
    11 
    12 [files]
    13 extend-exclude = [
    14     "/*/*.csv",
    15     "/*.d*",
    16     "/*/*.d*",
    17-    "/*/*.py",
    18     "/*/*.go",
    19     "/*/*.json",
    20     "/*/*/*.json",
    21     "/*/*.mod",
    22     "/*/*.proto",
    23+    "/*/*.py",
    24     "scripts",
    25     "/*/*.s*",
    26     "/*/*.t*"
    

    storopoli commented at 5:32 pm on August 12, 2024:
    Done in 52fdb00b6d5844f48cb30b5c39b6fe23708281e4
  32. in .github/workflows/github-action-checks.yml:31 in 24d9b19a68 outdated
    26+    steps:
    27+    - name: Checkout Actions Repository
    28+      uses: actions/checkout@v4
    29+
    30+    - name: Check spelling
    31+      uses: crate-ci/typos@master
    


    jonatack commented at 3:15 pm on August 8, 2024:
    could use same indentation in this added section as the other steps: entries in this file

    storopoli commented at 5:32 pm on August 12, 2024:
    Done in 52fdb00b6d5844f48cb30b5c39b6fe23708281e4 Nice catch, thanks!
  33. jonatack commented at 3:16 pm on August 8, 2024: member

    @storopoli looks good to me (thanks!) A few nits follow. Let me know if you’d like to update for them or merge this pull as-is.

    Edit: also suggest doing the spelling fixups in a single commit.

  34. ci: add typo checking
    typos is a powerful source code spell checker.
    
    Adds a CI job that runs on every PR and
    push to master (but can also be run manually with
    workflow_dispatch) that checks for typos.
    
    Adds a config file .typos.toml that deals with
    false positives and only checks for top-level/one-level
    .mediawiki and .md files.
    52fdb00b6d
  35. storopoli force-pushed on Aug 12, 2024
  36. storopoli commented at 5:33 pm on August 12, 2024: contributor
    Addressed all the nits, sorry for the delay… Thanks!
  37. storopoli requested review from jonatack on Aug 12, 2024
  38. jonatack approved
  39. jonatack commented at 1:09 am on August 13, 2024: member

    ACK 52fdb00b6d5844f48cb30b5c39b6fe23708281e4 (thanks!)

    We could fill out the contributing guide a bit more.

  40. jonatack merged this on Aug 13, 2024
  41. jonatack closed this on Aug 13, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-09 06:10 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me