Remove return and corruptionPossible arguments from DoS, rename to Reject #12976

pull Empact wants to merge 5 commits into bitcoin:master from Empact:drop-dos-return-scripted changing 3 files +119 −111
  1. Empact commented at 11:55 AM on April 13, 2018: member

    This is a reformulation of #12463 which aims to be more boring and easier to review. A significant part of the change is now a scripted-diff and the other bits work up to that.

    This is best reviewed on a per-commit basis.

    The end result is removing Invalid, and removing 2 args from DoS. Renaming DoS to Reject is a protective measure against undetected merge conflicts, given the call flexibility of DoS.

  2. Explicitly call SetCorruptionPossible when corruption is possible
    This allows us to remove a rarely-used DoS argument while
    making the calls more explict and easily identifiable.
    d8f914cc01
  3. Empact force-pushed on Apr 13, 2018
  4. scripted-diff: Replace all calls to CValidationState::Invalid with ::DoS
    This enables simplification of DoS to occur without separately handling
    different call signatures.
    
    -BEGIN VERIFY SCRIPT-
    find ./src -type f \( -name *.cpp -o -name *.h \) -exec sed -i -E 's/\b\.Invalid\(([^)])/\.DoS\(0, \1/' {} \;
    -END VERIFY SCRIPT-
    e94e43d3e6
  5. Don't pass error to DoS
    Functionally, this was just passing through false each time.
    Better to separate the calls which allows for simplifying DoS.
    7ba193e4cb
  6. Empact force-pushed on Apr 13, 2018
  7. Tidy up DoS to return false always, and not have unnecessary default args
    And removed Invalid, unused since 2 commits back
    
    This is setting the stage for the next change...
    3c16e9835b
  8. Empact force-pushed on Apr 13, 2018
  9. scripted-diff: Rename CValidationState::DoS to ::Reject and drop return argument
    Renaming protects against silent merge conflicts, the argument can be dropped because it is always false,
    and was circumvented in the previous commit.
    
    -BEGIN VERIFY SCRIPT-
    find ./src -type f \( -name *.cpp -o -name *.h \) -exec sed -i -E 's/\bDoS\(([[:digit:]]+), false,/Reject\(\1,/' {} \;
    find ./src -type f \( -name *.cpp -o -name *.h \) -exec sed -i -E 's/\bInvalid\(/Reject\(/' {} \;
    sed -i 's/bool DoS(int level, bool ret,/bool Reject(int level,/' src/consensus/validation.h
    -END VERIFY SCRIPT-
    9a60ac858e
  10. Empact force-pushed on Apr 13, 2018
  11. Empact commented at 1:11 PM on April 13, 2018: member

    Test failure is unrelated.

  12. practicalswift commented at 1:58 PM on April 13, 2018: contributor

    Concept ACK

  13. skeees commented at 6:02 PM on April 13, 2018: contributor

    Strong concept ack - dramatically improves readiblity - if you are already going through the trouble of such an expansive change does it make sense to distinguish (via method name) for a reject with ban points and a reject with 0 score (maybe state.Reject(code,text) state.Punish(points,code,text)? Should further improve readibility / grepability

  14. Empact commented at 9:21 PM on April 15, 2018: member

    @skeees Your comment is making me think I should retain Invalid and DoS, and instead do the removals and adjustments on them. @sipa expressed concern about the optional arguments resulting in missed merge conflicts. I think I'll start by opening a PR to remove those optional arguments, as they aren't relied upon as-is. #12463 (comment)

  15. Empact closed this on Apr 15, 2018

  16. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 09:15 UTC

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