diff --git a/.arclint b/.arclint index dd0a01ade..d7a858295 100644 --- a/.arclint +++ b/.arclint @@ -1,300 +1,292 @@ { "linters": { "generated": { "type": "generated" }, "clang-format": { "type": "clang-format", "version": ">=10.0", "bin": ["clang-format-10", "clang-format"], "include": "(^src/.*\\.(h|c|cpp|mm)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)" ] }, "autopep8": { "type": "autopep8", "version": ">=1.3.4", "include": "(\\.py$)", "exclude": [ "(^contrib/gitian-builder/)", "(^contrib/apple-sdk-tools/)" ], "flags": [ "--aggressive", "--ignore=W503,W504" ] }, "flake8": { "type": "flake8", "version": ">=3.0", "include": "(\\.py$)", "exclude": [ "(^contrib/gitian-builder/)", "(^contrib/apple-sdk-tools/)" ], "flags": [ "--ignore=E303,E305,E501,E704,W503,W504" ] }, "lint-format-strings": { "type": "lint-format-strings", "include": "(^src/.*\\.(h|c|cpp)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)", "(^src/test/fuzz/strprintf.cpp$)" ] }, "check-doc": { "type": "check-doc", "include": "(^src/.*\\.(h|c|cpp)$)" }, "lint-tests": { "type": "lint-tests", "include": "(^src/(seeder/|rpc/|wallet/)?test/.*\\.(cpp)$)" }, "lint-python-format": { "type": "lint-python-format", "include": "(\\.py$)", "exclude": [ "(^test/lint/lint-python-format\\.py$)", "(^contrib/gitian-builder/)", "(^contrib/apple-sdk-tools/)" ] }, "phpcs": { "type": "phpcs", "include": "(\\.php$)", "exclude": [ "(^arcanist/__phutil_library_.+\\.php$)" ], "phpcs.standard": "arcanist/phpcs.xml" }, "lint-locale-dependence": { "type": "lint-locale-dependence", "include": "(^src/.*\\.(h|cpp)$)", "exclude": [ "(^src/(crypto/ctaes/|leveldb/|secp256k1/|tinyformat.h|univalue/))", "(^src/bench/nanobench.h$)" ] }, "lint-cheader": { "type": "lint-cheader", "include": "(^src/.*\\.(h|cpp)$)", "exclude": [ "(^src/(crypto/ctaes|secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)" ] }, "spelling": { "type": "spelling", "exclude": [ "(^build-aux/m4/)", "(^depends/)", "(^doc/release-notes/)", "(^contrib/gitian-builder/)", "(^src/(qt/locale|secp256k1|univalue|leveldb)/)", "(^test/lint/dictionary/)" ], "spelling.dictionaries": [ "test/lint/dictionary/english.json" ] }, "lint-assert-with-side-effects": { "type": "lint-assert-with-side-effects", "include": "(^src/.*\\.(h|cpp)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)" ] }, "lint-include-quotes": { "type": "lint-include-quotes", "include": "(^src/.*\\.(h|cpp)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)" ] }, "lint-include-guard": { "type": "lint-include-guard", "include": "(^src/.*\\.h$)", "exclude": [ "(^src/(crypto/ctaes|secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)", "(^src/tinyformat.h$)" ] }, "lint-include-source": { "type": "lint-include-source", "include": "(^src/.*\\.(h|c|cpp)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)" ] }, "lint-stdint": { "type": "lint-stdint", "include": "(^src/.*\\.(h|c|cpp)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)", "(^src/compat/assumptions.h$)" ] }, "lint-source-filename": { "type": "lint-source-filename", "include": "(^src/.*\\.(h|c|cpp)$)", "exclude": [ "(^src/(secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)" ] }, "lint-boost-dependencies": { "type": "lint-boost-dependencies", "include": "(^src/.*\\.(h|cpp)$)" }, "lint-python-encoding": { "type": "lint-python-encoding", "include": "(\\.py$)", "exclude": [ "(^contrib/gitian-builder/)", "(^contrib/apple-sdk-tools/)" ] }, "lint-python-shebang": { "type": "lint-python-shebang", "include": "(\\.py$)", "exclude": [ "(__init__\\.py$)", "(^contrib/gitian-builder/)", "(^contrib/apple-sdk-tools/)" ] }, "lint-bash-shebang": { "type": "lint-bash-shebang", "include": "(\\.sh$)", "exclude": [ "(^contrib/gitian-builder/)" ] }, "shellcheck": { "type": "shellcheck", "version": ">=0.7.0", "flags": [ "--external-sources", "--source-path=SCRIPTDIR" ], "include": "(\\.sh$)", "exclude": [ "(^contrib/gitian-builder/)", "(^src/(secp256k1|univalue)/)" ] }, "lint-shell-locale": { "type": "lint-shell-locale", "include": "(\\.sh$)", "exclude": [ "(^contrib/gitian-builder/)", "(^src/(secp256k1|univalue)/)", "(^cmake/utils/log-and-print-on-failure.sh)" ] }, "lint-cpp-void-parameters": { "type": "lint-cpp-void-parameters", "include": "(^src/.*\\.(h|cpp)$)", "exclude": [ "(^src/(crypto/ctaes|secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)", "(^src/compat/glibc_compat.cpp$)" ] }, "lint-logs": { "type": "lint-logs", "include": "(^src/.*\\.(h|cpp)$)" }, "lint-qt": { "type": "lint-qt", "include": "(^src/qt/.*\\.(h|cpp)$)", "exclude": [ "(^src/qt/(locale|forms|res)/)" ] }, "lint-doxygen": { "type": "lint-doxygen", "include": "(^src/.*\\.(h|c|cpp)$)", "exclude": [ "(^src/(crypto/ctaes|secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)" ] }, "lint-whitespace": { "type": "lint-whitespace", "include": "(\\.(ac|am|cmake|conf|in|include|json|m4|md|openrc|php|pl|sh|txt|yml)$)", "exclude": [ "(^contrib/gitian-builder/)", "(^src/(secp256k1|univalue|leveldb)/)", "(^src/bench/nanobench.h$)" ] }, - "lint-cppcheck": { - "type": "lint-cppcheck", - "include": "(^src/.*\\.(h|c|cpp)$)", - "exclude": [ - "(^src/(crypto/ctaes|secp256k1|univalue|leveldb)/)", - "(^src/bench/nanobench.h$)" - ] - }, "yamllint": { "type": "yamllint", "include": "(\\.(yml|yaml)$)", "exclude": "(^src/(secp256k1|univalue|leveldb)/)" }, "lint-check-nonfatal": { "type": "lint-check-nonfatal", "include": [ "(^src/rpc/.*\\.(h|c|cpp)$)", "(^src/wallet/rpc*.*\\.(h|c|cpp)$)" ], "exclude": "(^src/rpc/server.cpp)" }, "lint-markdown": { "type": "lint-markdown", "include": [ "(\\.md$)" ], "exclude": "(^contrib/gitian-builder/)" }, "lint-python-mypy": { "type": "lint-python-mypy", "version": ">=0.780", "include": "(\\.py$)", "exclude": "(^contrib/)", "flags": [ "--ignore-missing-imports" ] }, "lint-python-mutable-default": { "type": "lint-python-mutable-default", "include": "(\\.py$)", "exclude": [ "(^contrib/gitian-builder/)", "(^contrib/apple-sdk-tools/)" ] }, "prettier": { "type": "prettier", "version":">=2.4.1", "include": "(^web/.*\\.(css|html|js|json|jsx|md|scss|ts|tsx)$)", "exclude": "(^web/.*/translations/.*\\.json$)" }, "lint-python-isort": { "type": "lint-python-isort", "version": ">=5.6.4", "include": "(\\.py$)", "exclude": "(^contrib/)" } } } diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ff83a8a4f..e82768dc4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,277 +1,277 @@ Contributing to Bitcoin ABC =========================== The Bitcoin ABC project welcomes contributors! This guide is intended to help developers contribute effectively to Bitcoin ABC. Communicating with Developers ----------------------------- To get in contact with ABC developers, we monitor a telegram supergroup. The intent of this group is specifically to facilitate development of Bitcoin-ABC, and to welcome people who wish to participate. [Join the ABC Development telegram group](https://t.me/joinchat/HCYr50mxRWjA2uLqii-psw) Acceptable use of this supergroup includes the following: * Introducing yourself to other ABC developers. * Getting help with your development environment. * Discussing how to complete a patch. It is not for: * Market discussion * Non-constructive criticism Bitcoin ABC Development Philosophy ---------------------------------- Bitcoin ABC aims for fast iteration and continuous integration. This means that there should be quick turnaround for patches to be proposed, reviewed, and committed. Changes should not sit in a queue for long. Here are some tips to help keep the development working as intended. These are guidelines for the normal and expected development process. Developers can use their judgement to deviate from these guidelines when they have a good reason to do so. - Keep each change small and self-contained. - Reach out for a 1-on-1 review so things move quickly. - Land the Diff quickly after it is accepted. - Don't amend changes after the Diff accepted, new Diff for another fix. - Review Diffs from other developers as quickly as possible. - Large changes should be broken into logical chunks that are easy to review, and keep the code in a functional state. - Do not mix moving stuff around with changing stuff. Do changes with renames on their own. - Sometimes you want to replace one subsystem by another implementation, in which case it is not possible to do things incrementally. In such cases, you keep both implementations in the codebase for a while, as described [here](http://sevangelatos.com/john-carmack-on-parallel-implementations/) - There are no "development" branches, all Diffs apply to the master branch, and should always improve it (no regressions). - Don't break the build, it is important to keep master green as much as possible. If a Diff is landed, and breaks the build, fix it quickly. If it cannot be fixed quickly, it should be reverted, and re-applied later when it no longer breaks the build. - As soon as you see a bug, you fix it. Do not continue on. Fixing the bug becomes the top priority, more important than completing other tasks. - Automate as much as possible, and spend time on things only humans can do. Here are some handy links for development practices aligned with Bitcoin ABC: - [Developer Notes](doc/developer-notes.md) - [Statement of Bitcoin ABC Values and Visions](https://archive.md/ulgFI) - [How to Make Your Code Reviewer Fall in Love with You](https://mtlynch.io/code-review-love/) - [Large Diffs Are Hurting Your Ability To Ship](https://medium.com/@kurtisnusbaum/large-diffs-are-hurting-your-ability-to-ship-e0b2b41e8acf) - [Stacked Diffs: Keeping Phabricator Diffs Small](https://medium.com/@kurtisnusbaum/stacked-diffs-keeping-phabricator-diffs-small-d9964f4dcfa6) - [Parallel Implementations](http://sevangelatos.com/john-carmack-on-parallel-implementations/) - [The Pragmatic Programmer: From Journeyman to Master](https://www.amazon.com/Pragmatic-Programmer-Journeyman-Master/dp/020161622X) - [Monorepo: Advantages of monolithic version control](https://danluu.com/monorepo/) - [Monorepo: Why Google Stores Billions of Lines of Code in a Single Repository](https://www.youtube.com/watch?v=W71BTkUbdqE) - [The importance of fixing bugs immediately](https://youtu.be/E2MIpi8pIvY?t=16m0s) - [Slow Deployment Causes Meetings](https://www.facebook.com/notes/kent-beck/slow-deployment-causes-meetings/1055427371156793/) - [Good Work, Great Work, and Right Work](https://forum.dlang.org/post/q7u6g1$94p$1@digitalmars.com) - [Accelerate: The Science of Lean Software and DevOps](https://www.amazon.com/Accelerate-Software-Performing-Technology-Organizations/dp/1942788339) - [Facebook Engineering Process with Kent Beck](https://softwareengineeringdaily.com/2019/08/28/facebook-engineering-process-with-kent-beck/) - [Trunk Based Development](https://trunkbaseddevelopment.com/) - [Step-by-step: Programming incrementally](https://ourmachinery.com/post/step-by-step-programming-incrementally/) - [Semantic Compression](https://caseymuratori.com/blog_0015) Getting set up with the Bitcoin ABC Repository ---------------------------------------------- 1. Create an account at [reviews.bitcoinabc.org](https://reviews.bitcoinabc.org/) 2. Install Git and Arcanist on your machine Git documentation can be found at [git-scm.com](https://git-scm.com/). For Arcanist documentation, you can read [Arcanist Quick Start](https://secure.phabricator.com/book/phabricator/article/arcanist_quick_start/) and the [Arcanist User Guide](https://secure.phabricator.com/book/phabricator/article/arcanist/). To install these packages on Debian or Ubuntu, type: `sudo apt-get install git arcanist` 3. If you do not already have an SSH key set up, follow these steps: Type: `ssh-keygen -t rsa -b 4096 -C "your_email@example.com"` Enter a file in which to save the key (/home/*username*/.ssh/id_rsa): [Press enter] 4. Upload your SSH public key to - Go to: `https://reviews.bitcoinabc.org/settings/user/*username*/page/ssh/` - Under "SSH Key Actions", Select "Upload Public Key" Paste contents from: `/home/*username*/.ssh/id_rsa.pub` 5. Clone the repository and install Arcanist certificate: ``` git clone ssh://vcs@reviews.bitcoinabc.org:2221/source/bitcoin-abc.git cd bitcoin-abc arc install-certificate ``` Note: Arcanist tooling will tend to fail if your remote origin is set to something other than the above. A common mistake is to clone from Github and then forget to update your remotes. Follow instructions provided by `arc install-certificate` to provide your API token. Contributing to the node software --------------------------------- During submission of patches, arcanist will automatically run `arc lint` to enforce Bitcoin ABC code formatting standards, and often suggests changes. If code formatting tools do not install automatically on your system, you will have to install the following: On Ubuntu 20.04: ``` -sudo apt-get install clang-format clang-tidy clang-tools cppcheck python3-isort python3-autopep8 flake8 php-codesniffer yamllint +sudo apt-get install clang-format clang-tidy clang-tools python3-isort python3-autopep8 flake8 php-codesniffer yamllint ``` If not available in the distribution, `clang-format-10` and `clang-tidy` can be installed from or . On Debian (>= 10), the clang-10 family of tools is available from the https://apt.llvm.org/ repository: ``` wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 10 ``` For example, for macOS: ``` curl -L https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-apple-darwin.tar.xz | tar -xJv ln -s $PWD/clang+llvm-10.0.0-x86_64-apple-darwin/bin/clang-format /usr/local/bin/clang-format ln -s $PWD/clang+llvm-10.0.0-x86_64-apple-darwin/bin/clang-tidy /usr/local/bin/clang-tidy ``` If you are modifying a python script, you will need to install `mypy` and `isort`. The minimum required version for `mypy` is 0.780, because the previous ones are known to have issues with some python type annotations. On Debian based systems, this can be installed via: ``` sudo apt-get install python3-pip pip3 install isort==5.6.4 mypy==0.780 echo "export PATH=\"`python3 -m site --user-base`/bin:\$PATH\"" >> ~/.bashrc source ~/.bashrc ``` If you are modifying a shell script, you will need to install the `shellcheck` linter. A recent version is required and may not be packaged for your distribution. Standalone binaries are available for download on [the project's github release page](https://github.com/koalaman/shellcheck/releases). **Note**: In order for arcanist to detect the `shellcheck` executable, you need to make it available in your `PATH`; if another version is already installed, make sure the recent one is found first. Arcanist will tell you what version is expected and what is found when running `arc lint` against a shell script. If you are running Debian 10, it is also available in the backports repository: ``` sudo apt-get -t buster-backports install shellcheck ``` Contributing to the web projects -------------------------------- To contribute to web projects, you will need `nodejs` > 15 and `npm` > 6.14.8. Follow these [installation instructions](https://github.com/nvm-sh/nvm#installing-and-updating) to install `nodejs` with node version manager. Then: ``` cd bitcoin-abc [sudo] nvm install 15 [sudo] npm install -g npm@latest [sudo] npm install -g prettier ``` To work on the extension, you will need `browserify` ``` [sudo] npm install -g browserify ``` Working with The Bitcoin ABC Repository --------------------------------------- A typical workflow would be: - Create a topic branch in Git for your changes git checkout -b 'my-topic-branch' - Make your changes, and commit them git commit -a -m 'my-commit' - Create a differential with Arcanist arc diff You should add suggested reviewers and a test plan to the commit message. Note that Arcanist is set up to look only at the most-recent commit message, So all you changes for this Diff should be in one Git commit. - For large changes, break them into several Diffs, as described in this [guide](https://medium.com/@kurtisnusbaum/stacked-diffs-keeping-phabricator-diffs-small-d9964f4dcfa6). You can also include "Depends on Dxxx" in the Arcanist message to indicate dependence on other Diffs. - Log into Phabricator to see review and feedback. - Make changes as suggested by the reviewers. You can simply edit the files with my-topic-branch checked out, and then type `arc diff`. Arcanist will give you the option to add uncommited changes. Or, alternatively, you can commit the changes using `git commit -a --am` to add them to the last commit, or squash multiple commits by typing `git rebase -i master`. If you squash, make sure the commit message has the information needed for arcanist (such as the Diff number, reviewers, etc.). - Update your Diff by typing `arc diff` again. - When reviewers approve your Diff, it should be listed as "ready to Land" in Phabricator. When you want to commit your diff to the repository, check out type my-topic-branch in git, then type `arc land`. You have now successfully committed a change to the Bitcoin ABC repository. - When reviewing a Diff, apply the changeset on your local by using `arc patch D{NNNN}` - You will likely be re-writing git histories multiple times, which causes timestamp changes that require re-building a significant number of files. It's highly recommended to install `ccache` (re-run cmake if you install it later), as this will help cut your re-build times from several minutes to under a minute, in many cases. What to work on --------------- If you are looking for a useful task to contribute to the project, a good place to start is the list of tasks at . You could also try [backporting](doc/backporting.md) some code from Bitcoin Core. Copyright --------- By contributing to this repository, you agree to license your work under the MIT license unless specified otherwise in `contrib/debian/copyright` or at the top of the file itself. Any work contributed where you are not the original author must contain its license header with the original author(s) and source. Disclosure Policy ----------------- See [DISCLOSURE_POLICY](DISCLOSURE_POLICY.md). diff --git a/arcanist/.phutil_module_cache b/arcanist/.phutil_module_cache index ddd6c79d5..4382bee86 100644 --- a/arcanist/.phutil_module_cache +++ b/arcanist/.phutil_module_cache @@ -1 +1 @@ -{"__symbol_cache_version__":11,"ae5b7d3d6b8cf9598ce4abaf0cd56b21":{"have":{"class":{"ExtendedConfigurationDrivenLintEngine":19}},"need":{"function":{"newv":159,"pht":933},"class":{"ArcanistLintEngine":65,"ArcanistConfigurationDrivenLintEngine":171,"PhutilConsole":866},"class\/interface":{"ILintOnce":634}},"xmap":{"ExtendedConfigurationDrivenLintEngine":["ArcanistLintEngine"]}},"9780c82e3cf1cde0c46662563f00444f":{"have":{"class":{"ArcanistBitcoinABCConfiguration":13}},"need":{"function":{"pht":242},"class":{"ArcanistConfiguration":53,"ArcanistLintWorkflow":1652},"class\/interface":{"ArcanistWorkflow":385,"ArcanistNoEffectException":1371}},"xmap":{"ArcanistBitcoinABCConfiguration":["ArcanistConfiguration"]}},"90a8b110dc475955f15bb81d37268cb5":{"have":{"class":{"AutoPEP8FormatLinter":75}},"need":{"function":{"pht":297,"execx":769,"id":1903},"class":{"ArcanistExternalLinter":104,"ArcanistLintMessage":1910,"Filesystem":1754,"ArcanistLinter":2017,"ArcanistLintSeverity":2095}},"xmap":{"AutoPEP8FormatLinter":["ArcanistExternalLinter"]}},"729e2f379c278258d8040e156ba9da29":{"have":{"class":{"ShellLocaleLinter":107}},"need":{"function":{"pht":382},"class":{"ArcanistLinter":133,"ArcanistLintSeverity":734,"Filesystem":1044}},"xmap":{"ShellLocaleLinter":["ArcanistLinter"]}},"fbb3938ab9b412d7505335d9f7ed183d":{"have":{"class":{"ShellCheckLinter":95}},"need":{"function":{"pht":921,"execx":1443,"id":2414},"class":{"ArcanistExternalLinter":120,"ArcanistLintMessage":2421,"ArcanistLintSeverity":646,"ArcanistLinter":2469}},"xmap":{"ShellCheckLinter":["ArcanistExternalLinter"]}},"d792b114a2a4d16e2137dd237483ce42":{"have":{"class":{"PythonMutableDefaultLinter":155}},"need":{"function":{"pht":377},"class":{"ArcanistLinter":190,"ArcanistLintSeverity":740,"Filesystem":1030}},"xmap":{"PythonMutableDefaultLinter":["ArcanistLinter"]}},"cfe5966affc66e3444c34bf55a119446":{"have":{"function":{"startsWith":16},"class":{"MarkdownLinter":171}},"need":{"function":{"pht":361},"class":{"ArcanistLinter":194,"ArcanistLintSeverity":652,"Filesystem":1571}},"xmap":{"MarkdownLinter":["ArcanistLinter"]}},"f151089cf79fdb8257b2272ed4782d88":{"have":{"class":{"IncludeSourceLinter":99}},"need":{"function":{"pht":391},"class":{"ArcanistLinter":127,"ArcanistLintSeverity":699,"Filesystem":938}},"xmap":{"IncludeSourceLinter":["ArcanistLinter"]}},"b4005bc083930dd85220bffb4c5f8bdd":{"have":{"class":{"PythonFileEncodingLinter":111}},"need":{"function":{"pht":321},"class":{"ArcanistLinter":144,"ArcanistLintSeverity":685,"Filesystem":990}},"xmap":{"PythonFileEncodingLinter":["ArcanistLinter"]}},"146347e1ef63e514a6634ada8de5b5c9":{"have":{"class":{"Qt5Linter":70}},"need":{"function":{"pht":258},"class":{"ArcanistLinter":88,"ArcanistLintSeverity":609,"Filesystem":836}},"xmap":{"Qt5Linter":["ArcanistLinter"]}},"ab6085aa9abe6394d7f8ceffe6554c50":{"have":{"class":{"WhitespaceLinter":59}},"need":{"function":{"pht":258},"class":{"ArcanistLinter":84,"ArcanistLintSeverity":545,"Filesystem":948}},"xmap":{"WhitespaceLinter":["ArcanistLinter"]}},"5ea58c19df0397ed8ee0f463d90d6c72":{"have":{"class":{"BoostDependenciesLinter":145}},"need":{"function":{"pht":330,"id":1440},"class":{"GlobalExternalLinter":177,"ArcanistLintMessage":1447,"Filesystem":609,"ArcanistLinter":1524,"ArcanistLintSeverity":1624}},"xmap":{"BoostDependenciesLinter":["GlobalExternalLinter"]}},"2809b09d2021203b43c57da33d1fe8bf":{"have":{"class":{"AssertWithSideEffectsLinter":210}},"need":{"function":{"pht":439},"class":{"ArcanistLinter":246,"ArcanistLintSeverity":926,"Filesystem":1170}},"xmap":{"AssertWithSideEffectsLinter":["ArcanistLinter"]}},"38f0c676bff5192a344464142caaa253":{"have":{"class":{"CHeaderLinter":99}},"need":{"function":{"pht":611},"class":{"ArcanistLinter":121,"ArcanistLintSeverity":1060,"Filesystem":1307}},"xmap":{"CHeaderLinter":["ArcanistLinter"]}},"e6c7c36001803d09d667e83285bd04e7":{"have":{"class":{"YamllintLinter":77}},"need":{"function":{"pht":399,"execx":907,"id":1711},"class":{"ArcanistExternalLinter":100,"ArcanistLintMessage":1718,"ArcanistLintSeverity":184,"ArcanistLinter":1766}},"xmap":{"YamllintLinter":["ArcanistExternalLinter"]}},"6f2f22dd0f259fb2eaa284b4fab3bc29":{"have":{"class":{"PythonFormatLinter":123}},"need":{"function":{"pht":353,"id":1838},"class":{"ArcanistExternalLinter":150,"ArcanistLintMessage":1845,"Filesystem":776,"ArcanistLinter":1970,"ArcanistLintSeverity":2053}},"xmap":{"PythonFormatLinter":["ArcanistExternalLinter"]}},"9285ad9415f8ebe564f7119e5a72c559":{"have":{"class":{"FormatStringLinter":146}},"need":{"function":{"pht":377,"csprintf":1492,"id":1872},"class":{"ArcanistExternalLinter":173,"ArcanistLintMessage":1879,"Filesystem":827,"ArcanistLinter":1956,"ArcanistLintSeverity":2044}},"xmap":{"FormatStringLinter":["ArcanistExternalLinter"]}},"9bb48ec0fe2e9ced8e27d42540d0571c":{"have":{"class":{"CheckDocLinter":106}},"need":{"function":{"pht":321,"id":1845},"class":{"GlobalExternalLinter":129,"ArcanistLintMessage":1852,"Filesystem":729,"ArcanistLinter":1900,"ArcanistLintSeverity":1986}},"xmap":{"CheckDocLinter":["GlobalExternalLinter"]}},"09b7af4806790af70a69ee97158e6112":{"have":{"class":{"CheckNonFatalOverAssertInRpc":268}},"need":{"function":{"pht":582},"class":{"ArcanistLinter":305,"ArcanistLintSeverity":863,"Filesystem":1144}},"xmap":{"CheckNonFatalOverAssertInRpc":["ArcanistLinter"]}},"2cbb6e7228d81557f777ad648704f343":{"have":{"class":{"IncludeQuotesLinter":100}},"need":{"function":{"pht":306},"class":{"ArcanistLinter":128,"ArcanistLintSeverity":663,"Filesystem":964}},"xmap":{"IncludeQuotesLinter":["ArcanistLinter"]}},"04d01863b9bf57f467af4808b397e584":{"have":{"class":{"MyPyLinter":88}},"need":{"function":{"pht":243,"execx":758,"id":1303},"class":{"ArcanistExternalLinter":107,"ArcanistLintMessage":1310,"ArcanistLinter":1358,"ArcanistLintSeverity":1464}},"xmap":{"MyPyLinter":["ArcanistExternalLinter"]}},"2f99c841a569f2029d13ea030dee007c":{"have":{"class":{"TestsLinter":103}},"need":{"function":{"pht":318,"id":2638},"class":{"ArcanistExternalLinter":123,"ArcanistLintMessage":2645,"Filesystem":776,"ArcanistLinter":2693,"ArcanistLintSeverity":2801}},"xmap":{"TestsLinter":["ArcanistExternalLinter"]}},"5b9143afa84a8b098359597987dcddfe":{"have":{"class":{"CppCheckLinter":92}},"need":{"function":{"pht":7401,"execx":7761},"class":{"ArcanistExternalLinter":115,"ArcanistLintMessage":10229,"Filesystem":9351,"ArcanistLintSeverity":10538}},"xmap":{"CppCheckLinter":["ArcanistExternalLinter"]}},"85936cbfc0decd1aae05001717b359da":{"have":{"class":{"LogLinter":116}},"need":{"function":{"pht":297},"class":{"ArcanistLinter":134,"ArcanistLintSeverity":580,"Filesystem":875}},"xmap":{"LogLinter":["ArcanistLinter"]}},"3e6f662aafff47b2f59242e1823e3b14":{"have":{"class":{"LocaleDependenceLinter":1741}},"need":{"function":{"pht":7202},"class":{"ArcanistLinter":1772,"ArcanistLintSeverity":7705,"Filesystem":7951}},"xmap":{"LocaleDependenceLinter":["ArcanistLinter"]}},"2e11dd9ad67e594f863bc46ac59ea37e":{"have":{"class":{"GlobalExternalLinter":199}},"need":{"class":{"ArcanistExternalLinter":228},"interface":{"ILintOnce":262}},"xmap":{"GlobalExternalLinter":["ArcanistExternalLinter","ILintOnce"]}},"1dacb6d661b7ea83e6b1980c3c4f602d":{"have":{"class":{"StdintLinter":90}},"need":{"function":{"pht":567},"class":{"ArcanistLinter":111,"ArcanistLintSeverity":876,"Filesystem":1401}},"xmap":{"StdintLinter":["ArcanistLinter"]}},"3a184a47bce0d3fbf7dad76c6f755df5":{"have":{"class":{"PrettierLinter":76}},"need":{"function":{"pht":311,"execx":758,"id":1196},"class":{"ArcanistExternalLinter":99,"ArcanistLintMessage":1203,"Filesystem":1118,"ArcanistLinter":1276,"ArcanistLintSeverity":1362}},"xmap":{"PrettierLinter":["ArcanistExternalLinter"]}},"4584b1b007576d47eeff9504b80c4a77":{"have":{"class":{"ClangFormatLinter":79}},"need":{"function":{"pht":302,"execx":781,"id":2251},"class":{"ArcanistExternalLinter":105,"ArcanistLintMessage":2258,"Filesystem":2102,"ArcanistLinter":2365,"ArcanistLintSeverity":2443}},"xmap":{"ClangFormatLinter":["ArcanistExternalLinter"]}},"4c4adcac26dddfa5e350b85a40097755":{"have":{"class":{"BashShebangLinter":82}},"need":{"function":{"pht":281},"class":{"ArcanistLinter":108,"ArcanistLintSeverity":597,"Filesystem":837}},"xmap":{"BashShebangLinter":["ArcanistLinter"]}},"39694cf756ce58681ea84a028f3e007f":{"have":{"class":{"IncludeGuardLinter":98}},"need":{"function":{"pht":443},"class":{"ArcanistLinter":125,"ArcanistLintSeverity":796,"Filesystem":1162}},"xmap":{"IncludeGuardLinter":["ArcanistLinter"]}},"df78f1ac61b2f0f7cd5bd3cf434ce6e3":{"have":{"class":{"CppVoidParameterLinter":119}},"need":{"function":{"pht":392},"class":{"ArcanistLinter":150,"ArcanistLintSeverity":707,"Filesystem":1164}},"xmap":{"CppVoidParameterLinter":["ArcanistLinter"]}},"c073131f5baad372e3037328d2e71c0e":{"have":{"class":{"ISortFormatLinter":72}},"need":{"function":{"pht":318,"id":1597},"class":{"ArcanistExternalLinter":98,"ArcanistLintMessage":1604,"Filesystem":1448,"ArcanistLinter":1711,"ArcanistLintSeverity":1790}},"xmap":{"ISortFormatLinter":["ArcanistExternalLinter"]}},"3cd6909c95569e2564deabbd1ec38bbb":{"have":{"class":{"FileNameLinter":103}},"need":{"function":{"pht":382},"class":{"ArcanistLinter":126,"ArcanistLintSeverity":737,"Filesystem":1160}},"xmap":{"FileNameLinter":["ArcanistLinter"]}},"b2403124ec3e8be6cb4d10bf0f6c4134":{"have":{"interface":{"ILintOnce":69}},"need":[],"xmap":[]},"454160ed72e88797129d84ee589de304":{"have":{"class":{"PythonShebangLinter":87}},"need":{"function":{"pht":290},"class":{"ArcanistLinter":115,"ArcanistLintSeverity":614,"Filesystem":854}},"xmap":{"PythonShebangLinter":["ArcanistLinter"]}},"e4678dca551a849892aff414d3c4e24e":{"have":{"class":{"DoxygenLinter":91}},"need":{"function":{"pht":382},"class":{"ArcanistLinter":113,"ArcanistLintSeverity":695,"Filesystem":943}},"xmap":{"DoxygenLinter":["ArcanistLinter"]}},"e6886ead74de6310f1cbc0d589d8f5b0":{"have":{"class":{"ArcanistLandBotWorkflow":91}},"need":{"function":{"phutil_console_format":265,"pht":1577,"execx":2181},"class":{"ArcanistWorkflow":123,"ArcanistUsageException":2251}},"xmap":{"ArcanistLandBotWorkflow":["ArcanistWorkflow"]}}} \ No newline at end of file +{"__symbol_cache_version__":11,"e6886ead74de6310f1cbc0d589d8f5b0":{"have":{"class":{"ArcanistLandBotWorkflow":91}},"need":{"function":{"phutil_console_format":265,"pht":1577,"execx":2181},"class":{"ArcanistWorkflow":123,"ArcanistUsageException":2251}},"xmap":{"ArcanistLandBotWorkflow":["ArcanistWorkflow"]}},"ae5b7d3d6b8cf9598ce4abaf0cd56b21":{"have":{"class":{"ExtendedConfigurationDrivenLintEngine":19}},"need":{"function":{"newv":159,"pht":933},"class":{"ArcanistLintEngine":65,"ArcanistConfigurationDrivenLintEngine":171,"PhutilConsole":866},"class\/interface":{"ILintOnce":634}},"xmap":{"ExtendedConfigurationDrivenLintEngine":["ArcanistLintEngine"]}},"90a8b110dc475955f15bb81d37268cb5":{"have":{"class":{"AutoPEP8FormatLinter":75}},"need":{"function":{"pht":297,"execx":769,"id":1903},"class":{"ArcanistExternalLinter":104,"ArcanistLintMessage":1910,"Filesystem":1754,"ArcanistLinter":2017,"ArcanistLintSeverity":2095}},"xmap":{"AutoPEP8FormatLinter":["ArcanistExternalLinter"]}},"5ea58c19df0397ed8ee0f463d90d6c72":{"have":{"class":{"BoostDependenciesLinter":145}},"need":{"function":{"pht":330,"id":1440},"class":{"GlobalExternalLinter":177,"ArcanistLintMessage":1447,"Filesystem":609,"ArcanistLinter":1524,"ArcanistLintSeverity":1624}},"xmap":{"BoostDependenciesLinter":["GlobalExternalLinter"]}},"ab6085aa9abe6394d7f8ceffe6554c50":{"have":{"class":{"WhitespaceLinter":59}},"need":{"function":{"pht":258},"class":{"ArcanistLinter":84,"ArcanistLintSeverity":545,"Filesystem":948}},"xmap":{"WhitespaceLinter":["ArcanistLinter"]}},"6f2f22dd0f259fb2eaa284b4fab3bc29":{"have":{"class":{"PythonFormatLinter":123}},"need":{"function":{"pht":353,"id":1838},"class":{"ArcanistExternalLinter":150,"ArcanistLintMessage":1845,"Filesystem":776,"ArcanistLinter":1970,"ArcanistLintSeverity":2053}},"xmap":{"PythonFormatLinter":["ArcanistExternalLinter"]}},"e4678dca551a849892aff414d3c4e24e":{"have":{"class":{"DoxygenLinter":91}},"need":{"function":{"pht":382},"class":{"ArcanistLinter":113,"ArcanistLintSeverity":695,"Filesystem":943}},"xmap":{"DoxygenLinter":["ArcanistLinter"]}},"4c4adcac26dddfa5e350b85a40097755":{"have":{"class":{"BashShebangLinter":82}},"need":{"function":{"pht":281},"class":{"ArcanistLinter":108,"ArcanistLintSeverity":597,"Filesystem":837}},"xmap":{"BashShebangLinter":["ArcanistLinter"]}},"f151089cf79fdb8257b2272ed4782d88":{"have":{"class":{"IncludeSourceLinter":99}},"need":{"function":{"pht":391},"class":{"ArcanistLinter":127,"ArcanistLintSeverity":699,"Filesystem":938}},"xmap":{"IncludeSourceLinter":["ArcanistLinter"]}},"b2403124ec3e8be6cb4d10bf0f6c4134":{"have":{"interface":{"ILintOnce":69}},"need":[],"xmap":[]},"9285ad9415f8ebe564f7119e5a72c559":{"have":{"class":{"FormatStringLinter":146}},"need":{"function":{"pht":377,"csprintf":1492,"id":1872},"class":{"ArcanistExternalLinter":173,"ArcanistLintMessage":1879,"Filesystem":827,"ArcanistLinter":1956,"ArcanistLintSeverity":2044}},"xmap":{"FormatStringLinter":["ArcanistExternalLinter"]}},"04d01863b9bf57f467af4808b397e584":{"have":{"class":{"MyPyLinter":88}},"need":{"function":{"pht":243,"execx":758,"id":1303},"class":{"ArcanistExternalLinter":107,"ArcanistLintMessage":1310,"ArcanistLinter":1358,"ArcanistLintSeverity":1464}},"xmap":{"MyPyLinter":["ArcanistExternalLinter"]}},"09b7af4806790af70a69ee97158e6112":{"have":{"class":{"CheckNonFatalOverAssertInRpc":268}},"need":{"function":{"pht":582},"class":{"ArcanistLinter":305,"ArcanistLintSeverity":863,"Filesystem":1144}},"xmap":{"CheckNonFatalOverAssertInRpc":["ArcanistLinter"]}},"85936cbfc0decd1aae05001717b359da":{"have":{"class":{"LogLinter":116}},"need":{"function":{"pht":297},"class":{"ArcanistLinter":134,"ArcanistLintSeverity":580,"Filesystem":875}},"xmap":{"LogLinter":["ArcanistLinter"]}},"729e2f379c278258d8040e156ba9da29":{"have":{"class":{"ShellLocaleLinter":107}},"need":{"function":{"pht":382},"class":{"ArcanistLinter":133,"ArcanistLintSeverity":734,"Filesystem":1044}},"xmap":{"ShellLocaleLinter":["ArcanistLinter"]}},"1dacb6d661b7ea83e6b1980c3c4f602d":{"have":{"class":{"StdintLinter":90}},"need":{"function":{"pht":567},"class":{"ArcanistLinter":111,"ArcanistLintSeverity":876,"Filesystem":1401}},"xmap":{"StdintLinter":["ArcanistLinter"]}},"2cbb6e7228d81557f777ad648704f343":{"have":{"class":{"IncludeQuotesLinter":100}},"need":{"function":{"pht":306},"class":{"ArcanistLinter":128,"ArcanistLintSeverity":663,"Filesystem":964}},"xmap":{"IncludeQuotesLinter":["ArcanistLinter"]}},"38f0c676bff5192a344464142caaa253":{"have":{"class":{"CHeaderLinter":99}},"need":{"function":{"pht":611},"class":{"ArcanistLinter":121,"ArcanistLintSeverity":1060,"Filesystem":1307}},"xmap":{"CHeaderLinter":["ArcanistLinter"]}},"d792b114a2a4d16e2137dd237483ce42":{"have":{"class":{"PythonMutableDefaultLinter":155}},"need":{"function":{"pht":377},"class":{"ArcanistLinter":190,"ArcanistLintSeverity":740,"Filesystem":1030}},"xmap":{"PythonMutableDefaultLinter":["ArcanistLinter"]}},"3cd6909c95569e2564deabbd1ec38bbb":{"have":{"class":{"FileNameLinter":103}},"need":{"function":{"pht":382},"class":{"ArcanistLinter":126,"ArcanistLintSeverity":737,"Filesystem":1160}},"xmap":{"FileNameLinter":["ArcanistLinter"]}},"2e11dd9ad67e594f863bc46ac59ea37e":{"have":{"class":{"GlobalExternalLinter":199}},"need":{"class":{"ArcanistExternalLinter":228},"interface":{"ILintOnce":262}},"xmap":{"GlobalExternalLinter":["ArcanistExternalLinter","ILintOnce"]}},"146347e1ef63e514a6634ada8de5b5c9":{"have":{"class":{"Qt5Linter":70}},"need":{"function":{"pht":258},"class":{"ArcanistLinter":88,"ArcanistLintSeverity":609,"Filesystem":836}},"xmap":{"Qt5Linter":["ArcanistLinter"]}},"2f99c841a569f2029d13ea030dee007c":{"have":{"class":{"TestsLinter":103}},"need":{"function":{"pht":318,"id":2638},"class":{"ArcanistExternalLinter":123,"ArcanistLintMessage":2645,"Filesystem":776,"ArcanistLinter":2693,"ArcanistLintSeverity":2801}},"xmap":{"TestsLinter":["ArcanistExternalLinter"]}},"4584b1b007576d47eeff9504b80c4a77":{"have":{"class":{"ClangFormatLinter":79}},"need":{"function":{"pht":302,"execx":781,"id":2251},"class":{"ArcanistExternalLinter":105,"ArcanistLintMessage":2258,"Filesystem":2102,"ArcanistLinter":2365,"ArcanistLintSeverity":2443}},"xmap":{"ClangFormatLinter":["ArcanistExternalLinter"]}},"fbb3938ab9b412d7505335d9f7ed183d":{"have":{"class":{"ShellCheckLinter":95}},"need":{"function":{"pht":921,"execx":1443,"id":2414},"class":{"ArcanistExternalLinter":120,"ArcanistLintMessage":2421,"ArcanistLintSeverity":646,"ArcanistLinter":2469}},"xmap":{"ShellCheckLinter":["ArcanistExternalLinter"]}},"e6c7c36001803d09d667e83285bd04e7":{"have":{"class":{"YamllintLinter":77}},"need":{"function":{"pht":399,"execx":907,"id":1711},"class":{"ArcanistExternalLinter":100,"ArcanistLintMessage":1718,"ArcanistLintSeverity":184,"ArcanistLinter":1766}},"xmap":{"YamllintLinter":["ArcanistExternalLinter"]}},"39694cf756ce58681ea84a028f3e007f":{"have":{"class":{"IncludeGuardLinter":98}},"need":{"function":{"pht":443},"class":{"ArcanistLinter":125,"ArcanistLintSeverity":796,"Filesystem":1162}},"xmap":{"IncludeGuardLinter":["ArcanistLinter"]}},"cfe5966affc66e3444c34bf55a119446":{"have":{"function":{"startsWith":16},"class":{"MarkdownLinter":171}},"need":{"function":{"pht":361},"class":{"ArcanistLinter":194,"ArcanistLintSeverity":652,"Filesystem":1571}},"xmap":{"MarkdownLinter":["ArcanistLinter"]}},"df78f1ac61b2f0f7cd5bd3cf434ce6e3":{"have":{"class":{"CppVoidParameterLinter":119}},"need":{"function":{"pht":392},"class":{"ArcanistLinter":150,"ArcanistLintSeverity":707,"Filesystem":1164}},"xmap":{"CppVoidParameterLinter":["ArcanistLinter"]}},"454160ed72e88797129d84ee589de304":{"have":{"class":{"PythonShebangLinter":87}},"need":{"function":{"pht":290},"class":{"ArcanistLinter":115,"ArcanistLintSeverity":614,"Filesystem":854}},"xmap":{"PythonShebangLinter":["ArcanistLinter"]}},"3a184a47bce0d3fbf7dad76c6f755df5":{"have":{"class":{"PrettierLinter":76}},"need":{"function":{"pht":311,"execx":758,"id":1196},"class":{"ArcanistExternalLinter":99,"ArcanistLintMessage":1203,"Filesystem":1118,"ArcanistLinter":1276,"ArcanistLintSeverity":1362}},"xmap":{"PrettierLinter":["ArcanistExternalLinter"]}},"9bb48ec0fe2e9ced8e27d42540d0571c":{"have":{"class":{"CheckDocLinter":106}},"need":{"function":{"pht":321,"id":1845},"class":{"GlobalExternalLinter":129,"ArcanistLintMessage":1852,"Filesystem":729,"ArcanistLinter":1900,"ArcanistLintSeverity":1986}},"xmap":{"CheckDocLinter":["GlobalExternalLinter"]}},"c073131f5baad372e3037328d2e71c0e":{"have":{"class":{"ISortFormatLinter":72}},"need":{"function":{"pht":318,"id":1597},"class":{"ArcanistExternalLinter":98,"ArcanistLintMessage":1604,"Filesystem":1448,"ArcanistLinter":1711,"ArcanistLintSeverity":1790}},"xmap":{"ISortFormatLinter":["ArcanistExternalLinter"]}},"b4005bc083930dd85220bffb4c5f8bdd":{"have":{"class":{"PythonFileEncodingLinter":111}},"need":{"function":{"pht":321},"class":{"ArcanistLinter":144,"ArcanistLintSeverity":685,"Filesystem":990}},"xmap":{"PythonFileEncodingLinter":["ArcanistLinter"]}},"3e6f662aafff47b2f59242e1823e3b14":{"have":{"class":{"LocaleDependenceLinter":1741}},"need":{"function":{"pht":7202},"class":{"ArcanistLinter":1772,"ArcanistLintSeverity":7705,"Filesystem":7951}},"xmap":{"LocaleDependenceLinter":["ArcanistLinter"]}},"2809b09d2021203b43c57da33d1fe8bf":{"have":{"class":{"AssertWithSideEffectsLinter":210}},"need":{"function":{"pht":439},"class":{"ArcanistLinter":246,"ArcanistLintSeverity":926,"Filesystem":1170}},"xmap":{"AssertWithSideEffectsLinter":["ArcanistLinter"]}},"9780c82e3cf1cde0c46662563f00444f":{"have":{"class":{"ArcanistBitcoinABCConfiguration":13}},"need":{"function":{"pht":242},"class":{"ArcanistConfiguration":53,"ArcanistLintWorkflow":1652},"class\/interface":{"ArcanistWorkflow":385,"ArcanistNoEffectException":1371}},"xmap":{"ArcanistBitcoinABCConfiguration":["ArcanistConfiguration"]}}} \ No newline at end of file diff --git a/arcanist/__phutil_library_map__.php b/arcanist/__phutil_library_map__.php index 0a8a12172..97d16e8d2 100644 --- a/arcanist/__phutil_library_map__.php +++ b/arcanist/__phutil_library_map__.php @@ -1,96 +1,94 @@ 2, 'class' => array( 'ArcanistBitcoinABCConfiguration' => 'configuration/ArcanistBitcoinABCConfiguration.php', 'ArcanistLandBotWorkflow' => 'workflow/ArcanistLandBotWorkflow.php', 'AssertWithSideEffectsLinter' => 'linter/AssertWithSideEffectsLinter.php', 'AutoPEP8FormatLinter' => 'linter/AutoPEP8Linter.php', 'BashShebangLinter' => 'linter/BashShebangLinter.php', 'BoostDependenciesLinter' => 'linter/BoostDependenciesLinter.php', 'CHeaderLinter' => 'linter/CHeaderLinter.php', 'CheckDocLinter' => 'linter/CheckDocLinter.php', 'CheckNonFatalOverAssertInRpc' => 'linter/CheckNonFatalOverAssertInRpc.php', 'ClangFormatLinter' => 'linter/ClangFormatLinter.php', - 'CppCheckLinter' => 'linter/CppCheckLinter.php', 'CppVoidParameterLinter' => 'linter/CppVoidParameterLinter.php', 'DoxygenLinter' => 'linter/DoxygenLinter.php', 'ExtendedConfigurationDrivenLintEngine' => 'engine/ExtendedConfigurationDrivenLintEngine.php', 'FileNameLinter' => 'linter/FileNameLinter.php', 'FormatStringLinter' => 'linter/FormatStringLinter.php', 'GlobalExternalLinter' => 'linter/GlobalExternalLinter.php', 'ILintOnce' => 'linter/ILintOnce.php', 'ISortFormatLinter' => 'linter/ISortLinter.php', 'IncludeGuardLinter' => 'linter/IncludeGuardLinter.php', 'IncludeQuotesLinter' => 'linter/IncludeQuotesLinter.php', 'IncludeSourceLinter' => 'linter/IncludeSourceLinter.php', 'LocaleDependenceLinter' => 'linter/LocaleDependenceLinter.php', 'LogLinter' => 'linter/LogLinter.php', 'MarkdownLinter' => 'linter/MarkdownLinter.php', 'MyPyLinter' => 'linter/MyPyLinter.php', 'PrettierLinter' => 'linter/PrettierLinter.php', 'PythonFileEncodingLinter' => 'linter/PythonFileEncodingLinter.php', 'PythonFormatLinter' => 'linter/PythonFormatLinter.php', 'PythonMutableDefaultLinter' => 'linter/PythonMutableDefaultLinter.php', 'PythonShebangLinter' => 'linter/PythonShebangLinter.php', 'Qt5Linter' => 'linter/Qt5Linter.php', 'ShellCheckLinter' => 'linter/ShellCheckLinter.php', 'ShellLocaleLinter' => 'linter/ShellLocaleLinter.php', 'StdintLinter' => 'linter/StdintLinter.php', 'TestsLinter' => 'linter/TestsLinter.php', 'WhitespaceLinter' => 'linter/WhitespaceLinter.php', 'YamllintLinter' => 'linter/YamllintLinter.php', ), 'function' => array( 'startsWith' => 'linter/MarkdownLinter.php', ), 'xmap' => array( 'ArcanistBitcoinABCConfiguration' => 'ArcanistConfiguration', 'ArcanistLandBotWorkflow' => 'ArcanistWorkflow', 'AssertWithSideEffectsLinter' => 'ArcanistLinter', 'AutoPEP8FormatLinter' => 'ArcanistExternalLinter', 'BashShebangLinter' => 'ArcanistLinter', 'BoostDependenciesLinter' => 'GlobalExternalLinter', 'CHeaderLinter' => 'ArcanistLinter', 'CheckDocLinter' => 'GlobalExternalLinter', 'CheckNonFatalOverAssertInRpc' => 'ArcanistLinter', 'ClangFormatLinter' => 'ArcanistExternalLinter', - 'CppCheckLinter' => 'ArcanistExternalLinter', 'CppVoidParameterLinter' => 'ArcanistLinter', 'DoxygenLinter' => 'ArcanistLinter', 'ExtendedConfigurationDrivenLintEngine' => 'ArcanistLintEngine', 'FileNameLinter' => 'ArcanistLinter', 'FormatStringLinter' => 'ArcanistExternalLinter', 'GlobalExternalLinter' => array( 'ArcanistExternalLinter', 'ILintOnce', ), 'ISortFormatLinter' => 'ArcanistExternalLinter', 'IncludeGuardLinter' => 'ArcanistLinter', 'IncludeQuotesLinter' => 'ArcanistLinter', 'IncludeSourceLinter' => 'ArcanistLinter', 'LocaleDependenceLinter' => 'ArcanistLinter', 'LogLinter' => 'ArcanistLinter', 'MarkdownLinter' => 'ArcanistLinter', 'MyPyLinter' => 'ArcanistExternalLinter', 'PrettierLinter' => 'ArcanistExternalLinter', 'PythonFileEncodingLinter' => 'ArcanistLinter', 'PythonFormatLinter' => 'ArcanistExternalLinter', 'PythonMutableDefaultLinter' => 'ArcanistLinter', 'PythonShebangLinter' => 'ArcanistLinter', 'Qt5Linter' => 'ArcanistLinter', 'ShellCheckLinter' => 'ArcanistExternalLinter', 'ShellLocaleLinter' => 'ArcanistLinter', 'StdintLinter' => 'ArcanistLinter', 'TestsLinter' => 'ArcanistExternalLinter', 'WhitespaceLinter' => 'ArcanistLinter', 'YamllintLinter' => 'ArcanistExternalLinter', ), )); diff --git a/arcanist/linter/CppCheckLinter.php b/arcanist/linter/CppCheckLinter.php deleted file mode 100644 index 2cfef6bd5..000000000 --- a/arcanist/linter/CppCheckLinter.php +++ /dev/null @@ -1,291 +0,0 @@ - [messages]> to whitelist. */ - const CPPCHECK_IGNORED_WARNINGS = array( - "src/arith_uint256.h" => array( - "Class 'arith_uint256' has a constructor with 1 argument that is not explicit.", - "Class 'base_uint < 256 >' has a constructor with 1 argument that is not explicit.", - "Class 'base_uint' has a constructor with 1 argument that is not explicit.", - ), - "src/avalanche/test/processor_tests.cpp" => array( - // This is a false positive, there is an assertion that the array has - // the expected size using a BOOST_CHECK expression. - "Out of bounds access in expression 'updates[0]' because 'updates' is empty.", - ), - "src/bench/mempool_stress.cpp" => array( - // Remove this once this false positive is fixed in cppcheck - // https://trac.cppcheck.net/ticket/9537 - "Syntax Error: AST broken, 'for' doesn't have two operands.", - ), - "src/bench/prevector.cpp" => array( - // Remove this once this false positive is fixed in cppcheck - "syntax error", - ), - "src/coins.h" => array( - "Class 'CCoinsViewBacked' has a constructor with 1 argument that is not explicit.", - "Class 'CCoinsViewCache' has a constructor with 1 argument that is not explicit.", - "Class 'CCoinsViewCursor' has a constructor with 1 argument that is not explicit.", - ), - "src/compat/glibcxx_sanity.cpp" => array( - // This is a deliberate sanity check and not a real issue - "Out of bounds access in expression 'test.at(1)' because 'test' is empty and 'at' may be non-zero.", - ), - "src/cuckoocache.h" => array( - "Struct 'KeyOnly' has a constructor with 1 argument that is not explicit.", - ), - "src/init.cpp" => array( - // This is a cppcheck issue, occurring on Debian Buster's version 1.86. - // This no longer occurs with version 2.3, and maybe other earlier - // versions (untested). FIXME: remove when the bug is fixed. - "Syntax Error: AST broken, binary operator '=' doesn't have two operands.", - ), - "src/net.h" => array( - "Class 'CNetMessage' has a constructor with 1 argument that is not explicit.", - ), - "src/net_processing.cpp" => array( - "Same iterator is used with different containers 'mapOrphanTransactions' and 'itPrev.second'.", - "Analysis failed. If the code is valid then please report this failure.", - ), - "src/policy/feerate.h" => array( - "Class 'CFeeRate' has a constructor with 1 argument that is not explicit.", - ), - "src/prevector.h" => array( - "Class 'const_iterator' has a constructor with 1 argument that is not explicit.", - "Class 'const_reverse_iterator' has a constructor with 1 argument that is not explicit.", - "Class 'iterator' has a constructor with 1 argument that is not explicit.", - "Class 'reverse_iterator' has a constructor with 1 argument that is not explicit.", - ), - "src/primitives/block.h" => array( - "Class 'CBlock' has a constructor with 1 argument that is not explicit.", - ), - "src/primitives/transaction.h" => array( - "Class 'CTransaction' has a constructor with 1 argument that is not explicit.", - ), - "src/protocol.h" => array( - "Class 'CMessageHeader' has a constructor with 1 argument that is not explicit.", - ), - "src/qt/guiutil.h" => array( - "Class 'ItemDelegate' has a constructor with 1 argument that is not explicit.", - ), - "src/rpc/util.h" => array( - "Struct 'RPCResults' has a constructor with 1 argument that is not explicit.", - "Struct 'UniValueType' has a constructor with 1 argument that is not explicit.", - ), - "src/script/descriptor.cpp" => array( - "Class 'AddressDescriptor' has a constructor with 1 argument that is not explicit.", - "Class 'ComboDescriptor' has a constructor with 1 argument that is not explicit.", - "Class 'ConstPubkeyProvider' has a constructor with 1 argument that is not explicit.", - "Class 'PKDescriptor' has a constructor with 1 argument that is not explicit.", - "Class 'PKHDescriptor' has a constructor with 1 argument that is not explicit.", - "Class 'RawDescriptor' has a constructor with 1 argument that is not explicit.", - "Class 'SHDescriptor' has a constructor with 1 argument that is not explicit.", - "Class 'WPKHDescriptor' has a constructor with 1 argument that is not explicit.", - "Class 'WSHDescriptor' has a constructor with 1 argument that is not explicit.", - ), - "src/script/script.h" => array( - "Class 'CScript' has a constructor with 1 argument that is not explicit.", - ), - "src/script/standard.h" => array( - "Class 'CScriptID' has a constructor with 1 argument that is not explicit.", - ), - "src/support/allocators/secure.h" => array( - "Struct 'secure_allocator < char >' has a constructor with 1 argument that is not explicit.", - "Struct 'secure_allocator < RNGState >' has a constructor with 1 argument that is not explicit.", - "Struct 'secure_allocator < unsigned char >' has a constructor with 1 argument that is not explicit.", - ), - "src/support/allocators/zeroafterfree.h" => array( - "Struct 'zero_after_free_allocator < char >' has a constructor with 1 argument that is not explicit.", - ), - "src/test/blockindex_tests.cpp" => array( - // This is a false positive, the array is list initialized - "Out of bounds access in 'times[i]', if 'times' size is 1 and 'i' is 11", - "Out of bounds access in 'times2[i]', if 'times2' size is 1 and 'i' is 11", - ), - "src/test/checkqueue_tests.cpp" => array( - "Struct 'FailingCheck' has a constructor with 1 argument that is not explicit.", - "Struct 'MemoryCheck' has a constructor with 1 argument that is not explicit.", - "Struct 'UniqueCheck' has a constructor with 1 argument that is not explicit.", - ), - "src/test/cuckoocache_tests.cpp" => array( - "Struct 'KeyType' has a constructor with 1 argument that is not explicit.", - "Struct 'TestMapElement' has a constructor with 1 argument that is not explicit." - ), - "src/test/prevector_tests.cpp" => array( - // Remove this once this false positive is fixed in cppcheck - "syntax error", - ), - "src/wallet/db.h" => array( - "Class 'BerkeleyEnvironment' has a constructor with 1 argument that is not explicit.", - ), - ); - // phpcs:enable - - const CPPCHECK_OPTIONS = array( - '-j2', - '--enable=all', - '--language=c++', - ); - - const CPPCHECK_DEFINITIONS = array( - '-D__cplusplus', - '-DCLIENT_VERSION_BUILD', - '-DCLIENT_VERSION_IS_RELEASE', - '-DCLIENT_VERSION_MAJOR', - '-DCLIENT_VERSION_MINOR', - '-DCLIENT_VERSION_REVISION', - '-DCOPYRIGHT_YEAR', - '-DDEBUG', - ); - - public function getInfoName() { - return 'cppcheck'; - } - - public function getInfoURI() { - return 'http://cppcheck.sourceforge.net'; - } - - public function getInfoDescription() { - return pht( - 'Use `%s` to perform static analysis on C/C++ code.', - 'cppcheck'); - } - - public function getLinterName() { - return 'lint-cppcheck'; - } - - public function getLinterConfigurationName() { - return 'lint-cppcheck'; - } - - public function getDefaultBinary() { - return 'cppcheck'; - } - - public function getVersion() { - list($stdout) = execx('%C --version', $this->getExecutableCommand()); - - $matches = array(); - $regex = '/^Cppcheck (?P\d+\.\d+)$/'; - if (preg_match($regex, $stdout, $matches)) { - return $matches['version']; - } - - return false; - } - - public function getInstallInstructions() { - return pht( - 'Install Cppcheck using `%s` or similar.', - 'apt-get install cppcheck'); - } - - protected function getDefaultFlags() { - return array_merge( - self::CPPCHECK_OPTIONS, - self::CPPCHECK_DEFINITIONS - ); - } - - protected function getMandatoryFlags() { - return array( - '--quiet', - '--inline-suppr', - '--xml', - '--xml-version=2', - ); - } - - public function shouldExpectCommandErrors() { - return false; - } - - private function isWhitelisted($path, $errorId, $errorDescription) { - return array_key_exists($path, self::CPPCHECK_IGNORED_WARNINGS) && - in_array($errorDescription, self::CPPCHECK_IGNORED_WARNINGS[$path]); - } - - private function isCheckEnabled($errorId) { - return in_array($errorId, self::CPPCHECK_ENABLED_CHECKS); - } - - private function isCheckDisabled($errorId) { - return in_array($errorId, self::CPPCHECK_DISABLED_CHECKS); - } - - protected function parseLinterOutput($path, $err, $stdout, $stderr) { - $dom = new DOMDocument(); - $ok = @$dom->loadXML($stderr); - - if (!$ok) { - return false; - } - - $errors = $dom->getElementsByTagName('error'); - $messages = array(); - foreach ($errors as $error) { - foreach ($error->getElementsByTagName('location') as $location) { - $errorPath = Filesystem::readablePath( - $location->getAttribute('file'), $this->getProjectRoot()); - $errorId = $error->getAttribute('id'); - $errorDescription = $error->getAttribute('msg'); - - /* - * Only raise errors related to the actual source file. - * This prevents from printing tons of duplicates. - */ - if ($errorPath !== $path || $this->isWhitelisted( - $errorPath, $errorId, $errorDescription)) { - continue; - } - - // For errors, we work on a blacklist basis. - // For advices and warnings, we work on a whitelist basis. - $is_error = $error->getAttribute('severity') == 'error'; - if ($is_error && $this->isCheckDisabled($errorId)) { - continue; - } else if (!$is_error && !$this->isCheckEnabled($errorId)) { - continue; - } - - $message = new ArcanistLintMessage(); - $message->setPath($errorPath); - $message->setLine($location->getAttribute('line')); - $message->setCode('CPPCHECK'); - $message->setName($errorId); - $message->setDescription($errorDescription); - - if ($is_error) { - $message->setSeverity(ArcanistLintSeverity::SEVERITY_ERROR); - } elseif ($error->getAttribute('inconclusive')) { - $message->setSeverity(ArcanistLintSeverity::SEVERITY_ADVICE); - } else { - $message->setSeverity(ArcanistLintSeverity::SEVERITY_WARNING); - } - - $messages[] = $message; - } - } - - return $messages; - } -} diff --git a/contrib/utils/install-dependencies.sh b/contrib/utils/install-dependencies.sh index 227900ac5..a85c52280 100755 --- a/contrib/utils/install-dependencies.sh +++ b/contrib/utils/install-dependencies.sh @@ -1,140 +1,139 @@ #!/usr/bin/env bash export LC_ALL=C.UTF-8 set -euxo pipefail dpkg --add-architecture i386 PACKAGES=( arcanist automake autotools-dev binutils bsdmainutils build-essential ccache - cppcheck curl default-jdk devscripts doxygen dput flake8 g++-aarch64-linux-gnu g++-arm-linux-gnueabihf gettext-base git golang g++-mingw-w64 gnupg graphviz gperf help2man imagemagick jq lcov less lib32stdc++-8-dev libboost-all-dev libbz2-dev libc6-dev:i386 libcap-dev libdb++-dev libdb-dev libevent-dev libjemalloc-dev libminiupnpc-dev libprotobuf-dev libqrencode-dev libqt5core5a libqt5dbus5 libqt5gui5 librsvg2-bin libsqlite3-dev libssl-dev libtiff-tools libtinfo5 libtool libzmq3-dev lld make ninja-build nsis php-codesniffer pkg-config protobuf-compiler python3 python3-autopep8 python3-pip python3-setuptools python3-yaml python3-zmq qemu-user-static qttools5-dev qttools5-dev-tools software-properties-common tar wget xvfb yamllint wine ) function join_by() { local IFS="$1" shift echo "$*" } apt-get update DEBIAN_FRONTEND=noninteractive apt-get install -y $(join_by ' ' "${PACKAGES[@]}") BACKPORTS=( cmake shellcheck ) echo "deb http://deb.debian.org/debian buster-backports main" | tee -a /etc/apt/sources.list apt-get update DEBIAN_FRONTEND=noninteractive apt-get -t buster-backports install -y $(join_by ' ' "${BACKPORTS[@]}") # Install llvm-8 and clang-10 apt-key add "$(dirname "$0")"/llvm.pub add-apt-repository "deb https://apt.llvm.org/buster/ llvm-toolchain-buster-8 main" add-apt-repository "deb https://apt.llvm.org/buster/ llvm-toolchain-buster-10 main" apt-get update LLVM_PACKAGES=( clang-10 clang-format-10 clang-tidy-10 clang-tools-10 ) DEBIAN_FRONTEND=noninteractive apt-get install -y $(join_by ' ' "${LLVM_PACKAGES[@]}") # Use the mingw posix variant update-alternatives --set x86_64-w64-mingw32-g++ $(command -v x86_64-w64-mingw32-g++-posix) update-alternatives --set x86_64-w64-mingw32-gcc $(command -v x86_64-w64-mingw32-gcc-posix) # Python library for merging nested structures pip3 install deepmerge # For running Python test suites pip3 install pytest # Up-to-date mypy and isort packages are required python linters pip3 install isort==5.6.4 mypy==0.780 echo "export PATH=\"$(python3 -m site --user-base)/bin:\$PATH\"" >> ~/.bashrc # shellcheck source=/dev/null source ~/.bashrc # Install pandoc. The version from buster is outdated, so get a more recent one # from github. wget https://github.com/jgm/pandoc/releases/download/2.10.1/pandoc-2.10.1-1-amd64.deb echo "4515d6fe2bf8b82765d8dfa1e1b63ccb0ff3332d60389f948672eaa37932e936 pandoc-2.10.1-1-amd64.deb" | sha256sum -c DEBIAN_FRONTEND=noninteractive dpkg -i pandoc-2.10.1-1-amd64.deb # Install npm v7.x and nodejs v15.x curl -sL https://deb.nodesource.com/setup_15.x | bash - apt-get install -y nodejs diff --git a/src/avalanche/peermanager.cpp b/src/avalanche/peermanager.cpp index 3a37a00e3..70b4c3c8b 100644 --- a/src/avalanche/peermanager.cpp +++ b/src/avalanche/peermanager.cpp @@ -1,719 +1,716 @@ // Copyright (c) 2020 The Bitcoin developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include #include #include #include #include #include // For ChainstateActive() #include #include namespace avalanche { bool PeerManager::addNode(NodeId nodeid, const ProofId &proofid) { auto &pview = peers.get(); auto it = pview.find(proofid); if (it == pview.end()) { // If the node exists, it is actually updating its proof to an unknown // one. In this case we need to remove it so it is not both active and // pending at the same time. removeNode(nodeid); pendingNodes.emplace(proofid, nodeid); return false; } return addOrUpdateNode(peers.project<0>(it), nodeid); } bool PeerManager::addOrUpdateNode(const PeerSet::iterator &it, NodeId nodeid) { assert(it != peers.end()); const PeerId peerid = it->peerid; auto nit = nodes.find(nodeid); if (nit == nodes.end()) { if (!nodes.emplace(nodeid, peerid).second) { return false; } } else { const PeerId oldpeerid = nit->peerid; if (!nodes.modify(nit, [&](Node &n) { n.peerid = peerid; })) { return false; } // We actually have this node already, we need to update it. bool success = removeNodeFromPeer(peers.find(oldpeerid)); assert(success); } bool success = addNodeToPeer(it); assert(success); // If the added node was in the pending set, remove it pendingNodes.get().erase(nodeid); return true; } bool PeerManager::addNodeToPeer(const PeerSet::iterator &it) { assert(it != peers.end()); return peers.modify(it, [&](Peer &p) { if (p.node_count++ > 0) { // We are done. return; } // We need to allocate this peer. p.index = uint32_t(slots.size()); const uint32_t score = p.getScore(); const uint64_t start = slotCount; slots.emplace_back(start, score, it->peerid); slotCount = start + score; }); } bool PeerManager::removeNode(NodeId nodeid) { auto it = nodes.find(nodeid); if (it == nodes.end()) { return false; } const PeerId peerid = it->peerid; nodes.erase(it); pendingNodes.get().erase(nodeid); // Keep the track of the reference count. bool success = removeNodeFromPeer(peers.find(peerid)); assert(success); return true; } bool PeerManager::removeNodeFromPeer(const PeerSet::iterator &it, uint32_t count) { // It is possible for nodes to be dangling. If there was an inflight query // when the peer gets removed, the node was not erased. In this case there // is nothing to do. if (it == peers.end()) { return true; } assert(count <= it->node_count); if (count == 0) { // This is a NOOP. return false; } const uint32_t new_count = it->node_count - count; if (!peers.modify(it, [&](Peer &p) { p.node_count = new_count; })) { return false; } if (new_count > 0) { // We are done. return true; } // There are no more node left, we need to cleanup. const size_t i = it->index; assert(i < slots.size()); if (i + 1 == slots.size()) { slots.pop_back(); slotCount = slots.empty() ? 0 : slots.back().getStop(); } else { fragmentation += slots[i].getScore(); slots[i] = slots[i].withPeerId(NO_PEER); } return true; } bool PeerManager::updateNextRequestTime(NodeId nodeid, TimePoint timeout) { auto it = nodes.find(nodeid); if (it == nodes.end()) { return false; } return nodes.modify(it, [&](Node &n) { n.nextRequestTime = timeout; }); } static bool isOrphanState(const ProofValidationState &state) { return state.GetResult() == ProofValidationResult::MISSING_UTXO || state.GetResult() == ProofValidationResult::HEIGHT_MISMATCH; } bool PeerManager::updateNextPossibleConflictTime( PeerId peerid, const std::chrono::seconds &nextTime) { auto it = peers.find(peerid); if (it == peers.end()) { // No such peer return false; } // Make sure we don't move the time in the past. peers.modify(it, [&](Peer &p) { p.nextPossibleConflictTime = std::max(p.nextPossibleConflictTime, nextTime); }); return it->nextPossibleConflictTime == nextTime; } void PeerManager::moveToConflictingPool(const ProofRef &proof) { auto &peersView = peers.get(); auto it = peersView.find(proof->getId()); if (it != peersView.end()) { removePeer(it->peerid); } conflictingProofPool.addProofIfPreferred(proof); } bool PeerManager::registerProof(const ProofRef &proof, ProofRegistrationState ®istrationState, RegistrationMode mode) { assert(proof); const ProofId &proofid = proof->getId(); auto invalidate = [&](ProofRegistrationResult result, const std::string &message) { return registrationState.Invalid( result, message, strprintf("proofid: %s", proofid.ToString())); }; if ((mode != RegistrationMode::FORCE_ACCEPT || !isInConflictingPool(proofid)) && exists(proofid)) { // In default mode, we expect the proof to be unknown, i.e. in none of // the pools. // In forced accept mode, the proof can be in the conflicting pool. return invalidate(ProofRegistrationResult::ALREADY_REGISTERED, "proof-already-registered"); } // Check the proof's validity. ProofValidationState validationState; - // Using WITH_LOCK directly inside the if statement will trigger a cppcheck - // false positive syntax error - const bool valid = WITH_LOCK( - cs_main, - return proof->verify(validationState, ::ChainstateActive().CoinsTip())); - if (!valid) { + if (!WITH_LOCK(cs_main, + return proof->verify(validationState, + ::ChainstateActive().CoinsTip()))) { if (isOrphanState(validationState)) { orphanProofPool.addProofIfPreferred(proof); return invalidate(ProofRegistrationResult::ORPHAN, "orphan-proof"); } // Reject invalid proof. return invalidate(ProofRegistrationResult::INVALID, "invalid-proof"); } auto now = GetTime(); auto nextCooldownTimePoint = now + std::chrono::seconds( gArgs.GetArg("-avalancheconflictingproofcooldown", AVALANCHE_DEFAULT_CONFLICTING_PROOF_COOLDOWN)); ProofPool::ConflictingProofSet conflictingProofs; switch (validProofPool.addProofIfNoConflict(proof, conflictingProofs)) { case ProofPool::AddProofStatus::REJECTED: { if (mode != RegistrationMode::FORCE_ACCEPT) { auto bestPossibleConflictTime = std::chrono::seconds(); auto &pview = peers.get(); for (auto &conflictingProof : conflictingProofs) { auto it = pview.find(conflictingProof->getId()); assert(it != pview.end()); // Search the most recent time over the peers bestPossibleConflictTime = std::max( bestPossibleConflictTime, it->nextPossibleConflictTime); updateNextPossibleConflictTime(it->peerid, nextCooldownTimePoint); } if (bestPossibleConflictTime > now) { // Cooldown not elapsed, reject the proof. return invalidate( ProofRegistrationResult::COOLDOWN_NOT_ELAPSED, "cooldown-not-elapsed"); } // If proof replacement is enabled, give the proof a chance to // replace the conflicting ones. if (gArgs.GetBoolArg( "-enableavalancheproofreplacement", AVALANCHE_DEFAULT_PROOF_REPLACEMENT_ENABLED)) { if (validProofPool.addProofIfPreferred(proof)) { // If we have overridden other proofs due to conflict, // remove the peers and attempt to move them to the // conflicting pool. for (const ProofRef &conflictingProof : conflictingProofs) { moveToConflictingPool(conflictingProof); } // Replacement is successful, continue to peer creation break; } } // Not the preferred proof, or replacement is not enabled return conflictingProofPool.addProofIfPreferred(proof) == ProofPool::AddProofStatus::REJECTED ? invalidate(ProofRegistrationResult::REJECTED, "rejected-proof") : invalidate(ProofRegistrationResult::CONFLICTING, "conflicting-utxos"); } conflictingProofPool.removeProof(proofid); // Move the conflicting proofs from the valid pool to the // conflicting pool auto &peersView = peers.get(); for (const ProofRef &conflictingProof : conflictingProofs) { auto it = peersView.find(conflictingProof->getId()); if (it != peersView.end()) { removePeer(it->peerid); } conflictingProofPool.addProofIfPreferred(conflictingProof); } auto status = validProofPool.addProofIfNoConflict(proof); assert(status == ProofPool::AddProofStatus::SUCCEED); break; } case ProofPool::AddProofStatus::DUPLICATED: // If the proof was already in the pool, don't duplicate the peer. return invalidate(ProofRegistrationResult::ALREADY_REGISTERED, "proof-already-registered"); case ProofPool::AddProofStatus::SUCCEED: break; // No default case, so the compiler can warn about missing cases } // At this stage we are going to create a peer so the proof should never // exist in the conflicting pool, but use belt and suspenders. conflictingProofPool.removeProof(proofid); // New peer means new peerid! const PeerId peerid = nextPeerId++; // We have no peer for this proof, time to create it. auto inserted = peers.emplace(peerid, proof, nextCooldownTimePoint); assert(inserted.second); // If there are nodes waiting for this proof, add them auto &pendingNodesView = pendingNodes.get(); auto range = pendingNodesView.equal_range(proofid); // We want to update the nodes then remove them from the pending set. That // will invalidate the range iterators, so we need to save the node ids // first before we can loop over them. std::vector nodeids; nodeids.reserve(std::distance(range.first, range.second)); std::transform(range.first, range.second, std::back_inserter(nodeids), [](const PendingNode &n) { return n.nodeid; }); for (const NodeId &nodeid : nodeids) { addOrUpdateNode(inserted.first, nodeid); } return true; } bool PeerManager::rejectProof(const ProofId &proofid, RejectionMode mode) { if (!exists(proofid)) { return false; } if (orphanProofPool.removeProof(proofid)) { return true; } if (mode == RejectionMode::DEFAULT && conflictingProofPool.getProof(proofid)) { // In default mode we keep the proof in the conflicting pool return true; } if (mode == RejectionMode::INVALIDATE && conflictingProofPool.removeProof(proofid)) { // In invalidate mode we remove the proof completely return true; } auto &pview = peers.get(); auto it = pview.find(proofid); assert(it != pview.end()); const ProofRef proof = it->proof; if (!removePeer(it->peerid)) { return false; } // If there was conflicting proofs, attempt to pull them back for (const SignedStake &ss : proof->getStakes()) { const ProofRef conflictingProof = conflictingProofPool.getProof(ss.getStake().getUTXO()); if (!conflictingProof) { continue; } conflictingProofPool.removeProof(conflictingProof->getId()); registerProof(conflictingProof); } if (mode == RejectionMode::DEFAULT) { conflictingProofPool.addProofIfPreferred(proof); } return true; } NodeId PeerManager::selectNode() { for (int retry = 0; retry < SELECT_NODE_MAX_RETRY; retry++) { const PeerId p = selectPeer(); // If we cannot find a peer, it may be due to the fact that it is // unlikely due to high fragmentation, so compact and retry. if (p == NO_PEER) { compact(); continue; } // See if that peer has an available node. auto &nview = nodes.get(); auto it = nview.lower_bound(boost::make_tuple(p, TimePoint())); if (it != nview.end() && it->peerid == p && it->nextRequestTime <= std::chrono::steady_clock::now()) { return it->nodeid; } } return NO_NODE; } void PeerManager::updatedBlockTip() { std::vector invalidProofIds; std::vector newOrphans; { LOCK(cs_main); const CCoinsViewCache &coins = ::ChainstateActive().CoinsTip(); for (const auto &p : peers) { ProofValidationState state; if (!p.proof->verify(state, coins)) { if (isOrphanState(state)) { newOrphans.push_back(p.proof); } invalidProofIds.push_back(p.getProofId()); } } } // Remove the invalid proofs before the orphans rescan. This makes it // possible to pull back proofs with utxos that conflicted with these // invalid proofs. for (const ProofId &invalidProofId : invalidProofIds) { rejectProof(invalidProofId, RejectionMode::INVALIDATE); } orphanProofPool.rescan(*this); for (auto &p : newOrphans) { orphanProofPool.addProofIfPreferred(p); } } ProofRef PeerManager::getProof(const ProofId &proofid) const { ProofRef proof = nullptr; forPeer(proofid, [&](const Peer &p) { proof = p.proof; return true; }); if (!proof) { proof = conflictingProofPool.getProof(proofid); } if (!proof) { proof = orphanProofPool.getProof(proofid); } return proof; } bool PeerManager::isBoundToPeer(const ProofId &proofid) const { auto &pview = peers.get(); return pview.find(proofid) != pview.end(); } bool PeerManager::isOrphan(const ProofId &proofid) const { return orphanProofPool.getProof(proofid) != nullptr; } bool PeerManager::isInConflictingPool(const ProofId &proofid) const { return conflictingProofPool.getProof(proofid) != nullptr; } bool PeerManager::removePeer(const PeerId peerid) { auto it = peers.find(peerid); if (it == peers.end()) { return false; } // Remove all nodes from this peer. removeNodeFromPeer(it, it->node_count); auto &nview = nodes.get(); // Add the nodes to the pending set auto range = nview.equal_range(peerid); for (auto &nit = range.first; nit != range.second; ++nit) { pendingNodes.emplace(it->getProofId(), nit->nodeid); }; // Remove nodes associated with this peer, unless their timeout is still // active. This ensure that we don't overquery them in case they are // subsequently added to another peer. nview.erase(nview.lower_bound(boost::make_tuple(peerid, TimePoint())), nview.upper_bound(boost::make_tuple( peerid, std::chrono::steady_clock::now()))); // Release UTXOs attached to this proof. validProofPool.removeProof(it->getProofId()); m_unbroadcast_proofids.erase(it->getProofId()); peers.erase(it); return true; } PeerId PeerManager::selectPeer() const { if (slots.empty() || slotCount == 0) { return NO_PEER; } const uint64_t max = slotCount; for (int retry = 0; retry < SELECT_PEER_MAX_RETRY; retry++) { size_t i = selectPeerImpl(slots, GetRand(max), max); if (i != NO_PEER) { return i; } } return NO_PEER; } uint64_t PeerManager::compact() { // There is nothing to compact. if (fragmentation == 0) { return 0; } std::vector newslots; newslots.reserve(peers.size()); uint64_t prevStop = 0; uint32_t i = 0; for (auto it = peers.begin(); it != peers.end(); it++) { if (it->node_count == 0) { continue; } newslots.emplace_back(prevStop, it->getScore(), it->peerid); prevStop = slots[i].getStop(); if (!peers.modify(it, [&](Peer &p) { p.index = i++; })) { return 0; } } slots = std::move(newslots); const uint64_t saved = slotCount - prevStop; slotCount = prevStop; fragmentation = 0; return saved; } bool PeerManager::verify() const { uint64_t prevStop = 0; for (size_t i = 0; i < slots.size(); i++) { const Slot &s = slots[i]; // Slots must be in correct order. if (s.getStart() < prevStop) { return false; } prevStop = s.getStop(); // If this is a dead slot, then nothing more needs to be checked. if (s.getPeerId() == NO_PEER) { continue; } // We have a live slot, verify index. auto it = peers.find(s.getPeerId()); if (it == peers.end() || it->index != i) { return false; } } std::unordered_set peersUtxos; for (const auto &p : peers) { // A peer should have a proof attached if (!p.proof) { return false; } // Check proof pool consistency for (const auto &ss : p.proof->getStakes()) { const COutPoint &outpoint = ss.getStake().getUTXO(); auto proof = validProofPool.getProof(outpoint); if (!proof) { // Missing utxo return false; } if (proof != p.proof) { // Wrong proof return false; } if (!peersUtxos.emplace(outpoint).second) { // Duplicated utxo return false; } } // Count node attached to this peer. const auto count_nodes = [&]() { size_t count = 0; auto &nview = nodes.get(); auto begin = nview.lower_bound(boost::make_tuple(p.peerid, TimePoint())); auto end = nview.upper_bound(boost::make_tuple(p.peerid + 1, TimePoint())); for (auto it = begin; it != end; ++it) { count++; } return count; }; if (p.node_count != count_nodes()) { return false; } // If there are no nodes attached to this peer, then we are done. if (p.node_count == 0) { continue; } // The index must point to a slot refering to this peer. if (p.index >= slots.size() || slots[p.index].getPeerId() != p.peerid) { return false; } // If the score do not match, same thing. if (slots[p.index].getScore() != p.getScore()) { return false; } } // We checked the utxo consistency for all our peers utxos already, so if // the pool size differs from the expected one there are dangling utxos. if (validProofPool.size() != peersUtxos.size()) { return false; } return true; } PeerId selectPeerImpl(const std::vector &slots, const uint64_t slot, const uint64_t max) { assert(slot <= max); size_t begin = 0, end = slots.size(); uint64_t bottom = 0, top = max; // Try to find the slot using dichotomic search. while ((end - begin) > 8) { // The slot we picked in not allocated. if (slot < bottom || slot >= top) { return NO_PEER; } // Guesstimate the position of the slot. size_t i = begin + ((slot - bottom) * (end - begin) / (top - bottom)); assert(begin <= i && i < end); // We have a match. if (slots[i].contains(slot)) { return slots[i].getPeerId(); } // We undershooted. if (slots[i].precedes(slot)) { begin = i + 1; if (begin >= end) { return NO_PEER; } bottom = slots[begin].getStart(); continue; } // We overshooted. if (slots[i].follows(slot)) { end = i; top = slots[end].getStart(); continue; } // We have an unalocated slot. return NO_PEER; } // Enough of that nonsense, let fallback to linear search. for (size_t i = begin; i < end; i++) { // We have a match. if (slots[i].contains(slot)) { return slots[i].getPeerId(); } } // We failed to find a slot, retry. return NO_PEER; } void PeerManager::addUnbroadcastProof(const ProofId &proofid) { // The proof should be bound to a peer if (isBoundToPeer(proofid)) { m_unbroadcast_proofids.insert(proofid); } } void PeerManager::removeUnbroadcastProof(const ProofId &proofid) { m_unbroadcast_proofids.erase(proofid); } } // namespace avalanche