diff --git a/.ci/entrypoint.sh b/.ci/entrypoint.sh index b7f4e503..439863c9 100755 --- a/.ci/entrypoint.sh +++ b/.ci/entrypoint.sh @@ -10,5 +10,5 @@ set -e -x if [[ ${BIGCHAINDB_CI_ABCI} == 'enable' ]]; then sleep 3600 else - bigchaindb -l DEBUG start + corechaindb -l DEBUG start fi diff --git a/.ci/travis-before-script.sh b/.ci/travis-before-script.sh index 6723dcff..b890ca85 100755 --- a/.ci/travis-before-script.sh +++ b/.ci/travis-before-script.sh @@ -10,7 +10,7 @@ set -e -x if [[ -z ${TOXENV} ]]; then if [[ ${BIGCHAINDB_CI_ABCI} == 'enable' ]]; then - docker-compose up -d bigchaindb + docker-compose up -d corechaindb else docker-compose up -d bdb fi diff --git a/.ci/travis-install.sh b/.ci/travis-install.sh index 0e2c6f14..aeae73c0 100755 --- a/.ci/travis-install.sh +++ b/.ci/travis-install.sh @@ -12,10 +12,10 @@ pip install --upgrade pip if [[ -n ${TOXENV} ]]; then pip install --upgrade tox elif [[ ${BIGCHAINDB_CI_ABCI} == 'enable' ]]; then - docker-compose build --no-cache --build-arg abci_status=enable bigchaindb + docker-compose build --no-cache --build-arg abci_status=enable corechaindb elif [[ $BIGCHAINDB_INTEGRATION_TEST == 'enable' ]]; then - docker-compose build bigchaindb python-driver + docker-compose build corechaindb python-driver else - docker-compose build --no-cache bigchaindb + docker-compose build --no-cache corechaindb pip install --upgrade codecov fi diff --git a/.ci/travis_script.sh b/.ci/travis_script.sh index 91ad5b62..3049abe9 100755 --- a/.ci/travis_script.sh +++ b/.ci/travis_script.sh @@ -10,9 +10,9 @@ set -e -x if [[ -n ${TOXENV} ]]; then tox -e ${TOXENV} elif [[ ${BIGCHAINDB_CI_ABCI} == 'enable' ]]; then - docker-compose exec bigchaindb pytest -v -m abci + docker-compose exec corechaindb pytest -v -m abci elif [[ ${BIGCHAINDB_ACCEPTANCE_TEST} == 'enable' ]]; then ./run-acceptance-test.sh else - docker-compose exec bigchaindb pytest -v --cov=bigchaindb --cov-report xml:htmlcov/coverage.xml + docker-compose exec corechaindb pytest -v --cov=corechaindb --cov-report xml:htmlcov/coverage.xml fi diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d9c3d0b5..c76db580 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -9,6 +9,6 @@ Code is Apache-2.0 and docs are CC-BY-4.0 There are many ways you can contribute to the BigchainDB project, some very easy and others more involved. -All of that is documented elsewhere: go to the "[Contributing to BigchainDB" docs on ReadTheDocs](https://docs.bigchaindb.com/projects/contributing/en/latest/index.html). +All of that is documented elsewhere: go to the "[Contributing to BigchainDB" docs on ReadTheDocs](https://docs.corechaindb.com/projects/contributing/en/latest/index.html). Note: GitHub automatically links to this file (`.github/CONTRIBUTING.md`) when a contributor creates a new issue or pull request, so you shouldn't delete it. Just use it to point people to full and proper help elsewhere. diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 03514515..92cea561 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,9 +1,9 @@ # Do you want to: - make a bug report? Then read below about what should go in a bug report. -- make a feature request or proposal? Then read [the page about how to make a feature request or proposal](https://docs.bigchaindb.com/projects/contributing/en/latest/ways-can-contribute/make-a-feature-request-or-proposal.html). -- ask a question about BigchainDB? Then [go to Gitter](https://gitter.im/bigchaindb/bigchaindb) (our chat room) and ask it there. -- share your neat idea or realization? Then [go to Gitter](https://gitter.im/bigchaindb/bigchaindb) (our chat room) and share it there. +- make a feature request or proposal? Then read [the page about how to make a feature request or proposal](https://docs.corechaindb.com/projects/contributing/en/latest/ways-can-contribute/make-a-feature-request-or-proposal.html). +- ask a question about BigchainDB? Then [go to Gitter](https://gitter.im/corechaindb/corechaindb) (our chat room) and ask it there. +- share your neat idea or realization? Then [go to Gitter](https://gitter.im/corechaindb/corechaindb) (our chat room) and share it there. # What Should Go in a Bug Report diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 9305a8a6..321cb084 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -15,4 +15,4 @@ Resolves #MMMM ## BEPs Implemented -What [BEPs](https://github.com/bigchaindb/beps) does this pull request implement, if any? +What [BEPs](https://github.com/corechaindb/beps) does this pull request implement, if any? diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 88d85839..7e5e04d3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,5 +21,5 @@ repos: # list of error codes to check, see: http://www.pydocstyle.org/en/latest/error_codes.html args: ['--select=D204,D201,D209,D210,D212,D300,D403'] -# negate the exclude to only apply the hooks to 'bigchaindb' and 'tests' folder -exclude: '^(?!bigchaindb/)(?!tests/)(?!acceptance/)' +# negate the exclude to only apply the hooks to 'corechaindb' and 'tests' folder +exclude: '^(?!corechaindb/)(?!tests/)(?!acceptance/)' diff --git a/CHANGELOG.md b/CHANGELOG.md index 1505054d..d56d9dce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ Code is Apache-2.0 and docs are CC-BY-4.0 All _notable_ changes to this project will be documented in this file (`CHANGELOG.md`). -This project adheres to [the Python form of Semantic Versioning](https://packaging.python.org/tutorials/distributing-packages/#choosing-a-versioning-scheme) (or at least we try). The BigchainDB public API _was_ defined in this file but that definition was moved and can now be found in [BEP-7](https://github.com/bigchaindb/BEPs/tree/master/7). +This project adheres to [the Python form of Semantic Versioning](https://packaging.python.org/tutorials/distributing-packages/#choosing-a-versioning-scheme) (or at least we try). The BigchainDB public API _was_ defined in this file but that definition was moved and can now be found in [BEP-7](https://github.com/corechaindb/BEPs/tree/master/7). Contributors to this file, please follow the guidelines on [keepachangelog.com](http://keepachangelog.com/). Note that each version (or "release") is the name of a [Git _tag_](https://git-scm.com/book/en/v2/Git-Basics-Tagging) of a particular commit, so the associated date and time are the date and time of that commit (as reported by GitHub), _not_ the "Uploaded on" date listed on PyPI (which may differ). @@ -37,14 +37,14 @@ Several dependencies updated including Flask that had vulnerability. ### External Contributors -* @aostrun - [#2708](https://github.com/bigchaindb/bigchaindb/pull/2708) +* @aostrun - [#2708](https://github.com/corechaindb/corechaindb/pull/2708) ## [2.2.1] - 2020-04-14 ### Fixed -Gevent library API update is incompatible with bigchaindb-abci 1.0.1 version. -Updated bigchaindb-abci. +Gevent library API update is incompatible with corechaindb-abci 1.0.1 version. +Updated corechaindb-abci. ## [2.2.0] - 2020-02-20 @@ -68,30 +68,30 @@ Migrated from Tendermint 0.22.8 to 0.31.5. ### Changed -Removed support for TLSv1 and TLSv1.1 in all NGINX config files. Kept support for TLSv1.2 and added support for TLSv1.3. [Pull Request #2601](https://github.com/bigchaindb/bigchaindb/pull/2601) +Removed support for TLSv1 and TLSv1.1 in all NGINX config files. Kept support for TLSv1.2 and added support for TLSv1.3. [Pull Request #2601](https://github.com/corechaindb/corechaindb/pull/2601) ### Fixed -Fixed two issues with schema validation. Pull requests [#2606](https://github.com/bigchaindb/bigchaindb/pull/2606) & [#2607](https://github.com/bigchaindb/bigchaindb/pull/2607) +Fixed two issues with schema validation. Pull requests [#2606](https://github.com/corechaindb/corechaindb/pull/2606) & [#2607](https://github.com/corechaindb/corechaindb/pull/2607) ### External Contributors -[@gamjapark](https://github.com/gamjapark) and team translated all the [BigchainDB root docs](https://docs.bigchaindb.com/en/latest/korean/index.html) into Korean. [Pull Request #2603](https://github.com/bigchaindb/bigchaindb/pull/2603) +[@gamjapark](https://github.com/gamjapark) and team translated all the [BigchainDB root docs](https://docs.corechaindb.com/en/latest/korean/index.html) into Korean. [Pull Request #2603](https://github.com/corechaindb/corechaindb/pull/2603) ## [2.0 Beta 8] - 2018-11-03 ### Changed -* Revised the [Simple Deployment Template](http://docs.bigchaindb.com/projects/server/en/latest/simple-deployment-template/index.html) in the docs. Added NGINX to the mix. Pull Requests [#2578](https://github.com/bigchaindb/bigchaindb/pull/2578) and [#2579](https://github.com/bigchaindb/bigchaindb/pull/2579) -* Revised `nginx/nginx.conf` to enable CORS. [Pull Request #2580](https://github.com/bigchaindb/bigchaindb/pull/2580) +* Revised the [Simple Deployment Template](http://docs.corechaindb.com/projects/server/en/latest/simple-deployment-template/index.html) in the docs. Added NGINX to the mix. Pull Requests [#2578](https://github.com/corechaindb/corechaindb/pull/2578) and [#2579](https://github.com/corechaindb/corechaindb/pull/2579) +* Revised `nginx/nginx.conf` to enable CORS. [Pull Request #2580](https://github.com/corechaindb/corechaindb/pull/2580) ### Fixed -* Fixed a typo in the Kubernetes ConfigMap template. [Pull Request #2583](https://github.com/bigchaindb/bigchaindb/pull/2583) +* Fixed a typo in the Kubernetes ConfigMap template. [Pull Request #2583](https://github.com/corechaindb/corechaindb/pull/2583) ### External Contributors -[@gamjapark](https://github.com/gamjapark) translated the main `README.md` file into Korean. [Pull Request #2592](https://github.com/bigchaindb/bigchaindb/pull/2592) +[@gamjapark](https://github.com/gamjapark) translated the main `README.md` file into Korean. [Pull Request #2592](https://github.com/corechaindb/corechaindb/pull/2592) ## [2.0 Beta 7] - 2018-09-28 @@ -99,24 +99,24 @@ Tag name: v2.0.0b7 ### Added -Completed the implementation of chain-migration elections (BEP-42). Pull requests [#2553](https://github.com/bigchaindb/bigchaindb/pull/2553), [#2556](https://github.com/bigchaindb/bigchaindb/pull/2556), [#2558](https://github.com/bigchaindb/bigchaindb/pull/2558), [#2563](https://github.com/bigchaindb/bigchaindb/pull/2563) and [#2566](https://github.com/bigchaindb/bigchaindb/pull/2566) +Completed the implementation of chain-migration elections (BEP-42). Pull requests [#2553](https://github.com/corechaindb/corechaindb/pull/2553), [#2556](https://github.com/corechaindb/corechaindb/pull/2556), [#2558](https://github.com/corechaindb/corechaindb/pull/2558), [#2563](https://github.com/corechaindb/corechaindb/pull/2563) and [#2566](https://github.com/corechaindb/corechaindb/pull/2566) ### Changed -* Code that used the Python driver's (deprecated) transactions.send() method now uses its transactions.send_commit() method instead. [Pull request #2547](https://github.com/bigchaindb/bigchaindb/pull/2547) -* Code that implied pluggable "consensus" now implies pluggable transaction "validation" (a more accurate word). [Pull request #2561](https://github.com/bigchaindb/bigchaindb/pull/2561) +* Code that used the Python driver's (deprecated) transactions.send() method now uses its transactions.send_commit() method instead. [Pull request #2547](https://github.com/corechaindb/corechaindb/pull/2547) +* Code that implied pluggable "consensus" now implies pluggable transaction "validation" (a more accurate word). [Pull request #2561](https://github.com/corechaindb/corechaindb/pull/2561) ### Removed -Benchmark logs. [Pull request #2565](https://github.com/bigchaindb/bigchaindb/pull/2565) +Benchmark logs. [Pull request #2565](https://github.com/corechaindb/corechaindb/pull/2565) ### Fixed -A bug caused by an incorrect MongoDB query. [Pull request #2567](https://github.com/bigchaindb/bigchaindb/pull/2567) +A bug caused by an incorrect MongoDB query. [Pull request #2567](https://github.com/corechaindb/corechaindb/pull/2567) ### Notes -There's now better documentation about logs, log rotation, and the `server.bind` config setting. Pull requests [#2546](https://github.com/bigchaindb/bigchaindb/pull/2546) and [#2575](https://github.com/bigchaindb/bigchaindb/pull/2575) +There's now better documentation about logs, log rotation, and the `server.bind` config setting. Pull requests [#2546](https://github.com/corechaindb/corechaindb/pull/2546) and [#2575](https://github.com/corechaindb/corechaindb/pull/2575) ## [2.0 Beta 6] - 2018-09-17 @@ -124,49 +124,49 @@ Tag name: v2.0.0b6 ### Added -* [New documentation about privacy and handling private data](https://docs.bigchaindb.com/en/latest/private-data.html). [Pull request #2437](https://github.com/bigchaindb/bigchaindb/pull/2437) -* New documentation about log rotation. Also rotate Tendermint logs if started using Monit. [Pull request #2528](https://github.com/bigchaindb/bigchaindb/pull/2528) -* Began implementing one of the migration strategies outlined in [BEP-42](https://github.com/bigchaindb/BEPs/tree/master/42). That involved creating a more general-purpose election process and commands. Pull requests [#2488](https://github.com/bigchaindb/bigchaindb/pull/2488), [#2495](https://github.com/bigchaindb/bigchaindb/pull/2495), [#2498](https://github.com/bigchaindb/bigchaindb/pull/2498), [#2515](https://github.com/bigchaindb/bigchaindb/pull/2515), [#2535](https://github.com/bigchaindb/bigchaindb/pull/2535) -* Used memoization to avoid doing some validation checks multiple times. [Pull request #2490](https://github.com/bigchaindb/bigchaindb/pull/2490) -* Created an all-in-one Docker image containing BigchainDB Server, Tendermint and MongoDB. It was created for a particular user and is not recommended for production use unless you really know what you're doing. [Pull request #2424](https://github.com/bigchaindb/bigchaindb/pull/2424) +* [New documentation about privacy and handling private data](https://docs.corechaindb.com/en/latest/private-data.html). [Pull request #2437](https://github.com/corechaindb/corechaindb/pull/2437) +* New documentation about log rotation. Also rotate Tendermint logs if started using Monit. [Pull request #2528](https://github.com/corechaindb/corechaindb/pull/2528) +* Began implementing one of the migration strategies outlined in [BEP-42](https://github.com/corechaindb/BEPs/tree/master/42). That involved creating a more general-purpose election process and commands. Pull requests [#2488](https://github.com/corechaindb/corechaindb/pull/2488), [#2495](https://github.com/corechaindb/corechaindb/pull/2495), [#2498](https://github.com/corechaindb/corechaindb/pull/2498), [#2515](https://github.com/corechaindb/corechaindb/pull/2515), [#2535](https://github.com/corechaindb/corechaindb/pull/2535) +* Used memoization to avoid doing some validation checks multiple times. [Pull request #2490](https://github.com/corechaindb/corechaindb/pull/2490) +* Created an all-in-one Docker image containing BigchainDB Server, Tendermint and MongoDB. It was created for a particular user and is not recommended for production use unless you really know what you're doing. [Pull request #2424](https://github.com/corechaindb/corechaindb/pull/2424) ### Changed -* The supported versions of Tendermint are now hard-wired into BigchainDB Server: it checks to see what version the connected Tendermint has, and if it's not compatible, BigchainDB Server exits with an error message. [Pull request #2541](https://github.com/bigchaindb/bigchaindb/pull/2541) -* The docs no longer say to install the highest version of Tendermint: they say to install a specific version. [Pull request #2524](https://github.com/bigchaindb/bigchaindb/pull/2524) -* The setup docs include more recommended settings for `config.toml`. [Pull request #2516](https://github.com/bigchaindb/bigchaindb/pull/2516) -* The process to add, remove or update the voting power of a validator at run time (using the `bigchaindb upsert-validator` subcommands) was completely changed and is now fully working. See [issue #2372](https://github.com/bigchaindb/bigchaindb/issues/2372) and all the pull requests it references. Pull requests [#2439](https://github.com/bigchaindb/bigchaindb/pull/2439) and [#2440](https://github.com/bigchaindb/bigchaindb/pull/2440) -* The license on the documentation was changed from CC-BY-SA-4 to CC-BY-4. [Pull request #2427](https://github.com/bigchaindb/bigchaindb/pull/2427) -* Re-activated and/or updated some unit tests that had been deacivated during the migration to Tendermint. Pull requests [#2390](https://github.com/bigchaindb/bigchaindb/pull/2390), [#2415](https://github.com/bigchaindb/bigchaindb/pull/2415), [#2452](https://github.com/bigchaindb/bigchaindb/pull/24), [#2456](https://github.com/bigchaindb/bigchaindb/pull/2456) -* Updated RapidJSON to a newer, faster version. [Pull request #2470](https://github.com/bigchaindb/bigchaindb/pull/2470) -* The Java driver is now officially supported. [Pull request #2478](https://github.com/bigchaindb/bigchaindb/pull/2478) -* The MongoDB indexes on transaction id and block height were changed to be [unique indexes](https://docs.mongodb.com/manual/core/index-unique/). [Pull request #2492](https://github.com/bigchaindb/bigchaindb/pull/2492) -* Updated the required `cryptoconditions` package to a newer one. [Pull request #2494](https://github.com/bigchaindb/bigchaindb/pull/2494) +* The supported versions of Tendermint are now hard-wired into BigchainDB Server: it checks to see what version the connected Tendermint has, and if it's not compatible, BigchainDB Server exits with an error message. [Pull request #2541](https://github.com/corechaindb/corechaindb/pull/2541) +* The docs no longer say to install the highest version of Tendermint: they say to install a specific version. [Pull request #2524](https://github.com/corechaindb/corechaindb/pull/2524) +* The setup docs include more recommended settings for `config.toml`. [Pull request #2516](https://github.com/corechaindb/corechaindb/pull/2516) +* The process to add, remove or update the voting power of a validator at run time (using the `corechaindb upsert-validator` subcommands) was completely changed and is now fully working. See [issue #2372](https://github.com/corechaindb/corechaindb/issues/2372) and all the pull requests it references. Pull requests [#2439](https://github.com/corechaindb/corechaindb/pull/2439) and [#2440](https://github.com/corechaindb/corechaindb/pull/2440) +* The license on the documentation was changed from CC-BY-SA-4 to CC-BY-4. [Pull request #2427](https://github.com/corechaindb/corechaindb/pull/2427) +* Re-activated and/or updated some unit tests that had been deacivated during the migration to Tendermint. Pull requests [#2390](https://github.com/corechaindb/corechaindb/pull/2390), [#2415](https://github.com/corechaindb/corechaindb/pull/2415), [#2452](https://github.com/corechaindb/corechaindb/pull/24), [#2456](https://github.com/corechaindb/corechaindb/pull/2456) +* Updated RapidJSON to a newer, faster version. [Pull request #2470](https://github.com/corechaindb/corechaindb/pull/2470) +* The Java driver is now officially supported. [Pull request #2478](https://github.com/corechaindb/corechaindb/pull/2478) +* The MongoDB indexes on transaction id and block height were changed to be [unique indexes](https://docs.mongodb.com/manual/core/index-unique/). [Pull request #2492](https://github.com/corechaindb/corechaindb/pull/2492) +* Updated the required `cryptoconditions` package to a newer one. [Pull request #2494](https://github.com/corechaindb/corechaindb/pull/2494) ### Removed * Removed some old code and tests. Pull requests - [#2374](https://github.com/bigchaindb/bigchaindb/pull/2374), - [#2452](https://github.com/bigchaindb/bigchaindb/pull/2452), - [#2474](https://github.com/bigchaindb/bigchaindb/pull/2474), - [#2476](https://github.com/bigchaindb/bigchaindb/pull/2476), - [#2491](https://github.com/bigchaindb/bigchaindb/pull/2491) + [#2374](https://github.com/corechaindb/corechaindb/pull/2374), + [#2452](https://github.com/corechaindb/corechaindb/pull/2452), + [#2474](https://github.com/corechaindb/corechaindb/pull/2474), + [#2476](https://github.com/corechaindb/corechaindb/pull/2476), + [#2491](https://github.com/corechaindb/corechaindb/pull/2491) ### Fixed -* Fixed the Events API so that it only sends valid transactions to subscribers. Also changed how it works internally, so now it is more reliable. [Pull request #2529](https://github.com/bigchaindb/bigchaindb/pull/2529) -* Fixed a bug where MongoDB database initialization would abort if a collection already existed. [Pull request #2520](https://github.com/bigchaindb/bigchaindb/pull/2520) -* Fixed a unit test that was failing randomly. [Pull request #2423](https://github.com/bigchaindb/bigchaindb/pull/2423) -* Fixed the validator curl port. [Pull request #2447](https://github.com/bigchaindb/bigchaindb/pull/2447) -* Fixed an error in the docs about the HTTP POST /transactions endpoint. [Pull request #2481](https://github.com/bigchaindb/bigchaindb/pull/2481) -* Fixed a unit test that could loop forever. [Pull requqest #2486](https://github.com/bigchaindb/bigchaindb/pull/2486) -* Fixed a bug when validating a CREATE + TRANSFER. [Pull request #2487](https://github.com/bigchaindb/bigchaindb/pull/2487) -* Fixed the HTTP response when posting a transaction in commit mode. [Pull request #2510](https://github.com/bigchaindb/bigchaindb/pull/2510) -* Fixed a crash that happened when attempting to restart BigchainDB at Tendermint block height 1. [Pull request#2519](https://github.com/bigchaindb/bigchaindb/pull/2519) +* Fixed the Events API so that it only sends valid transactions to subscribers. Also changed how it works internally, so now it is more reliable. [Pull request #2529](https://github.com/corechaindb/corechaindb/pull/2529) +* Fixed a bug where MongoDB database initialization would abort if a collection already existed. [Pull request #2520](https://github.com/corechaindb/corechaindb/pull/2520) +* Fixed a unit test that was failing randomly. [Pull request #2423](https://github.com/corechaindb/corechaindb/pull/2423) +* Fixed the validator curl port. [Pull request #2447](https://github.com/corechaindb/corechaindb/pull/2447) +* Fixed an error in the docs about the HTTP POST /transactions endpoint. [Pull request #2481](https://github.com/corechaindb/corechaindb/pull/2481) +* Fixed a unit test that could loop forever. [Pull requqest #2486](https://github.com/corechaindb/corechaindb/pull/2486) +* Fixed a bug when validating a CREATE + TRANSFER. [Pull request #2487](https://github.com/corechaindb/corechaindb/pull/2487) +* Fixed the HTTP response when posting a transaction in commit mode. [Pull request #2510](https://github.com/corechaindb/corechaindb/pull/2510) +* Fixed a crash that happened when attempting to restart BigchainDB at Tendermint block height 1. [Pull request#2519](https://github.com/corechaindb/corechaindb/pull/2519) ### External Contributors -@danacr - [Pull request #2447](https://github.com/bigchaindb/bigchaindb/pull/2447) +@danacr - [Pull request #2447](https://github.com/corechaindb/corechaindb/pull/2447) ### Notes @@ -178,11 +178,11 @@ Tag name: v2.0.0b5 ### Changed -* Supported version of Tendermint `0.22.3` -> `0.22.8`. [Pull request #2429](https://github.com/bigchaindb/bigchaindb/pull/2429). +* Supported version of Tendermint `0.22.3` -> `0.22.8`. [Pull request #2429](https://github.com/corechaindb/corechaindb/pull/2429). ### Fixed -* Stateful validation raises a DoubleSpend exception if there is any other transaction that spends the same output(s) even if it has the same transaction ID. [Pull request #2422](https://github.com/bigchaindb/bigchaindb/pull/2422). +* Stateful validation raises a DoubleSpend exception if there is any other transaction that spends the same output(s) even if it has the same transaction ID. [Pull request #2422](https://github.com/corechaindb/corechaindb/pull/2422). ## [2.0 Beta 4] - 2018-07-30 @@ -190,22 +190,22 @@ Tag name: v2.0.0b4 ### Added -- Added scripts for creating a configuration to manage processes with Monit. [Pull request #2410](https://github.com/bigchaindb/bigchaindb/pull/2410). +- Added scripts for creating a configuration to manage processes with Monit. [Pull request #2410](https://github.com/corechaindb/corechaindb/pull/2410). ### Fixed -- Redundant asset and metadata queries were removed. [Pull request #2409](https://github.com/bigchaindb/bigchaindb/pull/2409). -- Signal handling was fixed for BigchainDB processes. [Pull request #2395](https://github.com/bigchaindb/bigchaindb/pull/2395). -- Some of the abruptly closed sockets that used to stay in memory are being cleaned up now. [Pull request 2408](https://github.com/bigchaindb/bigchaindb/pull/2408). -- Fixed the bug when WebSockets powering Events API became unresponsive. [Pull request #2413](https://github.com/bigchaindb/bigchaindb/pull/2413). +- Redundant asset and metadata queries were removed. [Pull request #2409](https://github.com/corechaindb/corechaindb/pull/2409). +- Signal handling was fixed for BigchainDB processes. [Pull request #2395](https://github.com/corechaindb/corechaindb/pull/2395). +- Some of the abruptly closed sockets that used to stay in memory are being cleaned up now. [Pull request 2408](https://github.com/corechaindb/corechaindb/pull/2408). +- Fixed the bug when WebSockets powering Events API became unresponsive. [Pull request #2413](https://github.com/corechaindb/corechaindb/pull/2413). ### Notes: -* The instructions on how to write a BEP were simplified. [Pull request #2347](https://github.com/bigchaindb/bigchaindb/pull/2347). -* A section about troubleshooting was added to the network setup guide. [Pull request #2398](https://github.com/bigchaindb/bigchaindb/pull/2398). -* Some of the core code was given a better package structure. [Pull request #2401](https://github.com/bigchaindb/bigchaindb/pull/2401). -* Some of the previously disabled unit tests were re-enabled and updated. Pull requests [#2404](https://github.com/bigchaindb/bigchaindb/pull/2404) and [#2402](https://github.com/bigchaindb/bigchaindb/pull/2402). -* Some building blocks for dynamically adding new validators were introduced. [Pull request #2392](https://github.com/bigchaindb/bigchaindb/pull/2392). +* The instructions on how to write a BEP were simplified. [Pull request #2347](https://github.com/corechaindb/corechaindb/pull/2347). +* A section about troubleshooting was added to the network setup guide. [Pull request #2398](https://github.com/corechaindb/corechaindb/pull/2398). +* Some of the core code was given a better package structure. [Pull request #2401](https://github.com/corechaindb/corechaindb/pull/2401). +* Some of the previously disabled unit tests were re-enabled and updated. Pull requests [#2404](https://github.com/corechaindb/corechaindb/pull/2404) and [#2402](https://github.com/corechaindb/corechaindb/pull/2402). +* Some building blocks for dynamically adding new validators were introduced. [Pull request #2392](https://github.com/corechaindb/corechaindb/pull/2392). ## [2.0 Beta 3] - 2018-07-18 @@ -213,7 +213,7 @@ Tag name: v2.0.0b3 ### Fixed -Fixed a bug in transaction validation. For some more-complex situations, it would say that a valid transaction was invalid. This bug was actually fixed before; it was [issue #1271](https://github.com/bigchaindb/bigchaindb/issues/1271). The unit test for it was turned off while we integrated Tendermint. Then the query implementation code got changed, reintroducing the bug, but the unit test was off so the bug wasn't caught. When we turned the test back on, shortly after releasing Beta 2, it failed, unveiling the bug. [Pull request #2389](https://github.com/bigchaindb/bigchaindb/pull/2389) +Fixed a bug in transaction validation. For some more-complex situations, it would say that a valid transaction was invalid. This bug was actually fixed before; it was [issue #1271](https://github.com/corechaindb/corechaindb/issues/1271). The unit test for it was turned off while we integrated Tendermint. Then the query implementation code got changed, reintroducing the bug, but the unit test was off so the bug wasn't caught. When we turned the test back on, shortly after releasing Beta 2, it failed, unveiling the bug. [Pull request #2389](https://github.com/corechaindb/corechaindb/pull/2389) ## [2.0 Beta 2] - 2018-07-16 @@ -221,44 +221,44 @@ Tag name: v2.0.0b2 ### Added -* Added new configuration settings `tendermint.host` and `tendermint.port`. [Pull request #2342](https://github.com/bigchaindb/bigchaindb/pull/2342) -* Added tests to ensure that BigchainDB gracefully handles "nasty" strings in keys and values. [Pull request #2334](https://github.com/bigchaindb/bigchaindb/pull/2334) -* Added a new logging handler to capture benchmark stats to a separate file. [Pull request #2349](https://github.com/bigchaindb/bigchaindb/pull/2349) +* Added new configuration settings `tendermint.host` and `tendermint.port`. [Pull request #2342](https://github.com/corechaindb/corechaindb/pull/2342) +* Added tests to ensure that BigchainDB gracefully handles "nasty" strings in keys and values. [Pull request #2334](https://github.com/corechaindb/corechaindb/pull/2334) +* Added a new logging handler to capture benchmark stats to a separate file. [Pull request #2349](https://github.com/corechaindb/corechaindb/pull/2349) ### Changed -* Changed the names of BigchainDB processes (Python processes) to include 'bigchaindb', so they are easier to spot and find. [Pull request #2354](https://github.com/bigchaindb/bigchaindb/pull/2354) -* Updated all code to support the latest version of Tendermint. Note that the BigchainDB ABCI server now listens to port 26657 instead of 46657. Pull requests [#2375](https://github.com/bigchaindb/bigchaindb/pull/2375) and [#2380](https://github.com/bigchaindb/bigchaindb/pull/2380) +* Changed the names of BigchainDB processes (Python processes) to include 'corechaindb', so they are easier to spot and find. [Pull request #2354](https://github.com/corechaindb/corechaindb/pull/2354) +* Updated all code to support the latest version of Tendermint. Note that the BigchainDB ABCI server now listens to port 26657 instead of 46657. Pull requests [#2375](https://github.com/corechaindb/corechaindb/pull/2375) and [#2380](https://github.com/corechaindb/corechaindb/pull/2380) ### Removed -Removed all support and code for the old backlog_reassign_delay setting. [Pull request #2332](https://github.com/bigchaindb/bigchaindb/pull/2332) +Removed all support and code for the old backlog_reassign_delay setting. [Pull request #2332](https://github.com/corechaindb/corechaindb/pull/2332) ### Fixed -* Fixed a bug that sometimes arose when using Docker Compose. (Tendermint would freeze.) [Pull request #2341](https://github.com/bigchaindb/bigchaindb/pull/2341) -* Fixed a bug in the code that creates a MongoDB index for the "id" in the transactions collection. It works now, and performance is improved. [Pull request #2378](https://github.com/bigchaindb/bigchaindb/pull/2378) -* The logging server would keep runnning in some tear-down scenarios. It doesn't do that any more. [Pull request #2304](https://github.com/bigchaindb/bigchaindb/pull/2304) +* Fixed a bug that sometimes arose when using Docker Compose. (Tendermint would freeze.) [Pull request #2341](https://github.com/corechaindb/corechaindb/pull/2341) +* Fixed a bug in the code that creates a MongoDB index for the "id" in the transactions collection. It works now, and performance is improved. [Pull request #2378](https://github.com/corechaindb/corechaindb/pull/2378) +* The logging server would keep runnning in some tear-down scenarios. It doesn't do that any more. [Pull request #2304](https://github.com/corechaindb/corechaindb/pull/2304) ### External Contributors -@hrntknr - [Pull request #2331](https://github.com/bigchaindb/bigchaindb/pull/2331) +@hrntknr - [Pull request #2331](https://github.com/corechaindb/corechaindb/pull/2331) ### Known Issues -The `bigchaindb upsert-validator` subcommand is not working yet, but a solution ([BEP-21](https://github.com/bigchaindb/BEPs/tree/master/21)) has been finalized and will be implemented before we release the final BigchainDB 2.0. +The `corechaindb upsert-validator` subcommand is not working yet, but a solution ([BEP-21](https://github.com/corechaindb/BEPs/tree/master/21)) has been finalized and will be implemented before we release the final BigchainDB 2.0. ### Notes * A lot of old/dead code was deleted. Pull requests -[#2319](https://github.com/bigchaindb/bigchaindb/pull/2319), -[#2338](https://github.com/bigchaindb/bigchaindb/pull/2338), -[#2357](https://github.com/bigchaindb/bigchaindb/pull/2357), -[#2365](https://github.com/bigchaindb/bigchaindb/pull/2365), -[#2366](https://github.com/bigchaindb/bigchaindb/pull/2366), -[#2368](https://github.com/bigchaindb/bigchaindb/pull/2368) and -[#2374](https://github.com/bigchaindb/bigchaindb/pull/2374) -* Improved the documentation page "How to setup a BigchainDB Network". [Pull Request #2312](https://github.com/bigchaindb/bigchaindb/pull/2312) +[#2319](https://github.com/corechaindb/corechaindb/pull/2319), +[#2338](https://github.com/corechaindb/corechaindb/pull/2338), +[#2357](https://github.com/corechaindb/corechaindb/pull/2357), +[#2365](https://github.com/corechaindb/corechaindb/pull/2365), +[#2366](https://github.com/corechaindb/corechaindb/pull/2366), +[#2368](https://github.com/corechaindb/corechaindb/pull/2368) and +[#2374](https://github.com/corechaindb/corechaindb/pull/2374) +* Improved the documentation page "How to setup a BigchainDB Network". [Pull Request #2312](https://github.com/corechaindb/corechaindb/pull/2312) ## [2.0 Beta 1] - 2018-06-01 @@ -266,18 +266,18 @@ Tag name: v2.0.0b1 ### Fixed -* Fixed a bug that arose with some code that treated transactions-waiting-for-block-inclusion as if they were already stored in MongoDB (i.e. already in a block). [Pull request #2318](https://github.com/bigchaindb/bigchaindb/pull/2318) -* If a user asked for a block and it happened to be an empty block, BigchainDB returned 404 Not Found, as if the block did not exist. Now it returns a 200 OK with a block containing no transactions, i.e. an empty block. [Pull request #2321](https://github.com/bigchaindb/bigchaindb/pull/2321) +* Fixed a bug that arose with some code that treated transactions-waiting-for-block-inclusion as if they were already stored in MongoDB (i.e. already in a block). [Pull request #2318](https://github.com/corechaindb/corechaindb/pull/2318) +* If a user asked for a block and it happened to be an empty block, BigchainDB returned 404 Not Found, as if the block did not exist. Now it returns a 200 OK with a block containing no transactions, i.e. an empty block. [Pull request #2321](https://github.com/corechaindb/corechaindb/pull/2321) ### Known Issues -* An issue was found with the `bigchaindb upsert-validator` command. A solution was proposed in [BEP-19](https://github.com/bigchaindb/BEPs/pull/45) and is being implemented in [pull request #2314](https://github.com/bigchaindb/bigchaindb/pull/2314) +* An issue was found with the `corechaindb upsert-validator` command. A solution was proposed in [BEP-19](https://github.com/corechaindb/BEPs/pull/45) and is being implemented in [pull request #2314](https://github.com/corechaindb/corechaindb/pull/2314) * If you run BigchainDB locally using `make start` (i.e. using Docker Compose) and then you put the node under heavy write load, Tendermint can become unresponsive and running `make stop` can hang. * There seems to be one or more issues with Tendermint when it is put under heavy load (i.e. even when BigchainDB isn't involved). See Tendermint issues [#1394](https://github.com/tendermint/tendermint/issues/1394), [#1642](https://github.com/tendermint/tendermint/issues/1642) and [#1661](https://github.com/tendermint/tendermint/issues/1661) ### Notes -* There's a [new docs page](https://docs.bigchaindb.com/projects/server/en/v2.0.0b1/simple-network-setup.html) about how to set up a network where each node uses a single virtual machine. +* There's a [new docs page](https://docs.corechaindb.com/projects/server/en/v2.0.0b1/simple-network-setup.html) about how to set up a network where each node uses a single virtual machine. * We checked, and BigchainDB 2.0 Beta 1 works with MongoDB 3.6 (and 3.4). * Support for RethinkDB is completely gone. @@ -287,11 +287,11 @@ Tag name: v2.0.0a6 ### Changed -Upgraded PyMongo to version 3.6 (which is compatible with MongoDB 3.6, 3.4 [and more](https://docs.mongodb.com/ecosystem/drivers/driver-compatibility-reference/#python-driver-compatibility)). [Pull request #2298](https://github.com/bigchaindb/bigchaindb/pull/2298) +Upgraded PyMongo to version 3.6 (which is compatible with MongoDB 3.6, 3.4 [and more](https://docs.mongodb.com/ecosystem/drivers/driver-compatibility-reference/#python-driver-compatibility)). [Pull request #2298](https://github.com/corechaindb/corechaindb/pull/2298) ### Fixed -When deploying a node using our Docker Compose file, it didn't expose port 46656, which is used by Tendermint for inter-node communications, so the node couldn't communicate with other nodes. We fixed that in [pull request #2299](https://github.com/bigchaindb/bigchaindb/pull/2299) +When deploying a node using our Docker Compose file, it didn't expose port 46656, which is used by Tendermint for inter-node communications, so the node couldn't communicate with other nodes. We fixed that in [pull request #2299](https://github.com/corechaindb/corechaindb/pull/2299) ### Notes @@ -303,7 +303,7 @@ Tag name: v2.0.0a5 ### Changed -To resolve [issue #2279](https://github.com/bigchaindb/bigchaindb/issues/2279), we made some changes to the `bigchaindb-abci` package (which is our fork of `py-abci`) and told BigchainDB to use the new version (`bigchaindb-abci==0.4.5`). [Pull request #2281](https://github.com/bigchaindb/bigchaindb/pull/2281). +To resolve [issue #2279](https://github.com/corechaindb/corechaindb/issues/2279), we made some changes to the `corechaindb-abci` package (which is our fork of `py-abci`) and told BigchainDB to use the new version (`corechaindb-abci==0.4.5`). [Pull request #2281](https://github.com/corechaindb/corechaindb/pull/2281). ## [2.0 Alpha 4] - 2018-05-09 @@ -311,15 +311,15 @@ Tag name: v2.0.0a4 ### Changed -The Kubernetes liveness probe for the BigchainDB StatefulSet was improved to check the Tendermint /status endpoint in addition to the Tendermint /abci_info endpoint. [Pull request #2275](https://github.com/bigchaindb/bigchaindb/pull/2275) +The Kubernetes liveness probe for the BigchainDB StatefulSet was improved to check the Tendermint /status endpoint in addition to the Tendermint /abci_info endpoint. [Pull request #2275](https://github.com/corechaindb/corechaindb/pull/2275) ### Fixed -[Pull request #2270](https://github.com/bigchaindb/bigchaindb/pull/2270) resolved [issue #2269](https://github.com/bigchaindb/bigchaindb/issues/2269). +[Pull request #2270](https://github.com/corechaindb/corechaindb/pull/2270) resolved [issue #2269](https://github.com/corechaindb/corechaindb/issues/2269). ### Notes -There's a new [page in the docs about storing files in BigchainDB](https://docs.bigchaindb.com/en/latest/store-files.html). [Pull request #2259](https://github.com/bigchaindb/bigchaindb/pull/2259) +There's a new [page in the docs about storing files in BigchainDB](https://docs.corechaindb.com/en/latest/store-files.html). [Pull request #2259](https://github.com/corechaindb/corechaindb/pull/2259) ## [2.0 Alpha 3] - 2018-05-03 @@ -327,17 +327,17 @@ Tag name: v2.0.0a3 ### Changed -* Upgraded BigchainDB Server code to use the latest version of Tendermint: version 0.19.2. Pull requests [#2249](https://github.com/bigchaindb/bigchaindb/pull/2249), [#2252](https://github.com/bigchaindb/bigchaindb/pull/2252) and [#2253](https://github.com/bigchaindb/bigchaindb/pull/2253) -* Made some fixes to `py-abci` (an external Python package) and used our fixed version with BigchainDB. Those fixes resolved several known issues, including [issue #2182](https://github.com/bigchaindb/bigchaindb/issues/2182) and issues with large transactions in general. Note: At the time of writing, our fixes to `py-abci` hadn't been merged into the main `py-abci` repository or its latest release on PyPI; we were using our own special `bigchaindb-abci` package (which included our fixes). Pull requests [#2250](https://github.com/bigchaindb/bigchaindb/pull/2250) and [#2261](https://github.com/bigchaindb/bigchaindb/pull/2261) -* If BigchainDB Server crashes and then comes back, Tendermint Core doesn't try to reconnect to it. That's just how Tendermint Core works. We revised our Kubernetes-based production deployment template to resolve that issue: BigchainDB Server and Tendermint Core are now in the same Kubernetes StatefulSet; if the connection between them ever goes down, then Kubernetes restarts the whole StatefulSet. [Pull request #2242](https://github.com/bigchaindb/bigchaindb/pull/2242) +* Upgraded BigchainDB Server code to use the latest version of Tendermint: version 0.19.2. Pull requests [#2249](https://github.com/corechaindb/corechaindb/pull/2249), [#2252](https://github.com/corechaindb/corechaindb/pull/2252) and [#2253](https://github.com/corechaindb/corechaindb/pull/2253) +* Made some fixes to `py-abci` (an external Python package) and used our fixed version with BigchainDB. Those fixes resolved several known issues, including [issue #2182](https://github.com/corechaindb/corechaindb/issues/2182) and issues with large transactions in general. Note: At the time of writing, our fixes to `py-abci` hadn't been merged into the main `py-abci` repository or its latest release on PyPI; we were using our own special `corechaindb-abci` package (which included our fixes). Pull requests [#2250](https://github.com/corechaindb/corechaindb/pull/2250) and [#2261](https://github.com/corechaindb/corechaindb/pull/2261) +* If BigchainDB Server crashes and then comes back, Tendermint Core doesn't try to reconnect to it. That's just how Tendermint Core works. We revised our Kubernetes-based production deployment template to resolve that issue: BigchainDB Server and Tendermint Core are now in the same Kubernetes StatefulSet; if the connection between them ever goes down, then Kubernetes restarts the whole StatefulSet. [Pull request #2242](https://github.com/corechaindb/corechaindb/pull/2242) ### Fixed -Re-enabled multi-threading. [Pull request #2258](https://github.com/bigchaindb/bigchaindb/pull/2258) +Re-enabled multi-threading. [Pull request #2258](https://github.com/corechaindb/corechaindb/pull/2258) ### Known Issues -Tendermint changed how it responds to a request to store data (via the [Tendermint Broadcast API](https://tendermint.com/docs/tendermint-core/using-tendermint.html#broadcast-api)) between version 0.12 and 0.19.2. We started modifying the code of BigchainDB Server to account for those changes in responses (in [pull request #2239](https://github.com/bigchaindb/bigchaindb/pull/2239)), but we found that there's a difference between what the Tendermint documentation _says_ about those responses and how Tendermint actually responds. We need to determine Tendermint's intent before we can finalize that pull request. +Tendermint changed how it responds to a request to store data (via the [Tendermint Broadcast API](https://tendermint.com/docs/tendermint-core/using-tendermint.html#broadcast-api)) between version 0.12 and 0.19.2. We started modifying the code of BigchainDB Server to account for those changes in responses (in [pull request #2239](https://github.com/corechaindb/corechaindb/pull/2239)), but we found that there's a difference between what the Tendermint documentation _says_ about those responses and how Tendermint actually responds. We need to determine Tendermint's intent before we can finalize that pull request. ### Notes @@ -349,11 +349,11 @@ Tag name: v2.0.0a2 ### Added -An implementation of [BEP-8 (BigchainDB Enhancement Proposal #8)](https://github.com/bigchaindb/BEPs/tree/master/8), which makes sure a node can recover from a system fault (e.g. a crash) into a consistent state, i.e. a state where the data in the node's local MongoDB database is consistent with the data stored in the blockchain. Pull requests [#2135](https://github.com/bigchaindb/bigchaindb/pull/2135) and [#2207](https://github.com/bigchaindb/bigchaindb/pull/2207) +An implementation of [BEP-8 (BigchainDB Enhancement Proposal #8)](https://github.com/corechaindb/BEPs/tree/master/8), which makes sure a node can recover from a system fault (e.g. a crash) into a consistent state, i.e. a state where the data in the node's local MongoDB database is consistent with the data stored in the blockchain. Pull requests [#2135](https://github.com/corechaindb/corechaindb/pull/2135) and [#2207](https://github.com/corechaindb/corechaindb/pull/2207) ### Changed -When someone uses the HTTP API to send a new transaction to a BigchainDB network using the [POST /api/v1/transactions?mode={mode}](https://docs.bigchaindb.com/projects/server/en/master/http-client-server-api.html#post--api-v1-transactions?mode=mode) endpoint, they now get back a more informative HTTP response, so they can better-understand what happened. This is only when mode is `commit` or `sync`, because `async` _means_ that the response is immediate, without waiting to see what happened to the transaction. [Pull request #2198](https://github.com/bigchaindb/bigchaindb/pull/2198) +When someone uses the HTTP API to send a new transaction to a BigchainDB network using the [POST /api/v1/transactions?mode={mode}](https://docs.corechaindb.com/projects/server/en/master/http-client-server-api.html#post--api-v1-transactions?mode=mode) endpoint, they now get back a more informative HTTP response, so they can better-understand what happened. This is only when mode is `commit` or `sync`, because `async` _means_ that the response is immediate, without waiting to see what happened to the transaction. [Pull request #2198](https://github.com/corechaindb/corechaindb/pull/2198) ### Known Issues @@ -366,15 +366,15 @@ Tag name: v2.0.0a1 There were _many_ changes between 1.3 and 2.0 Alpha, too many to list here. We wrote a series of blog posts to summarize most changes, especially those that affect end users and application developers: -* [BigchainDB 2.0 is Byzantine Fault Tolerant](https://blog.bigchaindb.com/bigchaindb-2-0-is-byzantine-fault-tolerant-5ffdac96bc44) -* [Some HTTP API Changes in the Next Release](https://blog.bigchaindb.com/some-http-api-changes-in-the-next-release-49612a537b0c) -* [Three Transaction Model Changes in the Next Release](https://blog.bigchaindb.com/three-transaction-model-changes-in-the-next-release-dadbac50094a) -* [Changes to the Server Command Line Interface in BigchainDB 2.0](https://blog.bigchaindb.com/changes-to-the-server-command-line-interface-in-bigchaindb-2-0-e1d6576e7155) +* [BigchainDB 2.0 is Byzantine Fault Tolerant](https://blog.corechaindb.com/corechaindb-2-0-is-byzantine-fault-tolerant-5ffdac96bc44) +* [Some HTTP API Changes in the Next Release](https://blog.corechaindb.com/some-http-api-changes-in-the-next-release-49612a537b0c) +* [Three Transaction Model Changes in the Next Release](https://blog.corechaindb.com/three-transaction-model-changes-in-the-next-release-dadbac50094a) +* [Changes to the Server Command Line Interface in BigchainDB 2.0](https://blog.corechaindb.com/changes-to-the-server-command-line-interface-in-corechaindb-2-0-e1d6576e7155) * _A forthcoming post about changes in BigchainDB Server configuration settings_ ### External Contributors -* @r7vme contributed [pull request #1984](https://github.com/bigchaindb/bigchaindb/pull/1984) which fixed a bug in our Kubernetes-based production deployment template. +* @r7vme contributed [pull request #1984](https://github.com/corechaindb/corechaindb/pull/1984) which fixed a bug in our Kubernetes-based production deployment template. ### Known Issues @@ -387,28 +387,28 @@ We intend to resolve these issues before releasing the final BigchainDB 2.0: Tag name: v1.3.0 ### Added -* Metadata full-text search. [Pull request #1812](https://github.com/bigchaindb/bigchaindb/pull/1812) +* Metadata full-text search. [Pull request #1812](https://github.com/corechaindb/corechaindb/pull/1812) ### Notes -* Improved documentation about blocks and votes. [Pull request #1855](https://github.com/bigchaindb/bigchaindb/pull/1855) +* Improved documentation about blocks and votes. [Pull request #1855](https://github.com/corechaindb/corechaindb/pull/1855) ## [1.2] - 2017-11-13 Tag name: v1.2.0 ### Added -* New and improved installation setup docs and code. Pull requests [#1775](https://github.com/bigchaindb/bigchaindb/pull/1775) and [#1785](https://github.com/bigchaindb/bigchaindb/pull/1785) -* New BigchainDB configuration setting to set the port number of the log server: `log.port`. [Pull request #1796](https://github.com/bigchaindb/bigchaindb/pull/1796) -* New secondary index on `id` in the bigchain table. That will make some queries execute faster. [Pull request #1803](https://github.com/bigchaindb/bigchaindb/pull/1803) -* When using MongoDB, there are some restrictions on allowed names for keys (JSON keys). Those restrictions were always there but now BigchainDB checks key names explicitly, rather than leaving that to MongoDB. Pull requests [#1807](https://github.com/bigchaindb/bigchaindb/pull/1807) and [#1811](https://github.com/bigchaindb/bigchaindb/pull/1811) -* When using MongoDB, there are some restrictions on the allowed values of "language" (if that key is used in the values of `metadata` or `asset.data`). Those restrictions were always there but now BigchainDB checks the values explicitly, rather than leaving that to MongoDB. Pull requests [#1806](https://github.com/bigchaindb/bigchaindb/pull/1806) and [#1811](https://github.com/bigchaindb/bigchaindb/pull/1811) -* There's a new page in the root docs about permissions in BigchainDB. [Pull request #1788](https://github.com/bigchaindb/bigchaindb/pull/1788) -* There's a new option in the `bigchaindb start` command: `bigchaindb start --no-init` will avoid doing `bigchaindb init` if it wasn't done already. [Pull request #1814](https://github.com/bigchaindb/bigchaindb/pull/1814) +* New and improved installation setup docs and code. Pull requests [#1775](https://github.com/corechaindb/corechaindb/pull/1775) and [#1785](https://github.com/corechaindb/corechaindb/pull/1785) +* New BigchainDB configuration setting to set the port number of the log server: `log.port`. [Pull request #1796](https://github.com/corechaindb/corechaindb/pull/1796) +* New secondary index on `id` in the bigchain table. That will make some queries execute faster. [Pull request #1803](https://github.com/corechaindb/corechaindb/pull/1803) +* When using MongoDB, there are some restrictions on allowed names for keys (JSON keys). Those restrictions were always there but now BigchainDB checks key names explicitly, rather than leaving that to MongoDB. Pull requests [#1807](https://github.com/corechaindb/corechaindb/pull/1807) and [#1811](https://github.com/corechaindb/corechaindb/pull/1811) +* When using MongoDB, there are some restrictions on the allowed values of "language" (if that key is used in the values of `metadata` or `asset.data`). Those restrictions were always there but now BigchainDB checks the values explicitly, rather than leaving that to MongoDB. Pull requests [#1806](https://github.com/corechaindb/corechaindb/pull/1806) and [#1811](https://github.com/corechaindb/corechaindb/pull/1811) +* There's a new page in the root docs about permissions in BigchainDB. [Pull request #1788](https://github.com/corechaindb/corechaindb/pull/1788) +* There's a new option in the `corechaindb start` command: `corechaindb start --no-init` will avoid doing `corechaindb init` if it wasn't done already. [Pull request #1814](https://github.com/corechaindb/corechaindb/pull/1814) ### Fixed -* Fixed a bug where setting the log level in a BigchainDB config file didn't have any effect. It does now. [Pull request #1797](https://github.com/bigchaindb/bigchaindb/pull/1797) -* The docs were wrong about there being no Ping/Pong support in the Events API. There is, so the docs were fixed. [Pull request #1799](https://github.com/bigchaindb/bigchaindb/pull/1799) -* Fixed an issue with closing WebSocket connections properly. [Pull request #1819](https://github.com/bigchaindb/bigchaindb/pull/1819) +* Fixed a bug where setting the log level in a BigchainDB config file didn't have any effect. It does now. [Pull request #1797](https://github.com/corechaindb/corechaindb/pull/1797) +* The docs were wrong about there being no Ping/Pong support in the Events API. There is, so the docs were fixed. [Pull request #1799](https://github.com/corechaindb/corechaindb/pull/1799) +* Fixed an issue with closing WebSocket connections properly. [Pull request #1819](https://github.com/corechaindb/corechaindb/pull/1819) ### Notes * Many changes were made to the Kubernetes-based production deployment template and code. @@ -418,26 +418,26 @@ Tag name: v1.2.0 Tag name: v1.1.0 ### Added -* Support for server-side plugins that can add support for alternate event consumers (other than the WebSocket API). [Pull request #1707](https://github.com/bigchaindb/bigchaindb/pull/1707) -* New configuration settings to set the *advertised* wsserver scheme, host and port. (The *advertised* ones are the ones that external users use to connect to the WebSocket API.) [Pull request #1703](https://github.com/bigchaindb/bigchaindb/pull/1703) -* Support for secure (TLS) WebSocket connections. [Pull request #1619](https://github.com/bigchaindb/bigchaindb/pull/1619) -* A new page of documentation about the contents of a condition (inside a transaction). [Pull request #1668](https://github.com/bigchaindb/bigchaindb/pull/1668) +* Support for server-side plugins that can add support for alternate event consumers (other than the WebSocket API). [Pull request #1707](https://github.com/corechaindb/corechaindb/pull/1707) +* New configuration settings to set the *advertised* wsserver scheme, host and port. (The *advertised* ones are the ones that external users use to connect to the WebSocket API.) [Pull request #1703](https://github.com/corechaindb/corechaindb/pull/1703) +* Support for secure (TLS) WebSocket connections. [Pull request #1619](https://github.com/corechaindb/corechaindb/pull/1619) +* A new page of documentation about the contents of a condition (inside a transaction). [Pull request #1668](https://github.com/corechaindb/corechaindb/pull/1668) ### Changed -* We updated our definition of the **public API** (at the top of this document). [Pull request #1700](https://github.com/bigchaindb/bigchaindb/pull/1700) -* The HTTP API Logger now logs the request path and method as well. [Pull request #1644](https://github.com/bigchaindb/bigchaindb/pull/1644) +* We updated our definition of the **public API** (at the top of this document). [Pull request #1700](https://github.com/corechaindb/corechaindb/pull/1700) +* The HTTP API Logger now logs the request path and method as well. [Pull request #1644](https://github.com/corechaindb/corechaindb/pull/1644) ### External Contributors -* @carchrae - [Pull request #1731](https://github.com/bigchaindb/bigchaindb/pull/1731) -* @ivanbakel - [Pull request #1706](https://github.com/bigchaindb/bigchaindb/pull/1706) -* @ketanbhatt - Pull requests [#1643](https://github.com/bigchaindb/bigchaindb/pull/1643) and [#1644](https://github.com/bigchaindb/bigchaindb/pull/1644) +* @carchrae - [Pull request #1731](https://github.com/corechaindb/corechaindb/pull/1731) +* @ivanbakel - [Pull request #1706](https://github.com/corechaindb/corechaindb/pull/1706) +* @ketanbhatt - Pull requests [#1643](https://github.com/corechaindb/corechaindb/pull/1643) and [#1644](https://github.com/corechaindb/corechaindb/pull/1644) ### Notes * New drivers & tools from our community: - * [Java driver](https://github.com/authenteq/java-bigchaindb-driver), by [Authenteq](https://authenteq.com/) - * [Ruby library](https://rubygems.org/gems/bigchaindb), by @nileshtrivedi + * [Java driver](https://github.com/authenteq/java-corechaindb-driver), by [Authenteq](https://authenteq.com/) + * [Ruby library](https://rubygems.org/gems/corechaindb), by @nileshtrivedi * Many improvements to our production deployment template (which uses Kubernetes). -* The production deployment template for the multi-node case was out of date. We updated that and verified it. [Pull request #1713](https://github.com/bigchaindb/bigchaindb/pull/1713) +* The production deployment template for the multi-node case was out of date. We updated that and verified it. [Pull request #1713](https://github.com/corechaindb/corechaindb/pull/1713) ## [1.0.1] - 2017-07-13 @@ -445,14 +445,14 @@ Tag name: v1.0.1 ### Fixed * Various issues in the Quickstart page. Pull requests - [#1641](https://github.com/bigchaindb/bigchaindb/pull/1641) and - [#1648](https://github.com/bigchaindb/bigchaindb/pull/1648). + [#1641](https://github.com/corechaindb/corechaindb/pull/1641) and + [#1648](https://github.com/corechaindb/corechaindb/pull/1648). * Changefeed hanging when MongoDB primary node is turned off. - [Pull request #1638](https://github.com/bigchaindb/bigchaindb/pull/1638). + [Pull request #1638](https://github.com/corechaindb/corechaindb/pull/1638). * Missing `assets` tables for RethinkDB backend. - [Pull request #1646](https://github.com/bigchaindb/bigchaindb/pull/1646). + [Pull request #1646](https://github.com/corechaindb/corechaindb/pull/1646). * Cryptoconditions version mismatch. - [Pull request #1659](https://github.com/bigchaindb/bigchaindb/pull/1659). + [Pull request #1659](https://github.com/corechaindb/corechaindb/pull/1659). ## [1.0.0] - 2017-07-05 @@ -462,13 +462,13 @@ Tag name: v1.0.0 ### Changed * The file name of the upgrade guide changed from `docs/upgrade-guides/v0.10-->v1.0.md` to `docs/upgrade-guides/v0.10-v1.0.md`. -* In `transaction.inputs[n].fulfills`, `output` was renamed to `output_index`. [Pull Request #1596](https://github.com/bigchaindb/bigchaindb/pull/1596) -* In `transaction.outputs[n].condition.details`, 1) `signature` was removed (from signature conditions) and 2) `subfulfillments` was renamed to `subconditions` (in threshold conditions). [Pull Request #1589](https://github.com/bigchaindb/bigchaindb/pull/1589) -* Refined transaction schema validation to check that the `transaction.outputs[n].condition.uri` corresponds to a condition that BigchainDB Server 1.0.0 actually supports. [Pull Request #1597](https://github.com/bigchaindb/bigchaindb/pull/1597) -* Before, GET requests (to the HTTP API) with header `Content-Type: 'application/json'` would get a response with the message, "The browser (or proxy) sent a request that this server could not understand." Now, if a GET request includes a `Content-Type` header, that header gets deleted (i.e. ignored). [Pull Request #1630](https://github.com/bigchaindb/bigchaindb/pull/1630) +* In `transaction.inputs[n].fulfills`, `output` was renamed to `output_index`. [Pull Request #1596](https://github.com/corechaindb/corechaindb/pull/1596) +* In `transaction.outputs[n].condition.details`, 1) `signature` was removed (from signature conditions) and 2) `subfulfillments` was renamed to `subconditions` (in threshold conditions). [Pull Request #1589](https://github.com/corechaindb/corechaindb/pull/1589) +* Refined transaction schema validation to check that the `transaction.outputs[n].condition.uri` corresponds to a condition that BigchainDB Server 1.0.0 actually supports. [Pull Request #1597](https://github.com/corechaindb/corechaindb/pull/1597) +* Before, GET requests (to the HTTP API) with header `Content-Type: 'application/json'` would get a response with the message, "The browser (or proxy) sent a request that this server could not understand." Now, if a GET request includes a `Content-Type` header, that header gets deleted (i.e. ignored). [Pull Request #1630](https://github.com/corechaindb/corechaindb/pull/1630) ### Fixed -* If an end user sends a transaction with `operation` equal to `GENESIS`, it will be rejected as invalid. [Pull Request #1612](https://github.com/bigchaindb/bigchaindb/pull/1612) +* If an end user sends a transaction with `operation` equal to `GENESIS`, it will be rejected as invalid. [Pull Request #1612](https://github.com/corechaindb/corechaindb/pull/1612) ## [1.0.0rc1] - 2017-06-23 @@ -476,54 +476,54 @@ Tag name: v1.0.0rc1 ### Added * Support for secure TLS/SSL communication between MongoDB and {BigchainDB, MongoDB Backup Agent, MongoDB Monitoring Agent}. Pull Requests -[#1456](https://github.com/bigchaindb/bigchaindb/pull/1456), -[#1497](https://github.com/bigchaindb/bigchaindb/pull/1497), -[#1510](https://github.com/bigchaindb/bigchaindb/pull/1510), -[#1536](https://github.com/bigchaindb/bigchaindb/pull/1536), -[#1551](https://github.com/bigchaindb/bigchaindb/pull/1551) and -[#1552](https://github.com/bigchaindb/bigchaindb/pull/1552). -* Text search support (only if using MongoDB). Pull Requests [#1469](https://github.com/bigchaindb/bigchaindb/pull/1469) and [#1471](https://github.com/bigchaindb/bigchaindb/pull/1471) -* The `database.connection_timeout` configuration setting now works with RethinkDB too. [#1512](https://github.com/bigchaindb/bigchaindb/pull/1512) -* New code and tools for benchmarking CREATE transactions. [Pull Request #1511](https://github.com/bigchaindb/bigchaindb/pull/1511) +[#1456](https://github.com/corechaindb/corechaindb/pull/1456), +[#1497](https://github.com/corechaindb/corechaindb/pull/1497), +[#1510](https://github.com/corechaindb/corechaindb/pull/1510), +[#1536](https://github.com/corechaindb/corechaindb/pull/1536), +[#1551](https://github.com/corechaindb/corechaindb/pull/1551) and +[#1552](https://github.com/corechaindb/corechaindb/pull/1552). +* Text search support (only if using MongoDB). Pull Requests [#1469](https://github.com/corechaindb/corechaindb/pull/1469) and [#1471](https://github.com/corechaindb/corechaindb/pull/1471) +* The `database.connection_timeout` configuration setting now works with RethinkDB too. [#1512](https://github.com/corechaindb/corechaindb/pull/1512) +* New code and tools for benchmarking CREATE transactions. [Pull Request #1511](https://github.com/corechaindb/corechaindb/pull/1511) ### Changed -* There's an upgrade guide in `docs/upgrade-guides/v0.10-->v1.0.md`. It only covers changes to the transaction model and HTTP API. If that file hasn't been merged yet, see [Pull Request #1547](https://github.com/bigchaindb/bigchaindb/pull/1547) -* Cryptographic signatures now sign the whole (serialized) transaction body, including the transaction ID, but with all `"fulfillment"` values changed to `None`. [Pull Request #1225](https://github.com/bigchaindb/bigchaindb/pull/1225) -* In transactions, the value of `"amount"` must be a string. (Before, it was supposed to be a number.) [Pull Request #1286](https://github.com/bigchaindb/bigchaindb/pull/1286) -* In `setup.py`, the "Development Status" (as reported on PyPI) was changed from Alpha to Beta. [Pull Request #1437](https://github.com/bigchaindb/bigchaindb/pull/1437) -* If you explicitly specify a config file, e.g. `bigchaindb -c path/to/config start` and that file can't be found, then BigchainDB Server will fail with a helpful error message. [Pull Request #1486](https://github.com/bigchaindb/bigchaindb/pull/1486) -* Reduced the response time on the HTTP API endpoint to get all the unspent outputs associated with a given public key (a.k.a. "fast unspents"). [Pull Request #1411](https://github.com/bigchaindb/bigchaindb/pull/1411) -* Internally, the value of an asset's `"data"` is now stored in a separate assets table. This enabled the new text search. Each asset data is stored along with the associated CREATE transaction ID (asset ID). That data gets written when the containing block gets written to the bigchain table. [Pull Request #1460](https://github.com/bigchaindb/bigchaindb/pull/1460) -* Schema validation was sped up by switching to `rapidjson-schema`. [Pull Request #1494](https://github.com/bigchaindb/bigchaindb/pull/1494) -* If a node comes back from being down for a while, it will resume voting on blocks in the order determined by the MongoDB oplog, in the case of MongoDB. (In the case of RethinkDB, blocks missed in the changefeed will not be voted on.) [Pull Request #1389](https://github.com/bigchaindb/bigchaindb/pull/1389) -* Parallelized transaction schema validation in the vote pipeline. [Pull Request #1492](https://github.com/bigchaindb/bigchaindb/pull/1492) -* `asset.data` or `asset.id` are now *required* in a CREATE or TRANSFER transaction, respectively. [Pull Request #1518](https://github.com/bigchaindb/bigchaindb/pull/1518) -* The HTTP response body, in the response to the `GET /` and the `GET /api/v1` endpoints, was changed substantially. [Pull Request #1529](https://github.com/bigchaindb/bigchaindb/pull/1529) -* Changed the HTTP `GET /api/v1/transactions/{transaction_id}` endpoint. It now only returns the transaction if it's in a valid block. It also returns a new header with a relative link to a status monitor. [Pull Request #1543](https://github.com/bigchaindb/bigchaindb/pull/1543) -* All instances of `txid` and `tx_id` were replaced with `transaction_id`, in the transaction model and the HTTP API. [Pull Request #1532](https://github.com/bigchaindb/bigchaindb/pull/1532) -* The hostname and port were removed from all URLs in all HTTP API responses. [Pull Request #1538](https://github.com/bigchaindb/bigchaindb/pull/1538) -* Relative links were replaced with JSON objects in HTTP API responses. [Pull Request #1541](https://github.com/bigchaindb/bigchaindb/pull/1541) -* In the outputs endpoint of the HTTP API, the query parameter `unspent` was changed to `spent` (so no more double negatives). If that query parameter isn't included, then all outputs matching the specificed public key will be returned. If `spent=true`, then only the spent outputs will be returned. If `spent=false`, then only the unspent outputs will be returned. [Pull Request #1545](https://github.com/bigchaindb/bigchaindb/pull/1545) -* The supported crypto-conditions changed from version 01 of the crypto-conditions spec to version 02. [Pull Request #1562](https://github.com/bigchaindb/bigchaindb/pull/1562) -* The value of "version" inside a transaction must now be "1.0". (Before, it could be "0.anything".) [Pull Request #1574](https://github.com/bigchaindb/bigchaindb/pull/1574) +* There's an upgrade guide in `docs/upgrade-guides/v0.10-->v1.0.md`. It only covers changes to the transaction model and HTTP API. If that file hasn't been merged yet, see [Pull Request #1547](https://github.com/corechaindb/corechaindb/pull/1547) +* Cryptographic signatures now sign the whole (serialized) transaction body, including the transaction ID, but with all `"fulfillment"` values changed to `None`. [Pull Request #1225](https://github.com/corechaindb/corechaindb/pull/1225) +* In transactions, the value of `"amount"` must be a string. (Before, it was supposed to be a number.) [Pull Request #1286](https://github.com/corechaindb/corechaindb/pull/1286) +* In `setup.py`, the "Development Status" (as reported on PyPI) was changed from Alpha to Beta. [Pull Request #1437](https://github.com/corechaindb/corechaindb/pull/1437) +* If you explicitly specify a config file, e.g. `corechaindb -c path/to/config start` and that file can't be found, then BigchainDB Server will fail with a helpful error message. [Pull Request #1486](https://github.com/corechaindb/corechaindb/pull/1486) +* Reduced the response time on the HTTP API endpoint to get all the unspent outputs associated with a given public key (a.k.a. "fast unspents"). [Pull Request #1411](https://github.com/corechaindb/corechaindb/pull/1411) +* Internally, the value of an asset's `"data"` is now stored in a separate assets table. This enabled the new text search. Each asset data is stored along with the associated CREATE transaction ID (asset ID). That data gets written when the containing block gets written to the bigchain table. [Pull Request #1460](https://github.com/corechaindb/corechaindb/pull/1460) +* Schema validation was sped up by switching to `rapidjson-schema`. [Pull Request #1494](https://github.com/corechaindb/corechaindb/pull/1494) +* If a node comes back from being down for a while, it will resume voting on blocks in the order determined by the MongoDB oplog, in the case of MongoDB. (In the case of RethinkDB, blocks missed in the changefeed will not be voted on.) [Pull Request #1389](https://github.com/corechaindb/corechaindb/pull/1389) +* Parallelized transaction schema validation in the vote pipeline. [Pull Request #1492](https://github.com/corechaindb/corechaindb/pull/1492) +* `asset.data` or `asset.id` are now *required* in a CREATE or TRANSFER transaction, respectively. [Pull Request #1518](https://github.com/corechaindb/corechaindb/pull/1518) +* The HTTP response body, in the response to the `GET /` and the `GET /api/v1` endpoints, was changed substantially. [Pull Request #1529](https://github.com/corechaindb/corechaindb/pull/1529) +* Changed the HTTP `GET /api/v1/transactions/{transaction_id}` endpoint. It now only returns the transaction if it's in a valid block. It also returns a new header with a relative link to a status monitor. [Pull Request #1543](https://github.com/corechaindb/corechaindb/pull/1543) +* All instances of `txid` and `tx_id` were replaced with `transaction_id`, in the transaction model and the HTTP API. [Pull Request #1532](https://github.com/corechaindb/corechaindb/pull/1532) +* The hostname and port were removed from all URLs in all HTTP API responses. [Pull Request #1538](https://github.com/corechaindb/corechaindb/pull/1538) +* Relative links were replaced with JSON objects in HTTP API responses. [Pull Request #1541](https://github.com/corechaindb/corechaindb/pull/1541) +* In the outputs endpoint of the HTTP API, the query parameter `unspent` was changed to `spent` (so no more double negatives). If that query parameter isn't included, then all outputs matching the specificed public key will be returned. If `spent=true`, then only the spent outputs will be returned. If `spent=false`, then only the unspent outputs will be returned. [Pull Request #1545](https://github.com/corechaindb/corechaindb/pull/1545) +* The supported crypto-conditions changed from version 01 of the crypto-conditions spec to version 02. [Pull Request #1562](https://github.com/corechaindb/corechaindb/pull/1562) +* The value of "version" inside a transaction must now be "1.0". (Before, it could be "0.anything".) [Pull Request #1574](https://github.com/corechaindb/corechaindb/pull/1574) ### Removed -* The `server.threads` configuration setting (for the Gunicorn HTTP server) was removed from the default set of BigchainDB configuration settings. [Pull Request #1488](https://github.com/bigchaindb/bigchaindb/pull/1488) +* The `server.threads` configuration setting (for the Gunicorn HTTP server) was removed from the default set of BigchainDB configuration settings. [Pull Request #1488](https://github.com/corechaindb/corechaindb/pull/1488) ### Fixed -* The `GET /api/v1/outputs` endpoint was failing for some transactions with threshold conditions. Fixed in [Pull Request #1450](https://github.com/bigchaindb/bigchaindb/pull/1450) +* The `GET /api/v1/outputs` endpoint was failing for some transactions with threshold conditions. Fixed in [Pull Request #1450](https://github.com/corechaindb/corechaindb/pull/1450) ### External Contributors -* @elopio - Pull Requests [#1415](https://github.com/bigchaindb/bigchaindb/pull/1415) and [#1491](https://github.com/bigchaindb/bigchaindb/pull/1491) -* @CsterKuroi - [Pull Request #1447](https://github.com/bigchaindb/bigchaindb/pull/1447) -* @tdsgit - [Pull Request #1512](https://github.com/bigchaindb/bigchaindb/pull/1512) -* @lavinasachdev3 - [Pull Request #1357](https://github.com/bigchaindb/bigchaindb/pull/1357) +* @elopio - Pull Requests [#1415](https://github.com/corechaindb/corechaindb/pull/1415) and [#1491](https://github.com/corechaindb/corechaindb/pull/1491) +* @CsterKuroi - [Pull Request #1447](https://github.com/corechaindb/corechaindb/pull/1447) +* @tdsgit - [Pull Request #1512](https://github.com/corechaindb/corechaindb/pull/1512) +* @lavinasachdev3 - [Pull Request #1357](https://github.com/corechaindb/corechaindb/pull/1357) ### Notes -* We dropped support for Python 3.4. [Pull Request #1564](https://github.com/bigchaindb/bigchaindb/pull/1564) +* We dropped support for Python 3.4. [Pull Request #1564](https://github.com/corechaindb/corechaindb/pull/1564) * There were many improvements to our Kubernetes-based production deployment template (and the associated documentaiton). -* There is now a [BigchainDB Ruby driver](https://github.com/LicenseRocks/bigchaindb_ruby), created by @addywaddy at [license.rocks](https://github.com/bigchaindb/bigchaindb/pull/1437). -* The [BigchainDB JavaScript driver](https://github.com/bigchaindb/js-bigchaindb-driver) was moved to a different GitHub repo and is now officially maintained by the BigchainDB team. +* There is now a [BigchainDB Ruby driver](https://github.com/LicenseRocks/corechaindb_ruby), created by @addywaddy at [license.rocks](https://github.com/corechaindb/corechaindb/pull/1437). +* The [BigchainDB JavaScript driver](https://github.com/corechaindb/js-corechaindb-driver) was moved to a different GitHub repo and is now officially maintained by the BigchainDB team. * We continue to recommend using MongoDB. ## [0.10.3] - 2017-06-29 @@ -532,89 +532,89 @@ Tag name: v0.10.3 ## Fixed * Pin minor+ version of `cryptoconditions` to avoid upgrading to a non compatible version. -[commit 97268a5](https://github.com/bigchaindb/bigchaindb/commit/97268a577bf27942a87d8eb838f4816165c84fd5) +[commit 97268a5](https://github.com/corechaindb/corechaindb/commit/97268a577bf27942a87d8eb838f4816165c84fd5) ## [0.10.2] - 2017-05-16 Tag name: v0.10.2 ### Added * Add Cross Origin Resource Sharing (CORS) support for the HTTP API. - [Commit 6cb7596](https://github.com/bigchaindb/bigchaindb/commit/6cb75960b05403c77bdae0fd327612482589efcb) + [Commit 6cb7596](https://github.com/corechaindb/corechaindb/commit/6cb75960b05403c77bdae0fd327612482589efcb) ### Fixed * Fixed `streams_v1` API link in response to `GET /api/v1`. - [Pull Request #1466](https://github.com/bigchaindb/bigchaindb/pull/1466) + [Pull Request #1466](https://github.com/corechaindb/corechaindb/pull/1466) * Fixed mismatch between docs and implementation for `GET /blocks?status=` endpoint. The `status` query parameter is now case insensitive. - [Pull Request #1464](https://github.com/bigchaindb/bigchaindb/pull/1464) + [Pull Request #1464](https://github.com/corechaindb/corechaindb/pull/1464) ## [0.10.1] - 2017-04-19 Tag name: v0.10.1 ### Added -* Documentation for the BigchainDB settings `wsserver.host` and `wsserver.port`. [Pull Request #1408](https://github.com/bigchaindb/bigchaindb/pull/1408) +* Documentation for the BigchainDB settings `wsserver.host` and `wsserver.port`. [Pull Request #1408](https://github.com/corechaindb/corechaindb/pull/1408) ### Fixed -* Fixed `Dockerfile`, which was failing to build. It now starts `FROM python:3.6` (instead of `FROM ubuntu:xenial`). [Pull Request #1410](https://github.com/bigchaindb/bigchaindb/pull/1410) -* Fixed the `Makefile` so that `release` depends on `dist`. [Pull Request #1405](https://github.com/bigchaindb/bigchaindb/pull/1405) +* Fixed `Dockerfile`, which was failing to build. It now starts `FROM python:3.6` (instead of `FROM ubuntu:xenial`). [Pull Request #1410](https://github.com/corechaindb/corechaindb/pull/1410) +* Fixed the `Makefile` so that `release` depends on `dist`. [Pull Request #1405](https://github.com/corechaindb/corechaindb/pull/1405) ## [0.10.0] - 2017-04-18 Tag name: v0.10.0 ### Added -* Improved logging. Added logging to file. Added `--log-level` option to `bigchaindb start` command. Added new logging configuration settings. Pull Requests -[#1285](https://github.com/bigchaindb/bigchaindb/pull/1285), -[#1307](https://github.com/bigchaindb/bigchaindb/pull/1307), -[#1324](https://github.com/bigchaindb/bigchaindb/pull/1324), -[#1326](https://github.com/bigchaindb/bigchaindb/pull/1326), -[#1327](https://github.com/bigchaindb/bigchaindb/pull/1327), -[#1330](https://github.com/bigchaindb/bigchaindb/pull/1330), -[#1365](https://github.com/bigchaindb/bigchaindb/pull/1365), -[#1394](https://github.com/bigchaindb/bigchaindb/pull/1394), -[#1396](https://github.com/bigchaindb/bigchaindb/pull/1396), -[#1398](https://github.com/bigchaindb/bigchaindb/pull/1398) and -[#1402](https://github.com/bigchaindb/bigchaindb/pull/1402) +* Improved logging. Added logging to file. Added `--log-level` option to `corechaindb start` command. Added new logging configuration settings. Pull Requests +[#1285](https://github.com/corechaindb/corechaindb/pull/1285), +[#1307](https://github.com/corechaindb/corechaindb/pull/1307), +[#1324](https://github.com/corechaindb/corechaindb/pull/1324), +[#1326](https://github.com/corechaindb/corechaindb/pull/1326), +[#1327](https://github.com/corechaindb/corechaindb/pull/1327), +[#1330](https://github.com/corechaindb/corechaindb/pull/1330), +[#1365](https://github.com/corechaindb/corechaindb/pull/1365), +[#1394](https://github.com/corechaindb/corechaindb/pull/1394), +[#1396](https://github.com/corechaindb/corechaindb/pull/1396), +[#1398](https://github.com/corechaindb/corechaindb/pull/1398) and +[#1402](https://github.com/corechaindb/corechaindb/pull/1402) * Events API using WebSocket protocol. Pull Requests -[#1086](https://github.com/bigchaindb/bigchaindb/pull/1086), -[#1347](https://github.com/bigchaindb/bigchaindb/pull/1347), -[#1349](https://github.com/bigchaindb/bigchaindb/pull/1349), -[#1356](https://github.com/bigchaindb/bigchaindb/pull/1356), -[#1368](https://github.com/bigchaindb/bigchaindb/pull/1368), -[#1401](https://github.com/bigchaindb/bigchaindb/pull/1401) and -[#1403](https://github.com/bigchaindb/bigchaindb/pull/1403) +[#1086](https://github.com/corechaindb/corechaindb/pull/1086), +[#1347](https://github.com/corechaindb/corechaindb/pull/1347), +[#1349](https://github.com/corechaindb/corechaindb/pull/1349), +[#1356](https://github.com/corechaindb/corechaindb/pull/1356), +[#1368](https://github.com/corechaindb/corechaindb/pull/1368), +[#1401](https://github.com/corechaindb/corechaindb/pull/1401) and +[#1403](https://github.com/corechaindb/corechaindb/pull/1403) * Initial support for using SSL with MongoDB (work in progress). Pull Requests -[#1299](https://github.com/bigchaindb/bigchaindb/pull/1299) and -[#1348](https://github.com/bigchaindb/bigchaindb/pull/1348) +[#1299](https://github.com/corechaindb/corechaindb/pull/1299) and +[#1348](https://github.com/corechaindb/corechaindb/pull/1348) ### Changed -* The main BigchainDB Dockerfile (and its generated Docker image) now contains only BigchainDB Server. (It used to contain both BigchainDB Server and RethinkDB.) You must now run MongoDB or RethinkDB in a separate Docker container. [Pull Request #1174](https://github.com/bigchaindb/bigchaindb/pull/1174) -* Made separate schemas for CREATE and TRANSFER transactions. [Pull Request #1257](https://github.com/bigchaindb/bigchaindb/pull/1257) -* When signing transactions with threshold conditions, we now sign all subconditions for a public key. [Pull Request #1294](https://github.com/bigchaindb/bigchaindb/pull/1294) -* Many changes to the voting-related code, including how we validate votes and prevent duplicate votes by the same node. Pull Requests [#1215](https://github.com/bigchaindb/bigchaindb/pull/1215) and [#1258](https://github.com/bigchaindb/bigchaindb/pull/1258) +* The main BigchainDB Dockerfile (and its generated Docker image) now contains only BigchainDB Server. (It used to contain both BigchainDB Server and RethinkDB.) You must now run MongoDB or RethinkDB in a separate Docker container. [Pull Request #1174](https://github.com/corechaindb/corechaindb/pull/1174) +* Made separate schemas for CREATE and TRANSFER transactions. [Pull Request #1257](https://github.com/corechaindb/corechaindb/pull/1257) +* When signing transactions with threshold conditions, we now sign all subconditions for a public key. [Pull Request #1294](https://github.com/corechaindb/corechaindb/pull/1294) +* Many changes to the voting-related code, including how we validate votes and prevent duplicate votes by the same node. Pull Requests [#1215](https://github.com/corechaindb/corechaindb/pull/1215) and [#1258](https://github.com/corechaindb/corechaindb/pull/1258) ### Removed -* Removed the `bigchaindb load` command. Pull Requests -[#1261](https://github.com/bigchaindb/bigchaindb/pull/1261), -[#1273](https://github.com/bigchaindb/bigchaindb/pull/1273) and -[#1301](https://github.com/bigchaindb/bigchaindb/pull/1301) -* Removed old `/speed-tests` and `/benchmarking-tests` directories. [Pull Request #1359](https://github.com/bigchaindb/bigchaindb/pull/1359) +* Removed the `corechaindb load` command. Pull Requests +[#1261](https://github.com/corechaindb/corechaindb/pull/1261), +[#1273](https://github.com/corechaindb/corechaindb/pull/1273) and +[#1301](https://github.com/corechaindb/corechaindb/pull/1301) +* Removed old `/speed-tests` and `/benchmarking-tests` directories. [Pull Request #1359](https://github.com/corechaindb/corechaindb/pull/1359) ### Fixed -* Fixed the URL of the BigchainDB docs returned by the HTTP API. [Pull Request #1178](https://github.com/bigchaindb/bigchaindb/pull/1178) -* Fixed the MongoDB changefeed: it wasn't reporting update operations. [Pull Request #1193](https://github.com/bigchaindb/bigchaindb/pull/1193) +* Fixed the URL of the BigchainDB docs returned by the HTTP API. [Pull Request #1178](https://github.com/corechaindb/corechaindb/pull/1178) +* Fixed the MongoDB changefeed: it wasn't reporting update operations. [Pull Request #1193](https://github.com/corechaindb/corechaindb/pull/1193) * Fixed the block-creation process: it wasn't checking if the transaction was previously included in: - * a valid block. [Pull Request #1208](https://github.com/bigchaindb/bigchaindb/pull/1208) - * the block-under-construction. Pull Requests [#1237](https://github.com/bigchaindb/bigchaindb/issues/1237) and [#1377](https://github.com/bigchaindb/bigchaindb/issues/1377) + * a valid block. [Pull Request #1208](https://github.com/corechaindb/corechaindb/pull/1208) + * the block-under-construction. Pull Requests [#1237](https://github.com/corechaindb/corechaindb/issues/1237) and [#1377](https://github.com/corechaindb/corechaindb/issues/1377) ### External Contributors In alphabetical order by GitHub username: -* @anryko - [Pull Request #1277](https://github.com/bigchaindb/bigchaindb/pull/1277) -* @anujism - [Pull Request #1366](https://github.com/bigchaindb/bigchaindb/pull/1366) -* @jackric - [Pull Request #1365](https://github.com/bigchaindb/bigchaindb/pull/1365) -* @lavinasachdev3 - [Pull Request #1358](https://github.com/bigchaindb/bigchaindb/pull/1358) -* @morrme - [Pull Request #1340](https://github.com/bigchaindb/bigchaindb/pull/1340) -* @tomconte - [Pull Request #1299](https://github.com/bigchaindb/bigchaindb/pull/1299) -* @tymlez - Pull Requests [#1108](https://github.com/bigchaindb/bigchaindb/pull/1108) & [#1209](https://github.com/bigchaindb/bigchaindb/pull/1209) +* @anryko - [Pull Request #1277](https://github.com/corechaindb/corechaindb/pull/1277) +* @anujism - [Pull Request #1366](https://github.com/corechaindb/corechaindb/pull/1366) +* @jackric - [Pull Request #1365](https://github.com/corechaindb/corechaindb/pull/1365) +* @lavinasachdev3 - [Pull Request #1358](https://github.com/corechaindb/corechaindb/pull/1358) +* @morrme - [Pull Request #1340](https://github.com/corechaindb/corechaindb/pull/1340) +* @tomconte - [Pull Request #1299](https://github.com/corechaindb/corechaindb/pull/1299) +* @tymlez - Pull Requests [#1108](https://github.com/corechaindb/corechaindb/pull/1108) & [#1209](https://github.com/corechaindb/corechaindb/pull/1209) ### Notes * MongoDB is now the recommended database backend (not RethinkDB). @@ -645,7 +645,7 @@ Fixed HTTP API 500 error on `GET /outputs`: issues #1200 and #1231. Tag name: v0.9.2 ### Fixed -Pin `python-rapidjson` library in `setup.py` to prevent `bigchaindb`'s +Pin `python-rapidjson` library in `setup.py` to prevent `corechaindb`'s installation to fail due to https://github.com/python-rapidjson/python-rapidjson/issues/62. @@ -653,7 +653,7 @@ https://github.com/python-rapidjson/python-rapidjson/issues/62. Tag name: v0.9.1 ### Fixed -* Fixed bug in how the transaction `VERSION` string was calculated from the BigchainDB Server `__short_version__` string. [Pull Request #1160](https://github.com/bigchaindb/bigchaindb/pull/1160) +* Fixed bug in how the transaction `VERSION` string was calculated from the BigchainDB Server `__short_version__` string. [Pull Request #1160](https://github.com/corechaindb/corechaindb/pull/1160) ## [0.9.0] - 2017-02-06 @@ -663,34 +663,34 @@ It has been more than two months since the v0.8.0 release, so there have been _m ### Added - Support for MongoDB as a backend database. -- Some configuration settings and `bigchaindb` command-line commands were added. In particular, one can specify the database backend (`rethinkdb` or `mongodb`). For MongoDB, one can specify the name of the replicaset. Also for MongoDB, there are new command-line commands to add and remove hosts from the replicaset. See [the Settings & CLI docs](https://docs.bigchaindb.com/projects/server/en/v0.9.0/server-reference/index.html). -- Transaction schema validation. The transaction schema is also used to auto-generate some docs. [Pull Request #880](https://github.com/bigchaindb/bigchaindb/pull/880) -- Vote schema validation. The vote schema is also used to auto-generate some docs. [Pull Request #865](https://github.com/bigchaindb/bigchaindb/pull/865) -- New `ENABLE_WEB_ADMIN` setting in the AWS deployment configuration file. [Pull Request #1015](https://github.com/bigchaindb/bigchaindb/pull/1015) +- Some configuration settings and `corechaindb` command-line commands were added. In particular, one can specify the database backend (`rethinkdb` or `mongodb`). For MongoDB, one can specify the name of the replicaset. Also for MongoDB, there are new command-line commands to add and remove hosts from the replicaset. See [the Settings & CLI docs](https://docs.corechaindb.com/projects/server/en/v0.9.0/server-reference/index.html). +- Transaction schema validation. The transaction schema is also used to auto-generate some docs. [Pull Request #880](https://github.com/corechaindb/corechaindb/pull/880) +- Vote schema validation. The vote schema is also used to auto-generate some docs. [Pull Request #865](https://github.com/corechaindb/corechaindb/pull/865) +- New `ENABLE_WEB_ADMIN` setting in the AWS deployment configuration file. [Pull Request #1015](https://github.com/corechaindb/corechaindb/pull/1015) ### Changed -- The transaction model has changed substantially. @libscott wrote a blog post about the changes and it will be published soon on [the BigchainDB Blog](https://blog.bigchaindb.com/). Also, see [the docs about the transaction model](https://docs.bigchaindb.com/projects/server/en/v0.9.0/data-models/transaction-model.html). -- The HTTP API has changed substantially. @diminator wrote a blog post about the changes and it will be published soon on [the BigchainDB Blog](https://blog.bigchaindb.com/). Also, see [the docs about the vote model](https://docs.bigchaindb.com/projects/server/en/v0.9.0/data-models/vote-model.html). +- The transaction model has changed substantially. @libscott wrote a blog post about the changes and it will be published soon on [the BigchainDB Blog](https://blog.corechaindb.com/). Also, see [the docs about the transaction model](https://docs.corechaindb.com/projects/server/en/v0.9.0/data-models/transaction-model.html). +- The HTTP API has changed substantially. @diminator wrote a blog post about the changes and it will be published soon on [the BigchainDB Blog](https://blog.corechaindb.com/). Also, see [the docs about the vote model](https://docs.corechaindb.com/projects/server/en/v0.9.0/data-models/vote-model.html). - All RethinkDB-specific database calls were replaced with abstract calls to a backend database. -- Some improvements to the Dockerfile, e.g. Pull Requests [#1011](https://github.com/bigchaindb/bigchaindb/pull/1011) and [#1121](https://github.com/bigchaindb/bigchaindb/pull/1121) +- Some improvements to the Dockerfile, e.g. Pull Requests [#1011](https://github.com/corechaindb/corechaindb/pull/1011) and [#1121](https://github.com/corechaindb/corechaindb/pull/1121) - Many improvements to the tests - We standardized on supporting Ubuntu 16.04 for now (but BigchainDB Server also works on similar Linux distros). ### Removed -- `api_endpoint` was removed from the BigchainDB configuration settings. (It was never used anyway.) [Pull Request #821](https://github.com/bigchaindb/bigchaindb/pull/821) -- Removed all remaining StatsD monitoring code, configuration settings, docs, etc. (We'll add another monitoring solution in the future.) [Pull Request #1138](https://github.com/bigchaindb/bigchaindb/pull/1138) +- `api_endpoint` was removed from the BigchainDB configuration settings. (It was never used anyway.) [Pull Request #821](https://github.com/corechaindb/corechaindb/pull/821) +- Removed all remaining StatsD monitoring code, configuration settings, docs, etc. (We'll add another monitoring solution in the future.) [Pull Request #1138](https://github.com/corechaindb/corechaindb/pull/1138) ### Fixed -- Fixed a memory (RAM) overflow problem when under heavy load by bounding the size of the queue at the entrance to the block pipeline. [Pull Request #908](https://github.com/bigchaindb/bigchaindb/pull/908) -- Fixed some logic in block validation. [Pull Request #1130](https://github.com/bigchaindb/bigchaindb/pull/1130) +- Fixed a memory (RAM) overflow problem when under heavy load by bounding the size of the queue at the entrance to the block pipeline. [Pull Request #908](https://github.com/corechaindb/corechaindb/pull/908) +- Fixed some logic in block validation. [Pull Request #1130](https://github.com/corechaindb/corechaindb/pull/1130) ### External Contributors -- @amirelemam - [Pull Request #762](https://github.com/bigchaindb/bigchaindb/pull/762) (closed but used as the basis for [Pull Request #1074](https://github.com/bigchaindb/bigchaindb/pull/1074)) -- @utarl - [Pull Request #1019](https://github.com/bigchaindb/bigchaindb/pull/1019) +- @amirelemam - [Pull Request #762](https://github.com/corechaindb/corechaindb/pull/762) (closed but used as the basis for [Pull Request #1074](https://github.com/corechaindb/corechaindb/pull/1074)) +- @utarl - [Pull Request #1019](https://github.com/corechaindb/corechaindb/pull/1019) ### Notes - There were many additions and changes to the documentation. Fun fact: The JSON in the HTTP API docs is now auto-generated to be consistent with the current code. -- There's a draft spec for a BigchainDB Event Stream API and we welcome your feedback. See [Pull Request #1086](https://github.com/bigchaindb/bigchaindb/pull/1086) +- There's a draft spec for a BigchainDB Event Stream API and we welcome your feedback. See [Pull Request #1086](https://github.com/corechaindb/corechaindb/pull/1086) ## [0.8.2] - 2017-01-27 @@ -698,7 +698,7 @@ Tag name: v0.8.2 ### Fixed - Fix spend input twice in same transaction - (https://github.com/bigchaindb/bigchaindb/issues/1099). + (https://github.com/corechaindb/corechaindb/issues/1099). ## [0.8.1] - 2017-01-16 @@ -716,62 +716,62 @@ Tag name: v0.8.1 Tag name: v0.8.0 ### Added -- The big new thing in version 0.8.0 is support for divisible assets, i.e. assets like carrots or thumbtacks, where the initial CREATE transaction can register/create some amount (e.g. 542 carrots), the first TRANSFER transaction can split that amount across multiple owners, and so on. [Pull Request #794](https://github.com/bigchaindb/bigchaindb/pull/794) -- Wrote a formal schema for the JSON structure of transactions. [Pull Request #798](https://github.com/bigchaindb/bigchaindb/pull/798) -- New configuration parameter: `backlog_reassign_delay`. [Pull Request #883](https://github.com/bigchaindb/bigchaindb/pull/883) +- The big new thing in version 0.8.0 is support for divisible assets, i.e. assets like carrots or thumbtacks, where the initial CREATE transaction can register/create some amount (e.g. 542 carrots), the first TRANSFER transaction can split that amount across multiple owners, and so on. [Pull Request #794](https://github.com/corechaindb/corechaindb/pull/794) +- Wrote a formal schema for the JSON structure of transactions. [Pull Request #798](https://github.com/corechaindb/corechaindb/pull/798) +- New configuration parameter: `backlog_reassign_delay`. [Pull Request #883](https://github.com/corechaindb/corechaindb/pull/883) ### Changed -- CREATE transactions must now be signed by all `owners_before` (rather than by a federation node). [Pull Request #794](https://github.com/bigchaindb/bigchaindb/pull/794) -- The user-provided timestamp was removed from the transaction data model (schema). [Pull Request #817](https://github.com/bigchaindb/bigchaindb/pull/817) -- `get_transaction()` will now return a transaction from the backlog, even if there are copies of the transaction in invalid blocks. [Pull Request #793](https://github.com/bigchaindb/bigchaindb/pull/793) +- CREATE transactions must now be signed by all `owners_before` (rather than by a federation node). [Pull Request #794](https://github.com/corechaindb/corechaindb/pull/794) +- The user-provided timestamp was removed from the transaction data model (schema). [Pull Request #817](https://github.com/corechaindb/corechaindb/pull/817) +- `get_transaction()` will now return a transaction from the backlog, even if there are copies of the transaction in invalid blocks. [Pull Request #793](https://github.com/corechaindb/corechaindb/pull/793) - Several pull requests to introduce a generalized database interface, to move RethinkDB calls into a separate implementation of that interface, and to work on a new MongoDB implementation of that interface. Pull Requests -[#754](https://github.com/bigchaindb/bigchaindb/pull/754), -[#783](https://github.com/bigchaindb/bigchaindb/pull/783), -[#799](https://github.com/bigchaindb/bigchaindb/pull/799), -[#806](https://github.com/bigchaindb/bigchaindb/pull/806), -[#809](https://github.com/bigchaindb/bigchaindb/pull/809), -[#853](https://github.com/bigchaindb/bigchaindb/pull/853) -- Renamed "verifying key" to "public key". Renamed "signing key" to "private key". Renamed "vk" to "pk". [Pull Request #807](https://github.com/bigchaindb/bigchaindb/pull/807) -- `get_transaction_by_asset_id` now ignores invalid transactions. [Pull Request #810](https://github.com/bigchaindb/bigchaindb/pull/810) -- `get_transaction_by_metadata_id` now ignores invalid transactions. [Pull Request #811](https://github.com/bigchaindb/bigchaindb/pull/811) +[#754](https://github.com/corechaindb/corechaindb/pull/754), +[#783](https://github.com/corechaindb/corechaindb/pull/783), +[#799](https://github.com/corechaindb/corechaindb/pull/799), +[#806](https://github.com/corechaindb/corechaindb/pull/806), +[#809](https://github.com/corechaindb/corechaindb/pull/809), +[#853](https://github.com/corechaindb/corechaindb/pull/853) +- Renamed "verifying key" to "public key". Renamed "signing key" to "private key". Renamed "vk" to "pk". [Pull Request #807](https://github.com/corechaindb/corechaindb/pull/807) +- `get_transaction_by_asset_id` now ignores invalid transactions. [Pull Request #810](https://github.com/corechaindb/corechaindb/pull/810) +- `get_transaction_by_metadata_id` now ignores invalid transactions. [Pull Request #811](https://github.com/corechaindb/corechaindb/pull/811) - Updates to the configs and scripts for deploying a test network on AWS. The example config file deploys virtual machines running Ubuntu 16.04 now. Pull Requests -[#771](https://github.com/bigchaindb/bigchaindb/pull/771), -[#813](https://github.com/bigchaindb/bigchaindb/pull/813) -- Changed logging of transactions on block creation so now it just says the length of the list of transactions, rather than listing all the transactions. [Pull Request #861](https://github.com/bigchaindb/bigchaindb/pull/861) +[#771](https://github.com/corechaindb/corechaindb/pull/771), +[#813](https://github.com/corechaindb/corechaindb/pull/813) +- Changed logging of transactions on block creation so now it just says the length of the list of transactions, rather than listing all the transactions. [Pull Request #861](https://github.com/corechaindb/corechaindb/pull/861) ### Fixed -- Equality checks with AssetLinks. [Pull Request #825](https://github.com/bigchaindb/bigchaindb/pull/825) -- Bug in `bigchaindb load`. [Pull Request #824](https://github.com/bigchaindb/bigchaindb/pull/824) -- Two issues found with timestamp indexes. [Pull Request #816](https://github.com/bigchaindb/bigchaindb/pull/816) -- Hard-coded `backlog_reassign_delay`. [Pull Request #854](https://github.com/bigchaindb/bigchaindb/pull/854) -- Race condition in `test_stale_monitor.py`. [Pull Request #846](https://github.com/bigchaindb/bigchaindb/pull/846) -- When creating a signed vote, decode the vote signature to a `str`. [Pull Request #869](https://github.com/bigchaindb/bigchaindb/pull/869) -- Bug in AWS deployment scripts. Setting `BIND_HTTP_TO_LOCALHOST` to `False` didn't actually work. It does now. [Pull Request #870](https://github.com/bigchaindb/bigchaindb/pull/870) +- Equality checks with AssetLinks. [Pull Request #825](https://github.com/corechaindb/corechaindb/pull/825) +- Bug in `corechaindb load`. [Pull Request #824](https://github.com/corechaindb/corechaindb/pull/824) +- Two issues found with timestamp indexes. [Pull Request #816](https://github.com/corechaindb/corechaindb/pull/816) +- Hard-coded `backlog_reassign_delay`. [Pull Request #854](https://github.com/corechaindb/corechaindb/pull/854) +- Race condition in `test_stale_monitor.py`. [Pull Request #846](https://github.com/corechaindb/corechaindb/pull/846) +- When creating a signed vote, decode the vote signature to a `str`. [Pull Request #869](https://github.com/corechaindb/corechaindb/pull/869) +- Bug in AWS deployment scripts. Setting `BIND_HTTP_TO_LOCALHOST` to `False` didn't actually work. It does now. [Pull Request #870](https://github.com/corechaindb/corechaindb/pull/870) ### External Contributors -- @najlachamseddine - [Pull Request #528](https://github.com/bigchaindb/bigchaindb/pull/528) -- @ChristianGaertner - [Pull Request #659](https://github.com/bigchaindb/bigchaindb/pull/659) -- @MinchinWeb - [Pull Request #695](https://github.com/bigchaindb/bigchaindb/pull/695) -- @ckeyer - [Pull Request #785](https://github.com/bigchaindb/bigchaindb/pull/785) +- @najlachamseddine - [Pull Request #528](https://github.com/corechaindb/corechaindb/pull/528) +- @ChristianGaertner - [Pull Request #659](https://github.com/corechaindb/corechaindb/pull/659) +- @MinchinWeb - [Pull Request #695](https://github.com/corechaindb/corechaindb/pull/695) +- @ckeyer - [Pull Request #785](https://github.com/corechaindb/corechaindb/pull/785) ### Notes - @ChristianGaertner added a Python style checker (Flake8) to Travis CI, so external contributors should be aware that the Python code in their pull requests will be checked. See [our Python Style Guide](PYTHON_STYLE_GUIDE.md). - Several additions and changes to the documentation, e.g. Pull Requests -[#690](https://github.com/bigchaindb/bigchaindb/pull/690), -[#764](https://github.com/bigchaindb/bigchaindb/pull/764), -[#766](https://github.com/bigchaindb/bigchaindb/pull/766), -[#769](https://github.com/bigchaindb/bigchaindb/pull/769), -[#777](https://github.com/bigchaindb/bigchaindb/pull/777), -[#800](https://github.com/bigchaindb/bigchaindb/pull/800), -[#801](https://github.com/bigchaindb/bigchaindb/pull/801), -[#802](https://github.com/bigchaindb/bigchaindb/pull/802), -[#803](https://github.com/bigchaindb/bigchaindb/pull/803), -[#819](https://github.com/bigchaindb/bigchaindb/pull/819), -[#827](https://github.com/bigchaindb/bigchaindb/pull/827), -[#859](https://github.com/bigchaindb/bigchaindb/pull/859), -[#872](https://github.com/bigchaindb/bigchaindb/pull/872), -[#882](https://github.com/bigchaindb/bigchaindb/pull/882), -[#883](https://github.com/bigchaindb/bigchaindb/pull/883) +[#690](https://github.com/corechaindb/corechaindb/pull/690), +[#764](https://github.com/corechaindb/corechaindb/pull/764), +[#766](https://github.com/corechaindb/corechaindb/pull/766), +[#769](https://github.com/corechaindb/corechaindb/pull/769), +[#777](https://github.com/corechaindb/corechaindb/pull/777), +[#800](https://github.com/corechaindb/corechaindb/pull/800), +[#801](https://github.com/corechaindb/corechaindb/pull/801), +[#802](https://github.com/corechaindb/corechaindb/pull/802), +[#803](https://github.com/corechaindb/corechaindb/pull/803), +[#819](https://github.com/corechaindb/corechaindb/pull/819), +[#827](https://github.com/corechaindb/corechaindb/pull/827), +[#859](https://github.com/corechaindb/corechaindb/pull/859), +[#872](https://github.com/corechaindb/corechaindb/pull/872), +[#882](https://github.com/corechaindb/corechaindb/pull/882), +[#883](https://github.com/corechaindb/corechaindb/pull/883) ## [0.7.0] - 2016-10-28 @@ -780,62 +780,62 @@ Tag name: v0.7.0 committed: Oct 28, 2016, 4:00 PM GMT+2 ### Added -- Stale transactions in the `backlog` table now get reassigned to another node (for inclusion in a new block): [Pull Request #359](https://github.com/bigchaindb/bigchaindb/pull/359) -- Many improvements to make the database connection more robust: [Pull Request #623](https://github.com/bigchaindb/bigchaindb/pull/623) -- The new `--dev-allow-temp-keypair` option on `bigchaindb start` will generate a temporary keypair if no keypair is found. The `Dockerfile` was updated to use this. [Pull Request #635](https://github.com/bigchaindb/bigchaindb/pull/635) +- Stale transactions in the `backlog` table now get reassigned to another node (for inclusion in a new block): [Pull Request #359](https://github.com/corechaindb/corechaindb/pull/359) +- Many improvements to make the database connection more robust: [Pull Request #623](https://github.com/corechaindb/corechaindb/pull/623) +- The new `--dev-allow-temp-keypair` option on `corechaindb start` will generate a temporary keypair if no keypair is found. The `Dockerfile` was updated to use this. [Pull Request #635](https://github.com/corechaindb/corechaindb/pull/635) - The AWS deployment scripts now allow you to: - - specify the AWS security group as a configuration parameter: [Pull Request #620](https://github.com/bigchaindb/bigchaindb/pull/620) - - tell RethinkDB to bind HTTP to localhost (a more secure setup; now the default in the example config file): [Pull Request #666](https://github.com/bigchaindb/bigchaindb/pull/666) + - specify the AWS security group as a configuration parameter: [Pull Request #620](https://github.com/corechaindb/corechaindb/pull/620) + - tell RethinkDB to bind HTTP to localhost (a more secure setup; now the default in the example config file): [Pull Request #666](https://github.com/corechaindb/corechaindb/pull/666) ### Changed -- Integrated the new `Transaction` model. This was a **big** change; 49 files changed. [Pull Request #641](https://github.com/bigchaindb/bigchaindb/pull/641) -- Merged "common" code (used by BigchainDB Server and the Python driver), which used to be in its own repository (`bigchaindb/bigchaindb-common`), into the main `bigchaindb/bigchaindb` repository (this one): [Pull Request #742](https://github.com/bigchaindb/bigchaindb/pull/742) -- Integrated the new digital asset model. This changed the data structure of a transaction and will make it easier to support divisible assets in the future. [Pull Request #680](https://github.com/bigchaindb/bigchaindb/pull/680) -- Transactions are now deleted from the `backlog` table _after_ a block containing them is written to the `bigchain` table: [Pull Request #609](https://github.com/bigchaindb/bigchaindb/pull/609) -- Changed the example AWS deployment configuration file: [Pull Request #665](https://github.com/bigchaindb/bigchaindb/pull/665) -- Support for version 0.5.0 of the `cryptoconditions` Python package. Note that this means you must now install `ffi.h` (e.g. `sudo apt-get install libffi-dev` on Ubuntu). See Pull Requests [#685](https://github.com/bigchaindb/bigchaindb/pull/685) and [#698](https://github.com/bigchaindb/bigchaindb/pull/698) -- Updated some database access code: Pull Requests [#676](https://github.com/bigchaindb/bigchaindb/pull/676) and [#701](https://github.com/bigchaindb/bigchaindb/pull/701) +- Integrated the new `Transaction` model. This was a **big** change; 49 files changed. [Pull Request #641](https://github.com/corechaindb/corechaindb/pull/641) +- Merged "common" code (used by BigchainDB Server and the Python driver), which used to be in its own repository (`corechaindb/corechaindb-common`), into the main `corechaindb/corechaindb` repository (this one): [Pull Request #742](https://github.com/corechaindb/corechaindb/pull/742) +- Integrated the new digital asset model. This changed the data structure of a transaction and will make it easier to support divisible assets in the future. [Pull Request #680](https://github.com/corechaindb/corechaindb/pull/680) +- Transactions are now deleted from the `backlog` table _after_ a block containing them is written to the `bigchain` table: [Pull Request #609](https://github.com/corechaindb/corechaindb/pull/609) +- Changed the example AWS deployment configuration file: [Pull Request #665](https://github.com/corechaindb/corechaindb/pull/665) +- Support for version 0.5.0 of the `cryptoconditions` Python package. Note that this means you must now install `ffi.h` (e.g. `sudo apt-get install libffi-dev` on Ubuntu). See Pull Requests [#685](https://github.com/corechaindb/corechaindb/pull/685) and [#698](https://github.com/corechaindb/corechaindb/pull/698) +- Updated some database access code: Pull Requests [#676](https://github.com/corechaindb/corechaindb/pull/676) and [#701](https://github.com/corechaindb/corechaindb/pull/701) ### Fixed - Internally, when a transaction is in the `backlog` table, it carries some extra book-keeping fields: 1. an `assignment_timestamp` (i.e. the time when it was assigned to a node), which is used to determine if it has gone stale. 2. an `assignee`: the public key of the node it was assigned to. -- The `assignment_timestamp` wasn't removed before writing the transaction to a block. That was fixed in [Pull Request #627](https://github.com/bigchaindb/bigchaindb/pull/627) -- The `assignment_timestamp` and `assignee` weren't removed in the response to an HTTP API request sent to the `/api/v1/transactions/` endpoint. That was fixed in [Pull Request #646](https://github.com/bigchaindb/bigchaindb/pull/646) -- When validating a TRANSFER transaction, if any fulfillment refers to a transaction that's _not_ in a valid block, then the transaction isn't valid. This wasn't checked before but it is now. [Pull Request #629](https://github.com/bigchaindb/bigchaindb/pull/629) +- The `assignment_timestamp` wasn't removed before writing the transaction to a block. That was fixed in [Pull Request #627](https://github.com/corechaindb/corechaindb/pull/627) +- The `assignment_timestamp` and `assignee` weren't removed in the response to an HTTP API request sent to the `/api/v1/transactions/` endpoint. That was fixed in [Pull Request #646](https://github.com/corechaindb/corechaindb/pull/646) +- When validating a TRANSFER transaction, if any fulfillment refers to a transaction that's _not_ in a valid block, then the transaction isn't valid. This wasn't checked before but it is now. [Pull Request #629](https://github.com/corechaindb/corechaindb/pull/629) ### External Contributors -- @MinchinWeb - [Pull Request #696](https://github.com/bigchaindb/bigchaindb/pull/696) +- @MinchinWeb - [Pull Request #696](https://github.com/corechaindb/corechaindb/pull/696) ### Notes -- We made a small change to how we do version labeling. Going forward, we will have the version label set to 0.X.Y.dev in the master branch as we work on what will eventually be released as version 0.X.Y. The version number will only be changed to 0.X.Y just before the release. This version labeling scheme began with [Pull Request #752](https://github.com/bigchaindb/bigchaindb/pull/752) +- We made a small change to how we do version labeling. Going forward, we will have the version label set to 0.X.Y.dev in the master branch as we work on what will eventually be released as version 0.X.Y. The version number will only be changed to 0.X.Y just before the release. This version labeling scheme began with [Pull Request #752](https://github.com/corechaindb/corechaindb/pull/752) - Several additions and changes to the documentation, e.g. Pull Requests -[#618](https://github.com/bigchaindb/bigchaindb/pull/618), -[#621](https://github.com/bigchaindb/bigchaindb/pull/621), -[#625](https://github.com/bigchaindb/bigchaindb/pull/625), -[#645](https://github.com/bigchaindb/bigchaindb/pull/645), -[#647](https://github.com/bigchaindb/bigchaindb/pull/647), -[#648](https://github.com/bigchaindb/bigchaindb/pull/648), -[#650](https://github.com/bigchaindb/bigchaindb/pull/650), -[#651](https://github.com/bigchaindb/bigchaindb/pull/651), -[#653](https://github.com/bigchaindb/bigchaindb/pull/653), -[#655](https://github.com/bigchaindb/bigchaindb/pull/655), -[#656](https://github.com/bigchaindb/bigchaindb/pull/656), -[#657](https://github.com/bigchaindb/bigchaindb/pull/657), -[#667](https://github.com/bigchaindb/bigchaindb/pull/667), -[#668](https://github.com/bigchaindb/bigchaindb/pull/668), -[#669](https://github.com/bigchaindb/bigchaindb/pull/669), -[#673](https://github.com/bigchaindb/bigchaindb/pull/673), -[#678](https://github.com/bigchaindb/bigchaindb/pull/678), -[#684](https://github.com/bigchaindb/bigchaindb/pull/684), -[#688](https://github.com/bigchaindb/bigchaindb/pull/688), -[#699](https://github.com/bigchaindb/bigchaindb/pull/699), -[#705](https://github.com/bigchaindb/bigchaindb/pull/705), -[#737](https://github.com/bigchaindb/bigchaindb/pull/737), -[#748](https://github.com/bigchaindb/bigchaindb/pull/748), -[#753](https://github.com/bigchaindb/bigchaindb/pull/753), -[#757](https://github.com/bigchaindb/bigchaindb/pull/757), -[#759](https://github.com/bigchaindb/bigchaindb/pull/759), and more +[#618](https://github.com/corechaindb/corechaindb/pull/618), +[#621](https://github.com/corechaindb/corechaindb/pull/621), +[#625](https://github.com/corechaindb/corechaindb/pull/625), +[#645](https://github.com/corechaindb/corechaindb/pull/645), +[#647](https://github.com/corechaindb/corechaindb/pull/647), +[#648](https://github.com/corechaindb/corechaindb/pull/648), +[#650](https://github.com/corechaindb/corechaindb/pull/650), +[#651](https://github.com/corechaindb/corechaindb/pull/651), +[#653](https://github.com/corechaindb/corechaindb/pull/653), +[#655](https://github.com/corechaindb/corechaindb/pull/655), +[#656](https://github.com/corechaindb/corechaindb/pull/656), +[#657](https://github.com/corechaindb/corechaindb/pull/657), +[#667](https://github.com/corechaindb/corechaindb/pull/667), +[#668](https://github.com/corechaindb/corechaindb/pull/668), +[#669](https://github.com/corechaindb/corechaindb/pull/669), +[#673](https://github.com/corechaindb/corechaindb/pull/673), +[#678](https://github.com/corechaindb/corechaindb/pull/678), +[#684](https://github.com/corechaindb/corechaindb/pull/684), +[#688](https://github.com/corechaindb/corechaindb/pull/688), +[#699](https://github.com/corechaindb/corechaindb/pull/699), +[#705](https://github.com/corechaindb/corechaindb/pull/705), +[#737](https://github.com/corechaindb/corechaindb/pull/737), +[#748](https://github.com/corechaindb/corechaindb/pull/748), +[#753](https://github.com/corechaindb/corechaindb/pull/753), +[#757](https://github.com/corechaindb/corechaindb/pull/757), +[#759](https://github.com/corechaindb/corechaindb/pull/759), and more ## [0.6.0] - 2016-09-01 @@ -844,42 +844,42 @@ Tag name: v0.6.0 committed: Sep 1, 2016, 2:15 PM GMT+2 ### Added -- Support for multiple operations in the ChangeFeed class: [Pull Request #569](https://github.com/bigchaindb/bigchaindb/pull/569) +- Support for multiple operations in the ChangeFeed class: [Pull Request #569](https://github.com/corechaindb/corechaindb/pull/569) - Instructions, templates and code for deploying a starter node on AWS using Terraform and Ansible: Pull Requests -[#572](https://github.com/bigchaindb/bigchaindb/pull/572), -[#589](https://github.com/bigchaindb/bigchaindb/pull/589), -[#600](https://github.com/bigchaindb/bigchaindb/pull/600), -[#605](https://github.com/bigchaindb/bigchaindb/pull/605), -[#610](https://github.com/bigchaindb/bigchaindb/pull/610) -- Check that the majority of votes on a block agree on the previous block. If they don't, consider the block invalid. [Pull Request #565](https://github.com/bigchaindb/bigchaindb/pull/565) +[#572](https://github.com/corechaindb/corechaindb/pull/572), +[#589](https://github.com/corechaindb/corechaindb/pull/589), +[#600](https://github.com/corechaindb/corechaindb/pull/600), +[#605](https://github.com/corechaindb/corechaindb/pull/605), +[#610](https://github.com/corechaindb/corechaindb/pull/610) +- Check that the majority of votes on a block agree on the previous block. If they don't, consider the block invalid. [Pull Request #565](https://github.com/corechaindb/corechaindb/pull/565) ### Changed -- Set RethinkDB `read-mode='majority'` everywhere: [Pull Request #497](https://github.com/bigchaindb/bigchaindb/pull/497) -- Ported election logic and voting logic to the new pipeline architecture: Pull Requests [#510](https://github.com/bigchaindb/bigchaindb/pull/510) and [#515](https://github.com/bigchaindb/bigchaindb/pull/515) -- Moved the transaction (model) `version` inside the `transaction` (in the transaction data model): [Pull Request #518](https://github.com/bigchaindb/bigchaindb/pull/518) -- Changed how the BigchainDB config file (JSON) gets written so it's easier for humans to read: [Pull Request #522](https://github.com/bigchaindb/bigchaindb/pull/522) -- Improved and expanded the GET/POST endpoints for transactions (in the HTTP API): [Pull Request #563](https://github.com/bigchaindb/bigchaindb/pull/563) -- Changed the AWS cluster deployment scripts so that the deployer now generates their keypair locally, rather than having Amazon do it: [Pull Request #567](https://github.com/bigchaindb/bigchaindb/pull/567) -- When a transaction is retrieved by `get_transaction`, a `validity` field is added with a value one of `valid`, `undecided`, or `backlog`: [Pull Request #574](https://github.com/bigchaindb/bigchaindb/pull/574) -- Renamed `current_owners` and `new_owners` (in the data models) to `owners_before` and `owners_after`, respectively (i.e. before/after *the transaction*): [Pull Request #578](https://github.com/bigchaindb/bigchaindb/pull/578) -- Use `flask_restful` and class-based views for realizing the HTTP API: [Pull Request #588](https://github.com/bigchaindb/bigchaindb/pull/588) +- Set RethinkDB `read-mode='majority'` everywhere: [Pull Request #497](https://github.com/corechaindb/corechaindb/pull/497) +- Ported election logic and voting logic to the new pipeline architecture: Pull Requests [#510](https://github.com/corechaindb/corechaindb/pull/510) and [#515](https://github.com/corechaindb/corechaindb/pull/515) +- Moved the transaction (model) `version` inside the `transaction` (in the transaction data model): [Pull Request #518](https://github.com/corechaindb/corechaindb/pull/518) +- Changed how the BigchainDB config file (JSON) gets written so it's easier for humans to read: [Pull Request #522](https://github.com/corechaindb/corechaindb/pull/522) +- Improved and expanded the GET/POST endpoints for transactions (in the HTTP API): [Pull Request #563](https://github.com/corechaindb/corechaindb/pull/563) +- Changed the AWS cluster deployment scripts so that the deployer now generates their keypair locally, rather than having Amazon do it: [Pull Request #567](https://github.com/corechaindb/corechaindb/pull/567) +- When a transaction is retrieved by `get_transaction`, a `validity` field is added with a value one of `valid`, `undecided`, or `backlog`: [Pull Request #574](https://github.com/corechaindb/corechaindb/pull/574) +- Renamed `current_owners` and `new_owners` (in the data models) to `owners_before` and `owners_after`, respectively (i.e. before/after *the transaction*): [Pull Request #578](https://github.com/corechaindb/corechaindb/pull/578) +- Use `flask_restful` and class-based views for realizing the HTTP API: [Pull Request #588](https://github.com/corechaindb/corechaindb/pull/588) ### Fixed -- Fixed the confusing error message when there was a syntax error in the BigchainDB config file: [Pull Request #531](https://github.com/bigchaindb/bigchaindb/pull/531) -- Fixed `write_transaction` so it no longer has the side effect of adding `assignee` to a transaction that is being processed: [Pull Request #606](https://github.com/bigchaindb/bigchaindb/pull/606) +- Fixed the confusing error message when there was a syntax error in the BigchainDB config file: [Pull Request #531](https://github.com/corechaindb/corechaindb/pull/531) +- Fixed `write_transaction` so it no longer has the side effect of adding `assignee` to a transaction that is being processed: [Pull Request #606](https://github.com/corechaindb/corechaindb/pull/606) ### External Contributors -- @eladve - [Pull Request #518](https://github.com/bigchaindb/bigchaindb/pull/518) -- @d01phin - Pull Requests [#522](https://github.com/bigchaindb/bigchaindb/pull/522) and [#531](https://github.com/bigchaindb/bigchaindb/pull/531) -- @Kentoseth - [Pull Request #537](https://github.com/bigchaindb/bigchaindb/pull/537) +- @eladve - [Pull Request #518](https://github.com/corechaindb/corechaindb/pull/518) +- @d01phin - Pull Requests [#522](https://github.com/corechaindb/corechaindb/pull/522) and [#531](https://github.com/corechaindb/corechaindb/pull/531) +- @Kentoseth - [Pull Request #537](https://github.com/corechaindb/corechaindb/pull/537) ### Notes - Several additions and changes to the documentation, e.g. Pull Requests -[#523](https://github.com/bigchaindb/bigchaindb/pull/523), -[#532](https://github.com/bigchaindb/bigchaindb/pull/532), -[#537](https://github.com/bigchaindb/bigchaindb/pull/537), -[#539](https://github.com/bigchaindb/bigchaindb/pull/539), -[#610](https://github.com/bigchaindb/bigchaindb/pull/610), and more +[#523](https://github.com/corechaindb/corechaindb/pull/523), +[#532](https://github.com/corechaindb/corechaindb/pull/532), +[#537](https://github.com/corechaindb/corechaindb/pull/537), +[#539](https://github.com/corechaindb/corechaindb/pull/539), +[#610](https://github.com/corechaindb/corechaindb/pull/610), and more ## [0.5.1] - 2016-07-29 @@ -888,40 +888,40 @@ Tag name: v0.5.1 committed: Jul 29, 2016, 2:38 PM GMT+2 ### Added -- New third table, the 'votes' table: [Pull Request #379](https://github.com/bigchaindb/bigchaindb/pull/379) -- Added `get_tx_by_payload_uuid()` including index: [Pull Request #411](https://github.com/bigchaindb/bigchaindb/pull/411) -- Ability to deploy a test cluster on AWS using Amazon Elastic Block Store (EBS) for storage: [Pull Request #469](https://github.com/bigchaindb/bigchaindb/pull/469) -- Ability to add different-size payloads to transactions when filling the backlog for benchmarking: [Pull Request #273](https://github.com/bigchaindb/bigchaindb/pull/273) +- New third table, the 'votes' table: [Pull Request #379](https://github.com/corechaindb/corechaindb/pull/379) +- Added `get_tx_by_payload_uuid()` including index: [Pull Request #411](https://github.com/corechaindb/corechaindb/pull/411) +- Ability to deploy a test cluster on AWS using Amazon Elastic Block Store (EBS) for storage: [Pull Request #469](https://github.com/corechaindb/corechaindb/pull/469) +- Ability to add different-size payloads to transactions when filling the backlog for benchmarking: [Pull Request #273](https://github.com/corechaindb/corechaindb/pull/273) ### Changed -- Votes are no longer appended to the blocks inside the 'bigchain' table. They're now written to their own table, the 'votes' table: [Pull Request #379](https://github.com/bigchaindb/bigchaindb/pull/379) -- Refactored how blocks get constructed using the new approach to doing multiprocessing, using the `multipipes` package: [Pull Request #484](https://github.com/bigchaindb/bigchaindb/pull/484) -- Changed all queries to use `read_mode='majority'`: [Pull Request #497](https://github.com/bigchaindb/bigchaindb/pull/497) -- Revised how base software gets deployed on AWS instances: [Pull Request #478](https://github.com/bigchaindb/bigchaindb/pull/478) -- Refactored `db.utils.init()`: [Pull Request #471](https://github.com/bigchaindb/bigchaindb/pull/471) +- Votes are no longer appended to the blocks inside the 'bigchain' table. They're now written to their own table, the 'votes' table: [Pull Request #379](https://github.com/corechaindb/corechaindb/pull/379) +- Refactored how blocks get constructed using the new approach to doing multiprocessing, using the `multipipes` package: [Pull Request #484](https://github.com/corechaindb/corechaindb/pull/484) +- Changed all queries to use `read_mode='majority'`: [Pull Request #497](https://github.com/corechaindb/corechaindb/pull/497) +- Revised how base software gets deployed on AWS instances: [Pull Request #478](https://github.com/corechaindb/corechaindb/pull/478) +- Refactored `db.utils.init()`: [Pull Request #471](https://github.com/corechaindb/corechaindb/pull/471) ### External Contributors -- @shauns - [Pull Request #411](https://github.com/bigchaindb/bigchaindb/pull/411) -- @lonelypeanut - [Pull Request #479](https://github.com/bigchaindb/bigchaindb/pull/479) -- @lluminita - Pull Requests [#435](https://github.com/bigchaindb/bigchaindb/pull/435) & [#471](https://github.com/bigchaindb/bigchaindb/pull/471) +- @shauns - [Pull Request #411](https://github.com/corechaindb/corechaindb/pull/411) +- @lonelypeanut - [Pull Request #479](https://github.com/corechaindb/corechaindb/pull/479) +- @lluminita - Pull Requests [#435](https://github.com/corechaindb/corechaindb/pull/435) & [#471](https://github.com/corechaindb/corechaindb/pull/471) ### Notes - Several additions and changes to the documentation: Pull Requests -[#416](https://github.com/bigchaindb/bigchaindb/pull/416), -[#417](https://github.com/bigchaindb/bigchaindb/pull/417), -[#418](https://github.com/bigchaindb/bigchaindb/pull/418), -[#420](https://github.com/bigchaindb/bigchaindb/pull/420), -[#421](https://github.com/bigchaindb/bigchaindb/pull/421), -[#422](https://github.com/bigchaindb/bigchaindb/pull/422), -[#423](https://github.com/bigchaindb/bigchaindb/pull/423), -[#425](https://github.com/bigchaindb/bigchaindb/pull/425), -[#428](https://github.com/bigchaindb/bigchaindb/pull/428), -[#430](https://github.com/bigchaindb/bigchaindb/pull/430), -[#431](https://github.com/bigchaindb/bigchaindb/pull/431), -[#435](https://github.com/bigchaindb/bigchaindb/pull/435), -[#442](https://github.com/bigchaindb/bigchaindb/pull/442), -[#472](https://github.com/bigchaindb/bigchaindb/pull/472), -[#481](https://github.com/bigchaindb/bigchaindb/pull/481) +[#416](https://github.com/corechaindb/corechaindb/pull/416), +[#417](https://github.com/corechaindb/corechaindb/pull/417), +[#418](https://github.com/corechaindb/corechaindb/pull/418), +[#420](https://github.com/corechaindb/corechaindb/pull/420), +[#421](https://github.com/corechaindb/corechaindb/pull/421), +[#422](https://github.com/corechaindb/corechaindb/pull/422), +[#423](https://github.com/corechaindb/corechaindb/pull/423), +[#425](https://github.com/corechaindb/corechaindb/pull/425), +[#428](https://github.com/corechaindb/corechaindb/pull/428), +[#430](https://github.com/corechaindb/corechaindb/pull/430), +[#431](https://github.com/corechaindb/corechaindb/pull/431), +[#435](https://github.com/corechaindb/corechaindb/pull/435), +[#442](https://github.com/corechaindb/corechaindb/pull/442), +[#472](https://github.com/corechaindb/corechaindb/pull/472), +[#481](https://github.com/corechaindb/corechaindb/pull/481) ## [0.5.0] - 2016-07-04 @@ -930,23 +930,23 @@ Tag name: v0.5.0 committed: July 4, 2016, 1:07 PM GMT+2 ### Added -- New `bigchaindb set-replicas` subcommand: [Pull Request #392](https://github.com/bigchaindb/bigchaindb/pull/392) -- Informative JSON message when one makes a request to the root endpoint of the HTTP client-server API: [Pull Request #367](https://github.com/bigchaindb/bigchaindb/pull/367) -- Return HTTP response code 404 when a transaction is not found: [Pull Request #369](https://github.com/bigchaindb/bigchaindb/pull/369) +- New `corechaindb set-replicas` subcommand: [Pull Request #392](https://github.com/corechaindb/corechaindb/pull/392) +- Informative JSON message when one makes a request to the root endpoint of the HTTP client-server API: [Pull Request #367](https://github.com/corechaindb/corechaindb/pull/367) +- Return HTTP response code 404 when a transaction is not found: [Pull Request #369](https://github.com/corechaindb/corechaindb/pull/369) ### Changed -- Changed the order in which configuration settings get their values. If a setting is set by an environment variable, then that value will be _the_ value, regardless of whether another value is set in a local config file. Also added a method to programattically update the config settings. [Pull Request #395](https://github.com/bigchaindb/bigchaindb/pull/395) -- Changed the definition of `util.sign_tx()`. It now has a third, optional argument: a Bigchain instance. [Pull Request #410](https://github.com/bigchaindb/bigchaindb/pull/410) +- Changed the order in which configuration settings get their values. If a setting is set by an environment variable, then that value will be _the_ value, regardless of whether another value is set in a local config file. Also added a method to programattically update the config settings. [Pull Request #395](https://github.com/corechaindb/corechaindb/pull/395) +- Changed the definition of `util.sign_tx()`. It now has a third, optional argument: a Bigchain instance. [Pull Request #410](https://github.com/corechaindb/corechaindb/pull/410) ### Notes - Several additions and changes to the documentation: Pull Requests -[#388](https://github.com/bigchaindb/bigchaindb/pull/388), -[#393](https://github.com/bigchaindb/bigchaindb/pull/393), -[#397](https://github.com/bigchaindb/bigchaindb/pull/397), -[#402](https://github.com/bigchaindb/bigchaindb/pull/402), -[#403](https://github.com/bigchaindb/bigchaindb/pull/403), -[#406](https://github.com/bigchaindb/bigchaindb/pull/406), -[#408](https://github.com/bigchaindb/bigchaindb/pull/408) +[#388](https://github.com/corechaindb/corechaindb/pull/388), +[#393](https://github.com/corechaindb/corechaindb/pull/393), +[#397](https://github.com/corechaindb/corechaindb/pull/397), +[#402](https://github.com/corechaindb/corechaindb/pull/402), +[#403](https://github.com/corechaindb/corechaindb/pull/403), +[#406](https://github.com/corechaindb/corechaindb/pull/406), +[#408](https://github.com/corechaindb/corechaindb/pull/408) ## [0.4.2] - 2016-06-15 @@ -955,11 +955,11 @@ Tag name: v0.4.2 committed: June 15, 2016, 1:42 PM GMT+2 ### Added -- Report the BigchainDB version number when starting BigchainDB: [Pull Request #385](https://github.com/bigchaindb/bigchaindb/pull/385) +- Report the BigchainDB version number when starting BigchainDB: [Pull Request #385](https://github.com/corechaindb/corechaindb/pull/385) ### Changed -- Round timestamps to a precision of one second, and replace payload hash with payload UUID in transactions: [Pull Request #384](https://github.com/bigchaindb/bigchaindb/pull/384) -- Updated cryptoconditions API usage: [Pull Request #373](https://github.com/bigchaindb/bigchaindb/pull/373) +- Round timestamps to a precision of one second, and replace payload hash with payload UUID in transactions: [Pull Request #384](https://github.com/corechaindb/corechaindb/pull/384) +- Updated cryptoconditions API usage: [Pull Request #373](https://github.com/corechaindb/corechaindb/pull/373) ## [0.4.1] - 2016-06-13 @@ -968,22 +968,22 @@ Tag name: v0.4.1 committed: June 13, 2016, 9:52 AM GMT+2 ### Added -- Revert `bigchain` deletes: [Pull Request #330](https://github.com/bigchaindb/bigchaindb/pull/330) +- Revert `bigchain` deletes: [Pull Request #330](https://github.com/corechaindb/corechaindb/pull/330) ### Changed -- Use inverted threshold condition instead of negative weights for escrow: [Pull Request #355](https://github.com/bigchaindb/bigchaindb/pull/355) +- Use inverted threshold condition instead of negative weights for escrow: [Pull Request #355](https://github.com/corechaindb/corechaindb/pull/355) ### Fixed -- Removed duplicate `pytest` in `setup.py`: [Pull Request #365](https://github.com/bigchaindb/bigchaindb/pull/365) +- Removed duplicate `pytest` in `setup.py`: [Pull Request #365](https://github.com/corechaindb/corechaindb/pull/365) ### Notes - There were several additions and changes to the documentation: Pull Requests -[#343](https://github.com/bigchaindb/bigchaindb/pull/343), -[#363](https://github.com/bigchaindb/bigchaindb/pull/363), -[#364](https://github.com/bigchaindb/bigchaindb/pull/364), -[#366](https://github.com/bigchaindb/bigchaindb/pull/366), -[#370](https://github.com/bigchaindb/bigchaindb/pull/370), -[#372](https://github.com/bigchaindb/bigchaindb/pull/372) +[#343](https://github.com/corechaindb/corechaindb/pull/343), +[#363](https://github.com/corechaindb/corechaindb/pull/363), +[#364](https://github.com/corechaindb/corechaindb/pull/364), +[#366](https://github.com/corechaindb/corechaindb/pull/366), +[#370](https://github.com/corechaindb/corechaindb/pull/370), +[#372](https://github.com/corechaindb/corechaindb/pull/372) ## [0.4.0] - 2016-05-27 @@ -992,32 +992,32 @@ Tag name: v0.4.0 committed: May 27, 2016, 1:42 PM GMT+2 ### Added -- Support for escrow (possible because of two other new things: cryptoconditions with inverters, and a timeout condition): [Pull Request #329](https://github.com/bigchaindb/bigchaindb/pull/329) -- Caching of calls to `load_consensus_plugin()`, using [`@lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache). This speeds up the instantiation of `Bigchain` objects and greatly improves overall performance. [Pull Request #271](https://github.com/bigchaindb/bigchaindb/pull/271) -- New `Dockerfile-dev` Docker file to make it easier for developers to _develop_ BigchainDB with Docker. One can run all unit tests with Docker again. [Pull Request #313](https://github.com/bigchaindb/bigchaindb/pull/313) -- Transactions in invalid blocks are copied to the backlog: [Pull Request #221](https://github.com/bigchaindb/bigchaindb/pull/221). -- Queries to the bigchain table now ignore invalid blocks: [Pull Request #324](https://github.com/bigchaindb/bigchaindb/issues/324) -- Use secondary index on get_transaction: [Pull Request #324](https://github.com/bigchaindb/bigchaindb/issues/324) -- New `bigchaindb` command to set the number of RethinkDB shards (in both tables): [Pull Request #258](https://github.com/bigchaindb/bigchaindb/pull/258) -- Better handling of an outdated `setuptools`: [Pull Request #279](https://github.com/bigchaindb/bigchaindb/pull/279) +- Support for escrow (possible because of two other new things: cryptoconditions with inverters, and a timeout condition): [Pull Request #329](https://github.com/corechaindb/corechaindb/pull/329) +- Caching of calls to `load_consensus_plugin()`, using [`@lru_cache`](https://docs.python.org/3/library/functools.html#functools.lru_cache). This speeds up the instantiation of `Bigchain` objects and greatly improves overall performance. [Pull Request #271](https://github.com/corechaindb/corechaindb/pull/271) +- New `Dockerfile-dev` Docker file to make it easier for developers to _develop_ BigchainDB with Docker. One can run all unit tests with Docker again. [Pull Request #313](https://github.com/corechaindb/corechaindb/pull/313) +- Transactions in invalid blocks are copied to the backlog: [Pull Request #221](https://github.com/corechaindb/corechaindb/pull/221). +- Queries to the bigchain table now ignore invalid blocks: [Pull Request #324](https://github.com/corechaindb/corechaindb/issues/324) +- Use secondary index on get_transaction: [Pull Request #324](https://github.com/corechaindb/corechaindb/issues/324) +- New `corechaindb` command to set the number of RethinkDB shards (in both tables): [Pull Request #258](https://github.com/corechaindb/corechaindb/pull/258) +- Better handling of an outdated `setuptools`: [Pull Request #279](https://github.com/corechaindb/corechaindb/pull/279) ### Changed -- The block processes now use GroupProcess: [Pull Request #267](https://github.com/bigchaindb/bigchaindb/pull/267) -- Replaced the `json` Python package with `rapidjson` (a Python wrapper for a fast JSON parser/generator written in C++), to speed up JSON serialization and deserialization: [Pull Request #318](https://github.com/bigchaindb/bigchaindb/pull/318) -- Overhauled `ROADMAP.md` and moved it to [the bigchaindb/org repository](https://github.com/bigchaindb/org): Pull Requests -[#282](https://github.com/bigchaindb/bigchaindb/pull/282), -[#306](https://github.com/bigchaindb/bigchaindb/pull/306), -[#308](https://github.com/bigchaindb/bigchaindb/pull/308), -[#325](https://github.com/bigchaindb/bigchaindb/pull/325) -- AWS deployment has better support for [New Relic Server Monitoring](https://newrelic.com/server-monitoring): [Pull Request #316](https://github.com/bigchaindb/bigchaindb/pull/316) -- AWS deployment script now reads from a configuration file: [Pull Request #291](https://github.com/bigchaindb/bigchaindb/pull/291) -- AWS deployment script doesn't auto-start the BigchainDB servers anymore: [Pull Request #257](https://github.com/bigchaindb/bigchaindb/pull/257) +- The block processes now use GroupProcess: [Pull Request #267](https://github.com/corechaindb/corechaindb/pull/267) +- Replaced the `json` Python package with `rapidjson` (a Python wrapper for a fast JSON parser/generator written in C++), to speed up JSON serialization and deserialization: [Pull Request #318](https://github.com/corechaindb/corechaindb/pull/318) +- Overhauled `ROADMAP.md` and moved it to [the corechaindb/org repository](https://github.com/corechaindb/org): Pull Requests +[#282](https://github.com/corechaindb/corechaindb/pull/282), +[#306](https://github.com/corechaindb/corechaindb/pull/306), +[#308](https://github.com/corechaindb/corechaindb/pull/308), +[#325](https://github.com/corechaindb/corechaindb/pull/325) +- AWS deployment has better support for [New Relic Server Monitoring](https://newrelic.com/server-monitoring): [Pull Request #316](https://github.com/corechaindb/corechaindb/pull/316) +- AWS deployment script now reads from a configuration file: [Pull Request #291](https://github.com/corechaindb/corechaindb/pull/291) +- AWS deployment script doesn't auto-start the BigchainDB servers anymore: [Pull Request #257](https://github.com/corechaindb/corechaindb/pull/257) ### Fixed -- Bug related to transaction malleability: [Pull Request #281](https://github.com/bigchaindb/bigchaindb/pull/281) +- Bug related to transaction malleability: [Pull Request #281](https://github.com/corechaindb/corechaindb/pull/281) ### Notes -You can now see a big-picture view of all BigchainDB repositories on [a waffle.io board](https://waffle.io/bigchaindb/org). +You can now see a big-picture view of all BigchainDB repositories on [a waffle.io board](https://waffle.io/corechaindb/org). ## [0.3.0] - 2016-05-03 @@ -1026,14 +1026,14 @@ Tag name: v0.3.0 committed: May 3, 2016, 11:52 AM GMT+2 ### Added -- Crypto-conditions specs according to the Interledger protocol: [Pull Request #174](https://github.com/bigchaindb/bigchaindb/pull/174) -- Added support for anonymous hashlocked conditions and fulfillments: [Pull Request #211](https://github.com/bigchaindb/bigchaindb/pull/211) +- Crypto-conditions specs according to the Interledger protocol: [Pull Request #174](https://github.com/corechaindb/corechaindb/pull/174) +- Added support for anonymous hashlocked conditions and fulfillments: [Pull Request #211](https://github.com/corechaindb/corechaindb/pull/211) ### Changed -- Several improvements to the AWS deployment scripts: [Pull Request #227](https://github.com/bigchaindb/bigchaindb/pull/227) +- Several improvements to the AWS deployment scripts: [Pull Request #227](https://github.com/corechaindb/corechaindb/pull/227) ### Fixed -- Bug related to block validation: [Pull Request #233](https://github.com/bigchaindb/bigchaindb/pull/233) +- Bug related to block validation: [Pull Request #233](https://github.com/corechaindb/corechaindb/pull/233) ### Notes This release completely refactored the structure of the transactions and broke compatibility with older versions @@ -1049,43 +1049,43 @@ Tag name: v0.2.0 committed: April 26, 2016, 11:09 AM GMT+2 ### Added -- Ability to use environment variables to set (or partially set) configuration settings: [Pull Request #153](https://github.com/bigchaindb/bigchaindb/pull/153) -- `bigchaindb --export-my-pubkey`: [Pull Request #186](https://github.com/bigchaindb/bigchaindb/pull/186) -- `bigchaindb --version`, and one central source for the current version (`version.py`): [Pull Request #208](https://github.com/bigchaindb/bigchaindb/pull/208) +- Ability to use environment variables to set (or partially set) configuration settings: [Pull Request #153](https://github.com/corechaindb/corechaindb/pull/153) +- `corechaindb --export-my-pubkey`: [Pull Request #186](https://github.com/corechaindb/corechaindb/pull/186) +- `corechaindb --version`, and one central source for the current version (`version.py`): [Pull Request #208](https://github.com/corechaindb/corechaindb/pull/208) - AWS deployment scripts: Pull Requests -[#160](https://github.com/bigchaindb/bigchaindb/pull/160), -[#166](https://github.com/bigchaindb/bigchaindb/pull/166), -[#172](https://github.com/bigchaindb/bigchaindb/pull/172), -[#203](https://github.com/bigchaindb/bigchaindb/pull/203) -- `codecov.yml`: [Pull Request #161](https://github.com/bigchaindb/bigchaindb/pull/161) -- `CHANGELOG.md` (this file): [Pull Request #117](https://github.com/bigchaindb/bigchaindb/pull/117) +[#160](https://github.com/corechaindb/corechaindb/pull/160), +[#166](https://github.com/corechaindb/corechaindb/pull/166), +[#172](https://github.com/corechaindb/corechaindb/pull/172), +[#203](https://github.com/corechaindb/corechaindb/pull/203) +- `codecov.yml`: [Pull Request #161](https://github.com/corechaindb/corechaindb/pull/161) +- `CHANGELOG.md` (this file): [Pull Request #117](https://github.com/corechaindb/corechaindb/pull/117) - Signatures using Ed25519: Pull Requests -[#138](https://github.com/bigchaindb/bigchaindb/pull/138), -[#152](https://github.com/bigchaindb/bigchaindb/pull/152) -- Multisig support: [Pull Request #107](https://github.com/bigchaindb/bigchaindb/pull/107) +[#138](https://github.com/corechaindb/corechaindb/pull/138), +[#152](https://github.com/corechaindb/corechaindb/pull/152) +- Multisig support: [Pull Request #107](https://github.com/corechaindb/corechaindb/pull/107) - HTTP Server & Web API: Pull Requests -[#102](https://github.com/bigchaindb/bigchaindb/pull/102), -[#150](https://github.com/bigchaindb/bigchaindb/pull/150), -[#155](https://github.com/bigchaindb/bigchaindb/pull/155), -[#183](https://github.com/bigchaindb/bigchaindb/pull/183) -- Python driver/SDK/API: [Pull Request #102](https://github.com/bigchaindb/bigchaindb/pull/102) -- Python Style Guide: [Pull Request #89](https://github.com/bigchaindb/bigchaindb/pull/89) +[#102](https://github.com/corechaindb/corechaindb/pull/102), +[#150](https://github.com/corechaindb/corechaindb/pull/150), +[#155](https://github.com/corechaindb/corechaindb/pull/155), +[#183](https://github.com/corechaindb/corechaindb/pull/183) +- Python driver/SDK/API: [Pull Request #102](https://github.com/corechaindb/corechaindb/pull/102) +- Python Style Guide: [Pull Request #89](https://github.com/corechaindb/corechaindb/pull/89) - Monitoring & dashboard tools: Pull Requests -[#72](https://github.com/bigchaindb/bigchaindb/pull/72), -[#181](https://github.com/bigchaindb/bigchaindb/pull/181) +[#72](https://github.com/corechaindb/corechaindb/pull/72), +[#181](https://github.com/corechaindb/corechaindb/pull/181) ### Changed -- Rewrote [`README.md`](README.md) into four sets of links: Pull Requests [#80](https://github.com/bigchaindb/bigchaindb/pull/80) and [#115](https://github.com/bigchaindb/bigchaindb/pull/115) +- Rewrote [`README.md`](README.md) into four sets of links: Pull Requests [#80](https://github.com/corechaindb/corechaindb/pull/80) and [#115](https://github.com/corechaindb/corechaindb/pull/115) ### Fixed -- Bug related to config overwrite: [Pull Request #97](https://github.com/bigchaindb/bigchaindb/pull/97) -- Bug related to running the `bigchaindb-benchmark load` on docker [Pull Request #225](https://github.com/bigchaindb/bigchaindb/pull/225) +- Bug related to config overwrite: [Pull Request #97](https://github.com/corechaindb/corechaindb/pull/97) +- Bug related to running the `corechaindb-benchmark load` on docker [Pull Request #225](https://github.com/corechaindb/corechaindb/pull/225) ## External Contributors - [@thedoctor](https://github.com/thedoctor): Pull Requests -[#99](https://github.com/bigchaindb/bigchaindb/pull/99), -[#136](https://github.com/bigchaindb/bigchaindb/pull/136) -- [@roderik](https://github.com/roderik): [Pull Request #162](https://github.com/bigchaindb/bigchaindb/pull/162) +[#99](https://github.com/corechaindb/corechaindb/pull/99), +[#136](https://github.com/corechaindb/corechaindb/pull/136) +- [@roderik](https://github.com/roderik): [Pull Request #162](https://github.com/corechaindb/corechaindb/pull/162) ## [0.1.5] - 2016-04-20 @@ -1094,7 +1094,7 @@ Tag name: v0.1.5 committed: April 20, 2016, 3:31 PM GMT+2 ### Fixed -- [Issue #71](https://github.com/bigchaindb/bigchaindb/issues/71) (Voter is not validating blocks correctly when checking for double spends) in [Pull Request #76](https://github.com/bigchaindb/bigchaindb/pull/76) +- [Issue #71](https://github.com/corechaindb/corechaindb/issues/71) (Voter is not validating blocks correctly when checking for double spends) in [Pull Request #76](https://github.com/corechaindb/corechaindb/pull/76) ## [0.1.4] - 2016-02-22 @@ -1106,8 +1106,8 @@ committed: Feb 22, 2016, 11:51 AM GMT+1 - Added to `classifiers` to setup.py ### Changed -- Allow running pytest tests in parallel (using [xdist](http://pytest.org/latest/xdist.html)): [Pull Request #65](https://github.com/bigchaindb/bigchaindb/pull/65) -- Allow non-interactive first start: [Pull Request #64](https://github.com/bigchaindb/bigchaindb/pull/64) to resolve [Issue #58](https://github.com/bigchaindb/bigchaindb/issues/58) +- Allow running pytest tests in parallel (using [xdist](http://pytest.org/latest/xdist.html)): [Pull Request #65](https://github.com/corechaindb/corechaindb/pull/65) +- Allow non-interactive first start: [Pull Request #64](https://github.com/corechaindb/corechaindb/pull/64) to resolve [Issue #58](https://github.com/corechaindb/corechaindb/issues/58) ## [0.1.3] - 2016-02-16 @@ -1128,7 +1128,7 @@ committed Feb 15, 2016, 2:23 PM GMT+1 - Various tests ### Fixed -- Fix exception when running `start`: [Pull Request #32](https://github.com/bigchaindb/bigchaindb/pull/32) resolved [Issue #35] +- Fix exception when running `start`: [Pull Request #32](https://github.com/corechaindb/corechaindb/pull/32) resolved [Issue #35] ## [0.1.1] - 2016-02-15 Tag name: v0.1.1 @@ -1136,14 +1136,14 @@ Tag name: v0.1.1 committed Feb 15, 2016, 10:48 AM GMT+1 ### Added -- "release 0.1.1": [Pull Request #37](https://github.com/bigchaindb/bigchaindb/pull/37) +- "release 0.1.1": [Pull Request #37](https://github.com/corechaindb/corechaindb/pull/37) ### Removed -- `tox.ini` [Pull Request #18](https://github.com/bigchaindb/bigchaindb/pull/18) -- `requirements.txt` in the root directory, and the entire `requirements/` directory: [Pull Request #14](https://github.com/bigchaindb/bigchaindb/pull/14) +- `tox.ini` [Pull Request #18](https://github.com/corechaindb/corechaindb/pull/18) +- `requirements.txt` in the root directory, and the entire `requirements/` directory: [Pull Request #14](https://github.com/corechaindb/corechaindb/pull/14) ### Fixed -- Hotfix for AttributeError, fixed [Issue #27](https://github.com/bigchaindb/bigchaindb/issues/27) +- Hotfix for AttributeError, fixed [Issue #27](https://github.com/corechaindb/corechaindb/issues/27) ## [0.1.0] - 2016-02-10 @@ -1154,7 +1154,7 @@ committed Feb 10, 2016, 10:04 PM GMT+1 The first public release of BigchainDB, including: - Initial BigchainDB Server code, including many tests and some code for benchmarking. -- Initial documentation (in `bigchaindb/docs`). +- Initial documentation (in `corechaindb/docs`). - Initial `README.md`, `ROADMAP.md`, `CODE_OF_CONDUCT.md`, and `CONTRIBUTING.md`. - Packaging for PyPI, including `setup.py` and `setup.cfg`. - Initial `Dockerfile` and `docker-compose.yml` (for deployment using Docker and Docker Compose). diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 4dff95cd..3366dea8 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -42,7 +42,7 @@ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Instances of abusive, harassing, or otherwise unacceptable behavior directed at yourself or another community member may be -reported by contacting a project maintainer at [contact@bigchaindb.com](mailto:contact@bigchaindb.com). All +reported by contacting a project maintainer at [contact@corechaindb.com](mailto:contact@corechaindb.com). All complaints will be reviewed and investigated and will result in a response that is appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an diff --git a/Dockerfile b/Dockerfile index ea644271..6faa1834 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,12 +13,12 @@ RUN apt-get -qq update \ VOLUME ["/data", "/certs"] ENV PYTHONUNBUFFERED 0 -ENV BIGCHAINDB_CONFIG_PATH /data/.bigchaindb +ENV BIGCHAINDB_CONFIG_PATH /data/.corechaindb ENV BIGCHAINDB_SERVER_BIND 0.0.0.0:9984 ENV BIGCHAINDB_WSSERVER_HOST 0.0.0.0 ENV BIGCHAINDB_WSSERVER_SCHEME ws ENV BIGCHAINDB_WSSERVER_ADVERTISED_HOST 0.0.0.0 ENV BIGCHAINDB_WSSERVER_ADVERTISED_SCHEME ws ENV BIGCHAINDB_WSSERVER_ADVERTISED_PORT 9985 -ENTRYPOINT ["bigchaindb"] +ENTRYPOINT ["corechaindb"] CMD ["start"] diff --git a/Dockerfile-alpine b/Dockerfile-alpine index 3f9b1909..b4aea217 100644 --- a/Dockerfile-alpine +++ b/Dockerfile-alpine @@ -27,4 +27,4 @@ ENV BIGCHAINDB_WSSERVER_ADVERTISED_SCHEME ws ENV BIGCHAINDB_TENDERMINT_PORT 26657 ARG backend -RUN bigchaindb -y configure "$backend" \ No newline at end of file +RUN corechaindb -y configure "$backend" \ No newline at end of file diff --git a/Dockerfile-dev b/Dockerfile-dev index 40f38d90..9523ee2d 100644 --- a/Dockerfile-dev +++ b/Dockerfile-dev @@ -32,4 +32,4 @@ RUN mkdir -p /usr/src/app COPY . /usr/src/app/ WORKDIR /usr/src/app RUN pip install -e .[dev] -RUN bigchaindb -y configure +RUN corechaindb -y configure diff --git a/LICENSES.md b/LICENSES.md index 57d68574..12af030b 100644 --- a/LICENSES.md +++ b/LICENSES.md @@ -5,8 +5,8 @@ For all the code and documentation in this repository, the copyright is owned by one or more of the following: - BigchainDB GmbH -- A BigchainDB contributor who agreed to a BigchainDB Contributor License Agreement (CLA) with BigchainDB GmbH. (See [BEP-16](https://github.com/bigchaindb/BEPs/tree/master/16).) -- A BigchainDB contributor who signed off on the Developer Certificate of Origin (DCO) for all their contributions. (See [BEP-24](https://github.com/bigchaindb/BEPs/tree/master/24).) +- A BigchainDB contributor who agreed to a BigchainDB Contributor License Agreement (CLA) with BigchainDB GmbH. (See [BEP-16](https://github.com/corechaindb/BEPs/tree/master/16).) +- A BigchainDB contributor who signed off on the Developer Certificate of Origin (DCO) for all their contributions. (See [BEP-24](https://github.com/corechaindb/BEPs/tree/master/24).) - (Rarely, see the **Exceptions Section** below) A third pary who licensed the code in question under an open source license. ## Code Licenses diff --git a/Makefile b/Makefile index 8465d909..455773ab 100644 --- a/Makefile +++ b/Makefile @@ -56,34 +56,34 @@ help: ## Show this help @$(HELP) < $(MAKEFILE_LIST) run: check-deps ## Run BigchainDB from source (stop it with ctrl+c) - # although bigchaindb has tendermint and mongodb in depends_on, + # although corechaindb has tendermint and mongodb in depends_on, # launch them first otherwise tendermint will get stuck upon sending yet another log # due to some docker-compose issue; does not happen when containers are run as daemons - @$(DC) up --no-deps mongodb tendermint bigchaindb + @$(DC) up --no-deps mongodb tendermint corechaindb start: check-deps ## Run BigchainDB from source and daemonize it (stop with `make stop`) - @$(DC) up -d bigchaindb + @$(DC) up -d corechaindb stop: check-deps ## Stop BigchainDB @$(DC) stop logs: check-deps ## Attach to the logs - @$(DC) logs -f bigchaindb + @$(DC) logs -f corechaindb test: check-deps test-unit test-acceptance ## Run unit and acceptance tests test-unit: check-deps ## Run all tests once @$(DC) up -d bdb - @$(DC) exec bigchaindb pytest + @$(DC) exec corechaindb pytest test-unit-watch: check-deps ## Run all tests and wait. Every time you change code, tests will be run again - @$(DC) run --rm --no-deps bigchaindb pytest -f + @$(DC) run --rm --no-deps corechaindb pytest -f test-acceptance: check-deps ## Run all acceptance tests @./run-acceptance-test.sh cov: check-deps ## Check code coverage and open the result in the browser - @$(DC) run --rm bigchaindb pytest -v --cov=bigchaindb --cov-report html + @$(DC) run --rm corechaindb pytest -v --cov=corechaindb --cov-report html $(BROWSER) htmlcov/index.html doc: check-deps ## Generate HTML documentation and open it in the browser diff --git a/PYTHON_STYLE_GUIDE.md b/PYTHON_STYLE_GUIDE.md index 5cdb39b8..4f2ce986 100644 --- a/PYTHON_STYLE_GUIDE.md +++ b/PYTHON_STYLE_GUIDE.md @@ -16,7 +16,7 @@ Our starting point is [PEP8](https://www.python.org/dev/peps/pep-0008/), the sta BigchainDB uses Python 3.5+, so you can ignore all PEP8 guidelines specific to Python 2. We use [pre-commit](http://pre-commit.com/) to check some of the rules below before every commit but not everything is realized yet. -The hooks we use can be found in the [.pre-commit-config.yaml](https://github.com/bigchaindb/bigchaindb/blob/master/.pre-commit-config.yaml) file. +The hooks we use can be found in the [.pre-commit-config.yaml](https://github.com/corechaindb/corechaindb/blob/master/.pre-commit-config.yaml) file. ### Python Docstrings @@ -86,12 +86,12 @@ we use the `format()` version. The [official Python documentation says](https:// We use [Flake8](http://flake8.pycqa.org/en/latest/index.html) to check our Python code style. Once you have it installed, you can run it using: ```text -flake8 --max-line-length 119 bigchaindb/ +flake8 --max-line-length 119 corechaindb/ ``` ## Writing and Running (Python) Tests -The content of this section was moved to [`bigchaindb/tests/README.md`](https://github.com/bigchaindb/bigchaindb/blob/master/tests/README.md). +The content of this section was moved to [`corechaindb/tests/README.md`](https://github.com/corechaindb/corechaindb/blob/master/tests/README.md). Note: We automatically run all tests on all pull requests (using Travis CI), so you should definitely run all tests locally before you submit a pull request. See the above-linked README file for instructions. diff --git a/README.md b/README.md index fb23ac0e..80597a93 100644 --- a/README.md +++ b/README.md @@ -10,12 +10,12 @@ Code is Apache-2.0 and docs are CC-BY-4.0 so show the latest GitHub release instead. ---> -[![Codecov branch](https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb/master.svg)](https://codecov.io/github/bigchaindb/bigchaindb?branch=master) -[![Latest release](https://img.shields.io/github/release/bigchaindb/bigchaindb/all.svg)](https://github.com/bigchaindb/bigchaindb/releases) -[![Status on PyPI](https://img.shields.io/pypi/status/bigchaindb.svg)](https://pypi.org/project/BigchainDB/) -[![Travis branch](https://img.shields.io/travis/bigchaindb/bigchaindb/master.svg)](https://travis-ci.com/bigchaindb/bigchaindb) -[![Documentation Status](https://readthedocs.org/projects/bigchaindb-server/badge/?version=latest)](https://docs.bigchaindb.com/projects/server/en/latest/) -[![Join the chat at https://gitter.im/bigchaindb/bigchaindb](https://badges.gitter.im/bigchaindb/bigchaindb.svg)](https://gitter.im/bigchaindb/bigchaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Codecov branch](https://img.shields.io/codecov/c/github/corechaindb/corechaindb/master.svg)](https://codecov.io/github/corechaindb/corechaindb?branch=master) +[![Latest release](https://img.shields.io/github/release/corechaindb/corechaindb/all.svg)](https://github.com/corechaindb/corechaindb/releases) +[![Status on PyPI](https://img.shields.io/pypi/status/corechaindb.svg)](https://pypi.org/project/BigchainDB/) +[![Travis branch](https://img.shields.io/travis/corechaindb/corechaindb/master.svg)](https://travis-ci.com/corechaindb/corechaindb) +[![Documentation Status](https://readthedocs.org/projects/corechaindb-server/badge/?version=latest)](https://docs.corechaindb.com/projects/server/en/latest/) +[![Join the chat at https://gitter.im/corechaindb/corechaindb](https://badges.gitter.im/corechaindb/corechaindb.svg)](https://gitter.im/corechaindb/corechaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) # BigchainDB Server @@ -23,17 +23,17 @@ BigchainDB is the blockchain database. This repository is for _BigchainDB Server ## The Basics -* [Try the Quickstart](https://docs.bigchaindb.com/projects/server/en/latest/quickstart.html) -* [Read the BigchainDB 2.0 whitepaper](https://www.bigchaindb.com/whitepaper/) -* [Check out the _Hitchiker's Guide to BigchainDB_](https://www.bigchaindb.com/developers/guide/) +* [Try the Quickstart](https://docs.corechaindb.com/projects/server/en/latest/quickstart.html) +* [Read the BigchainDB 2.0 whitepaper](https://www.corechaindb.com/whitepaper/) +* [Check out the _Hitchiker's Guide to BigchainDB_](https://www.corechaindb.com/developers/guide/) ## Run and Test BigchainDB Server from the `master` Branch Running and testing the latest version of BigchainDB Server is easy. Make sure you have a recent version of [Docker Compose](https://docs.docker.com/compose/install/) installed. When you are ready, fire up a terminal and run: ```text -git clone https://github.com/bigchaindb/bigchaindb.git -cd bigchaindb +git clone https://github.com/corechaindb/corechaindb.git +cd corechaindb make run ``` @@ -55,23 +55,23 @@ To view all commands available, run `make`. ## Links for Everyone -* [BigchainDB.com](https://www.bigchaindb.com/) - the main BigchainDB website, including newsletter signup -* [Roadmap](https://github.com/bigchaindb/org/blob/master/ROADMAP.md) -* [Blog](https://medium.com/the-bigchaindb-blog) +* [BigchainDB.com](https://www.corechaindb.com/) - the main BigchainDB website, including newsletter signup +* [Roadmap](https://github.com/corechaindb/org/blob/master/ROADMAP.md) +* [Blog](https://medium.com/the-corechaindb-blog) * [Twitter](https://twitter.com/BigchainDB) ## Links for Developers -* [All BigchainDB Documentation](https://docs.bigchaindb.com/en/latest/) -* [BigchainDB Server Documentation](https://docs.bigchaindb.com/projects/server/en/latest/index.html) +* [All BigchainDB Documentation](https://docs.corechaindb.com/en/latest/) +* [BigchainDB Server Documentation](https://docs.corechaindb.com/projects/server/en/latest/index.html) * [CONTRIBUTING.md](.github/CONTRIBUTING.md) - how to contribute * [Community guidelines](CODE_OF_CONDUCT.md) -* [Open issues](https://github.com/bigchaindb/bigchaindb/issues) -* [Open pull requests](https://github.com/bigchaindb/bigchaindb/pulls) -* [Gitter chatroom](https://gitter.im/bigchaindb/bigchaindb) +* [Open issues](https://github.com/corechaindb/corechaindb/issues) +* [Open pull requests](https://github.com/corechaindb/corechaindb/pulls) +* [Gitter chatroom](https://gitter.im/corechaindb/corechaindb) ## Legal * [Licenses](LICENSES.md) - open source & open content -* [Imprint](https://www.bigchaindb.com/imprint/) -* [Contact Us](https://www.bigchaindb.com/contact/) +* [Imprint](https://www.corechaindb.com/imprint/) +* [Contact Us](https://www.corechaindb.com/contact/) diff --git a/README_cn.md b/README_cn.md index a8d96c7a..8c2afb9c 100644 --- a/README_cn.md +++ b/README_cn.md @@ -10,12 +10,12 @@ Code is Apache-2.0 and docs are CC-BY-4.0 so show the latest GitHub release instead. ---> -[![Codecov branch](https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb/master.svg)](https://codecov.io/github/bigchaindb/bigchaindb?branch=master) -[![Latest release](https://img.shields.io/github/release/bigchaindb/bigchaindb/all.svg)](https://github.com/bigchaindb/bigchaindb/releases) -[![Status on PyPI](https://img.shields.io/pypi/status/bigchaindb.svg)](https://pypi.org/project/BigchainDB/) -[![Travis branch](https://img.shields.io/travis/bigchaindb/bigchaindb/master.svg)](https://travis-ci.com/bigchaindb/bigchaindb) -[![Documentation Status](https://readthedocs.org/projects/bigchaindb-server/badge/?version=latest)](https://docs.bigchaindb.com/projects/server/en/latest/) -[![Join the chat at https://gitter.im/bigchaindb/bigchaindb](https://badges.gitter.im/bigchaindb/bigchaindb.svg)](https://gitter.im/bigchaindb/bigchaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Codecov branch](https://img.shields.io/codecov/c/github/corechaindb/corechaindb/master.svg)](https://codecov.io/github/corechaindb/corechaindb?branch=master) +[![Latest release](https://img.shields.io/github/release/corechaindb/corechaindb/all.svg)](https://github.com/corechaindb/corechaindb/releases) +[![Status on PyPI](https://img.shields.io/pypi/status/corechaindb.svg)](https://pypi.org/project/BigchainDB/) +[![Travis branch](https://img.shields.io/travis/corechaindb/corechaindb/master.svg)](https://travis-ci.com/corechaindb/corechaindb) +[![Documentation Status](https://readthedocs.org/projects/corechaindb-server/badge/?version=latest)](https://docs.corechaindb.com/projects/server/en/latest/) +[![Join the chat at https://gitter.im/corechaindb/corechaindb](https://badges.gitter.im/corechaindb/corechaindb.svg)](https://gitter.im/corechaindb/corechaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) # BigchainDB 服务器 @@ -23,17 +23,17 @@ BigchainDB 是区块链数据库. 这是 _BigchainDB 服务器_ 的仓库. ## 基础知识 -* [尝试快速开始](https://docs.bigchaindb.com/projects/server/en/latest/quickstart.html) -* [阅读 BigchainDB 2.0 白皮书](https://www.bigchaindb.com/whitepaper/) -* [查阅漫游指南](https://www.bigchaindb.com/developers/guide/) +* [尝试快速开始](https://docs.corechaindb.com/projects/server/en/latest/quickstart.html) +* [阅读 BigchainDB 2.0 白皮书](https://www.corechaindb.com/whitepaper/) +* [查阅漫游指南](https://www.corechaindb.com/developers/guide/) ## 运行和测试 `master` 分支的 BigchainDB 服务器 运行和测试最新版本的 BigchainDB 服务器非常简单. 确认你有安装最新版本的 [Docker Compose](https://docs.docker.com/compose/install/). 当你准备好了, 打开一个终端并运行: ```text -git clone https://github.com/bigchaindb/bigchaindb.git -cd bigchaindb +git clone https://github.com/corechaindb/corechaindb.git +cd corechaindb make run ``` @@ -55,23 +55,23 @@ BigchainDB 应该可以通过 `http://localhost:9984/` 访问. ## 一般人员链接 -* [BigchainDB.com](https://www.bigchaindb.com/) - BigchainDB 主网站, 包括新闻订阅 -* [路线图](https://github.com/bigchaindb/org/blob/master/ROADMAP.md) -* [博客](https://medium.com/the-bigchaindb-blog) +* [BigchainDB.com](https://www.corechaindb.com/) - BigchainDB 主网站, 包括新闻订阅 +* [路线图](https://github.com/corechaindb/org/blob/master/ROADMAP.md) +* [博客](https://medium.com/the-corechaindb-blog) * [推特](https://twitter.com/BigchainDB) ## 开发人员链接 -* [所有的 BigchainDB 文档](https://docs.bigchaindb.com/en/latest/) -* [BigchainDB 服务器 文档](https://docs.bigchaindb.com/projects/server/en/latest/index.html) +* [所有的 BigchainDB 文档](https://docs.corechaindb.com/en/latest/) +* [BigchainDB 服务器 文档](https://docs.corechaindb.com/projects/server/en/latest/index.html) * [CONTRIBUTING.md](.github/CONTRIBUTING.md) - how to contribute * [社区指南](CODE_OF_CONDUCT.md) -* [公开问题](https://github.com/bigchaindb/bigchaindb/issues) -* [公开的 pull request](https://github.com/bigchaindb/bigchaindb/pulls) -* [Gitter 聊天室](https://gitter.im/bigchaindb/bigchaindb) +* [公开问题](https://github.com/corechaindb/corechaindb/issues) +* [公开的 pull request](https://github.com/corechaindb/corechaindb/pulls) +* [Gitter 聊天室](https://gitter.im/corechaindb/corechaindb) ## 法律声明 * [许可](LICENSES.md) - 开源代码 & 开源内容 -* [印记](https://www.bigchaindb.com/imprint/) -* [联系我们](https://www.bigchaindb.com/contact/) +* [印记](https://www.corechaindb.com/imprint/) +* [联系我们](https://www.corechaindb.com/contact/) diff --git a/README_kor.md b/README_kor.md index 84d55279..afacf91a 100644 --- a/README_kor.md +++ b/README_kor.md @@ -1,9 +1,9 @@ -[![Codecov branch](https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb/master.svg)](https://codecov.io/github/bigchaindb/bigchaindb?branch=master) -[![Latest release](https://img.shields.io/github/release/bigchaindb/bigchaindb/all.svg)](https://github.com/bigchaindb/bigchaindb/releases) -[![Status on PyPI](https://img.shields.io/pypi/status/bigchaindb.svg)](https://pypi.org/project/BigchainDB/) -[![Travis branch](https://img.shields.io/travis/bigchaindb/bigchaindb/master.svg)](https://travis-ci.org/bigchaindb/bigchaindb) -[![Documentation Status](https://readthedocs.org/projects/bigchaindb-server/badge/?version=latest)](https://docs.bigchaindb.com/projects/server/en/latest/) -[![Join the chat at https://gitter.im/bigchaindb/bigchaindb](https://badges.gitter.im/bigchaindb/bigchaindb.svg)](https://gitter.im/bigchaindb/bigchaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![Codecov branch](https://img.shields.io/codecov/c/github/corechaindb/corechaindb/master.svg)](https://codecov.io/github/corechaindb/corechaindb?branch=master) +[![Latest release](https://img.shields.io/github/release/corechaindb/corechaindb/all.svg)](https://github.com/corechaindb/corechaindb/releases) +[![Status on PyPI](https://img.shields.io/pypi/status/corechaindb.svg)](https://pypi.org/project/BigchainDB/) +[![Travis branch](https://img.shields.io/travis/corechaindb/corechaindb/master.svg)](https://travis-ci.org/corechaindb/corechaindb) +[![Documentation Status](https://readthedocs.org/projects/corechaindb-server/badge/?version=latest)](https://docs.corechaindb.com/projects/server/en/latest/) +[![Join the chat at https://gitter.im/corechaindb/corechaindb](https://badges.gitter.im/corechaindb/corechaindb.svg)](https://gitter.im/corechaindb/corechaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) # BigchainDB 서버 @@ -11,17 +11,17 @@ BigchaingDB는 블록체인 데이터베이스입니다. 이 저장소는 _Bigch ### 기본 사항 -* [빠른 시작 사용해보기](https://docs.bigchaindb.com/projects/server/en/latest/quickstart.html) -* [BigchainDB 2.0 백서 읽기](https://www.bigchaindb.com/whitepaper/) -* [BigchainDB에 대한 _Hitchiker's Guide_를 확인십시오.](https://www.bigchaindb.com/developers/guide/) +* [빠른 시작 사용해보기](https://docs.corechaindb.com/projects/server/en/latest/quickstart.html) +* [BigchainDB 2.0 백서 읽기](https://www.corechaindb.com/whitepaper/) +* [BigchainDB에 대한 _Hitchiker's Guide_를 확인십시오.](https://www.corechaindb.com/developers/guide/) ### `master` Branch에서 BigchainDB 서버 실행 및 테스트 BigchaingDB 서버의 최신 버전을 실행하고 테스트하는 것은 어렵지 않습니다. [Docker Compose](https://docs.docker.com/compose/install/)의 최신 버전이 설치되어 있는지 확인하십시오. 준비가 되었다면, 터미널에서 다음을 실행하십시오. ```text -git clone https://github.com/bigchaindb/bigchaindb.git -cd bigchaindb +git clone https://github.com/corechaindb/corechaindb.git +cd corechaindb make run ``` @@ -43,23 +43,23 @@ make run ### 모두를 위한 링크들 -* [BigchainDB.com ](https://www.bigchaindb.com/)- 뉴스 레터 가입을 포함하는 BigchainDB 주요 웹 사이트 -* [로드맵](https://github.com/bigchaindb/org/blob/master/ROADMAP.md) -* [블로그](https://medium.com/the-bigchaindb-blog) +* [BigchainDB.com ](https://www.corechaindb.com/)- 뉴스 레터 가입을 포함하는 BigchainDB 주요 웹 사이트 +* [로드맵](https://github.com/corechaindb/org/blob/master/ROADMAP.md) +* [블로그](https://medium.com/the-corechaindb-blog) * [트위터](https://twitter.com/BigchainDB) ### 개발자들을 위한 링크들 -* [모든 BigchainDB 문서](https://docs.bigchaindb.com/en/latest/) -* [BigchainDB 서버 문서](https://docs.bigchaindb.com/projects/server/en/latest/index.html) -* [CONTRIBUTING.md](https://github.com/bigchaindb/bigchaindb/blob/master/.github/CONTRIBUTING.md) - 기여를 하는 방법 -* [커뮤니티 가이드라인](https://github.com/bigchaindb/bigchaindb/blob/master/CODE_OF_CONDUCT.md) -* [이슈 작성](https://github.com/bigchaindb/bigchaindb/issues) -* [pull request 하기](https://github.com/bigchaindb/bigchaindb/pulls) -* [Gitter 채팅방](https://gitter.im/bigchaindb/bigchaindb) +* [모든 BigchainDB 문서](https://docs.corechaindb.com/en/latest/) +* [BigchainDB 서버 문서](https://docs.corechaindb.com/projects/server/en/latest/index.html) +* [CONTRIBUTING.md](https://github.com/corechaindb/corechaindb/blob/master/.github/CONTRIBUTING.md) - 기여를 하는 방법 +* [커뮤니티 가이드라인](https://github.com/corechaindb/corechaindb/blob/master/CODE_OF_CONDUCT.md) +* [이슈 작성](https://github.com/corechaindb/corechaindb/issues) +* [pull request 하기](https://github.com/corechaindb/corechaindb/pulls) +* [Gitter 채팅방](https://gitter.im/corechaindb/corechaindb) ### 합법 -* [라이선스](https://github.com/bigchaindb/bigchaindb/blob/master/LICENSES.md) - 오픈 소스 & 오픈 콘텐츠 -* [발행](https://www.bigchaindb.com/imprint/) -* [연락처](https://www.bigchaindb.com/contact/) +* [라이선스](https://github.com/corechaindb/corechaindb/blob/master/LICENSES.md) - 오픈 소스 & 오픈 콘텐츠 +* [발행](https://www.corechaindb.com/imprint/) +* [연락처](https://www.corechaindb.com/contact/) diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md index 84e19247..e2edf072 100644 --- a/RELEASE_PROCESS.md +++ b/RELEASE_PROCESS.md @@ -25,7 +25,7 @@ to [regular semantic versioning](http://semver.org/), but there's no hyphen, e.g We use `0.9` and `0.9.0` as example version and short-version values below. You should replace those with the correct values for your new version. -We follow [BEP-1](https://github.com/bigchaindb/BEPs/tree/master/1), which is our variant of C4, the Collective Code Construction Contract, so a release is just a [tagged commit](https://git-scm.com/book/en/v2/Git-Basics-Tagging) on the `master` branch, i.e. a label for a particular Git commit. +We follow [BEP-1](https://github.com/corechaindb/BEPs/tree/master/1), which is our variant of C4, the Collective Code Construction Contract, so a release is just a [tagged commit](https://git-scm.com/book/en/v2/Git-Basics-Tagging) on the `master` branch, i.e. a label for a particular Git commit. The following steps are what we do to release a new version of _BigchainDB Server_. The steps to release the Python Driver are similar but not the same. @@ -37,13 +37,13 @@ The following steps are what we do to release a new version of _BigchainDB Serve - Update all Docker image tags in all Kubernetes YAML files (in the `k8s/` directory). For example, in the files: - - `k8s/bigchaindb/bigchaindb-ss.yaml` and - - `k8s/dev-setup/bigchaindb.yaml` + - `k8s/corechaindb/corechaindb-ss.yaml` and + - `k8s/dev-setup/corechaindb.yaml` - find the line of the form `image: bigchaindb/bigchaindb:0.8.1` and change the version number to the new version number, e.g. `0.9.0`. (This is the Docker image that Kubernetes should pull from Docker Hub.) + find the line of the form `image: corechaindb/corechaindb:0.8.1` and change the version number to the new version number, e.g. `0.9.0`. (This is the Docker image that Kubernetes should pull from Docker Hub.) Keep in mind that this is a _Docker image tag_ so our naming convention is a bit different; see Note 2 in the **Notes** section above. - - In `bigchaindb/version.py`: + - In `corechaindb/version.py`: - update `__version__` to e.g. `0.9.0` (with no `.dev` on the end) - update `__short_version__` to e.g. `0.9` (with no `.dev` on the end) - In the docs about installing BigchainDB (and Tendermint), and in the associated scripts, recommend/install a version of Tendermint that _actually works_ with the soon-to-be-released version of BigchainDB. You can find all such references by doing a search for the previously-recommended version number, such as `0.31.5`. @@ -51,7 +51,7 @@ The following steps are what we do to release a new version of _BigchainDB Serve 2. **Wait for all the tests to pass!** 3. Merge the pull request into the `master` branch. -4. Go to the [bigchaindb/bigchaindb Releases page on GitHub](https://github.com/bigchaindb/bigchaindb/releases) +4. Go to the [corechaindb/corechaindb Releases page on GitHub](https://github.com/corechaindb/corechaindb/releases) and click the "Draft a new release" button. 5. Fill in the details: - **Tag version:** version number preceded by `v`, e.g. `v0.9.1` @@ -59,9 +59,9 @@ The following steps are what we do to release a new version of _BigchainDB Serve - **Title:** Same as tag version above, e.g `v0.9.1` - **Description:** The body of the changelog entry (Added, Changed, etc.) 6. Click "Publish release" to publish the release on GitHub. -7. On your local computer, make sure you're on the `master` branch and that it's up-to-date with the `master` branch in the bigchaindb/bigchaindb repository (e.g. `git pull upstream master`). We're going to use that to push a new `bigchaindb` package to PyPI. +7. On your local computer, make sure you're on the `master` branch and that it's up-to-date with the `master` branch in the corechaindb/corechaindb repository (e.g. `git pull upstream master`). We're going to use that to push a new `corechaindb` package to PyPI. 8. Make sure you have a `~/.pypirc` file containing credentials for PyPI. -9. Do `make release` to build and publish the new `bigchaindb` package on PyPI. For this step you need to have `twine` installed. If you get an error like `Makefile:135: recipe for target 'clean-pyc' failed` then try doing +9. Do `make release` to build and publish the new `corechaindb` package on PyPI. For this step you need to have `twine` installed. If you get an error like `Makefile:135: recipe for target 'clean-pyc' failed` then try doing ```text sudo chown -R $(whoami):$(whoami) . ``` @@ -80,8 +80,8 @@ The following steps are what we do to release a new version of _BigchainDB Serve 3. Scroll to the bottom of the page and click "Save". 11. Go to [Docker Hub](https://hub.docker.com/) and sign in, then: - Click on "Organizations" - - Click on "bigchaindb" - - Click on "bigchaindb/bigchaindb" + - Click on "corechaindb" + - Click on "corechaindb/corechaindb" - Click on "Build Settings" - Find the row where "Docker Tag Name" equals `latest` and change the value of "Name" to the name (Git tag) diff --git a/ROADMAP.md b/ROADMAP.md index e17d52a2..ab6da059 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -7,8 +7,8 @@ Code is Apache-2.0 and docs are CC-BY-4.0 # BigchainDB Roadmap -We moved the BigchainDB Roadmap to the bigchaindb/org repository; see: +We moved the BigchainDB Roadmap to the corechaindb/org repository; see: -[https://github.com/bigchaindb/org/blob/master/ROADMAP.md](https://github.com/bigchaindb/org/blob/master/ROADMAP.md) +[https://github.com/corechaindb/org/blob/master/ROADMAP.md](https://github.com/corechaindb/org/blob/master/ROADMAP.md) (We kept this file here to avoid breaking some links.) diff --git a/acceptance/python/Dockerfile b/acceptance/python/Dockerfile index 144fe64c..65929eae 100644 --- a/acceptance/python/Dockerfile +++ b/acceptance/python/Dockerfile @@ -5,5 +5,5 @@ RUN pip install --upgrade \ pycco \ websocket-client~=0.47.0 \ pytest~=3.0 \ - bigchaindb-driver~=0.6.2 \ + corechaindb-driver~=0.6.2 \ blns diff --git a/acceptance/python/src/test_basic.py b/acceptance/python/src/test_basic.py index 93be07c1..736df09a 100644 --- a/acceptance/python/src/test_basic.py +++ b/acceptance/python/src/test_basic.py @@ -16,7 +16,7 @@ # the remote system, and also checking the `outputs` of a given public key. # # This acceptance test is a rip-off of our -# [tutorial](https://docs.bigchaindb.com/projects/py-driver/en/latest/usage.html). +# [tutorial](https://docs.corechaindb.com/projects/py-driver/en/latest/usage.html). # ## Imports # We need some utils from the `os` package, we will interact with @@ -24,8 +24,8 @@ import os # For this test case we import and use the Python Driver. -from bigchaindb_driver import BigchainDB -from bigchaindb_driver.crypto import generate_keypair +from corechaindb_driver import BigchainDB +from corechaindb_driver.crypto import generate_keypair def test_basic(): diff --git a/acceptance/python/src/test_divisible_asset.py b/acceptance/python/src/test_divisible_asset.py index beee81de..b7bafe48 100644 --- a/acceptance/python/src/test_divisible_asset.py +++ b/acceptance/python/src/test_divisible_asset.py @@ -17,7 +17,7 @@ # of a given transaction. # # This integration test is a rip-off of our -# [tutorial](https://docs.bigchaindb.com/projects/py-driver/en/latest/usage.html). +# [tutorial](https://docs.corechaindb.com/projects/py-driver/en/latest/usage.html). # ## Imports # We need some utils from the `os` package, we will interact with @@ -26,11 +26,11 @@ # And of course, we also need the `BadRequest`. import os import pytest -from bigchaindb_driver.exceptions import BadRequest +from corechaindb_driver.exceptions import BadRequest # For this test case we import and use the Python Driver. -from bigchaindb_driver import BigchainDB -from bigchaindb_driver.crypto import generate_keypair +from corechaindb_driver import BigchainDB +from corechaindb_driver.crypto import generate_keypair def test_divisible_assets(): diff --git a/acceptance/python/src/test_double_spend.py b/acceptance/python/src/test_double_spend.py index 3ffb7c06..82619f90 100644 --- a/acceptance/python/src/test_double_spend.py +++ b/acceptance/python/src/test_double_spend.py @@ -11,9 +11,9 @@ from uuid import uuid4 from threading import Thread import queue -import bigchaindb_driver.exceptions -from bigchaindb_driver import BigchainDB -from bigchaindb_driver.crypto import generate_keypair +import corechaindb_driver.exceptions +from corechaindb_driver import BigchainDB +from corechaindb_driver.crypto import generate_keypair def test_double_create(): @@ -33,7 +33,7 @@ def test_double_create(): try: bdb.transactions.send_commit(tx) results.put('OK') - except bigchaindb_driver.exceptions.TransportError as e: + except corechaindb_driver.exceptions.TransportError as e: results.put('FAIL') t1 = Thread(target=send_and_queue, args=(tx, )) diff --git a/acceptance/python/src/test_multiple_owners.py b/acceptance/python/src/test_multiple_owners.py index 6e76b770..40c29c18 100644 --- a/acceptance/python/src/test_multiple_owners.py +++ b/acceptance/python/src/test_multiple_owners.py @@ -17,7 +17,7 @@ # of a given transaction. # # This integration test is a rip-off of our -# [tutorial](https://docs.bigchaindb.com/projects/py-driver/en/latest/usage.html). +# [tutorial](https://docs.corechaindb.com/projects/py-driver/en/latest/usage.html). # ## Imports # We need some utils from the `os` package, we will interact with @@ -25,8 +25,8 @@ import os # For this test case we import and use the Python Driver. -from bigchaindb_driver import BigchainDB -from bigchaindb_driver.crypto import generate_keypair +from corechaindb_driver import BigchainDB +from corechaindb_driver.crypto import generate_keypair def test_multiple_owners(): diff --git a/acceptance/python/src/test_naughty_strings.py b/acceptance/python/src/test_naughty_strings.py index 92acd066..15fe9139 100644 --- a/acceptance/python/src/test_naughty_strings.py +++ b/acceptance/python/src/test_naughty_strings.py @@ -24,9 +24,9 @@ from blns import blns import pytest # For this test case we import and use the Python Driver. -from bigchaindb_driver import BigchainDB -from bigchaindb_driver.crypto import generate_keypair -from bigchaindb_driver.exceptions import BadRequest +from corechaindb_driver import BigchainDB +from corechaindb_driver.crypto import generate_keypair +from corechaindb_driver.exceptions import BadRequest naughty_strings = blns.all() diff --git a/acceptance/python/src/test_stream.py b/acceptance/python/src/test_stream.py index 54d62b48..59da0b98 100644 --- a/acceptance/python/src/test_stream.py +++ b/acceptance/python/src/test_stream.py @@ -27,8 +27,8 @@ from uuid import uuid4 # [websocket](https://github.com/websocket-client/websocket-client) module from websocket import create_connection -from bigchaindb_driver import BigchainDB -from bigchaindb_driver.crypto import generate_keypair +from corechaindb_driver import BigchainDB +from corechaindb_driver.crypto import generate_keypair def test_stream(): diff --git a/codecov.yml b/codecov.yml index 3643618c..ec112c78 100644 --- a/codecov.yml +++ b/codecov.yml @@ -25,7 +25,7 @@ coverage: ignore: # files and folders that will be removed during processing - "docs/*" - "tests/*" - - "bigchaindb/version.py" + - "corechaindb/version.py" - "k8s/*" comment: diff --git a/bigchaindb/README.md b/corechaindb/README.md similarity index 84% rename from bigchaindb/README.md rename to corechaindb/README.md index e877b71a..f4f45dc1 100644 --- a/bigchaindb/README.md +++ b/corechaindb/README.md @@ -17,7 +17,7 @@ The `BigchainDB` class is defined here. Most node-level operations and database ### [`models.py`](./models.py) -`Block`, `Transaction`, and `Asset` classes are defined here. The classes mirror the block and transaction structure from the [documentation](https://docs.bigchaindb.com/projects/server/en/latest/data-models/index.html), but also include methods for validation and signing. +`Block`, `Transaction`, and `Asset` classes are defined here. The classes mirror the block and transaction structure from the [documentation](https://docs.corechaindb.com/projects/server/en/latest/data-models/index.html), but also include methods for validation and signing. ### [`validation.py`](./validation.py) @@ -35,7 +35,7 @@ Methods for managing the configuration, including loading configuration files, a ### [`commands`](./commands) -Contains code for the [CLI](https://docs.bigchaindb.com/projects/server/en/latest/server-reference/bigchaindb-cli.html) for BigchainDB. +Contains code for the [CLI](https://docs.corechaindb.com/projects/server/en/latest/server-reference/corechaindb-cli.html) for BigchainDB. ### [`db`](./db) diff --git a/corechaindb/__init__.py b/corechaindb/__init__.py new file mode 100644 index 00000000..e975f2cb --- /dev/null +++ b/corechaindb/__init__.py @@ -0,0 +1,106 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import copy +import logging + +from corechaindb.log import DEFAULT_LOGGING_CONFIG as log_config +from corechaindb.lib import BigchainDB # noqa +from corechaindb.migrations.chain_migration_election import ChainMigrationElection +from corechaindb.version import __version__ # noqa +from corechaindb.core import App # noqa + +# from functools import reduce +# PORT_NUMBER = reduce(lambda x, y: x * y, map(ord, 'BigchainDB')) % 2**16 +# basically, the port number is 9984 + +# The following variable is used by `corechaindb configure` to +# prompt the user for database values. We cannot rely on +# _base_database_localmongodb.keys() because dicts are unordered. +# I tried to configure + +_database_keys_map = { + 'localmongodb': ('host', 'port', 'name'), +} + +_base_database_localmongodb = { + 'host': 'localhost', + 'port': 27017, + 'name': 'bigchain', + 'replicaset': None, + 'login': None, + 'password': None, +} + +_database_localmongodb = { + 'backend': 'localmongodb', + 'connection_timeout': 5000, + 'max_tries': 3, + 'ssl': False, + 'ca_cert': None, + 'certfile': None, + 'keyfile': None, + 'keyfile_passphrase': None, + 'crlfile': None, +} +_database_localmongodb.update(_base_database_localmongodb) + +_database_map = { + 'localmongodb': _database_localmongodb, +} + +config = { + 'server': { + # Note: this section supports all the Gunicorn settings: + # - http://docs.gunicorn.org/en/stable/settings.html + 'bind': 'localhost:9984', + 'loglevel': logging.getLevelName( + log_config['handlers']['console']['level']).lower(), + 'workers': None, # if None, the value will be cpu_count * 2 + 1 + }, + 'wsserver': { + 'scheme': 'ws', + 'host': 'localhost', + 'port': 9985, + 'advertised_scheme': 'ws', + 'advertised_host': 'localhost', + 'advertised_port': 9985, + }, + 'tendermint': { + 'host': 'localhost', + 'port': 26657, + 'version': 'v0.31.5', # look for __tm_supported_versions__ + }, + # FIXME: hardcoding to localmongodb for now + 'database': _database_map['localmongodb'], + 'log': { + 'file': log_config['handlers']['file']['filename'], + 'error_file': log_config['handlers']['errors']['filename'], + 'level_console': logging.getLevelName( + log_config['handlers']['console']['level']).lower(), + 'level_logfile': logging.getLevelName( + log_config['handlers']['file']['level']).lower(), + 'datefmt_console': log_config['formatters']['console']['datefmt'], + 'datefmt_logfile': log_config['formatters']['file']['datefmt'], + 'fmt_console': log_config['formatters']['console']['format'], + 'fmt_logfile': log_config['formatters']['file']['format'], + 'granular_levels': {}, + }, +} + +# We need to maintain a backup copy of the original config dict in case +# the user wants to reconfigure the node. Check ``corechaindb.config_utils`` +# for more info. +_config = copy.deepcopy(config) +from corechaindb.common.transaction import Transaction # noqa +from corechaindb import models # noqa +from corechaindb.upsert_validator import ValidatorElection # noqa +from corechaindb.elections.vote import Vote # noqa + +Transaction.register_type(Transaction.CREATE, models.Transaction) +Transaction.register_type(Transaction.TRANSFER, models.Transaction) +Transaction.register_type(ValidatorElection.OPERATION, ValidatorElection) +Transaction.register_type(ChainMigrationElection.OPERATION, ChainMigrationElection) +Transaction.register_type(Vote.OPERATION, Vote) diff --git a/bigchaindb/backend/README.md b/corechaindb/backend/README.md similarity index 88% rename from bigchaindb/backend/README.md rename to corechaindb/backend/README.md index cb510fb6..50579914 100644 --- a/bigchaindb/backend/README.md +++ b/corechaindb/backend/README.md @@ -27,17 +27,17 @@ generic functions based on certain conditions being met (e.g. the database backe To see what this looks like in BigchainDB, first note that our backend interfaces have been configured to dispatch based on a backend's **connection type**. -Call `bigchaindb.backend.connect()` to create an instance of a `Connection`: +Call `corechaindb.backend.connect()` to create an instance of a `Connection`: ```python -from bigchaindb.backend import connect +from corechaindb.backend import connect connection = connect() # By default, uses the current configuration for backend, host, port, etc. ``` Then, we can call a backend function by directly calling its interface: ```python -from bigchaindb.backend import query +from corechaindb.backend import query query.write_transaction(connection, ...) ``` @@ -46,6 +46,6 @@ Code can simply call the base interface function with a `Connection` instance, a will handle routing the call to the actual implementation. BigchainDB will load and register the configured backend's implementation automatically (see -`bigchaindb.backend.connect()`), so you should always just be able to call an interface function if +`corechaindb.backend.connect()`), so you should always just be able to call an interface function if you have a `Connection` instance. A few helper utilities (see [`backend/utils.py`](./utils.py)) are also provided to make registering new backend implementations easier. diff --git a/corechaindb/backend/__init__.py b/corechaindb/backend/__init__.py new file mode 100644 index 00000000..72787d97 --- /dev/null +++ b/corechaindb/backend/__init__.py @@ -0,0 +1,17 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Generic backend database interfaces expected by BigchainDB. + +The interfaces in this module allow BigchainDB to be agnostic about its +database backend. One can configure BigchainDB to use different databases as +its data store by setting the ``database.backend`` property in the +configuration or the ``BIGCHAINDB_DATABASE_BACKEND`` environment variable. +""" + +# Include the backend interfaces +from corechaindb.backend import schema, query # noqa + +from corechaindb.backend.connection import connect # noqa diff --git a/corechaindb/backend/connection.py b/corechaindb/backend/connection.py new file mode 100644 index 00000000..1f3deb6b --- /dev/null +++ b/corechaindb/backend/connection.py @@ -0,0 +1,170 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import logging +from importlib import import_module +from itertools import repeat + +import corechaindb +from corechaindb.backend.exceptions import ConnectionError +from corechaindb.backend.utils import get_corechaindb_config_value, get_corechaindb_config_value_or_key_error +from corechaindb.common.exceptions import ConfigurationError + +BACKENDS = { + 'localmongodb': 'corechaindb.backend.localmongodb.connection.LocalMongoDBConnection', +} + +logger = logging.getLogger(__name__) + + +def connect(backend=None, host=None, port=None, name=None, max_tries=None, + connection_timeout=None, replicaset=None, ssl=None, login=None, password=None, + ca_cert=None, certfile=None, keyfile=None, keyfile_passphrase=None, + crlfile=None): + """Create a new connection to the database backend. + + All arguments default to the current configuration's values if not + given. + + Args: + backend (str): the name of the backend to use. + host (str): the host to connect to. + port (int): the port to connect to. + name (str): the name of the database to use. + replicaset (str): the name of the replica set (only relevant for + MongoDB connections). + + Returns: + An instance of :class:`~corechaindb.backend.connection.Connection` + based on the given (or defaulted) :attr:`backend`. + + Raises: + :exc:`~ConnectionError`: If the connection to the database fails. + :exc:`~ConfigurationError`: If the given (or defaulted) :attr:`backend` + is not supported or could not be loaded. + :exc:`~AuthenticationError`: If there is a OperationFailure due to + Authentication failure after connecting to the database. + """ + + backend = backend or get_corechaindb_config_value_or_key_error('backend') + host = host or get_corechaindb_config_value_or_key_error('host') + port = port or get_corechaindb_config_value_or_key_error('port') + dbname = name or get_corechaindb_config_value_or_key_error('name') + # Not sure how to handle this here. This setting is only relevant for + # mongodb. + # I added **kwargs for both RethinkDBConnection and MongoDBConnection + # to handle these these additional args. In case of RethinkDBConnection + # it just does not do anything with it. + # + # UPD: RethinkDBConnection is not here anymore cause we no longer support RethinkDB. + # The problem described above might be reconsidered next time we introduce a backend, + # if it ever happens. + replicaset = replicaset or get_corechaindb_config_value('replicaset') + ssl = ssl if ssl is not None else get_corechaindb_config_value('ssl', False) + login = login or get_corechaindb_config_value('login') + password = password or get_corechaindb_config_value('password') + ca_cert = ca_cert or get_corechaindb_config_value('ca_cert') + certfile = certfile or get_corechaindb_config_value('certfile') + keyfile = keyfile or get_corechaindb_config_value('keyfile') + keyfile_passphrase = keyfile_passphrase or get_corechaindb_config_value('keyfile_passphrase', None) + crlfile = crlfile or get_corechaindb_config_value('crlfile') + + try: + module_name, _, class_name = BACKENDS[backend].rpartition('.') + Class = getattr(import_module(module_name), class_name) + except KeyError: + raise ConfigurationError('Backend `{}` is not supported. ' + 'BigchainDB currently supports {}'.format(backend, BACKENDS.keys())) + except (ImportError, AttributeError) as exc: + raise ConfigurationError('Error loading backend `{}`'.format(backend)) from exc + + logger.debug('Connection: {}'.format(Class)) + return Class(host=host, port=port, dbname=dbname, + max_tries=max_tries, connection_timeout=connection_timeout, + replicaset=replicaset, ssl=ssl, login=login, password=password, + ca_cert=ca_cert, certfile=certfile, keyfile=keyfile, + keyfile_passphrase=keyfile_passphrase, crlfile=crlfile) + + +class Connection: + """Connection class interface. + + All backend implementations should provide a connection class that inherits + from and implements this class. + """ + + def __init__(self, host=None, port=None, dbname=None, + connection_timeout=None, max_tries=None, + **kwargs): + """Create a new :class:`~.Connection` instance. + + Args: + host (str): the host to connect to. + port (int): the port to connect to. + dbname (str): the name of the database to use. + connection_timeout (int, optional): the milliseconds to wait + until timing out the database connection attempt. + Defaults to 5000ms. + max_tries (int, optional): how many tries before giving up, + if 0 then try forever. Defaults to 3. + **kwargs: arbitrary keyword arguments provided by the + configuration's ``database`` settings + """ + + dbconf = corechaindb.config['database'] + + self.host = host or dbconf['host'] + self.port = port or dbconf['port'] + self.dbname = dbname or dbconf['name'] + self.connection_timeout = connection_timeout if connection_timeout is not None \ + else dbconf['connection_timeout'] + self.max_tries = max_tries if max_tries is not None else dbconf['max_tries'] + self.max_tries_counter = range(self.max_tries) if self.max_tries != 0 else repeat(0) + self._conn = None + + @property + def conn(self): + if self._conn is None: + self.connect() + return self._conn + + def run(self, query): + """Run a query. + + Args: + query: the query to run + Raises: + :exc:`~DuplicateKeyError`: If the query fails because of a + duplicate key constraint. + :exc:`~OperationFailure`: If the query fails for any other + reason. + :exc:`~ConnectionError`: If the connection to the database + fails. + """ + + raise NotImplementedError() + + def connect(self): + """Try to connect to the database. + + Raises: + :exc:`~ConnectionError`: If the connection to the database + fails. + """ + + attempt = 0 + for i in self.max_tries_counter: + attempt += 1 + try: + self._conn = self._connect() + except ConnectionError as exc: + logger.warning('Attempt %s/%s. Connection to %s:%s failed after %sms.', + attempt, self.max_tries if self.max_tries != 0 else '∞', + self.host, self.port, self.connection_timeout) + if attempt == self.max_tries: + logger.critical('Cannot connect to the Database. Giving up.') + raise ConnectionError() from exc + else: + break diff --git a/corechaindb/backend/exceptions.py b/corechaindb/backend/exceptions.py new file mode 100644 index 00000000..c858b533 --- /dev/null +++ b/corechaindb/backend/exceptions.py @@ -0,0 +1,22 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +from corechaindb.exceptions import BigchainDBError + + +class BackendError(BigchainDBError): + """Top level exception for any backend exception.""" + + +class ConnectionError(BackendError): + """Exception raised when the connection to the backend fails.""" + + +class OperationError(BackendError): + """Exception raised when a backend operation fails.""" + + +class DuplicateKeyError(OperationError): + """Exception raised when an insert fails because the key is not unique""" diff --git a/corechaindb/backend/localmongodb/__init__.py b/corechaindb/backend/localmongodb/__init__.py new file mode 100644 index 00000000..046b6ac7 --- /dev/null +++ b/corechaindb/backend/localmongodb/__init__.py @@ -0,0 +1,28 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""MongoDB backend implementation. + +Contains a MongoDB-specific implementation of the +:mod:`~corechaindb.backend.schema` and :mod:`~corechaindb.backend.query` interfaces. + +You can specify BigchainDB to use MongoDB as its database backend by either +setting ``database.backend`` to ``'localmongodb'`` in your configuration file, or +setting the ``BIGCHAINDB_DATABASE_BACKEND`` environment variable to +``'localmongodb'``. + +MongoDB is the default database backend for BigchainDB. + +If configured to use MongoDB, BigchainDB will automatically return instances +of :class:`~corechaindb.backend.localmongodb.LocalMongoDBConnection` for +:func:`~corechaindb.backend.connection.connect` and dispatch calls of the +generic backend interfaces to the implementations in this module. +""" + +# Register the single dispatched modules on import. +from corechaindb.backend.localmongodb import schema, query # noqa + +# MongoDBConnection should always be accessed via +# ``corechaindb.backend.connect()``. diff --git a/corechaindb/backend/localmongodb/connection.py b/corechaindb/backend/localmongodb/connection.py new file mode 100644 index 00000000..d5de8242 --- /dev/null +++ b/corechaindb/backend/localmongodb/connection.py @@ -0,0 +1,136 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import logging +from ssl import CERT_REQUIRED + +import pymongo + +from corechaindb.backend.connection import Connection +from corechaindb.backend.exceptions import (DuplicateKeyError, + OperationError, + ConnectionError) +from corechaindb.backend.utils import get_corechaindb_config_value +from corechaindb.common.exceptions import ConfigurationError +from corechaindb.utils import Lazy + +logger = logging.getLogger(__name__) + + +class LocalMongoDBConnection(Connection): + + def __init__(self, replicaset=None, ssl=None, login=None, password=None, + ca_cert=None, certfile=None, keyfile=None, + keyfile_passphrase=None, crlfile=None, **kwargs): + """Create a new Connection instance. + + Args: + replicaset (str, optional): the name of the replica set to + connect to. + **kwargs: arbitrary keyword arguments provided by the + configuration's ``database`` settings + """ + + super().__init__(**kwargs) + self.replicaset = replicaset or get_corechaindb_config_value('replicaset') + self.ssl = ssl if ssl is not None else get_corechaindb_config_value('ssl', False) + self.login = login or get_corechaindb_config_value('login') + self.password = password or get_corechaindb_config_value('password') + self.ca_cert = ca_cert or get_corechaindb_config_value('ca_cert') + self.certfile = certfile or get_corechaindb_config_value('certfile') + self.keyfile = keyfile or get_corechaindb_config_value('keyfile') + self.keyfile_passphrase = keyfile_passphrase or get_corechaindb_config_value('keyfile_passphrase') + self.crlfile = crlfile or get_corechaindb_config_value('crlfile') + + @property + def db(self): + return self.conn[self.dbname] + + def query(self): + return Lazy() + + def collection(self, name): + """Return a lazy object that can be used to compose a query. + + Args: + name (str): the name of the collection to query. + """ + return self.query()[self.dbname][name] + + def run(self, query): + try: + try: + return query.run(self.conn) + except pymongo.errors.AutoReconnect: + logger.warning('Lost connection to the database, ' + 'retrying query.') + return query.run(self.conn) + except pymongo.errors.AutoReconnect as exc: + raise ConnectionError from exc + except pymongo.errors.DuplicateKeyError as exc: + raise DuplicateKeyError from exc + except pymongo.errors.OperationFailure as exc: + print(f'DETAILS: {exc.details}') + raise OperationError from exc + + def _connect(self): + """Try to connect to the database. + + Raises: + :exc:`~ConnectionError`: If the connection to the database + fails. + :exc:`~AuthenticationError`: If there is a OperationFailure due to + Authentication failure after connecting to the database. + :exc:`~ConfigurationError`: If there is a ConfigurationError while + connecting to the database. + """ + + try: + # FYI: the connection process might raise a + # `ServerSelectionTimeoutError`, that is a subclass of + # `ConnectionFailure`. + # The presence of ca_cert, certfile, keyfile, crlfile implies the + # use of certificates for TLS connectivity. + if self.ca_cert is None or self.certfile is None or \ + self.keyfile is None or self.crlfile is None: + client = pymongo.MongoClient(self.host, + self.port, + replicaset=self.replicaset, + serverselectiontimeoutms=self.connection_timeout, + ssl=self.ssl, + **MONGO_OPTS) + if self.login is not None and self.password is not None: + client[self.dbname].authenticate(self.login, self.password) + else: + logger.info('Connecting to MongoDB over TLS/SSL...') + client = pymongo.MongoClient(self.host, + self.port, + replicaset=self.replicaset, + serverselectiontimeoutms=self.connection_timeout, + ssl=self.ssl, + ssl_ca_certs=self.ca_cert, + ssl_certfile=self.certfile, + ssl_keyfile=self.keyfile, + ssl_pem_passphrase=self.keyfile_passphrase, + ssl_crlfile=self.crlfile, + ssl_cert_reqs=CERT_REQUIRED, + **MONGO_OPTS) + if self.login is not None: + client[self.dbname].authenticate(self.login, + mechanism='MONGODB-X509') + + return client + + except (pymongo.errors.ConnectionFailure, + pymongo.errors.OperationFailure) as exc: + logger.info('Exception in _connect(): {}'.format(exc)) + raise ConnectionError(str(exc)) from exc + except pymongo.errors.ConfigurationError as exc: + raise ConfigurationError from exc + + +MONGO_OPTS = { + 'socketTimeoutMS': 20000, +} diff --git a/corechaindb/backend/localmongodb/query.py b/corechaindb/backend/localmongodb/query.py new file mode 100644 index 00000000..e460f10d --- /dev/null +++ b/corechaindb/backend/localmongodb/query.py @@ -0,0 +1,377 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Query implementation for MongoDB""" + +from pymongo import DESCENDING + +from corechaindb import backend +from corechaindb.backend.exceptions import DuplicateKeyError +from corechaindb.backend.utils import module_dispatch_registrar +from corechaindb.backend.localmongodb.connection import LocalMongoDBConnection +from corechaindb.common.transaction import Transaction + +register_query = module_dispatch_registrar(backend.query) + + +@register_query(LocalMongoDBConnection) +def store_transactions(conn, signed_transactions): + return conn.run(conn.collection('transactions') + .insert_many(signed_transactions)) + + +@register_query(LocalMongoDBConnection) +def get_transaction(conn, transaction_id): + return conn.run( + conn.collection('transactions') + .find_one({'id': transaction_id}, {'_id': 0})) + + +@register_query(LocalMongoDBConnection) +def get_transactions(conn, transaction_ids): + try: + return conn.run( + conn.collection('transactions') + .find({'id': {'$in': transaction_ids}}, + projection={'_id': False})) + except IndexError: + pass + + +@register_query(LocalMongoDBConnection) +def store_metadatas(conn, metadata): + return conn.run( + conn.collection('metadata') + .insert_many(metadata, ordered=False)) + + +@register_query(LocalMongoDBConnection) +def get_metadata(conn, transaction_ids): + return conn.run( + conn.collection('metadata') + .find({'id': {'$in': transaction_ids}}, + projection={'_id': False})) + + +@register_query(LocalMongoDBConnection) +def store_asset(conn, asset): + try: + return conn.run( + conn.collection('assets') + .insert_one(asset)) + except DuplicateKeyError: + pass + + +@register_query(LocalMongoDBConnection) +def store_assets(conn, assets): + return conn.run( + conn.collection('assets') + .insert_many(assets, ordered=False)) + + +@register_query(LocalMongoDBConnection) +def get_asset(conn, asset_id): + try: + return conn.run( + conn.collection('assets') + .find_one({'id': asset_id}, {'_id': 0, 'id': 0})) + except IndexError: + pass + + +@register_query(LocalMongoDBConnection) +def get_assets(conn, asset_ids): + return conn.run( + conn.collection('assets') + .find({'id': {'$in': asset_ids}}, + projection={'_id': False})) + + +@register_query(LocalMongoDBConnection) +def get_spent(conn, transaction_id, output): + query = {'inputs': + {'$elemMatch': + {'$and': [{'fulfills.transaction_id': transaction_id}, + {'fulfills.output_index': output}]}}} + + return conn.run( + conn.collection('transactions') + .find(query, {'_id': 0})) + + +@register_query(LocalMongoDBConnection) +def get_latest_block(conn): + return conn.run( + conn.collection('blocks') + .find_one(projection={'_id': False}, + sort=[('height', DESCENDING)])) + + +@register_query(LocalMongoDBConnection) +def store_block(conn, block): + try: + return conn.run( + conn.collection('blocks') + .insert_one(block)) + except DuplicateKeyError: + pass + + +@register_query(LocalMongoDBConnection) +def get_txids_filtered(conn, asset_id, operation=None, last_tx=None): + + match = { + Transaction.CREATE: {'operation': 'CREATE', 'id': asset_id}, + Transaction.TRANSFER: {'operation': 'TRANSFER', 'asset.id': asset_id}, + None: {'$or': [{'asset.id': asset_id}, {'id': asset_id}]}, + }[operation] + + cursor = conn.run(conn.collection('transactions').find(match)) + + if last_tx: + cursor = cursor.sort([('$natural', DESCENDING)]).limit(1) + + return (elem['id'] for elem in cursor) + + +@register_query(LocalMongoDBConnection) +def text_search(conn, search, *, language='english', case_sensitive=False, + diacritic_sensitive=False, text_score=False, limit=0, table='assets'): + cursor = conn.run( + conn.collection(table) + .find({'$text': { + '$search': search, + '$language': language, + '$caseSensitive': case_sensitive, + '$diacriticSensitive': diacritic_sensitive}}, + {'score': {'$meta': 'textScore'}, '_id': False}) + .sort([('score', {'$meta': 'textScore'})]) + .limit(limit)) + + if text_score: + return cursor + + return (_remove_text_score(obj) for obj in cursor) + + +def _remove_text_score(asset): + asset.pop('score', None) + return asset + + +@register_query(LocalMongoDBConnection) +def get_owned_ids(conn, owner): + cursor = conn.run( + conn.collection('transactions').aggregate([ + {'$match': {'outputs.public_keys': owner}}, + {'$project': {'_id': False}} + ])) + return cursor + + +@register_query(LocalMongoDBConnection) +def get_spending_transactions(conn, inputs): + transaction_ids = [i['transaction_id'] for i in inputs] + output_indexes = [i['output_index'] for i in inputs] + query = {'inputs': + {'$elemMatch': + {'$and': + [ + {'fulfills.transaction_id': {'$in': transaction_ids}}, + {'fulfills.output_index': {'$in': output_indexes}} + ]}}} + + cursor = conn.run( + conn.collection('transactions').find(query, {'_id': False})) + return cursor + + +@register_query(LocalMongoDBConnection) +def get_block(conn, block_id): + return conn.run( + conn.collection('blocks') + .find_one({'height': block_id}, + projection={'_id': False})) + + +@register_query(LocalMongoDBConnection) +def get_block_with_transaction(conn, txid): + return conn.run( + conn.collection('blocks') + .find({'transactions': txid}, + projection={'_id': False, 'height': True})) + + +@register_query(LocalMongoDBConnection) +def delete_transactions(conn, txn_ids): + conn.run(conn.collection('assets').delete_many({'id': {'$in': txn_ids}})) + conn.run(conn.collection('metadata').delete_many({'id': {'$in': txn_ids}})) + conn.run(conn.collection('transactions').delete_many({'id': {'$in': txn_ids}})) + + +@register_query(LocalMongoDBConnection) +def store_unspent_outputs(conn, *unspent_outputs): + if unspent_outputs: + try: + return conn.run( + conn.collection('utxos').insert_many( + unspent_outputs, + ordered=False, + ) + ) + except DuplicateKeyError: + # TODO log warning at least + pass + + +@register_query(LocalMongoDBConnection) +def delete_unspent_outputs(conn, *unspent_outputs): + if unspent_outputs: + return conn.run( + conn.collection('utxos').delete_many({ + '$or': [{ + '$and': [ + {'transaction_id': unspent_output['transaction_id']}, + {'output_index': unspent_output['output_index']}, + ], + } for unspent_output in unspent_outputs] + }) + ) + + +@register_query(LocalMongoDBConnection) +def get_unspent_outputs(conn, *, query=None): + if query is None: + query = {} + return conn.run(conn.collection('utxos').find(query, + projection={'_id': False})) + + +@register_query(LocalMongoDBConnection) +def store_pre_commit_state(conn, state): + return conn.run( + conn.collection('pre_commit') + .replace_one({}, state, upsert=True) + ) + + +@register_query(LocalMongoDBConnection) +def get_pre_commit_state(conn): + return conn.run(conn.collection('pre_commit').find_one()) + + +@register_query(LocalMongoDBConnection) +def store_validator_set(conn, validators_update): + height = validators_update['height'] + return conn.run( + conn.collection('validators').replace_one( + {'height': height}, + validators_update, + upsert=True + ) + ) + + +@register_query(LocalMongoDBConnection) +def delete_validator_set(conn, height): + return conn.run( + conn.collection('validators').delete_many({'height': height}) + ) + + +@register_query(LocalMongoDBConnection) +def store_election(conn, election_id, height, is_concluded): + return conn.run( + conn.collection('elections').replace_one( + {'election_id': election_id, + 'height': height}, + {'election_id': election_id, + 'height': height, + 'is_concluded': is_concluded}, + upsert=True, + ) + ) + + +@register_query(LocalMongoDBConnection) +def store_elections(conn, elections): + return conn.run( + conn.collection('elections').insert_many(elections) + ) + + +@register_query(LocalMongoDBConnection) +def delete_elections(conn, height): + return conn.run( + conn.collection('elections').delete_many({'height': height}) + ) + + +@register_query(LocalMongoDBConnection) +def get_validator_set(conn, height=None): + query = {} + if height is not None: + query = {'height': {'$lte': height}} + + cursor = conn.run( + conn.collection('validators') + .find(query, projection={'_id': False}) + .sort([('height', DESCENDING)]) + .limit(1) + ) + + return next(cursor, None) + + +@register_query(LocalMongoDBConnection) +def get_election(conn, election_id): + query = {'election_id': election_id} + + return conn.run( + conn.collection('elections') + .find_one(query, projection={'_id': False}, + sort=[('height', DESCENDING)]) + ) + + +@register_query(LocalMongoDBConnection) +def get_asset_tokens_for_public_key(conn, asset_id, public_key): + query = {'outputs.public_keys': [public_key], + 'asset.id': asset_id} + + cursor = conn.run( + conn.collection('transactions').aggregate([ + {'$match': query}, + {'$project': {'_id': False}} + ])) + return cursor + + +@register_query(LocalMongoDBConnection) +def store_abci_chain(conn, height, chain_id, is_synced=True): + return conn.run( + conn.collection('abci_chains').replace_one( + {'height': height}, + {'height': height, 'chain_id': chain_id, + 'is_synced': is_synced}, + upsert=True, + ) + ) + + +@register_query(LocalMongoDBConnection) +def delete_abci_chain(conn, height): + return conn.run( + conn.collection('abci_chains').delete_many({'height': height}) + ) + + +@register_query(LocalMongoDBConnection) +def get_latest_abci_chain(conn): + return conn.run( + conn.collection('abci_chains') + .find_one(projection={'_id': False}, sort=[('height', DESCENDING)]) + ) diff --git a/corechaindb/backend/localmongodb/schema.py b/corechaindb/backend/localmongodb/schema.py new file mode 100644 index 00000000..cb36bd95 --- /dev/null +++ b/corechaindb/backend/localmongodb/schema.py @@ -0,0 +1,90 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Utils to initialize and drop the database.""" + +import logging + +from pymongo import ASCENDING, DESCENDING, TEXT +from pymongo.errors import CollectionInvalid + +from corechaindb import backend +from corechaindb.backend.utils import module_dispatch_registrar +from corechaindb.backend.localmongodb.connection import LocalMongoDBConnection + + +logger = logging.getLogger(__name__) +register_schema = module_dispatch_registrar(backend.schema) + + +INDEXES = { + 'transactions': [ + ('id', dict(unique=True, name='transaction_id')), + ('asset.id', dict(name='asset_id')), + ('outputs.public_keys', dict(name='outputs')), + ([('inputs.fulfills.transaction_id', ASCENDING), + ('inputs.fulfills.output_index', ASCENDING)], dict(name='inputs')), + ], + 'assets': [ + ('id', dict(name='asset_id', unique=True)), + ([('$**', TEXT)], dict(name='text')), + ], + 'blocks': [ + ([('height', DESCENDING)], dict(name='height', unique=True)), + ], + 'metadata': [ + ('id', dict(name='transaction_id', unique=True)), + ([('$**', TEXT)], dict(name='text')), + ], + 'utxos': [ + ([('transaction_id', ASCENDING), + ('output_index', ASCENDING)], dict(name='utxo', unique=True)), + ], + 'pre_commit': [ + ('height', dict(name='height', unique=True)), + ], + 'elections': [ + ([('height', DESCENDING), ('election_id', ASCENDING)], + dict(name='election_id_height', unique=True)), + ], + 'validators': [ + ('height', dict(name='height', unique=True)), + ], + 'abci_chains': [ + ('height', dict(name='height', unique=True)), + ('chain_id', dict(name='chain_id', unique=True)), + ], +} + + +@register_schema(LocalMongoDBConnection) +def create_database(conn, dbname): + logger.info('Create database `%s`.', dbname) + # TODO: read and write concerns can be declared here + conn.conn.get_database(dbname) + + +@register_schema(LocalMongoDBConnection) +def create_tables(conn, dbname): + for table_name in backend.schema.TABLES: + # create the table + # TODO: read and write concerns can be declared here + try: + logger.info(f'Create `{table_name}` table.') + conn.conn[dbname].create_collection(table_name) + except CollectionInvalid: + logger.info(f'Collection {table_name} already exists.') + create_indexes(conn, dbname, table_name, INDEXES[table_name]) + + +def create_indexes(conn, dbname, collection, indexes): + logger.info(f'Ensure secondary indexes for `{collection}`.') + for fields, kwargs in indexes: + conn.conn[dbname][collection].create_index(fields, **kwargs) + + +@register_schema(LocalMongoDBConnection) +def drop_database(conn, dbname): + conn.conn.drop_database(dbname) diff --git a/corechaindb/backend/query.py b/corechaindb/backend/query.py new file mode 100644 index 00000000..4f3184dc --- /dev/null +++ b/corechaindb/backend/query.py @@ -0,0 +1,430 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Query interfaces for backends.""" + +from functools import singledispatch + +from corechaindb.backend.exceptions import OperationError + + +@singledispatch +def store_asset(connection, asset): + """Write an asset to the asset table. + + Args: + asset (dict): the asset. + + Returns: + The result of the operation. + """ + + raise NotImplementedError + + +@singledispatch +def store_assets(connection, assets): + """Write a list of assets to the assets table. + + Args: + assets (list): a list of assets to write. + + Returns: + The database response. + """ + + raise NotImplementedError + + +@singledispatch +def store_metadatas(connection, metadata): + """Write a list of metadata to metadata table. + + Args: + metadata (list): list of metadata. + + Returns: + The result of the operation. + """ + + raise NotImplementedError + + +@singledispatch +def store_transactions(connection, signed_transactions): + """Store the list of transactions.""" + + raise NotImplementedError + + +@singledispatch +def get_transaction(connection, transaction_id): + """Get a transaction from the transactions table. + + Args: + transaction_id (str): the id of the transaction. + + Returns: + The result of the operation. + """ + + raise NotImplementedError + + +@singledispatch +def get_transactions(connection, transaction_ids): + """Get transactions from the transactions table. + + Args: + transaction_ids (list): list of transaction ids to fetch + + Returns: + The result of the operation. + """ + + raise NotImplementedError + + +@singledispatch +def get_asset(connection, asset_id): + """Get a transaction from the transactions table. + + Args: + asset_id (str): the id of the asset + + Returns: + The result of the operation. + """ + + raise NotImplementedError + + +@singledispatch +def get_spent(connection, transaction_id, condition_id): + """Check if a `txid` was already used as an input. + + A transaction can be used as an input for another transaction. Bigchain + needs to make sure that a given `txid` is only used once. + + Args: + transaction_id (str): The id of the transaction. + condition_id (int): The index of the condition in the respective + transaction. + + Returns: + The transaction that used the `txid` as an input else `None` + """ + + raise NotImplementedError + + +@singledispatch +def get_spending_transactions(connection, inputs): + """Return transactions which spend given inputs + + Args: + inputs (list): list of {txid, output} + + Returns: + Iterator of (block_ids, transaction) for transactions that + spend given inputs. + """ + raise NotImplementedError + + +@singledispatch +def get_owned_ids(connection, owner): + """Retrieve a list of `txids` that can we used has inputs. + + Args: + owner (str): base58 encoded public key. + + Returns: + Iterator of (block_id, transaction) for transactions + that list given owner in conditions. + """ + raise NotImplementedError + + +@singledispatch +def get_block(connection, block_id): + """Get a block from the bigchain table. + + Args: + block_id (str): block id of the block to get + + Returns: + block (dict): the block or `None` + """ + + raise NotImplementedError + + +@singledispatch +def get_block_with_transaction(connection, txid): + """Get a block containing transaction id `txid` + + Args: + txid (str): id of transaction to be searched. + + Returns: + block_id (int): the block id or `None` + """ + + raise NotImplementedError + + +@singledispatch +def get_metadata(connection, transaction_ids): + """Get a list of metadata from the metadata table. + + Args: + transaction_ids (list): a list of ids for the metadata to be retrieved from + the database. + + Returns: + metadata (list): the list of returned metadata. + """ + raise NotImplementedError + + +@singledispatch +def get_assets(connection, asset_ids): + """Get a list of assets from the assets table. + Args: + asset_ids (list): a list of ids for the assets to be retrieved from + the database. + Returns: + assets (list): the list of returned assets. + """ + raise NotImplementedError + + +@singledispatch +def get_txids_filtered(connection, asset_id, operation=None): + """Return all transactions for a particular asset id and optional operation. + + Args: + asset_id (str): ID of transaction that defined the asset + operation (str) (optional): Operation to filter on + """ + + raise NotImplementedError + + +@singledispatch +def text_search(conn, search, *, language='english', case_sensitive=False, + diacritic_sensitive=False, text_score=False, limit=0, table=None): + """Return all the assets that match the text search. + + The results are sorted by text score. + For more information about the behavior of text search on MongoDB see + https://docs.mongodb.com/manual/reference/operator/query/text/#behavior + + Args: + search (str): Text search string to query the text index + language (str, optional): The language for the search and the rules for + stemmer and tokenizer. If the language is ``None`` text search uses + simple tokenization and no stemming. + case_sensitive (bool, optional): Enable or disable case sensitive + search. + diacritic_sensitive (bool, optional): Enable or disable case sensitive + diacritic search. + text_score (bool, optional): If ``True`` returns the text score with + each document. + limit (int, optional): Limit the number of returned documents. + + Returns: + :obj:`list` of :obj:`dict`: a list of assets + + Raises: + OperationError: If the backend does not support text search + """ + + raise OperationError('This query is only supported when running ' + 'BigchainDB with MongoDB as the backend.') + + +@singledispatch +def get_latest_block(conn): + """Get the latest commited block i.e. block with largest height""" + + raise NotImplementedError + + +@singledispatch +def store_block(conn, block): + """Write a new block to the `blocks` table + + Args: + block (dict): block with current height and block hash. + + Returns: + The result of the operation. + """ + + raise NotImplementedError + + +@singledispatch +def store_unspent_outputs(connection, unspent_outputs): + """Store unspent outputs in ``utxo_set`` table.""" + + raise NotImplementedError + + +@singledispatch +def delete_unspent_outputs(connection, unspent_outputs): + """Delete unspent outputs in ``utxo_set`` table.""" + + raise NotImplementedError + + +@singledispatch +def delete_transactions(conn, txn_ids): + """Delete transactions from database + + Args: + txn_ids (list): list of transaction ids + + Returns: + The result of the operation. + """ + + raise NotImplementedError + + +@singledispatch +def get_unspent_outputs(connection, *, query=None): + """Retrieves unspent outputs. + + Args: + query (dict): An optional parameter to filter the result set. + Defaults to ``None``, which means that all UTXO records + will be returned. + + Returns: + Generator yielding unspent outputs (UTXO set) according to the + given query. + """ + + raise NotImplementedError + + +@singledispatch +def store_pre_commit_state(connection, state): + """Store pre-commit state. + + Args: + state (dict): pre-commit state. + + Returns: + The result of the operation. + """ + + raise NotImplementedError + + +@singledispatch +def get_pre_commit_state(connection): + """Get pre-commit state. + + Returns: + Document representing the pre-commit state. + """ + + raise NotImplementedError + + +@singledispatch +def store_validator_set(conn, validator_update): + """Store updated validator set""" + + raise NotImplementedError + + +@singledispatch +def delete_validator_set(conn, height): + """Delete the validator set at the given height.""" + + raise NotImplementedError + + +@singledispatch +def store_election(conn, election_id, height, is_concluded): + """Store election record""" + + raise NotImplementedError + + +@singledispatch +def store_elections(conn, elections): + """Store election records in bulk""" + + raise NotImplementedError + + +@singledispatch +def delete_elections(conn, height): + """Delete all election records at the given height""" + + raise NotImplementedError + + +@singledispatch +def get_validator_set(conn, height): + """Get validator set for a given `height`, if `height` is not specified + then return the latest validator set + """ + + raise NotImplementedError + + +@singledispatch +def get_election(conn, election_id): + """Return the election record + """ + + raise NotImplementedError + + +@singledispatch +def get_asset_tokens_for_public_key(connection, asset_id, public_key): + """Retrieve a list of tokens of type `asset_id` that are owned by the `public_key`. + Args: + asset_id (str): Id of the token. + public_key (str): base58 encoded public key + Returns: + Iterator of transaction that list given owner in conditions. + """ + raise NotImplementedError + + +@singledispatch +def store_abci_chain(conn, height, chain_id, is_synced=True): + """Create or update an ABCI chain at the given height. + Usually invoked in the beginning of the ABCI communications (height=0) + or when ABCI client (like Tendermint) is migrated (any height). + + Args: + is_synced: True if the chain is known by both ABCI client and server + """ + + raise NotImplementedError + + +@singledispatch +def delete_abci_chain(conn, height): + """Delete the ABCI chain at the given height.""" + + raise NotImplementedError + + +@singledispatch +def get_latest_abci_chain(conn): + """Returns the ABCI chain stored at the biggest height, if any, + None otherwise. + """ + raise NotImplementedError diff --git a/corechaindb/backend/schema.py b/corechaindb/backend/schema.py new file mode 100644 index 00000000..624267a6 --- /dev/null +++ b/corechaindb/backend/schema.py @@ -0,0 +1,128 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Database creation and schema-providing interfaces for backends.""" + +from functools import singledispatch +import logging + +import corechaindb +from corechaindb.backend.connection import connect +from corechaindb.common.exceptions import ValidationError +from corechaindb.common.utils import validate_all_values_for_key_in_obj, validate_all_values_for_key_in_list + +logger = logging.getLogger(__name__) + +# Tables/collections that every backend database must create +TABLES = ('transactions', 'blocks', 'assets', 'metadata', + 'validators', 'elections', 'pre_commit', 'utxos', 'abci_chains') + +VALID_LANGUAGES = ('danish', 'dutch', 'english', 'finnish', 'french', 'german', + 'hungarian', 'italian', 'norwegian', 'portuguese', 'romanian', + 'russian', 'spanish', 'swedish', 'turkish', 'none', + 'da', 'nl', 'en', 'fi', 'fr', 'de', 'hu', 'it', 'nb', 'pt', + 'ro', 'ru', 'es', 'sv', 'tr') + + +@singledispatch +def create_database(connection, dbname): + """Create database to be used by BigchainDB. + + Args: + dbname (str): the name of the database to create. + """ + + raise NotImplementedError + + +@singledispatch +def create_tables(connection, dbname): + """Create the tables to be used by BigchainDB. + + Args: + dbname (str): the name of the database to create tables for. + """ + + raise NotImplementedError + + +@singledispatch +def drop_database(connection, dbname): + """Drop the database used by BigchainDB. + + Args: + dbname (str): the name of the database to drop. + + Raises: + :exc:`~DatabaseDoesNotExist`: If the given :attr:`dbname` does not + exist as a database. + """ + + raise NotImplementedError + + +def init_database(connection=None, dbname=None): + """Initialize the configured backend for use with BigchainDB. + + Creates a database with :attr:`dbname` with any required tables + and supporting indexes. + + Args: + connection (:class:`~corechaindb.backend.connection.Connection`): an + existing connection to use to initialize the database. + Creates one if not given. + dbname (str): the name of the database to create. + Defaults to the database name given in the BigchainDB + configuration. + """ + + connection = connection or connect() + dbname = dbname or corechaindb.config['database']['name'] + + create_database(connection, dbname) + create_tables(connection, dbname) + + +def validate_language_key(obj, key): + """Validate all nested "language" key in `obj`. + + Args: + obj (dict): dictionary whose "language" key is to be validated. + + Returns: + None: validation successful + + Raises: + ValidationError: will raise exception in case language is not valid. + """ + backend = corechaindb.config['database']['backend'] + + if backend == 'localmongodb': + data = obj.get(key, {}) + if isinstance(data, dict): + validate_all_values_for_key_in_obj(data, 'language', validate_language) + elif isinstance(data, list): + validate_all_values_for_key_in_list(data, 'language', validate_language) + + +def validate_language(value): + """Check if `value` is a valid language. + https://docs.mongodb.com/manual/reference/text-search-languages/ + + Args: + value (str): language to validated + + Returns: + None: validation successful + + Raises: + ValidationError: will raise exception in case language is not valid. + """ + if value not in VALID_LANGUAGES: + error_str = ('MongoDB does not support text search for the ' + 'language "{}". If you do not understand this error ' + 'message then please rename key/field "language" to ' + 'something else like "lang".').format(value) + raise ValidationError(error_str) diff --git a/corechaindb/backend/utils.py b/corechaindb/backend/utils.py new file mode 100644 index 00000000..2516281a --- /dev/null +++ b/corechaindb/backend/utils.py @@ -0,0 +1,39 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import corechaindb + + +class ModuleDispatchRegistrationError(Exception): + """Raised when there is a problem registering dispatched functions for a + module + """ + + +def module_dispatch_registrar(module): + def dispatch_wrapper(obj_type): + def wrapper(func): + func_name = func.__name__ + try: + dispatch_registrar = getattr(module, func_name) + return dispatch_registrar.register(obj_type)(func) + except AttributeError as ex: + raise ModuleDispatchRegistrationError( + ('`{module}` does not contain a single-dispatchable ' + 'function named `{func}`. The module being registered ' + 'was not implemented correctly!').format( + func=func_name, module=module.__name__)) from ex + + return wrapper + + return dispatch_wrapper + + +def get_corechaindb_config_value(key, default_value=None): + return corechaindb.config['database'].get(key, default_value) + + +def get_corechaindb_config_value_or_key_error(key): + return corechaindb.config['database'][key] diff --git a/corechaindb/bigchaindb/README.md b/corechaindb/bigchaindb/README.md new file mode 100644 index 00000000..f4f45dc1 --- /dev/null +++ b/corechaindb/bigchaindb/README.md @@ -0,0 +1,42 @@ + + +# Overview + +A high-level description of the files and subdirectories of BigchainDB. + +## Files + +### [`lib.py`](lib.py) + +The `BigchainDB` class is defined here. Most node-level operations and database interactions are found in this file. This is the place to start if you are interested in implementing a server API, since many of these class methods concern BigchainDB interacting with the outside world. + +### [`models.py`](./models.py) + +`Block`, `Transaction`, and `Asset` classes are defined here. The classes mirror the block and transaction structure from the [documentation](https://docs.corechaindb.com/projects/server/en/latest/data-models/index.html), but also include methods for validation and signing. + +### [`validation.py`](./validation.py) + +Base class for validation methods (verification of votes, blocks, and transactions). The actual logic is mostly found in `transaction` and `block` models, defined in [`models.py`](./models.py). + +### [`processes.py`](./processes.py) + +Entry point for the BigchainDB process, after initialization. All subprocesses are started here: processes to handle new blocks, votes, etc. + +### [`config_utils.py`](./config_utils.py) + +Methods for managing the configuration, including loading configuration files, automatically generating the configuration, and keeping the configuration consistent across BigchainDB instances. + +## Folders + +### [`commands`](./commands) + +Contains code for the [CLI](https://docs.corechaindb.com/projects/server/en/latest/server-reference/corechaindb-cli.html) for BigchainDB. + +### [`db`](./db) + +Code for building the database connection, creating indexes, and other database setup tasks. diff --git a/bigchaindb/__init__.py b/corechaindb/bigchaindb/__init__.py similarity index 82% rename from bigchaindb/__init__.py rename to corechaindb/bigchaindb/__init__.py index cafc927d..b564602d 100644 --- a/bigchaindb/__init__.py +++ b/corechaindb/bigchaindb/__init__.py @@ -6,17 +6,17 @@ import copy import logging -from bigchaindb.log import DEFAULT_LOGGING_CONFIG as log_config -from bigchaindb.lib import BigchainDB # noqa -from bigchaindb.migrations.chain_migration_election import ChainMigrationElection -from bigchaindb.version import __version__ # noqa -from bigchaindb.core import App # noqa +from corechaindb.log import DEFAULT_LOGGING_CONFIG as log_config +from corechaindb.lib import BigchainDB # noqa +from corechaindb.migrations.chain_migration_election import ChainMigrationElection +from corechaindb.version import __version__ # noqa +from corechaindb.core import App # noqa # from functools import reduce # PORT_NUMBER = reduce(lambda x, y: x * y, map(ord, 'BigchainDB')) % 2**16 # basically, the port number is 9984 -# The following variable is used by `bigchaindb configure` to +# The following variable is used by `corechaindb configure` to # prompt the user for database values. We cannot rely on # _base_database_localmongodb.keys() because dicts are unordered. # I tried to configure @@ -91,13 +91,13 @@ config = { } # We need to maintain a backup copy of the original config dict in case -# the user wants to reconfigure the node. Check ``bigchaindb.config_utils`` +# the user wants to reconfigure the node. Check ``corechaindb.config_utils`` # for more info. _config = copy.deepcopy(config) -from bigchaindb.common.transaction import Transaction # noqa -from bigchaindb import models # noqa -from bigchaindb.upsert_validator import ValidatorElection # noqa -from bigchaindb.elections.vote import Vote # noqa +from corechaindb.common.transaction import Transaction # noqa +from corechaindb import models # noqa +from corechaindb.upsert_validator import ValidatorElection # noqa +from corechaindb.elections.vote import Vote # noqa Transaction.register_type(Transaction.CREATE, models.Transaction) Transaction.register_type(Transaction.TRANSFER, models.Transaction) diff --git a/corechaindb/bigchaindb/backend/README.md b/corechaindb/bigchaindb/backend/README.md new file mode 100644 index 00000000..50579914 --- /dev/null +++ b/corechaindb/bigchaindb/backend/README.md @@ -0,0 +1,51 @@ + + +# Backend Interfaces + +## Structure + +- [`connection.py`](./connection.py): Database connection-related interfaces +- [`query.py`](./query.py): Database query-related interfaces, dispatched through single-dispatch +- [`schema.py`](./schema.py): Database setup and schema-related interfaces, dispatched through + single-dispatch + +Built-in implementations (e.g. [MongoDB's](./localmongodb)) are provided in sub-directories and +have their connection type's location exposed as `BACKENDS` in [`connection.py`](./connection.py). + +## Single-Dispatched Interfaces + +The architecture of this module is based heavily upon Python's newly-introduced [single-dispatch +generic functions](https://www.python.org/dev/peps/pep-0443/). Single-dispatch is convenient, +because it allows Python, rather than something we design ourselves, to manage the dispatching of +generic functions based on certain conditions being met (e.g. the database backend to use). + +To see what this looks like in BigchainDB, first note that our backend interfaces have been +configured to dispatch based on a backend's **connection type**. + +Call `corechaindb.backend.connect()` to create an instance of a `Connection`: + +```python +from corechaindb.backend import connect +connection = connect() # By default, uses the current configuration for backend, host, port, etc. +``` + +Then, we can call a backend function by directly calling its interface: + +```python +from corechaindb.backend import query +query.write_transaction(connection, ...) +``` + +Notice that we don't need to care about which backend implementation to use or how to access it. +Code can simply call the base interface function with a `Connection` instance, and single-dispatch +will handle routing the call to the actual implementation. + +BigchainDB will load and register the configured backend's implementation automatically (see +`corechaindb.backend.connect()`), so you should always just be able to call an interface function if +you have a `Connection` instance. A few helper utilities (see [`backend/utils.py`](./utils.py)) are +also provided to make registering new backend implementations easier. diff --git a/bigchaindb/backend/__init__.py b/corechaindb/bigchaindb/backend/__init__.py similarity index 84% rename from bigchaindb/backend/__init__.py rename to corechaindb/bigchaindb/backend/__init__.py index 508b7972..f5d0a29b 100644 --- a/bigchaindb/backend/__init__.py +++ b/corechaindb/bigchaindb/backend/__init__.py @@ -12,6 +12,6 @@ configuration or the ``BIGCHAINDB_DATABASE_BACKEND`` environment variable. """ # Include the backend interfaces -from bigchaindb.backend import schema, query # noqa +from corechaindb.backend import schema, query # noqa -from bigchaindb.backend.connection import connect # noqa +from corechaindb.backend.connection import connect # noqa diff --git a/bigchaindb/backend/connection.py b/corechaindb/bigchaindb/backend/connection.py similarity index 80% rename from bigchaindb/backend/connection.py rename to corechaindb/bigchaindb/backend/connection.py index 43ece3c0..1ac3a86c 100644 --- a/bigchaindb/backend/connection.py +++ b/corechaindb/bigchaindb/backend/connection.py @@ -7,13 +7,13 @@ import logging from importlib import import_module from itertools import repeat -import bigchaindb -from bigchaindb.backend.exceptions import ConnectionError -from bigchaindb.backend.utils import get_bigchaindb_config_value, get_bigchaindb_config_value_or_key_error -from bigchaindb.common.exceptions import ConfigurationError +import corechaindb +from corechaindb.backend.exceptions import ConnectionError +from corechaindb.backend.utils import get_corechaindb_config_value, get_corechaindb_config_value_or_key_error +from corechaindb.common.exceptions import ConfigurationError BACKENDS = { - 'localmongodb': 'bigchaindb.backend.localmongodb.connection.LocalMongoDBConnection', + 'localmongodb': 'corechaindb.backend.localmongodb.connection.LocalMongoDBConnection', } logger = logging.getLogger(__name__) @@ -37,7 +37,7 @@ def connect(backend=None, host=None, port=None, name=None, max_tries=None, MongoDB connections). Returns: - An instance of :class:`~bigchaindb.backend.connection.Connection` + An instance of :class:`~corechaindb.backend.connection.Connection` based on the given (or defaulted) :attr:`backend`. Raises: @@ -48,10 +48,10 @@ def connect(backend=None, host=None, port=None, name=None, max_tries=None, Authentication failure after connecting to the database. """ - backend = backend or get_bigchaindb_config_value_or_key_error('backend') - host = host or get_bigchaindb_config_value_or_key_error('host') - port = port or get_bigchaindb_config_value_or_key_error('port') - dbname = name or get_bigchaindb_config_value_or_key_error('name') + backend = backend or get_corechaindb_config_value_or_key_error('backend') + host = host or get_corechaindb_config_value_or_key_error('host') + port = port or get_corechaindb_config_value_or_key_error('port') + dbname = name or get_corechaindb_config_value_or_key_error('name') # Not sure how to handle this here. This setting is only relevant for # mongodb. # I added **kwargs for both RethinkDBConnection and MongoDBConnection @@ -61,15 +61,15 @@ def connect(backend=None, host=None, port=None, name=None, max_tries=None, # UPD: RethinkDBConnection is not here anymore cause we no longer support RethinkDB. # The problem described above might be reconsidered next time we introduce a backend, # if it ever happens. - replicaset = replicaset or get_bigchaindb_config_value('replicaset') - ssl = ssl if ssl is not None else get_bigchaindb_config_value('ssl', False) - login = login or get_bigchaindb_config_value('login') - password = password or get_bigchaindb_config_value('password') - ca_cert = ca_cert or get_bigchaindb_config_value('ca_cert') - certfile = certfile or get_bigchaindb_config_value('certfile') - keyfile = keyfile or get_bigchaindb_config_value('keyfile') - keyfile_passphrase = keyfile_passphrase or get_bigchaindb_config_value('keyfile_passphrase', None) - crlfile = crlfile or get_bigchaindb_config_value('crlfile') + replicaset = replicaset or get_corechaindb_config_value('replicaset') + ssl = ssl if ssl is not None else get_corechaindb_config_value('ssl', False) + login = login or get_corechaindb_config_value('login') + password = password or get_corechaindb_config_value('password') + ca_cert = ca_cert or get_corechaindb_config_value('ca_cert') + certfile = certfile or get_corechaindb_config_value('certfile') + keyfile = keyfile or get_corechaindb_config_value('keyfile') + keyfile_passphrase = keyfile_passphrase or get_corechaindb_config_value('keyfile_passphrase', None) + crlfile = crlfile or get_corechaindb_config_value('crlfile') try: module_name, _, class_name = BACKENDS[backend].rpartition('.') @@ -113,7 +113,7 @@ class Connection: configuration's ``database`` settings """ - dbconf = bigchaindb.config['database'] + dbconf = corechaindb.config['database'] self.host = host or dbconf['host'] self.port = port or dbconf['port'] diff --git a/bigchaindb/backend/exceptions.py b/corechaindb/bigchaindb/backend/exceptions.py similarity index 92% rename from bigchaindb/backend/exceptions.py rename to corechaindb/bigchaindb/backend/exceptions.py index 412a7e5c..b87853cb 100644 --- a/bigchaindb/backend/exceptions.py +++ b/corechaindb/bigchaindb/backend/exceptions.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -from bigchaindb.exceptions import BigchainDBError +from corechaindb.exceptions import BigchainDBError class BackendError(BigchainDBError): diff --git a/bigchaindb/backend/localmongodb/__init__.py b/corechaindb/bigchaindb/backend/localmongodb/__init__.py similarity index 71% rename from bigchaindb/backend/localmongodb/__init__.py rename to corechaindb/bigchaindb/backend/localmongodb/__init__.py index 2a5e60e3..fa60438f 100644 --- a/bigchaindb/backend/localmongodb/__init__.py +++ b/corechaindb/bigchaindb/backend/localmongodb/__init__.py @@ -6,7 +6,7 @@ """MongoDB backend implementation. Contains a MongoDB-specific implementation of the -:mod:`~bigchaindb.backend.schema` and :mod:`~bigchaindb.backend.query` interfaces. +:mod:`~corechaindb.backend.schema` and :mod:`~corechaindb.backend.query` interfaces. You can specify BigchainDB to use MongoDB as its database backend by either setting ``database.backend`` to ``'localmongodb'`` in your configuration file, or @@ -16,13 +16,13 @@ setting the ``BIGCHAINDB_DATABASE_BACKEND`` environment variable to MongoDB is the default database backend for BigchainDB. If configured to use MongoDB, BigchainDB will automatically return instances -of :class:`~bigchaindb.backend.localmongodb.LocalMongoDBConnection` for -:func:`~bigchaindb.backend.connection.connect` and dispatch calls of the +of :class:`~corechaindb.backend.localmongodb.LocalMongoDBConnection` for +:func:`~corechaindb.backend.connection.connect` and dispatch calls of the generic backend interfaces to the implementations in this module. """ # Register the single dispatched modules on import. -from bigchaindb.backend.localmongodb import schema, query # noqa +from corechaindb.backend.localmongodb import schema, query # noqa # MongoDBConnection should always be accessed via -# ``bigchaindb.backend.connect()``. +# ``corechaindb.backend.connect()``. diff --git a/bigchaindb/backend/localmongodb/connection.py b/corechaindb/bigchaindb/backend/localmongodb/connection.py similarity index 83% rename from bigchaindb/backend/localmongodb/connection.py rename to corechaindb/bigchaindb/backend/localmongodb/connection.py index dda5b031..0f98a051 100644 --- a/bigchaindb/backend/localmongodb/connection.py +++ b/corechaindb/bigchaindb/backend/localmongodb/connection.py @@ -8,13 +8,13 @@ from ssl import CERT_REQUIRED import pymongo -from bigchaindb.backend.connection import Connection -from bigchaindb.backend.exceptions import (DuplicateKeyError, +from corechaindb.backend.connection import Connection +from corechaindb.backend.exceptions import (DuplicateKeyError, OperationError, ConnectionError) -from bigchaindb.backend.utils import get_bigchaindb_config_value -from bigchaindb.common.exceptions import ConfigurationError -from bigchaindb.utils import Lazy +from corechaindb.backend.utils import get_corechaindb_config_value +from corechaindb.common.exceptions import ConfigurationError +from corechaindb.utils import Lazy logger = logging.getLogger(__name__) @@ -34,15 +34,15 @@ class LocalMongoDBConnection(Connection): """ super().__init__(**kwargs) - self.replicaset = replicaset or get_bigchaindb_config_value('replicaset') - self.ssl = ssl if ssl is not None else get_bigchaindb_config_value('ssl', False) - self.login = login or get_bigchaindb_config_value('login') - self.password = password or get_bigchaindb_config_value('password') - self.ca_cert = ca_cert or get_bigchaindb_config_value('ca_cert') - self.certfile = certfile or get_bigchaindb_config_value('certfile') - self.keyfile = keyfile or get_bigchaindb_config_value('keyfile') - self.keyfile_passphrase = keyfile_passphrase or get_bigchaindb_config_value('keyfile_passphrase') - self.crlfile = crlfile or get_bigchaindb_config_value('crlfile') + self.replicaset = replicaset or get_corechaindb_config_value('replicaset') + self.ssl = ssl if ssl is not None else get_corechaindb_config_value('ssl', False) + self.login = login or get_corechaindb_config_value('login') + self.password = password or get_corechaindb_config_value('password') + self.ca_cert = ca_cert or get_corechaindb_config_value('ca_cert') + self.certfile = certfile or get_corechaindb_config_value('certfile') + self.keyfile = keyfile or get_corechaindb_config_value('keyfile') + self.keyfile_passphrase = keyfile_passphrase or get_corechaindb_config_value('keyfile_passphrase') + self.crlfile = crlfile or get_corechaindb_config_value('crlfile') @property def db(self): diff --git a/bigchaindb/backend/localmongodb/query.py b/corechaindb/bigchaindb/backend/localmongodb/query.py similarity index 97% rename from bigchaindb/backend/localmongodb/query.py rename to corechaindb/bigchaindb/backend/localmongodb/query.py index 217a7757..74f9e885 100644 --- a/bigchaindb/backend/localmongodb/query.py +++ b/corechaindb/bigchaindb/backend/localmongodb/query.py @@ -7,11 +7,11 @@ from pymongo import DESCENDING -from bigchaindb import backend -from bigchaindb.backend.exceptions import DuplicateKeyError -from bigchaindb.backend.utils import module_dispatch_registrar -from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection -from bigchaindb.common.transaction import Transaction +from corechaindb import backend +from corechaindb.backend.exceptions import DuplicateKeyError +from corechaindb.backend.utils import module_dispatch_registrar +from corechaindb.backend.localmongodb.connection import LocalMongoDBConnection +from corechaindb.common.transaction import Transaction register_query = module_dispatch_registrar(backend.query) diff --git a/bigchaindb/backend/localmongodb/schema.py b/corechaindb/bigchaindb/backend/localmongodb/schema.py similarity index 94% rename from bigchaindb/backend/localmongodb/schema.py rename to corechaindb/bigchaindb/backend/localmongodb/schema.py index 1fc8d7d1..01e04a69 100644 --- a/bigchaindb/backend/localmongodb/schema.py +++ b/corechaindb/bigchaindb/backend/localmongodb/schema.py @@ -10,9 +10,9 @@ import logging from pymongo import ASCENDING, DESCENDING, TEXT from pymongo.errors import CollectionInvalid -from bigchaindb import backend -from bigchaindb.backend.utils import module_dispatch_registrar -from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection +from corechaindb import backend +from corechaindb.backend.utils import module_dispatch_registrar +from corechaindb.backend.localmongodb.connection import LocalMongoDBConnection logger = logging.getLogger(__name__) diff --git a/bigchaindb/backend/query.py b/corechaindb/bigchaindb/backend/query.py similarity index 99% rename from bigchaindb/backend/query.py rename to corechaindb/bigchaindb/backend/query.py index b8b634c1..3602cbac 100644 --- a/bigchaindb/backend/query.py +++ b/corechaindb/bigchaindb/backend/query.py @@ -7,7 +7,7 @@ from functools import singledispatch -from bigchaindb.backend.exceptions import OperationError +from corechaindb.backend.exceptions import OperationError @singledispatch diff --git a/bigchaindb/backend/schema.py b/corechaindb/bigchaindb/backend/schema.py similarity index 89% rename from bigchaindb/backend/schema.py rename to corechaindb/bigchaindb/backend/schema.py index b99efafb..de4e5a2d 100644 --- a/bigchaindb/backend/schema.py +++ b/corechaindb/bigchaindb/backend/schema.py @@ -8,10 +8,10 @@ from functools import singledispatch import logging -import bigchaindb -from bigchaindb.backend.connection import connect -from bigchaindb.common.exceptions import ValidationError -from bigchaindb.common.utils import validate_all_values_for_key_in_obj, validate_all_values_for_key_in_list +import corechaindb +from corechaindb.backend.connection import connect +from corechaindb.common.exceptions import ValidationError +from corechaindb.common.utils import validate_all_values_for_key_in_obj, validate_all_values_for_key_in_list logger = logging.getLogger(__name__) @@ -70,7 +70,7 @@ def init_database(connection=None, dbname=None): and supporting indexes. Args: - connection (:class:`~bigchaindb.backend.connection.Connection`): an + connection (:class:`~corechaindb.backend.connection.Connection`): an existing connection to use to initialize the database. Creates one if not given. dbname (str): the name of the database to create. @@ -79,7 +79,7 @@ def init_database(connection=None, dbname=None): """ connection = connection or connect() - dbname = dbname or bigchaindb.config['database']['name'] + dbname = dbname or corechaindb.config['database']['name'] create_database(connection, dbname) create_tables(connection, dbname) @@ -97,7 +97,7 @@ def validate_language_key(obj, key): Raises: ValidationError: will raise exception in case language is not valid. """ - backend = bigchaindb.config['database']['backend'] + backend = corechaindb.config['database']['backend'] if backend == 'localmongodb': data = obj.get(key, {}) diff --git a/bigchaindb/backend/utils.py b/corechaindb/bigchaindb/backend/utils.py similarity index 81% rename from bigchaindb/backend/utils.py rename to corechaindb/bigchaindb/backend/utils.py index e236d4bd..c005abb9 100644 --- a/bigchaindb/backend/utils.py +++ b/corechaindb/bigchaindb/backend/utils.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -import bigchaindb +import corechaindb class ModuleDispatchRegistrationError(Exception): @@ -31,9 +31,9 @@ def module_dispatch_registrar(module): return dispatch_wrapper -def get_bigchaindb_config_value(key, default_value=None): - return bigchaindb.config['database'].get(key, default_value) +def get_corechaindb_config_value(key, default_value=None): + return corechaindb.config['database'].get(key, default_value) -def get_bigchaindb_config_value_or_key_error(key): - return bigchaindb.config['database'][key] +def get_corechaindb_config_value_or_key_error(key): + return corechaindb.config['database'][key] diff --git a/bigchaindb/commands/__init__.py b/corechaindb/bigchaindb/commands/__init__.py similarity index 100% rename from bigchaindb/commands/__init__.py rename to corechaindb/bigchaindb/commands/__init__.py diff --git a/bigchaindb/commands/bigchaindb.py b/corechaindb/bigchaindb/commands/corechaindb.py similarity index 89% rename from bigchaindb/commands/bigchaindb.py rename to corechaindb/bigchaindb/commands/corechaindb.py index 94fa73a1..3c6f71ca 100644 --- a/bigchaindb/commands/bigchaindb.py +++ b/corechaindb/bigchaindb/commands/corechaindb.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -"""Implementation of the `bigchaindb` command, +"""Implementation of the `corechaindb` command, the command-line interface (CLI) for BigchainDB Server. """ @@ -14,24 +14,24 @@ import copy import json import sys -from bigchaindb.core import rollback -from bigchaindb.migrations.chain_migration_election import ChainMigrationElection -from bigchaindb.utils import load_node_key -from bigchaindb.common.transaction_mode_types import BROADCAST_TX_COMMIT -from bigchaindb.common.exceptions import (DatabaseDoesNotExist, +from corechaindb.core import rollback +from corechaindb.migrations.chain_migration_election import ChainMigrationElection +from corechaindb.utils import load_node_key +from corechaindb.common.transaction_mode_types import BROADCAST_TX_COMMIT +from corechaindb.common.exceptions import (DatabaseDoesNotExist, ValidationError) -from bigchaindb.elections.vote import Vote -import bigchaindb -from bigchaindb import (backend, ValidatorElection, +from corechaindb.elections.vote import Vote +import corechaindb +from corechaindb import (backend, ValidatorElection, BigchainDB) -from bigchaindb.backend import schema -from bigchaindb.commands import utils -from bigchaindb.commands.utils import (configure_bigchaindb, +from corechaindb.backend import schema +from corechaindb.commands import utils +from corechaindb.commands.utils import (configure_corechaindb, input_on_stderr) -from bigchaindb.log import setup_logging -from bigchaindb.tendermint_utils import public_key_from_base64 -from bigchaindb.commands.election_types import elections -from bigchaindb.version import __tm_supported_versions__ +from corechaindb.log import setup_logging +from corechaindb.tendermint_utils import public_key_from_base64 +from corechaindb.commands.election_types import elections +from corechaindb.version import __tm_supported_versions__ logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) @@ -43,21 +43,21 @@ logger = logging.getLogger(__name__) # should be printed to stderr. -@configure_bigchaindb +@configure_corechaindb def run_show_config(args): """Show the current configuration""" # TODO Proposal: remove the "hidden" configuration. Only show config. If # the system needs to be configured, then display information on how to # configure the system. - config = copy.deepcopy(bigchaindb.config) + config = copy.deepcopy(corechaindb.config) del config['CONFIGURED'] print(json.dumps(config, indent=4, sort_keys=True)) -@configure_bigchaindb +@configure_corechaindb def run_configure(args): """Run a script to configure the current node.""" - config_path = args.config or bigchaindb.config_utils.CONFIG_DEFAULT_PATH + config_path = args.config or corechaindb.config_utils.CONFIG_DEFAULT_PATH config_file_exists = False # if the config path is `-` then it's stdout @@ -70,13 +70,13 @@ def run_configure(args): if want != 'y': return - conf = copy.deepcopy(bigchaindb.config) + conf = copy.deepcopy(corechaindb.config) # select the correct config defaults based on the backend print('Generating default configuration for backend {}' .format(args.backend), file=sys.stderr) - database_keys = bigchaindb._database_keys_map[args.backend] - conf['database'] = bigchaindb._database_map[args.backend] + database_keys = corechaindb._database_keys_map[args.backend] + conf['database'] = corechaindb._database_map[args.backend] if not args.yes: for key in ('bind', ): @@ -96,14 +96,14 @@ def run_configure(args): conf['tendermint'][key] = input_on_stderr('Tendermint {}? (default `{}`)'.format(key, val), val) if config_path != '-': - bigchaindb.config_utils.write_config(conf, config_path) + corechaindb.config_utils.write_config(conf, config_path) else: print(json.dumps(conf, indent=4, sort_keys=True)) print('Configuration written to {}'.format(config_path), file=sys.stderr) print('Ready to go!', file=sys.stderr) -@configure_bigchaindb +@configure_corechaindb def run_election(args): """Initiate and manage elections""" @@ -241,21 +241,21 @@ def run_election_show(args, bigchain): def _run_init(): - bdb = bigchaindb.BigchainDB() + bdb = corechaindb.BigchainDB() schema.init_database(connection=bdb.connection) -@configure_bigchaindb +@configure_corechaindb def run_init(args): """Initialize the database""" _run_init() -@configure_bigchaindb +@configure_corechaindb def run_drop(args): """Drop the database""" - dbname = bigchaindb.config['database']['name'] + dbname = corechaindb.config['database']['name'] if not args.yes: response = input_on_stderr('Do you want to drop `{}` database? [y/n]: '.format(dbname)) @@ -273,22 +273,22 @@ def run_recover(b): rollback(b) -@configure_bigchaindb +@configure_corechaindb def run_start(args): """Start the processes to run the node""" # Configure Logging setup_logging() - logger.info('BigchainDB Version %s', bigchaindb.__version__) - run_recover(bigchaindb.lib.BigchainDB()) + logger.info('BigchainDB Version %s', corechaindb.__version__) + run_recover(corechaindb.lib.BigchainDB()) if not args.skip_initialize_database: logger.info('Initializing database') _run_init() logger.info('Starting BigchainDB main process.') - from bigchaindb.start import start + from corechaindb.start import start start(args) diff --git a/bigchaindb/commands/election_types.py b/corechaindb/bigchaindb/commands/election_types.py similarity index 100% rename from bigchaindb/commands/election_types.py rename to corechaindb/bigchaindb/commands/election_types.py diff --git a/bigchaindb/commands/utils.py b/corechaindb/bigchaindb/commands/utils.py similarity index 93% rename from bigchaindb/commands/utils.py rename to corechaindb/bigchaindb/commands/utils.py index f0a61554..9eb6da2a 100644 --- a/bigchaindb/commands/utils.py +++ b/corechaindb/bigchaindb/commands/utils.py @@ -13,14 +13,14 @@ import functools import multiprocessing as mp import sys -import bigchaindb -import bigchaindb.config_utils -from bigchaindb.version import __version__ +import corechaindb +import corechaindb.config_utils +from corechaindb.version import __version__ -def configure_bigchaindb(command): +def configure_corechaindb(command): """Decorator to be used by command line functions, such that the - configuration of bigchaindb is performed before the execution of + configuration of corechaindb is performed before the execution of the command. Args: @@ -44,7 +44,7 @@ def configure_bigchaindb(command): } except AttributeError: pass - bigchaindb.config_utils.autoconfigure( + corechaindb.config_utils.autoconfigure( filename=args.config, config=config_from_cmdline, force=True) command(args) @@ -138,7 +138,7 @@ def start(parser, argv, scope): return func(args) -base_parser = argparse.ArgumentParser(add_help=False, prog='bigchaindb') +base_parser = argparse.ArgumentParser(add_help=False, prog='corechaindb') base_parser.add_argument('-c', '--config', help='Specify the location of the configuration file ' diff --git a/bigchaindb/common/__init__.py b/corechaindb/bigchaindb/common/__init__.py similarity index 100% rename from bigchaindb/common/__init__.py rename to corechaindb/bigchaindb/common/__init__.py diff --git a/bigchaindb/common/crypto.py b/corechaindb/bigchaindb/common/crypto.py similarity index 89% rename from bigchaindb/common/crypto.py rename to corechaindb/bigchaindb/common/crypto.py index 0466685a..ee9d8333 100644 --- a/bigchaindb/common/crypto.py +++ b/corechaindb/bigchaindb/common/crypto.py @@ -26,10 +26,10 @@ def generate_key_pair(): """Generates a cryptographic key pair. Returns: - :class:`~bigchaindb.common.crypto.CryptoKeypair`: A + :class:`~corechaindb.common.crypto.CryptoKeypair`: A :obj:`collections.namedtuple` with named fields - :attr:`~bigchaindb.common.crypto.CryptoKeypair.private_key` and - :attr:`~bigchaindb.common.crypto.CryptoKeypair.public_key`. + :attr:`~corechaindb.common.crypto.CryptoKeypair.private_key` and + :attr:`~corechaindb.common.crypto.CryptoKeypair.public_key`. """ # TODO FOR CC: Adjust interface so that this function becomes unnecessary diff --git a/bigchaindb/common/exceptions.py b/corechaindb/bigchaindb/common/exceptions.py similarity index 96% rename from bigchaindb/common/exceptions.py rename to corechaindb/bigchaindb/common/exceptions.py index 0bc79e24..4cb9b63f 100644 --- a/bigchaindb/common/exceptions.py +++ b/corechaindb/bigchaindb/common/exceptions.py @@ -3,9 +3,9 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -"""Custom exceptions used in the `bigchaindb` package. +"""Custom exceptions used in the `corechaindb` package. """ -from bigchaindb.exceptions import BigchainDBError +from corechaindb.exceptions import BigchainDBError class ConfigurationError(BigchainDBError): diff --git a/bigchaindb/common/memoize.py b/corechaindb/bigchaindb/common/memoize.py similarity index 100% rename from bigchaindb/common/memoize.py rename to corechaindb/bigchaindb/common/memoize.py diff --git a/bigchaindb/common/schema/README.md b/corechaindb/bigchaindb/common/schema/README.md similarity index 91% rename from bigchaindb/common/schema/README.md rename to corechaindb/bigchaindb/common/schema/README.md index 404ac34d..aca04f04 100644 --- a/bigchaindb/common/schema/README.md +++ b/corechaindb/bigchaindb/common/schema/README.md @@ -20,7 +20,7 @@ The aim is to provide: ## Sources The files defining the JSON Schema for transactions (`transaction_*.yaml`) -are based on the [BigchainDB Transactions Specs](https://github.com/bigchaindb/BEPs/tree/master/tx-specs). +are based on the [BigchainDB Transactions Specs](https://github.com/corechaindb/BEPs/tree/master/tx-specs). If you want to add a new transaction version, you must write a spec for it first. (You can't change the JSON Schema files for old versions. @@ -31,7 +31,7 @@ There used to be a file defining the JSON Schema for votes, named `vote.yaml`. It was used by BigchainDB version 1.3.0 and earlier. If you want a copy of the latest `vote.yaml` file, then you can get it from the version 1.3.0 release on GitHub, at -[https://github.com/bigchaindb/bigchaindb/blob/v1.3.0/bigchaindb/common/schema/vote.yaml](https://github.com/bigchaindb/bigchaindb/blob/v1.3.0/bigchaindb/common/schema/vote.yaml). +[https://github.com/corechaindb/corechaindb/blob/v1.3.0/corechaindb/common/schema/vote.yaml](https://github.com/corechaindb/corechaindb/blob/v1.3.0/corechaindb/common/schema/vote.yaml). ## Learn about JSON Schema diff --git a/bigchaindb/common/schema/__init__.py b/corechaindb/bigchaindb/common/schema/__init__.py similarity index 97% rename from bigchaindb/common/schema/__init__.py rename to corechaindb/bigchaindb/common/schema/__init__.py index dd4737d8..c42804cf 100644 --- a/bigchaindb/common/schema/__init__.py +++ b/corechaindb/bigchaindb/common/schema/__init__.py @@ -11,7 +11,7 @@ import jsonschema import yaml import rapidjson -from bigchaindb.common.exceptions import SchemaValidationError +from corechaindb.common.exceptions import SchemaValidationError logger = logging.getLogger(__name__) diff --git a/bigchaindb/common/schema/transaction_chain_migration_election_v2.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_chain_migration_election_v2.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_chain_migration_election_v2.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_chain_migration_election_v2.0.yaml diff --git a/bigchaindb/common/schema/transaction_create_v1.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_create_v1.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_create_v1.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_create_v1.0.yaml diff --git a/bigchaindb/common/schema/transaction_create_v2.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_create_v2.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_create_v2.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_create_v2.0.yaml diff --git a/bigchaindb/common/schema/transaction_transfer_v1.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_transfer_v1.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_transfer_v1.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_transfer_v1.0.yaml diff --git a/bigchaindb/common/schema/transaction_transfer_v2.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_transfer_v2.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_transfer_v2.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_transfer_v2.0.yaml diff --git a/bigchaindb/common/schema/transaction_v1.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_v1.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_v1.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_v1.0.yaml diff --git a/bigchaindb/common/schema/transaction_v2.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_v2.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_v2.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_v2.0.yaml diff --git a/bigchaindb/common/schema/transaction_validator_election_v2.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_validator_election_v2.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_validator_election_v2.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_validator_election_v2.0.yaml diff --git a/bigchaindb/common/schema/transaction_vote_v2.0.yaml b/corechaindb/bigchaindb/common/schema/transaction_vote_v2.0.yaml similarity index 100% rename from bigchaindb/common/schema/transaction_vote_v2.0.yaml rename to corechaindb/bigchaindb/common/schema/transaction_vote_v2.0.yaml diff --git a/bigchaindb/common/transaction.py b/corechaindb/bigchaindb/common/transaction.py similarity index 96% rename from bigchaindb/common/transaction.py rename to corechaindb/bigchaindb/common/transaction.py index e70fbe4a..0a2e9aa7 100644 --- a/bigchaindb/common/transaction.py +++ b/corechaindb/bigchaindb/common/transaction.py @@ -25,13 +25,13 @@ try: except ImportError: from sha3 import sha3_256 -from bigchaindb.common.crypto import PrivateKey, hash_data -from bigchaindb.common.exceptions import (KeypairMismatchException, +from corechaindb.common.crypto import PrivateKey, hash_data +from corechaindb.common.exceptions import (KeypairMismatchException, InputDoesNotExist, DoubleSpend, InvalidHash, InvalidSignature, AmountError, AssetIdMismatch, ThresholdTooDeep) -from bigchaindb.common.utils import serialize +from corechaindb.common.utils import serialize from .memoize import memoize_from_dict, memoize_to_dict @@ -58,7 +58,7 @@ class Input(object): to be signed with a private key. owners_before (:obj:`list` of :obj:`str`): A list of owners after a Transaction was confirmed. - fulfills (:class:`~bigchaindb.common.transaction. TransactionLink`, + fulfills (:class:`~corechaindb.common.transaction. TransactionLink`, optional): A link representing the input of a `TRANSFER` Transaction. """ @@ -71,7 +71,7 @@ class Input(object): Fulfillment to be signed with a private key. owners_before (:obj:`list` of :obj:`str`): A list of owners after a Transaction was confirmed. - fulfills (:class:`~bigchaindb.common.transaction. + fulfills (:class:`~corechaindb.common.transaction. TransactionLink`, optional): A link representing the input of a `TRANSFER` Transaction. """ @@ -141,7 +141,7 @@ class Input(object): data (dict): The Input to be transformed. Returns: - :class:`~bigchaindb.common.transaction.Input` + :class:`~corechaindb.common.transaction.Input` Raises: InvalidSignature: If an Input's URI couldn't be parsed. @@ -257,7 +257,7 @@ class TransactionLink(object): link (dict): The link to be transformed. Returns: - :class:`~bigchaindb.common.transaction.TransactionLink` + :class:`~corechaindb.common.transaction.TransactionLink` """ try: return cls(link['transaction_id'], link['output_index']) @@ -468,7 +468,7 @@ class Output(object): data (dict): The dict to be transformed. Returns: - :class:`~bigchaindb.common.transaction.Output` + :class:`~corechaindb.common.transaction.Output` """ try: fulfillment = _fulfillment_from_details(data['condition']['details']) @@ -491,10 +491,10 @@ class Transaction(object): Attributes: operation (str): Defines the operation of the Transaction. - inputs (:obj:`list` of :class:`~bigchaindb.common. + inputs (:obj:`list` of :class:`~corechaindb.common. transaction.Input`, optional): Define the assets to spend. - outputs (:obj:`list` of :class:`~bigchaindb.common. + outputs (:obj:`list` of :class:`~corechaindb.common. transaction.Output`, optional): Define the assets to lock. asset (dict): Asset payload for this Transaction. ``CREATE`` Transactions require a dict with a ``data`` @@ -521,9 +521,9 @@ class Transaction(object): Args: operation (str): Defines the operation of the Transaction. asset (dict): Asset payload for this Transaction. - inputs (:obj:`list` of :class:`~bigchaindb.common. + inputs (:obj:`list` of :class:`~corechaindb.common. transaction.Input`, optional): Define the assets to - outputs (:obj:`list` of :class:`~bigchaindb.common. + outputs (:obj:`list` of :class:`~corechaindb.common. transaction.Output`, optional): Define the assets to lock. metadata (dict): Metadata to be stored along with the @@ -660,7 +660,7 @@ class Transaction(object): be created in this Transaction. Returns: - :class:`~bigchaindb.common.transaction.Transaction` + :class:`~corechaindb.common.transaction.Transaction` """ (inputs, outputs) = cls.validate_create(tx_signers, recipients, asset, metadata) @@ -716,7 +716,7 @@ class Transaction(object): weight respectively. `inp2` is owned completely by `d`. Args: - inputs (:obj:`list` of :class:`~bigchaindb.common.transaction. + inputs (:obj:`list` of :class:`~corechaindb.common.transaction. Input`): Converted `Output`s, intended to be used as inputs in the transfer to generate. recipients (:obj:`list` of :obj:`tuple`): A list of @@ -728,7 +728,7 @@ class Transaction(object): Transaction. Returns: - :class:`~bigchaindb.common.transaction.Transaction` + :class:`~corechaindb.common.transaction.Transaction` """ (inputs, outputs) = cls.validate_transfer(inputs, recipients, asset_id, metadata) return cls(cls.TRANSFER, {'id': asset_id}, inputs, outputs, metadata) @@ -757,7 +757,7 @@ class Transaction(object): outputs should be returned as inputs. Returns: - :obj:`list` of :class:`~bigchaindb.common.transaction. + :obj:`list` of :class:`~corechaindb.common.transaction. Input` """ # NOTE: If no indices are passed, we just assume to take all outputs @@ -774,7 +774,7 @@ class Transaction(object): """Adds an input to a Transaction's list of inputs. Args: - input_ (:class:`~bigchaindb.common.transaction. + input_ (:class:`~corechaindb.common.transaction. Input`): An Input to be added to the Transaction. """ if not isinstance(input_, Input): @@ -785,7 +785,7 @@ class Transaction(object): """Adds an output to a Transaction's list of outputs. Args: - output (:class:`~bigchaindb.common.transaction. + output (:class:`~corechaindb.common.transaction. Output`): An Output to be added to the Transaction. """ @@ -811,7 +811,7 @@ class Transaction(object): Transaction. Returns: - :class:`~bigchaindb.common.transaction.Transaction` + :class:`~corechaindb.common.transaction.Transaction` """ # TODO: Singing should be possible with at least one of all private # keys supplied to this method. @@ -857,7 +857,7 @@ class Transaction(object): - ThresholdSha256. Args: - input_ (:class:`~bigchaindb.common.transaction. + input_ (:class:`~corechaindb.common.transaction. Input`) The Input to be signed. message (str): The message to be signed key_pairs (dict): The keys to sign the Transaction with. @@ -878,7 +878,7 @@ class Transaction(object): """Signs a Ed25519Fulfillment. Args: - input_ (:class:`~bigchaindb.common.transaction. + input_ (:class:`~corechaindb.common.transaction. Input`) The input to be signed. message (str): The message to be signed key_pairs (dict): The keys to sign the Transaction with. @@ -910,7 +910,7 @@ class Transaction(object): """Signs a ThresholdSha256. Args: - input_ (:class:`~bigchaindb.common.transaction. + input_ (:class:`~corechaindb.common.transaction. Input`) The Input to be signed. message (str): The message to be signed key_pairs (dict): The keys to sign the Transaction with. @@ -962,7 +962,7 @@ class Transaction(object): evaluate parts of the validation-checks to `True`. Args: - outputs (:obj:`list` of :class:`~bigchaindb.common. + outputs (:obj:`list` of :class:`~corechaindb.common. transaction.Output`): A list of Outputs to check the Inputs against. @@ -1025,7 +1025,7 @@ class Transaction(object): does not validate against `output_condition_uri`. Args: - input_ (:class:`~bigchaindb.common.transaction. + input_ (:class:`~corechaindb.common.transaction. Input`) The Input to be signed. operation (str): The type of Transaction. message (str): The fulfillment message. @@ -1134,7 +1134,7 @@ class Transaction(object): transaction are related to the same asset id. Args: - transactions (:obj:`list` of :class:`~bigchaindb.common. + transactions (:obj:`list` of :class:`~corechaindb.common. transaction.Transaction`): A list of Transactions. Usually input Transactions that should have a matching asset ID. @@ -1196,7 +1196,7 @@ class Transaction(object): tx_body (dict): The Transaction to be transformed. Returns: - :class:`~bigchaindb.common.transaction.Transaction` + :class:`~corechaindb.common.transaction.Transaction` """ operation = tx.get('operation', Transaction.CREATE) if isinstance(tx, dict) else Transaction.CREATE cls = Transaction.resolve_class(operation) @@ -1217,7 +1217,7 @@ class Transaction(object): asset from the asset table and reconstructs the transaction. Args: - bigchain (:class:`~bigchaindb.tendermint.BigchainDB`): An instance + bigchain (:class:`~corechaindb.tendermint.BigchainDB`): An instance of BigchainDB used to perform database queries. tx_dict_list (:list:`dict` or :obj:`dict`): The transaction dict or list of transaction dict as returned from the database. diff --git a/bigchaindb/common/transaction_mode_types.py b/corechaindb/bigchaindb/common/transaction_mode_types.py similarity index 100% rename from bigchaindb/common/transaction_mode_types.py rename to corechaindb/bigchaindb/common/transaction_mode_types.py diff --git a/bigchaindb/common/utils.py b/corechaindb/bigchaindb/common/utils.py similarity index 97% rename from bigchaindb/common/utils.py rename to corechaindb/bigchaindb/common/utils.py index 2beedd9b..46c76872 100644 --- a/bigchaindb/common/utils.py +++ b/corechaindb/bigchaindb/common/utils.py @@ -7,8 +7,8 @@ import time import re import rapidjson -import bigchaindb -from bigchaindb.common.exceptions import ValidationError +import corechaindb +from corechaindb.common.exceptions import ValidationError def gen_timestamp(): @@ -72,7 +72,7 @@ def validate_txn_obj(obj_name, obj, key, validation_fun): Raises: ValidationError: `validation_fun` will raise exception on failure """ - backend = bigchaindb.config['database']['backend'] + backend = corechaindb.config['database']['backend'] if backend == 'localmongodb': data = obj.get(key, {}) diff --git a/bigchaindb/config_utils.py b/corechaindb/bigchaindb/config_utils.py similarity index 84% rename from bigchaindb/config_utils.py rename to corechaindb/bigchaindb/config_utils.py index 98ae9079..6bb46e2e 100644 --- a/bigchaindb/config_utils.py +++ b/corechaindb/bigchaindb/config_utils.py @@ -12,7 +12,7 @@ determined according to the following rules: * Otherwise, if it's set in a local config file, then use that value * Otherwise, use the default value (contained in - ``bigchaindb.__init__``) + ``corechaindb.__init__``) """ @@ -25,11 +25,11 @@ from functools import lru_cache from pkg_resources import iter_entry_points, ResolutionError -from bigchaindb.common import exceptions +from corechaindb.common import exceptions -import bigchaindb +import corechaindb -from bigchaindb.validation import BaseValidationRules +from corechaindb.validation import BaseValidationRules # TODO: move this to a proper configuration file for logging logging.getLogger('requests').setLevel(logging.WARNING) @@ -37,7 +37,7 @@ logger = logging.getLogger(__name__) CONFIG_DEFAULT_PATH = os.environ.setdefault( 'BIGCHAINDB_CONFIG_PATH', - os.path.join(os.path.expanduser('~'), '.bigchaindb'), + os.path.join(os.path.expanduser('~'), '.corechaindb'), ) CONFIG_PREFIX = 'BIGCHAINDB' @@ -180,27 +180,27 @@ def update_types(config, reference, list_sep=':'): def set_config(config): - """Set bigchaindb.config equal to the default config dict, + """Set corechaindb.config equal to the default config dict, then update that with whatever is in the provided config dict, - and then set bigchaindb.config['CONFIGURED'] = True + and then set corechaindb.config['CONFIGURED'] = True Args: config (dict): the config dict to read for changes to the default config Note: - Any previous changes made to ``bigchaindb.config`` will be lost. + Any previous changes made to ``corechaindb.config`` will be lost. """ - # Deep copy the default config into bigchaindb.config - bigchaindb.config = copy.deepcopy(bigchaindb._config) + # Deep copy the default config into corechaindb.config + corechaindb.config = copy.deepcopy(corechaindb._config) # Update the default config with whatever is in the passed config - update(bigchaindb.config, update_types(config, bigchaindb.config)) - bigchaindb.config['CONFIGURED'] = True + update(corechaindb.config, update_types(config, corechaindb.config)) + corechaindb.config['CONFIGURED'] = True def update_config(config): - """Update bigchaindb.config with whatever is in the provided config dict, - and then set bigchaindb.config['CONFIGURED'] = True + """Update corechaindb.config with whatever is in the provided config dict, + and then set corechaindb.config['CONFIGURED'] = True Args: config (dict): the config dict to read for changes @@ -208,8 +208,8 @@ def update_config(config): """ # Update the default config with whatever is in the passed config - update(bigchaindb.config, update_types(config, bigchaindb.config)) - bigchaindb.config['CONFIGURED'] = True + update(corechaindb.config, update_types(config, corechaindb.config)) + corechaindb.config['CONFIGURED'] = True def write_config(config, filename=None): @@ -218,7 +218,7 @@ def write_config(config, filename=None): Args: config (dict): a dictionary with the configuration to load. filename (str): the name of the file that will store the new configuration. Defaults to ``None``. - If ``None``, the HOME of the current user and the string ``.bigchaindb`` will be used. + If ``None``, the HOME of the current user and the string ``.corechaindb`` will be used. """ if not filename: filename = CONFIG_DEFAULT_PATH @@ -228,7 +228,7 @@ def write_config(config, filename=None): def is_configured(): - return bool(bigchaindb.config.get('CONFIGURED')) + return bool(corechaindb.config.get('CONFIGURED')) def autoconfigure(filename=None, config=None, force=False): @@ -240,7 +240,7 @@ def autoconfigure(filename=None, config=None, force=False): return # start with the current configuration - newconfig = bigchaindb.config + newconfig = corechaindb.config # update configuration from file try: @@ -255,7 +255,7 @@ def autoconfigure(filename=None, config=None, force=False): newconfig = env_config(newconfig) if config: newconfig = update(newconfig, config) - set_config(newconfig) # sets bigchaindb.config + set_config(newconfig) # sets corechaindb.config @lru_cache() @@ -267,29 +267,29 @@ def load_validation_plugin(name=None): setup.py of the providing package. Returns: - an uninstantiated subclass of ``bigchaindb.validation.AbstractValidationRules`` + an uninstantiated subclass of ``corechaindb.validation.AbstractValidationRules`` """ if not name: return BaseValidationRules - # TODO: This will return the first plugin with group `bigchaindb.validation` + # TODO: This will return the first plugin with group `corechaindb.validation` # and name `name` in the active WorkingSet. # We should probably support Requirements specs in the config, e.g. # validation_plugin: 'my-plugin-package==0.0.1;default' plugin = None - for entry_point in iter_entry_points('bigchaindb.validation', name): + for entry_point in iter_entry_points('corechaindb.validation', name): plugin = entry_point.load() # No matching entry_point found if not plugin: raise ResolutionError( - 'No plugin found in group `bigchaindb.validation` with name `{}`'. + 'No plugin found in group `corechaindb.validation` with name `{}`'. format(name)) # Is this strictness desireable? # It will probably reduce developer headaches in the wild. if not issubclass(plugin, (BaseValidationRules,)): - raise TypeError('object of type "{}" does not implement `bigchaindb.' + raise TypeError('object of type "{}" does not implement `corechaindb.' 'validation.BaseValidationRules`'.format(type(plugin))) return plugin @@ -302,7 +302,7 @@ def load_events_plugins(names=None): return plugins for name in names: - for entry_point in iter_entry_points('bigchaindb.events', name): + for entry_point in iter_entry_points('corechaindb.events', name): plugins.append((name, entry_point.load())) return plugins diff --git a/bigchaindb/core.py b/corechaindb/bigchaindb/core.py similarity index 84% rename from bigchaindb/core.py rename to corechaindb/bigchaindb/core.py index 4898ee94..0b06f568 100644 --- a/bigchaindb/core.py +++ b/corechaindb/bigchaindb/core.py @@ -12,15 +12,15 @@ import sys from abci.application import BaseApplication from abci import CodeTypeOk -from bigchaindb import BigchainDB -from bigchaindb.elections.election import Election -from bigchaindb.version import __tm_supported_versions__ -from bigchaindb.utils import tendermint_version_is_compatible -from bigchaindb.tendermint_utils import (decode_transaction, +from corechaindb import BigchainDB +from corechaindb.elections.election import Election +from corechaindb.version import __tm_supported_versions__ +from corechaindb.utils import tendermint_version_is_compatible +from corechaindb.tendermint_utils import (decode_transaction, calculate_hash) -from bigchaindb.lib import Block -import bigchaindb.upsert_validator.validator_utils as vutils -from bigchaindb.events import EventTypes, Event +from corechaindb.lib import Block +import corechaindb.upsert_validator.validator_utils as vutils +from corechaindb.events import EventTypes, Event CodeTypeError = 1 @@ -34,16 +34,16 @@ class App(BaseApplication): transaction logic to Tendermint Core. """ - def __init__(self, abci, bigchaindb=None, events_queue=None,): + def __init__(self, abci, corechaindb=None, events_queue=None,): super().__init__(abci) self.events_queue = events_queue - self.bigchaindb = bigchaindb or BigchainDB() + self.corechaindb = corechaindb or BigchainDB() self.block_txn_ids = [] self.block_txn_hash = '' self.block_transactions = [] self.validators = None self.new_height = None - self.chain = self.bigchaindb.get_latest_abci_chain() + self.chain = self.corechaindb.get_latest_abci_chain() def log_abci_migration_error(self, chain_id, validators): logger.error('An ABCI chain migration is in process. ' @@ -54,7 +54,7 @@ class App(BaseApplication): if self.chain is None or self.chain['is_synced']: return - validators = self.bigchaindb.get_validators() + validators = self.corechaindb.get_validators() self.log_abci_migration_error(self.chain['chain_id'], validators) sys.exit(1) @@ -64,7 +64,7 @@ class App(BaseApplication): app_hash = '' height = 0 - known_chain = self.bigchaindb.get_latest_abci_chain() + known_chain = self.corechaindb.get_latest_abci_chain() if known_chain is not None: chain_id = known_chain['chain_id'] @@ -75,16 +75,16 @@ class App(BaseApplication): sys.exit(1) if chain_id != genesis.chain_id: - validators = self.bigchaindb.get_validators() + validators = self.corechaindb.get_validators() self.log_abci_migration_error(chain_id, validators) sys.exit(1) # set migration values for app hash and height - block = self.bigchaindb.get_latest_block() + block = self.corechaindb.get_latest_block() app_hash = '' if block is None else block['app_hash'] height = 0 if block is None else block['height'] + 1 - known_validators = self.bigchaindb.get_validators() + known_validators = self.corechaindb.get_validators() validator_set = [vutils.decode_validator(v) for v in genesis.validators] @@ -94,10 +94,10 @@ class App(BaseApplication): sys.exit(1) block = Block(app_hash=app_hash, height=height, transactions=[]) - self.bigchaindb.store_block(block._asdict()) - self.bigchaindb.store_validator_set(height + 1, validator_set) + self.corechaindb.store_block(block._asdict()) + self.corechaindb.store_validator_set(height + 1, validator_set) abci_chain_height = 0 if known_chain is None else known_chain['height'] - self.bigchaindb.store_abci_chain(abci_chain_height, + self.corechaindb.store_abci_chain(abci_chain_height, genesis.chain_id, True) self.chain = {'height': abci_chain_height, 'is_synced': True, 'chain_id': genesis.chain_id} @@ -117,7 +117,7 @@ class App(BaseApplication): logger.info(f"Tendermint version: {request.version}") r = self.abci.ResponseInfo() - block = self.bigchaindb.get_latest_block() + block = self.corechaindb.get_latest_block() if block: chain_shift = 0 if self.chain is None else self.chain['height'] r.last_block_height = block['height'] - chain_shift @@ -139,7 +139,7 @@ class App(BaseApplication): logger.debug('check_tx: %s', raw_transaction) transaction = decode_transaction(raw_transaction) - if self.bigchaindb.is_valid_transaction(transaction): + if self.corechaindb.is_valid_transaction(transaction): logger.debug('check_tx: VALID') return self.abci.ResponseCheckTx(code=CodeTypeOk) else: @@ -173,7 +173,7 @@ class App(BaseApplication): self.abort_if_abci_chain_is_not_synced() logger.debug('deliver_tx: %s', raw_transaction) - transaction = self.bigchaindb.is_valid_transaction( + transaction = self.corechaindb.is_valid_transaction( decode_transaction(raw_transaction), self.block_transactions) if not transaction: @@ -205,17 +205,17 @@ class App(BaseApplication): logger.debug(f'Updating pre-commit state: {self.new_height}') pre_commit_state = dict(height=self.new_height, transactions=self.block_txn_ids) - self.bigchaindb.store_pre_commit_state(pre_commit_state) + self.corechaindb.store_pre_commit_state(pre_commit_state) block_txn_hash = calculate_hash(self.block_txn_ids) - block = self.bigchaindb.get_latest_block() + block = self.corechaindb.get_latest_block() if self.block_txn_ids: self.block_txn_hash = calculate_hash([block['app_hash'], block_txn_hash]) else: self.block_txn_hash = block['app_hash'] - validator_update = Election.process_block(self.bigchaindb, + validator_update = Election.process_block(self.corechaindb, self.new_height, self.block_transactions) @@ -230,14 +230,14 @@ class App(BaseApplication): # register a new block only when new transactions are received if self.block_txn_ids: - self.bigchaindb.store_bulk_transactions(self.block_transactions) + self.corechaindb.store_bulk_transactions(self.block_transactions) block = Block(app_hash=self.block_txn_hash, height=self.new_height, transactions=self.block_txn_ids) # NOTE: storing the block should be the last operation during commit # this effects crash recovery. Refer BEP#8 for details - self.bigchaindb.store_block(block._asdict()) + self.corechaindb.store_block(block._asdict()) logger.debug('Commit-ing new block with hash: apphash=%s ,' 'height=%s, txn ids=%s', data, self.new_height, diff --git a/bigchaindb/elections/__init__.py b/corechaindb/bigchaindb/elections/__init__.py similarity index 100% rename from bigchaindb/elections/__init__.py rename to corechaindb/bigchaindb/elections/__init__.py diff --git a/bigchaindb/elections/election.py b/corechaindb/bigchaindb/elections/election.py similarity index 96% rename from bigchaindb/elections/election.py rename to corechaindb/bigchaindb/elections/election.py index fe13db2d..fa64eca9 100644 --- a/bigchaindb/elections/election.py +++ b/corechaindb/bigchaindb/elections/election.py @@ -7,17 +7,17 @@ from collections import OrderedDict import base58 from uuid import uuid4 -from bigchaindb import backend -from bigchaindb.elections.vote import Vote -from bigchaindb.common.exceptions import (InvalidSignature, +from corechaindb import backend +from corechaindb.elections.vote import Vote +from corechaindb.common.exceptions import (InvalidSignature, MultipleInputsError, InvalidProposer, UnequalValidatorSet, DuplicateTransaction) -from bigchaindb.tendermint_utils import key_from_base64, public_key_to_base64 -from bigchaindb.common.crypto import (public_key_from_ed25519_key) -from bigchaindb.common.transaction import Transaction -from bigchaindb.common.schema import (_validate_schema, +from corechaindb.tendermint_utils import key_from_base64, public_key_to_base64 +from corechaindb.common.crypto import (public_key_from_ed25519_key) +from corechaindb.common.transaction import Transaction +from corechaindb.common.schema import (_validate_schema, TX_SCHEMA_COMMON, TX_SCHEMA_CREATE) @@ -102,7 +102,7 @@ class Election(Transaction): allocated according to the voting power of each validator node. Args: - :param bigchain: (BigchainDB) an instantiated bigchaindb.lib.BigchainDB object. + :param bigchain: (BigchainDB) an instantiated corechaindb.lib.BigchainDB object. :param current_transactions: (list) A list of transactions to be validated along with the election Returns: diff --git a/bigchaindb/elections/vote.py b/corechaindb/bigchaindb/elections/vote.py similarity index 88% rename from bigchaindb/elections/vote.py rename to corechaindb/bigchaindb/elections/vote.py index df6ec46a..deedc282 100644 --- a/bigchaindb/elections/vote.py +++ b/corechaindb/bigchaindb/elections/vote.py @@ -3,8 +3,8 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -from bigchaindb.common.transaction import Transaction -from bigchaindb.common.schema import (_validate_schema, +from corechaindb.common.transaction import Transaction +from corechaindb.common.schema import (_validate_schema, TX_SCHEMA_COMMON, TX_SCHEMA_TRANSFER, TX_SCHEMA_VOTE) @@ -25,10 +25,10 @@ class Vote(Transaction): NOTE: There are no additional validity conditions on casting votes i.e. a vote is just a valid TRANFER transaction - For more details refer BEP-21: https://github.com/bigchaindb/BEPs/tree/master/21 + For more details refer BEP-21: https://github.com/corechaindb/BEPs/tree/master/21 Args: - bigchain (BigchainDB): an instantiated bigchaindb.lib.BigchainDB object. + bigchain (BigchainDB): an instantiated corechaindb.lib.BigchainDB object. Returns: Vote: a Vote object diff --git a/bigchaindb/events.py b/corechaindb/bigchaindb/events.py similarity index 95% rename from bigchaindb/events.py rename to corechaindb/bigchaindb/events.py index 1df33171..9e6632b0 100644 --- a/bigchaindb/events.py +++ b/corechaindb/bigchaindb/events.py @@ -34,7 +34,7 @@ class Event: Args: event_type (int): the type of the event, see - :class:`~bigchaindb.events.EventTypes` + :class:`~corechaindb.events.EventTypes` event_data (obj): the data of the event. """ @@ -88,7 +88,7 @@ class Exchange: """Given an event, send it to all the subscribers. Args - event (:class:`~bigchaindb.events.EventTypes`): the event to + event (:class:`~corechaindb.events.EventTypes`): the event to dispatch to all the subscribers. """ diff --git a/bigchaindb/exceptions.py b/corechaindb/bigchaindb/exceptions.py similarity index 100% rename from bigchaindb/exceptions.py rename to corechaindb/bigchaindb/exceptions.py diff --git a/bigchaindb/fastquery.py b/corechaindb/bigchaindb/fastquery.py similarity index 92% rename from bigchaindb/fastquery.py rename to corechaindb/bigchaindb/fastquery.py index 983b5d61..7cb6f5df 100644 --- a/bigchaindb/fastquery.py +++ b/corechaindb/bigchaindb/fastquery.py @@ -3,9 +3,9 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -from bigchaindb.utils import condition_details_has_owner -from bigchaindb.backend import query -from bigchaindb.common.transaction import TransactionLink +from corechaindb.utils import condition_details_has_owner +from corechaindb.backend import query +from corechaindb.common.transaction import TransactionLink class FastQuery(): diff --git a/bigchaindb/lib.py b/corechaindb/bigchaindb/lib.py similarity index 95% rename from bigchaindb/lib.py rename to corechaindb/bigchaindb/lib.py index f51f8754..b1b7aaac 100644 --- a/bigchaindb/lib.py +++ b/corechaindb/bigchaindb/lib.py @@ -21,18 +21,18 @@ except ImportError: import requests -import bigchaindb -from bigchaindb import backend, config_utils, fastquery -from bigchaindb.models import Transaction -from bigchaindb.common.exceptions import (SchemaValidationError, +import corechaindb +from corechaindb import backend, config_utils, fastquery +from corechaindb.models import Transaction +from corechaindb.common.exceptions import (SchemaValidationError, ValidationError, DoubleSpend) -from bigchaindb.common.transaction_mode_types import (BROADCAST_TX_COMMIT, +from corechaindb.common.transaction_mode_types import (BROADCAST_TX_COMMIT, BROADCAST_TX_ASYNC, BROADCAST_TX_SYNC) -from bigchaindb.tendermint_utils import encode_transaction, merkleroot -from bigchaindb import exceptions as core_exceptions -from bigchaindb.validation import BaseValidationRules +from corechaindb.tendermint_utils import encode_transaction, merkleroot +from corechaindb import exceptions as core_exceptions +from corechaindb.validation import BaseValidationRules logger = logging.getLogger(__name__) @@ -54,10 +54,10 @@ class BigchainDB(object): If that environment variable isn't set, then the value will come from the local configuration file. And if that variable isn't in the local configuration file, then the parameter will have - its default value (defined in bigchaindb.__init__). + its default value (defined in corechaindb.__init__). Args: - connection (:class:`~bigchaindb.backend.connection.Connection`): + connection (:class:`~corechaindb.backend.connection.Connection`): A connection to the database. """ config_utils.autoconfigure() @@ -65,18 +65,18 @@ class BigchainDB(object): self.mode_list = (BROADCAST_TX_ASYNC, BROADCAST_TX_SYNC, self.mode_commit) - self.tendermint_host = bigchaindb.config['tendermint']['host'] - self.tendermint_port = bigchaindb.config['tendermint']['port'] + self.tendermint_host = corechaindb.config['tendermint']['host'] + self.tendermint_port = corechaindb.config['tendermint']['port'] self.endpoint = 'http://{}:{}/'.format(self.tendermint_host, self.tendermint_port) - validationPlugin = bigchaindb.config.get('validation_plugin') + validationPlugin = corechaindb.config.get('validation_plugin') if validationPlugin: self.validation = config_utils.load_validation_plugin(validationPlugin) else: self.validation = BaseValidationRules - self.connection = connection if connection else backend.connect(**bigchaindb.config['database']) + self.connection = connection if connection else backend.connect(**corechaindb.config['database']) def post_transaction(self, transaction, mode): """Submit a valid transaction to the mempool.""" @@ -157,7 +157,7 @@ class BigchainDB(object): outputs that the given ``transaction`` creates. Args: - transaction (:obj:`~bigchaindb.models.Transaction`): A new + transaction (:obj:`~corechaindb.models.Transaction`): A new transaction incoming into the system for which the UTXO set needs to be updated. """ diff --git a/bigchaindb/log.py b/corechaindb/bigchaindb/log.py similarity index 91% rename from bigchaindb/log.py rename to corechaindb/bigchaindb/log.py index 9023b646..00daff89 100644 --- a/bigchaindb/log.py +++ b/corechaindb/bigchaindb/log.py @@ -3,10 +3,10 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -import bigchaindb +import corechaindb import logging -from bigchaindb.common.exceptions import ConfigurationError +from corechaindb.common.exceptions import ConfigurationError from logging.config import dictConfig as set_logging_config import os @@ -38,7 +38,7 @@ DEFAULT_LOGGING_CONFIG = { }, 'file': { 'class': 'logging.handlers.RotatingFileHandler', - 'filename': os.path.join(DEFAULT_LOG_DIR, 'bigchaindb.log'), + 'filename': os.path.join(DEFAULT_LOG_DIR, 'corechaindb.log'), 'mode': 'w', 'maxBytes': 209715200, 'backupCount': 5, @@ -47,7 +47,7 @@ DEFAULT_LOGGING_CONFIG = { }, 'errors': { 'class': 'logging.handlers.RotatingFileHandler', - 'filename': os.path.join(DEFAULT_LOG_DIR, 'bigchaindb-errors.log'), + 'filename': os.path.join(DEFAULT_LOG_DIR, 'corechaindb-errors.log'), 'mode': 'w', 'maxBytes': 209715200, 'backupCount': 5, @@ -78,13 +78,13 @@ def setup_logging(): Configuration, if needed, should be applied before invoking this decorator, as starting the subscriber process for logging will configure the root logger for the child process based on the - state of :obj:`bigchaindb.config` at the moment this decorator + state of :obj:`corechaindb.config` at the moment this decorator is invoked. """ logging_configs = DEFAULT_LOGGING_CONFIG - new_logging_configs = bigchaindb.config['log'] + new_logging_configs = corechaindb.config['log'] if 'file' in new_logging_configs: filename = new_logging_configs['file'] diff --git a/bigchaindb/migrations/__init__.py b/corechaindb/bigchaindb/migrations/__init__.py similarity index 100% rename from bigchaindb/migrations/__init__.py rename to corechaindb/bigchaindb/migrations/__init__.py diff --git a/bigchaindb/migrations/chain_migration_election.py b/corechaindb/bigchaindb/migrations/chain_migration_election.py similarity index 81% rename from bigchaindb/migrations/chain_migration_election.py rename to corechaindb/bigchaindb/migrations/chain_migration_election.py index 119392c2..1861bc69 100644 --- a/bigchaindb/migrations/chain_migration_election.py +++ b/corechaindb/bigchaindb/migrations/chain_migration_election.py @@ -1,7 +1,7 @@ import json -from bigchaindb.common.schema import TX_SCHEMA_CHAIN_MIGRATION_ELECTION -from bigchaindb.elections.election import Election +from corechaindb.common.schema import TX_SCHEMA_CHAIN_MIGRATION_ELECTION +from corechaindb.elections.election import Election class ChainMigrationElection(Election): @@ -11,14 +11,14 @@ class ChainMigrationElection(Election): ALLOWED_OPERATIONS = (OPERATION,) TX_SCHEMA_CUSTOM = TX_SCHEMA_CHAIN_MIGRATION_ELECTION - def has_concluded(self, bigchaindb, *args, **kwargs): - chain = bigchaindb.get_latest_abci_chain() + def has_concluded(self, corechaindb, *args, **kwargs): + chain = corechaindb.get_latest_abci_chain() if chain is not None and not chain['is_synced']: # do not conclude the migration election if # there is another migration in progress return False - return super().has_concluded(bigchaindb, *args, **kwargs) + return super().has_concluded(corechaindb, *args, **kwargs) def on_approval(self, bigchain, *args, **kwargs): bigchain.migrate_abci_chain() diff --git a/bigchaindb/models.py b/corechaindb/bigchaindb/models.py similarity index 85% rename from bigchaindb/models.py rename to corechaindb/bigchaindb/models.py index a1d5e5fa..6085642a 100644 --- a/bigchaindb/models.py +++ b/corechaindb/bigchaindb/models.py @@ -3,12 +3,12 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -from bigchaindb.backend.schema import validate_language_key -from bigchaindb.common.exceptions import (InvalidSignature, +from corechaindb.backend.schema import validate_language_key +from corechaindb.common.exceptions import (InvalidSignature, DuplicateTransaction) -from bigchaindb.common.schema import validate_transaction_schema -from bigchaindb.common.transaction import Transaction -from bigchaindb.common.utils import (validate_txn_obj, validate_key) +from corechaindb.common.schema import validate_transaction_schema +from corechaindb.common.transaction import Transaction +from corechaindb.common.utils import (validate_txn_obj, validate_key) class Transaction(Transaction): @@ -19,7 +19,7 @@ class Transaction(Transaction): def validate(self, bigchain, current_transactions=[]): """Validate transaction spend Args: - bigchain (BigchainDB): an instantiated bigchaindb.BigchainDB object. + bigchain (BigchainDB): an instantiated corechaindb.BigchainDB object. Returns: The transaction (Transaction) if the transaction is valid else it raises an exception describing the reason why the transaction is diff --git a/bigchaindb/parallel_validation.py b/corechaindb/bigchaindb/parallel_validation.py similarity index 92% rename from bigchaindb/parallel_validation.py rename to corechaindb/bigchaindb/parallel_validation.py index 0518c68e..1b42ead2 100644 --- a/bigchaindb/parallel_validation.py +++ b/corechaindb/bigchaindb/parallel_validation.py @@ -6,14 +6,14 @@ import multiprocessing as mp from collections import defaultdict -from bigchaindb import App, BigchainDB -from bigchaindb.tendermint_utils import decode_transaction +from corechaindb import App, BigchainDB +from corechaindb.tendermint_utils import decode_transaction from abci import CodeTypeOk class ParallelValidationApp(App): - def __init__(self, bigchaindb=None, events_queue=None, abci=None): - super().__init__(bigchaindb, events_queue, abci=abci) + def __init__(self, corechaindb=None, events_queue=None, abci=None): + super().__init__(corechaindb, events_queue, abci=abci) self.parallel_validator = ParallelValidator() self.parallel_validator.start() @@ -88,7 +88,7 @@ class ValidationWorker: def __init__(self, in_queue, results_queue): self.in_queue = in_queue self.results_queue = results_queue - self.bigchaindb = BigchainDB() + self.corechaindb = BigchainDB() self.reset() def reset(self): @@ -104,7 +104,7 @@ class ValidationWorker: except KeyError: asset_id = dict_transaction['id'] - transaction = self.bigchaindb.is_valid_transaction( + transaction = self.corechaindb.is_valid_transaction( dict_transaction, self.validated_transactions[asset_id]) diff --git a/bigchaindb/start.py b/corechaindb/bigchaindb/start.py similarity index 72% rename from bigchaindb/start.py rename to corechaindb/bigchaindb/start.py index 71d96533..5fa8de93 100644 --- a/bigchaindb/start.py +++ b/corechaindb/bigchaindb/start.py @@ -8,13 +8,13 @@ import setproctitle from abci import TmVersion, ABCI -import bigchaindb -from bigchaindb.lib import BigchainDB -from bigchaindb.core import App -from bigchaindb.parallel_validation import ParallelValidationApp -from bigchaindb.web import server, websocket_server -from bigchaindb.events import Exchange, EventTypes -from bigchaindb.utils import Process +import corechaindb +from corechaindb.lib import BigchainDB +from corechaindb.core import App +from corechaindb.parallel_validation import ParallelValidationApp +from corechaindb.web import server, websocket_server +from corechaindb.events import Exchange, EventTypes +from corechaindb.utils import Process logger = logging.getLogger(__name__) @@ -28,7 +28,7 @@ BANNER = """ * * * You can send HTTP requests via the HTTP API documented in the * * BigchainDB Server docs at: * -* https://bigchaindb.com/http-api * +* https://corechaindb.com/http-api * * * * Listening to client connections on: {:<15} * * * @@ -42,22 +42,22 @@ def start(args): exchange = Exchange() # start the web api app_server = server.create_server( - settings=bigchaindb.config['server'], - log_config=bigchaindb.config['log'], - bigchaindb_factory=BigchainDB) - p_webapi = Process(name='bigchaindb_webapi', target=app_server.run, daemon=True) + settings=corechaindb.config['server'], + log_config=corechaindb.config['log'], + corechaindb_factory=BigchainDB) + p_webapi = Process(name='corechaindb_webapi', target=app_server.run, daemon=True) p_webapi.start() - logger.info(BANNER.format(bigchaindb.config['server']['bind'])) + logger.info(BANNER.format(corechaindb.config['server']['bind'])) # start websocket server - p_websocket_server = Process(name='bigchaindb_ws', + p_websocket_server = Process(name='corechaindb_ws', target=websocket_server.start, daemon=True, args=(exchange.get_subscriber_queue(EventTypes.BLOCK_VALID),)) p_websocket_server.start() - p_exchange = Process(name='bigchaindb_exchange', target=exchange.run, daemon=True) + p_exchange = Process(name='corechaindb_exchange', target=exchange.run, daemon=True) p_exchange.start() # We need to import this after spawning the web server @@ -65,10 +65,10 @@ def start(args): # for gevent. from abci.server import ABCIServer - setproctitle.setproctitle('bigchaindb') + setproctitle.setproctitle('corechaindb') # Start the ABCIServer - abci = ABCI(TmVersion(bigchaindb.config['tendermint']['version'])) + abci = ABCI(TmVersion(corechaindb.config['tendermint']['version'])) if args.experimental_parallel_validation: app = ABCIServer( app=ParallelValidationApp( diff --git a/bigchaindb/tendermint_utils.py b/corechaindb/bigchaindb/tendermint_utils.py similarity index 100% rename from bigchaindb/tendermint_utils.py rename to corechaindb/bigchaindb/tendermint_utils.py diff --git a/bigchaindb/upsert_validator/__init__.py b/corechaindb/bigchaindb/upsert_validator/__init__.py similarity index 70% rename from bigchaindb/upsert_validator/__init__.py rename to corechaindb/bigchaindb/upsert_validator/__init__.py index a0f13f56..f926937f 100644 --- a/bigchaindb/upsert_validator/__init__.py +++ b/corechaindb/bigchaindb/upsert_validator/__init__.py @@ -4,4 +4,4 @@ # Code is Apache-2.0 and docs are CC-BY-4.0 -from bigchaindb.upsert_validator.validator_election import ValidatorElection # noqa +from corechaindb.upsert_validator.validator_election import ValidatorElection # noqa diff --git a/bigchaindb/upsert_validator/validator_election.py b/corechaindb/bigchaindb/upsert_validator/validator_election.py similarity index 87% rename from bigchaindb/upsert_validator/validator_election.py rename to corechaindb/bigchaindb/upsert_validator/validator_election.py index d004af60..ca197669 100644 --- a/bigchaindb/upsert_validator/validator_election.py +++ b/corechaindb/bigchaindb/upsert_validator/validator_election.py @@ -3,9 +3,9 @@ # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) # Code is Apache-2.0 and docs are CC-BY-4.0 -from bigchaindb.common.exceptions import InvalidPowerChange -from bigchaindb.elections.election import Election -from bigchaindb.common.schema import TX_SCHEMA_VALIDATOR_ELECTION +from corechaindb.common.exceptions import InvalidPowerChange +from corechaindb.elections.election import Election +from corechaindb.common.schema import TX_SCHEMA_VALIDATOR_ELECTION from .validator_utils import (new_validator_set, encode_validator, validate_asset_public_key) @@ -19,7 +19,7 @@ class ValidatorElection(Election): TX_SCHEMA_CUSTOM = TX_SCHEMA_VALIDATOR_ELECTION def validate(self, bigchain, current_transactions=[]): - """For more details refer BEP-21: https://github.com/bigchaindb/BEPs/tree/master/21 + """For more details refer BEP-21: https://github.com/corechaindb/BEPs/tree/master/21 """ current_validators = self.get_validators(bigchain) @@ -63,6 +63,6 @@ class ValidatorElection(Election): bigchain.store_validator_set(new_height + 1, updated_validator_set) return encode_validator(self.asset['data']) - def on_rollback(self, bigchaindb, new_height): + def on_rollback(self, corechaindb, new_height): # TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0. - bigchaindb.delete_validator_set(new_height + 1) + corechaindb.delete_validator_set(new_height + 1) diff --git a/bigchaindb/upsert_validator/validator_utils.py b/corechaindb/bigchaindb/upsert_validator/validator_utils.py similarity index 94% rename from bigchaindb/upsert_validator/validator_utils.py rename to corechaindb/bigchaindb/upsert_validator/validator_utils.py index 3fc315d1..cce9f98a 100644 --- a/bigchaindb/upsert_validator/validator_utils.py +++ b/corechaindb/bigchaindb/upsert_validator/validator_utils.py @@ -2,16 +2,16 @@ import base64 import binascii import codecs -import bigchaindb +import corechaindb from abci import types_v0_22_8, types_v0_31_5, TmVersion -from bigchaindb.common.exceptions import InvalidPublicKey, BigchainDBError +from corechaindb.common.exceptions import InvalidPublicKey, BigchainDBError def encode_validator(v): ed25519_public_key = v['public_key']['value'] # NOTE: tendermint expects public to be encoded in go-amino format try: - version = TmVersion(bigchaindb.config["tendermint"]["version"]) + version = TmVersion(corechaindb.config["tendermint"]["version"]) except ValueError: raise BigchainDBError('Invalid tendermint version, ' 'check BigchainDB configuration file') diff --git a/bigchaindb/utils.py b/corechaindb/bigchaindb/utils.py similarity index 97% rename from bigchaindb/utils.py rename to corechaindb/bigchaindb/utils.py index 0dd796ce..69383473 100644 --- a/bigchaindb/utils.py +++ b/corechaindb/bigchaindb/utils.py @@ -11,9 +11,9 @@ import json import setproctitle from packaging import version -from bigchaindb.version import __tm_supported_versions__ -from bigchaindb.tendermint_utils import key_from_base64 -from bigchaindb.common.crypto import key_pair_from_ed25519_key +from corechaindb.version import __tm_supported_versions__ +from corechaindb.tendermint_utils import key_from_base64 +from corechaindb.common.crypto import key_pair_from_ed25519_key class ProcessGroup(object): diff --git a/bigchaindb/validation.py b/corechaindb/bigchaindb/validation.py similarity index 60% rename from bigchaindb/validation.py rename to corechaindb/bigchaindb/validation.py index 3775561c..55a7ca5f 100644 --- a/bigchaindb/validation.py +++ b/corechaindb/bigchaindb/validation.py @@ -13,13 +13,13 @@ class BaseValidationRules(): """ @staticmethod - def validate_transaction(bigchaindb, transaction): - """See :meth:`bigchaindb.models.Transaction.validate` + def validate_transaction(corechaindb, transaction): + """See :meth:`corechaindb.models.Transaction.validate` for documentation. """ - return transaction.validate(bigchaindb) + return transaction.validate(corechaindb) @staticmethod - def validate_block(bigchaindb, block): - """See :meth:`bigchaindb.models.Block.validate` for documentation.""" - return block.validate(bigchaindb) + def validate_block(corechaindb, block): + """See :meth:`corechaindb.models.Block.validate` for documentation.""" + return block.validate(corechaindb) diff --git a/bigchaindb/version.py b/corechaindb/bigchaindb/version.py similarity index 100% rename from bigchaindb/version.py rename to corechaindb/bigchaindb/version.py diff --git a/bigchaindb/web/__init__.py b/corechaindb/bigchaindb/web/__init__.py similarity index 100% rename from bigchaindb/web/__init__.py rename to corechaindb/bigchaindb/web/__init__.py diff --git a/bigchaindb/web/routes.py b/corechaindb/bigchaindb/web/routes.py similarity index 97% rename from bigchaindb/web/routes.py rename to corechaindb/bigchaindb/web/routes.py index 58923b01..86f207d9 100644 --- a/bigchaindb/web/routes.py +++ b/corechaindb/bigchaindb/web/routes.py @@ -5,7 +5,7 @@ """API routes definition""" from flask_restful import Api -from bigchaindb.web.views import ( +from corechaindb.web.views import ( assets, metadata, blocks, diff --git a/bigchaindb/web/server.py b/corechaindb/bigchaindb/web/server.py similarity index 83% rename from bigchaindb/web/server.py rename to corechaindb/bigchaindb/web/server.py index f57284a4..e2b27487 100644 --- a/bigchaindb/web/server.py +++ b/corechaindb/bigchaindb/web/server.py @@ -15,10 +15,10 @@ from flask import Flask from flask_cors import CORS import gunicorn.app.base -from bigchaindb import utils -from bigchaindb import BigchainDB -from bigchaindb.web.routes import add_routes -from bigchaindb.web.strip_content_type_middleware import StripContentTypeMiddleware +from corechaindb import utils +from corechaindb import BigchainDB +from corechaindb.web.routes import add_routes +from corechaindb.web.strip_content_type_middleware import StripContentTypeMiddleware # TODO: Figure out if we do we need all this boilerplate. @@ -50,7 +50,7 @@ class StandaloneApplication(gunicorn.app.base.BaseApplication): config = dict((key, value) for key, value in self.options.items() if key in self.cfg.settings and value is not None) - config['default_proc_name'] = 'bigchaindb_gunicorn' + config['default_proc_name'] = 'corechaindb_gunicorn' for key, value in config.items(): # not sure if we need the `key.lower` here, will just keep # keep it for now. @@ -60,7 +60,7 @@ class StandaloneApplication(gunicorn.app.base.BaseApplication): return self.application -def create_app(*, debug=False, threads=1, bigchaindb_factory=None): +def create_app(*, debug=False, threads=1, corechaindb_factory=None): """Return an instance of the Flask application. Args: @@ -71,8 +71,8 @@ def create_app(*, debug=False, threads=1, bigchaindb_factory=None): an instance of the Flask application. """ - if not bigchaindb_factory: - bigchaindb_factory = BigchainDB + if not corechaindb_factory: + corechaindb_factory = BigchainDB app = Flask(__name__) app.wsgi_app = StripContentTypeMiddleware(app.wsgi_app) @@ -81,14 +81,14 @@ def create_app(*, debug=False, threads=1, bigchaindb_factory=None): app.debug = debug - app.config['bigchain_pool'] = utils.pool(bigchaindb_factory, size=threads) + app.config['bigchain_pool'] = utils.pool(corechaindb_factory, size=threads) add_routes(app) return app -def create_server(settings, log_config=None, bigchaindb_factory=None): +def create_server(settings, log_config=None, corechaindb_factory=None): """Wrap and return an application ready to be run. Args: @@ -113,6 +113,6 @@ def create_server(settings, log_config=None, bigchaindb_factory=None): settings['custom_log_config'] = log_config app = create_app(debug=settings.get('debug', False), threads=settings['threads'], - bigchaindb_factory=bigchaindb_factory) + corechaindb_factory=corechaindb_factory) standalone = StandaloneApplication(app, options=settings) return standalone diff --git a/bigchaindb/web/strip_content_type_middleware.py b/corechaindb/bigchaindb/web/strip_content_type_middleware.py similarity index 100% rename from bigchaindb/web/strip_content_type_middleware.py rename to corechaindb/bigchaindb/web/strip_content_type_middleware.py diff --git a/bigchaindb/web/views/__init__.py b/corechaindb/bigchaindb/web/views/__init__.py similarity index 100% rename from bigchaindb/web/views/__init__.py rename to corechaindb/bigchaindb/web/views/__init__.py diff --git a/bigchaindb/web/views/assets.py b/corechaindb/bigchaindb/web/views/assets.py similarity index 88% rename from bigchaindb/web/views/assets.py rename to corechaindb/bigchaindb/web/views/assets.py index 13e49c89..57f8ee0c 100644 --- a/bigchaindb/web/views/assets.py +++ b/corechaindb/bigchaindb/web/views/assets.py @@ -5,15 +5,15 @@ """This module provides the blueprint for some basic API endpoints. -For more information please refer to the documentation: http://bigchaindb.com/http-api +For more information please refer to the documentation: http://corechaindb.com/http-api """ import logging from flask_restful import reqparse, Resource from flask import current_app -from bigchaindb.backend.exceptions import OperationError -from bigchaindb.web.views.base import make_error +from corechaindb.backend.exceptions import OperationError +from corechaindb.web.views.base import make_error logger = logging.getLogger(__name__) diff --git a/bigchaindb/web/views/base.py b/corechaindb/bigchaindb/web/views/base.py similarity index 97% rename from bigchaindb/web/views/base.py rename to corechaindb/bigchaindb/web/views/base.py index 6fa24981..3a60268b 100644 --- a/bigchaindb/web/views/base.py +++ b/corechaindb/bigchaindb/web/views/base.py @@ -9,7 +9,7 @@ import logging from flask import jsonify, request -from bigchaindb import config +from corechaindb import config logger = logging.getLogger(__name__) diff --git a/bigchaindb/web/views/blocks.py b/corechaindb/bigchaindb/web/views/blocks.py similarity index 91% rename from bigchaindb/web/views/blocks.py rename to corechaindb/bigchaindb/web/views/blocks.py index ae5d61f9..f35d9674 100644 --- a/bigchaindb/web/views/blocks.py +++ b/corechaindb/bigchaindb/web/views/blocks.py @@ -5,12 +5,12 @@ """This module provides the blueprint for the blocks API endpoints. -For more information please refer to the documentation: http://bigchaindb.com/http-api +For more information please refer to the documentation: http://corechaindb.com/http-api """ from flask import current_app from flask_restful import Resource, reqparse -from bigchaindb.web.views.base import make_error +from corechaindb.web.views.base import make_error class BlockApi(Resource): diff --git a/bigchaindb/web/views/info.py b/corechaindb/bigchaindb/web/views/info.py similarity index 84% rename from bigchaindb/web/views/info.py rename to corechaindb/bigchaindb/web/views/info.py index 2444a66d..b7acfe65 100644 --- a/bigchaindb/web/views/info.py +++ b/corechaindb/bigchaindb/web/views/info.py @@ -8,15 +8,15 @@ import flask from flask_restful import Resource -from bigchaindb.web.views.base import base_ws_uri -from bigchaindb import version -from bigchaindb.web.websocket_server import EVENTS_ENDPOINT +from corechaindb.web.views.base import base_ws_uri +from corechaindb import version +from corechaindb.web.websocket_server import EVENTS_ENDPOINT class RootIndex(Resource): def get(self): docs_url = [ - 'https://docs.bigchaindb.com/projects/server/en/v', + 'https://docs.corechaindb.com/projects/server/en/v', version.__version__ + '/' ] return flask.jsonify({ @@ -40,7 +40,7 @@ def get_api_v1_info(api_prefix): """ websocket_root = base_ws_uri() + EVENTS_ENDPOINT docs_url = [ - 'https://docs.bigchaindb.com/projects/server/en/v', + 'https://docs.corechaindb.com/projects/server/en/v', version.__version__, '/http-client-server-api.html', ] diff --git a/bigchaindb/web/views/metadata.py b/corechaindb/bigchaindb/web/views/metadata.py similarity index 88% rename from bigchaindb/web/views/metadata.py rename to corechaindb/bigchaindb/web/views/metadata.py index 684c9f73..2242696a 100644 --- a/bigchaindb/web/views/metadata.py +++ b/corechaindb/bigchaindb/web/views/metadata.py @@ -5,15 +5,15 @@ """This module provides the blueprint for some basic API endpoints. -For more information please refer to the documentation: http://bigchaindb.com/http-api +For more information please refer to the documentation: http://corechaindb.com/http-api """ import logging from flask_restful import reqparse, Resource from flask import current_app -from bigchaindb.backend.exceptions import OperationError -from bigchaindb.web.views.base import make_error +from corechaindb.backend.exceptions import OperationError +from corechaindb.web.views.base import make_error logger = logging.getLogger(__name__) diff --git a/bigchaindb/web/views/outputs.py b/corechaindb/bigchaindb/web/views/outputs.py similarity index 96% rename from bigchaindb/web/views/outputs.py rename to corechaindb/bigchaindb/web/views/outputs.py index 0b9565ac..d3abaff9 100644 --- a/bigchaindb/web/views/outputs.py +++ b/corechaindb/bigchaindb/web/views/outputs.py @@ -6,7 +6,7 @@ from flask import current_app from flask_restful import reqparse, Resource -from bigchaindb.web.views import parameters +from corechaindb.web.views import parameters class OutputListApi(Resource): diff --git a/bigchaindb/web/views/parameters.py b/corechaindb/bigchaindb/web/views/parameters.py similarity index 94% rename from bigchaindb/web/views/parameters.py rename to corechaindb/bigchaindb/web/views/parameters.py index 2e0be473..e79eff81 100644 --- a/bigchaindb/web/views/parameters.py +++ b/corechaindb/bigchaindb/web/views/parameters.py @@ -5,7 +5,7 @@ import re -from bigchaindb.common.transaction_mode_types import (BROADCAST_TX_COMMIT, +from corechaindb.common.transaction_mode_types import (BROADCAST_TX_COMMIT, BROADCAST_TX_ASYNC, BROADCAST_TX_SYNC) diff --git a/bigchaindb/web/views/transactions.py b/corechaindb/bigchaindb/web/views/transactions.py similarity index 89% rename from bigchaindb/web/views/transactions.py rename to corechaindb/bigchaindb/web/views/transactions.py index d0c07522..f1ab3111 100644 --- a/bigchaindb/web/views/transactions.py +++ b/corechaindb/bigchaindb/web/views/transactions.py @@ -5,18 +5,18 @@ """This module provides the blueprint for some basic API endpoints. -For more information please refer to the documentation: http://bigchaindb.com/http-api +For more information please refer to the documentation: http://corechaindb.com/http-api """ import logging from flask import current_app, request, jsonify from flask_restful import Resource, reqparse -from bigchaindb.common.transaction_mode_types import BROADCAST_TX_ASYNC -from bigchaindb.common.exceptions import SchemaValidationError, ValidationError -from bigchaindb.web.views.base import make_error -from bigchaindb.web.views import parameters -from bigchaindb.models import Transaction +from corechaindb.common.transaction_mode_types import BROADCAST_TX_ASYNC +from corechaindb.common.exceptions import SchemaValidationError, ValidationError +from corechaindb.web.views.base import make_error +from corechaindb.web.views import parameters +from corechaindb.models import Transaction logger = logging.getLogger(__name__) diff --git a/bigchaindb/web/views/validators.py b/corechaindb/bigchaindb/web/views/validators.py similarity index 100% rename from bigchaindb/web/views/validators.py rename to corechaindb/bigchaindb/web/views/validators.py diff --git a/bigchaindb/web/websocket_server.py b/corechaindb/bigchaindb/web/websocket_server.py similarity index 98% rename from bigchaindb/web/websocket_server.py rename to corechaindb/bigchaindb/web/websocket_server.py index 4119f82c..6e84ca84 100644 --- a/bigchaindb/web/websocket_server.py +++ b/corechaindb/bigchaindb/web/websocket_server.py @@ -26,8 +26,8 @@ from concurrent.futures import CancelledError import aiohttp from aiohttp import web -from bigchaindb import config -from bigchaindb.events import EventTypes +from corechaindb import config +from corechaindb.events import EventTypes logger = logging.getLogger(__name__) diff --git a/corechaindb/commands/__init__.py b/corechaindb/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/corechaindb/commands/corechaindb.py b/corechaindb/commands/corechaindb.py new file mode 100644 index 00000000..fb0e08fc --- /dev/null +++ b/corechaindb/commands/corechaindb.py @@ -0,0 +1,398 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Implementation of the `corechaindb` command, +the command-line interface (CLI) for BigchainDB Server. +""" + +import os +import logging +import argparse +import copy +import json +import sys + +from corechaindb.core import rollback +from corechaindb.migrations.chain_migration_election import ChainMigrationElection +from corechaindb.utils import load_node_key +from corechaindb.common.transaction_mode_types import BROADCAST_TX_COMMIT +from corechaindb.common.exceptions import (DatabaseDoesNotExist, + ValidationError) +from corechaindb.elections.vote import Vote +import corechaindb +from corechaindb import (backend, ValidatorElection, + BigchainDB) +from corechaindb.backend import schema +from corechaindb.commands import utils +from corechaindb.commands.utils import (configure_corechaindb, + input_on_stderr) +from corechaindb.log import setup_logging +from corechaindb.tendermint_utils import public_key_from_base64 +from corechaindb.commands.election_types import elections +from corechaindb.version import __tm_supported_versions__ + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + + +# Note about printing: +# We try to print to stdout for results of a command that may be useful to +# someone (or another program). Strictly informational text, or errors, +# should be printed to stderr. + + +@configure_corechaindb +def run_show_config(args): + """Show the current configuration""" + # TODO Proposal: remove the "hidden" configuration. Only show config. If + # the system needs to be configured, then display information on how to + # configure the system. + config = copy.deepcopy(corechaindb.config) + del config['CONFIGURED'] + print(json.dumps(config, indent=4, sort_keys=True)) + + +@configure_corechaindb +def run_configure(args): + """Run a script to configure the current node.""" + config_path = args.config or corechaindb.config_utils.CONFIG_DEFAULT_PATH + + config_file_exists = False + # if the config path is `-` then it's stdout + if config_path != '-': + config_file_exists = os.path.exists(config_path) + + if config_file_exists and not args.yes: + want = input_on_stderr('Config file `{}` exists, do you want to ' + 'override it? (cannot be undone) [y/N]: '.format(config_path)) + if want != 'y': + return + + conf = copy.deepcopy(corechaindb.config) + + # select the correct config defaults based on the backend + print('Generating default configuration for backend {}' + .format(args.backend), file=sys.stderr) + database_keys = corechaindb._database_keys_map[args.backend] + conf['database'] = corechaindb._database_map[args.backend] + + if not args.yes: + for key in ('bind', ): + val = conf['server'][key] + conf['server'][key] = input_on_stderr('API Server {}? (default `{}`): '.format(key, val), val) + + for key in ('scheme', 'host', 'port'): + val = conf['wsserver'][key] + conf['wsserver'][key] = input_on_stderr('WebSocket Server {}? (default `{}`): '.format(key, val), val) + + for key in database_keys: + val = conf['database'][key] + conf['database'][key] = input_on_stderr('Database {}? (default `{}`): '.format(key, val), val) + + for key in ('host', 'port'): + val = conf['tendermint'][key] + conf['tendermint'][key] = input_on_stderr('Tendermint {}? (default `{}`)'.format(key, val), val) + + if config_path != '-': + corechaindb.config_utils.write_config(conf, config_path) + else: + print(json.dumps(conf, indent=4, sort_keys=True)) + print('Configuration written to {}'.format(config_path), file=sys.stderr) + print('Ready to go!', file=sys.stderr) + + +@configure_corechaindb +def run_election(args): + """Initiate and manage elections""" + + b = BigchainDB() + + # Call the function specified by args.action, as defined above + globals()[f'run_election_{args.action}'](args, b) + + +def run_election_new(args, bigchain): + election_type = args.election_type.replace('-', '_') + globals()[f'run_election_new_{election_type}'](args, bigchain) + + +def create_new_election(sk, bigchain, election_class, data): + try: + key = load_node_key(sk) + voters = election_class.recipients(bigchain) + election = election_class.generate([key.public_key], + voters, + data, None).sign([key.private_key]) + election.validate(bigchain) + except ValidationError as e: + logger.error(e) + return False + except FileNotFoundError as fd_404: + logger.error(fd_404) + return False + + resp = bigchain.write_transaction(election, BROADCAST_TX_COMMIT) + if resp == (202, ''): + logger.info('[SUCCESS] Submitted proposal with id: {}'.format(election.id)) + return election.id + else: + logger.error('Failed to commit election proposal') + return False + + +def run_election_new_upsert_validator(args, bigchain): + """Initiates an election to add/update/remove a validator to an existing BigchainDB network + + :param args: dict + args = { + 'public_key': the public key of the proposed peer, (str) + 'power': the proposed validator power for the new peer, (str) + 'node_id': the node_id of the new peer (str) + 'sk': the path to the private key of the node calling the election (str) + } + :param bigchain: an instance of BigchainDB + :return: election_id or `False` in case of failure + """ + + new_validator = { + 'public_key': {'value': public_key_from_base64(args.public_key), + 'type': 'ed25519-base16'}, + 'power': args.power, + 'node_id': args.node_id + } + + return create_new_election(args.sk, bigchain, ValidatorElection, new_validator) + + +def run_election_new_chain_migration(args, bigchain): + """Initiates an election to halt block production + + :param args: dict + args = { + 'sk': the path to the private key of the node calling the election (str) + } + :param bigchain: an instance of BigchainDB + :return: election_id or `False` in case of failure + """ + + return create_new_election(args.sk, bigchain, ChainMigrationElection, {}) + + +def run_election_approve(args, bigchain): + """Approve an election + + :param args: dict + args = { + 'election_id': the election_id of the election (str) + 'sk': the path to the private key of the signer (str) + } + :param bigchain: an instance of BigchainDB + :return: success log message or `False` in case of error + """ + + key = load_node_key(args.sk) + tx = bigchain.get_transaction(args.election_id) + voting_powers = [v.amount for v in tx.outputs if key.public_key in v.public_keys] + if len(voting_powers) > 0: + voting_power = voting_powers[0] + else: + logger.error('The key you provided does not match any of the eligible voters in this election.') + return False + + inputs = [i for i in tx.to_inputs() if key.public_key in i.owners_before] + election_pub_key = ValidatorElection.to_public_key(tx.id) + approval = Vote.generate(inputs, + [([election_pub_key], voting_power)], + tx.id).sign([key.private_key]) + approval.validate(bigchain) + + resp = bigchain.write_transaction(approval, BROADCAST_TX_COMMIT) + + if resp == (202, ''): + logger.info('[SUCCESS] Your vote has been submitted') + return approval.id + else: + logger.error('Failed to commit vote') + return False + + +def run_election_show(args, bigchain): + """Retrieves information about an election + + :param args: dict + args = { + 'election_id': the transaction_id for an election (str) + } + :param bigchain: an instance of BigchainDB + """ + + election = bigchain.get_transaction(args.election_id) + if not election: + logger.error(f'No election found with election_id {args.election_id}') + return + + response = election.show_election(bigchain) + + logger.info(response) + + return response + + +def _run_init(): + bdb = corechaindb.BigchainDB() + + schema.init_database(connection=bdb.connection) + + +@configure_corechaindb +def run_init(args): + """Initialize the database""" + _run_init() + + +@configure_corechaindb +def run_drop(args): + """Drop the database""" + dbname = corechaindb.config['database']['name'] + + if not args.yes: + response = input_on_stderr('Do you want to drop `{}` database? [y/n]: '.format(dbname)) + if response != 'y': + return + + conn = backend.connect() + try: + schema.drop_database(conn, dbname) + except DatabaseDoesNotExist: + print("Cannot drop '{name}'. The database does not exist.".format(name=dbname), file=sys.stderr) + + +def run_recover(b): + rollback(b) + + +@configure_corechaindb +def run_start(args): + """Start the processes to run the node""" + + # Configure Logging + setup_logging() + + logger.info('BigchainDB Version %s', corechaindb.__version__) + run_recover(corechaindb.lib.BigchainDB()) + + if not args.skip_initialize_database: + logger.info('Initializing database') + _run_init() + + logger.info('Starting BigchainDB main process.') + from corechaindb.start import start + start(args) + + +def run_tendermint_version(args): + """Show the supported Tendermint version(s)""" + supported_tm_ver = { + 'description': 'BigchainDB supports the following Tendermint version(s)', + 'tendermint': __tm_supported_versions__, + } + print(json.dumps(supported_tm_ver, indent=4, sort_keys=True)) + + +def create_parser(): + parser = argparse.ArgumentParser( + description='Control your BigchainDB node.', + parents=[utils.base_parser]) + + # all the commands are contained in the subparsers object, + # the command selected by the user will be stored in `args.command` + # that is used by the `main` function to select which other + # function to call. + subparsers = parser.add_subparsers(title='Commands', + dest='command') + + # parser for writing a config file + config_parser = subparsers.add_parser('configure', + help='Prepare the config file.') + + config_parser.add_argument('backend', + choices=['localmongodb'], + default='localmongodb', + const='localmongodb', + nargs='?', + help='The backend to use. It can only be ' + '"localmongodb", currently.') + + # parser for managing elections + election_parser = subparsers.add_parser('election', + help='Manage elections.') + + election_subparser = election_parser.add_subparsers(title='Action', + dest='action') + + new_election_parser = election_subparser.add_parser('new', + help='Calls a new election.') + + new_election_subparser = new_election_parser.add_subparsers(title='Election_Type', + dest='election_type') + + # Parser factory for each type of new election, so we get a bunch of commands that look like this: + # election new ... + for name, data in elections.items(): + args = data['args'] + generic_parser = new_election_subparser.add_parser(name, help=data['help']) + for arg, kwargs in args.items(): + generic_parser.add_argument(arg, **kwargs) + + approve_election_parser = election_subparser.add_parser('approve', + help='Approve the election.') + approve_election_parser.add_argument('election_id', + help='The election_id of the election.') + approve_election_parser.add_argument('--private-key', + dest='sk', + required=True, + help='Path to the private key of the election initiator.') + + show_election_parser = election_subparser.add_parser('show', + help='Provides information about an election.') + + show_election_parser.add_argument('election_id', + help='The transaction id of the election you wish to query.') + + # parsers for showing/exporting config values + subparsers.add_parser('show-config', + help='Show the current configuration') + + # parser for database-level commands + subparsers.add_parser('init', + help='Init the database') + + subparsers.add_parser('drop', + help='Drop the database') + + # parser for starting BigchainDB + start_parser = subparsers.add_parser('start', + help='Start BigchainDB') + + start_parser.add_argument('--no-init', + dest='skip_initialize_database', + default=False, + action='store_true', + help='Skip database initialization') + + subparsers.add_parser('tendermint-version', + help='Show the Tendermint supported versions') + + start_parser.add_argument('--experimental-parallel-validation', + dest='experimental_parallel_validation', + default=False, + action='store_true', + help='💀 EXPERIMENTAL: parallelize validation for better throughput 💀') + + return parser + + +def main(): + utils.start(create_parser(), sys.argv[1:], globals()) diff --git a/corechaindb/commands/election_types.py b/corechaindb/commands/election_types.py new file mode 100644 index 00000000..cfa58b9e --- /dev/null +++ b/corechaindb/commands/election_types.py @@ -0,0 +1,31 @@ +elections = { + 'upsert-validator': { + 'help': 'Propose a change to the validator set', + 'args': { + 'public_key': { + 'help': 'Public key of the validator to be added/updated/removed.' + }, + 'power': { + 'type': int, + 'help': 'The proposed power for the validator. Setting to 0 will remove the validator.'}, + 'node_id': { + 'help': 'The node_id of the validator.' + }, + '--private-key': { + 'dest': 'sk', + 'required': True, + 'help': 'Path to the private key of the election initiator.' + } + } + }, + 'chain-migration': { + 'help': 'Call for a halt to block production to allow for a version change across breaking changes.', + 'args': { + '--private-key': { + 'dest': 'sk', + 'required': True, + 'help': 'Path to the private key of the election initiator.' + } + } + } +} diff --git a/corechaindb/commands/utils.py b/corechaindb/commands/utils.py new file mode 100644 index 00000000..44d58fe7 --- /dev/null +++ b/corechaindb/commands/utils.py @@ -0,0 +1,161 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Utility functions and basic common arguments +for ``argparse.ArgumentParser``. +""" + +import argparse +import builtins +import functools +import multiprocessing as mp +import sys + +import corechaindb +import corechaindb.config_utils +from corechaindb.version import __version__ + + +def configure_corechaindb(command): + """Decorator to be used by command line functions, such that the + configuration of corechaindb is performed before the execution of + the command. + + Args: + command: The command to decorate. + + Returns: + The command wrapper function. + + """ + @functools.wraps(command) + def configure(args): + config_from_cmdline = None + try: + if args.log_level is not None: + config_from_cmdline = { + 'log': { + 'level_console': args.log_level, + 'level_logfile': args.log_level, + }, + 'server': {'loglevel': args.log_level}, + } + except AttributeError: + pass + corechaindb.config_utils.autoconfigure( + filename=args.config, config=config_from_cmdline, force=True) + command(args) + + return configure + + +def _convert(value, default=None, convert=None): + def convert_bool(value): + if value.lower() in ('true', 't', 'yes', 'y'): + return True + if value.lower() in ('false', 'f', 'no', 'n'): + return False + raise ValueError('{} cannot be converted to bool'.format(value)) + + if value == '': + value = None + + if convert is None: + if default is not None: + convert = type(default) + else: + convert = str + + if convert == bool: + convert = convert_bool + + if value is None: + return default + else: + return convert(value) + + +# We need this because `input` always prints on stdout, while it should print +# to stderr. It's a very old bug, check it out here: +# - https://bugs.python.org/issue1927 +def input_on_stderr(prompt='', default=None, convert=None): + """Output a string to stderr and wait for input. + + Args: + prompt (str): the message to display. + default: the default value to return if the user + leaves the field empty + convert (callable): a callable to be used to convert + the value the user inserted. If None, the type of + ``default`` will be used. + """ + + print(prompt, end='', file=sys.stderr) + value = builtins.input() + return _convert(value, default, convert) + + +def start(parser, argv, scope): + """Utility function to execute a subcommand. + + The function will look up in the ``scope`` + if there is a function called ``run_`` + and will run it using ``parser.args`` as first positional argument. + + Args: + parser: an ArgumentParser instance. + argv: the list of command line arguments without the script name. + scope (dict): map containing (eventually) the functions to be called. + + Raises: + NotImplementedError: if ``scope`` doesn't contain a function called + ``run_``. + """ + args = parser.parse_args(argv) + + if not args.command: + parser.print_help() + raise SystemExit() + + # look up in the current scope for a function called 'run_' + # replacing all the dashes '-' with the lowercase character '_' + func = scope.get('run_' + args.command.replace('-', '_')) + + # if no command has been found, raise a `NotImplementedError` + if not func: + raise NotImplementedError('Command `{}` not yet implemented'. + format(args.command)) + + args.multiprocess = getattr(args, 'multiprocess', False) + + if args.multiprocess is False: + args.multiprocess = 1 + elif args.multiprocess is None: + args.multiprocess = mp.cpu_count() + + return func(args) + + +base_parser = argparse.ArgumentParser(add_help=False, prog='corechaindb') + +base_parser.add_argument('-c', '--config', + help='Specify the location of the configuration file ' + '(use "-" for stdout)') + +# NOTE: this flag should not have any default value because that will override +# the environment variables provided to configure the logger. +base_parser.add_argument('-l', '--log-level', + type=str.upper, # convert to uppercase for comparison to choices + choices=['DEBUG', 'BENCHMARK', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], + help='Log level') + +base_parser.add_argument('-y', '--yes', '--yes-please', + action='store_true', + help='Assume "yes" as answer to all prompts and run ' + 'non-interactively') + +base_parser.add_argument('-v', '--version', + action='version', + version='%(prog)s {}'.format(__version__)) diff --git a/corechaindb/common/__init__.py b/corechaindb/common/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/corechaindb/common/crypto.py b/corechaindb/common/crypto.py new file mode 100644 index 00000000..20fd8b40 --- /dev/null +++ b/corechaindb/common/crypto.py @@ -0,0 +1,55 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +# Separate all crypto code so that we can easily test several implementations +from collections import namedtuple + +try: + from hashlib import sha3_256 +except ImportError: + from sha3 import sha3_256 + +from cryptoconditions import crypto + + +CryptoKeypair = namedtuple('CryptoKeypair', ('private_key', 'public_key')) + + +def hash_data(data): + """Hash the provided data using SHA3-256""" + return sha3_256(data.encode()).hexdigest() + + +def generate_key_pair(): + """Generates a cryptographic key pair. + + Returns: + :class:`~corechaindb.common.crypto.CryptoKeypair`: A + :obj:`collections.namedtuple` with named fields + :attr:`~corechaindb.common.crypto.CryptoKeypair.private_key` and + :attr:`~corechaindb.common.crypto.CryptoKeypair.public_key`. + + """ + # TODO FOR CC: Adjust interface so that this function becomes unnecessary + return CryptoKeypair( + *(k.decode() for k in crypto.ed25519_generate_key_pair())) + + +PrivateKey = crypto.Ed25519SigningKey +PublicKey = crypto.Ed25519VerifyingKey + + +def key_pair_from_ed25519_key(hex_private_key): + """Generate base58 encode public-private key pair from a hex encoded private key""" + priv_key = crypto.Ed25519SigningKey(bytes.fromhex(hex_private_key)[:32], encoding='bytes') + public_key = priv_key.get_verifying_key() + return CryptoKeypair(private_key=priv_key.encode(encoding='base58').decode('utf-8'), + public_key=public_key.encode(encoding='base58').decode('utf-8')) + + +def public_key_from_ed25519_key(hex_public_key): + """Generate base58 public key from hex encoded public key""" + public_key = crypto.Ed25519VerifyingKey(bytes.fromhex(hex_public_key), encoding='bytes') + return public_key.encode(encoding='base58').decode('utf-8') diff --git a/corechaindb/common/exceptions.py b/corechaindb/common/exceptions.py new file mode 100644 index 00000000..a46ae0f9 --- /dev/null +++ b/corechaindb/common/exceptions.py @@ -0,0 +1,115 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Custom exceptions used in the `corechaindb` package. +""" +from corechaindb.exceptions import BigchainDBError + + +class ConfigurationError(BigchainDBError): + """Raised when there is a problem with server configuration""" + + +class DatabaseDoesNotExist(BigchainDBError): + """Raised when trying to delete the database but the db is not there""" + + +class StartupError(BigchainDBError): + """Raised when there is an error starting up the system""" + + +class CyclicBlockchainError(BigchainDBError): + """Raised when there is a cycle in the blockchain""" + + +class KeypairMismatchException(BigchainDBError): + """Raised if the private key(s) provided for signing don't match any of the + current owner(s) + """ + + +class OperationError(BigchainDBError): + """Raised when an operation cannot go through""" + + +################################################################################ +# Validation errors +# +# All validation errors (which are handleable errors, not faults) should +# subclass ValidationError. However, where possible they should also have their +# own distinct type to differentiate them from other validation errors, +# especially for the purposes of testing. + + +class ValidationError(BigchainDBError): + """Raised if there was an error in validation""" + + +class DoubleSpend(ValidationError): + """Raised if a double spend is found""" + + +class InvalidHash(ValidationError): + """Raised if there was an error checking the hash for a particular + operation + """ + + +class SchemaValidationError(ValidationError): + """Raised if there was any error validating an object's schema""" + + +class InvalidSignature(ValidationError): + """Raised if there was an error checking the signature for a particular + operation + """ + + +class AssetIdMismatch(ValidationError): + """Raised when multiple transaction inputs related to different assets""" + + +class AmountError(ValidationError): + """Raised when there is a problem with a transaction's output amounts""" + + +class InputDoesNotExist(ValidationError): + """Raised if a transaction input does not exist""" + + +class TransactionOwnerError(ValidationError): + """Raised if a user tries to transfer a transaction they don't own""" + + +class DuplicateTransaction(ValidationError): + """Raised if a duplicated transaction is found""" + + +class ThresholdTooDeep(ValidationError): + """Raised if threshold condition is too deep""" + + +class MultipleValidatorOperationError(ValidationError): + """Raised when a validator update pending but new request is submited""" + + +class MultipleInputsError(ValidationError): + """Raised if there were multiple inputs when only one was expected""" + + +class InvalidProposer(ValidationError): + """Raised if the public key is not a part of the validator set""" + + +class UnequalValidatorSet(ValidationError): + """Raised if the validator sets differ""" + + +class InvalidPowerChange(ValidationError): + """Raised if proposed power change in validator set is >=1/3 total power""" + + +class InvalidPublicKey(ValidationError): + """Raised if public key doesn't match the encoding type""" diff --git a/corechaindb/common/memoize.py b/corechaindb/common/memoize.py new file mode 100644 index 00000000..b814e512 --- /dev/null +++ b/corechaindb/common/memoize.py @@ -0,0 +1,58 @@ +import functools +import codecs +from functools import lru_cache + + +class HDict(dict): + def __hash__(self): + return hash(codecs.decode(self['id'], 'hex')) + + +@lru_cache(maxsize=16384) +def from_dict(func, *args, **kwargs): + return func(*args, **kwargs) + + +def memoize_from_dict(func): + + @functools.wraps(func) + def memoized_func(*args, **kwargs): + + if args[1].get('id', None): + args = list(args) + args[1] = HDict(args[1]) + new_args = tuple(args) + return from_dict(func, *new_args, **kwargs) + else: + return func(*args, **kwargs) + + return memoized_func + + +class ToDictWrapper(): + def __init__(self, tx): + self.tx = tx + + def __eq__(self, other): + return self.tx.id == other.tx.id + + def __hash__(self): + return hash(self.tx.id) + + +@lru_cache(maxsize=16384) +def to_dict(func, tx_wrapped): + return func(tx_wrapped.tx) + + +def memoize_to_dict(func): + + @functools.wraps(func) + def memoized_func(*args, **kwargs): + + if args[0].id: + return to_dict(func, ToDictWrapper(args[0])) + else: + return func(*args, **kwargs) + + return memoized_func diff --git a/corechaindb/common/schema/README.md b/corechaindb/common/schema/README.md new file mode 100644 index 00000000..aca04f04 --- /dev/null +++ b/corechaindb/common/schema/README.md @@ -0,0 +1,54 @@ + + +# Introduction + +This directory contains the schemas for the different JSON documents BigchainDB uses. + +The aim is to provide: + +- a strict definition of the data structures used in BigchainDB, +- a language-independent tool to validate the structure of incoming/outcoming + data. (There are several ready to use + [implementations](http://json-schema.org/implementations.html) written in + different languages.) + +## Sources + +The files defining the JSON Schema for transactions (`transaction_*.yaml`) +are based on the [BigchainDB Transactions Specs](https://github.com/corechaindb/BEPs/tree/master/tx-specs). +If you want to add a new transaction version, +you must write a spec for it first. +(You can't change the JSON Schema files for old versions. +Those were used to validate old transactions +and are needed to re-check those transactions.) + +There used to be a file defining the JSON Schema for votes, named `vote.yaml`. +It was used by BigchainDB version 1.3.0 and earlier. +If you want a copy of the latest `vote.yaml` file, +then you can get it from the version 1.3.0 release on GitHub, at +[https://github.com/corechaindb/corechaindb/blob/v1.3.0/corechaindb/common/schema/vote.yaml](https://github.com/corechaindb/corechaindb/blob/v1.3.0/corechaindb/common/schema/vote.yaml). + +## Learn about JSON Schema + +A good resource is [Understanding JSON Schema](http://spacetelescope.github.io/understanding-json-schema/index.html). +It provides a *more accessible documentation for JSON schema* than the [specs](http://json-schema.org/documentation.html). + +## If it's supposed to be JSON, why's everything in YAML D:? + +YAML is great for its conciseness and friendliness towards human-editing in comparision to JSON. + +Although YAML is a superset of JSON, at the end of the day, JSON Schema processors, like +[json-schema](http://python-jsonschema.readthedocs.io/en/latest/), take in a native object (e.g. +Python dicts or JavaScript objects) as the schema used for validation. As long as we can serialize +the YAML into what the JSON Schema processor expects (almost always as simple as loading the YAML +like you would with a JSON file), it's the same as using JSON. + +Specific advantages of using YAML: + - Legibility, especially when nesting + - Multi-line string literals, that make it easy to include descriptions that can be [auto-generated + into Sphinx documentation](/docs/server/generate_schema_documentation.py) diff --git a/corechaindb/common/schema/__init__.py b/corechaindb/common/schema/__init__.py new file mode 100644 index 00000000..d5272f4d --- /dev/null +++ b/corechaindb/common/schema/__init__.py @@ -0,0 +1,82 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Schema validation related functions and data""" +import os.path +import logging + +import jsonschema +import yaml +import rapidjson + +from corechaindb.common.exceptions import SchemaValidationError + + +logger = logging.getLogger(__name__) + + +def _load_schema(name, path=__file__): + """Load a schema from disk""" + path = os.path.join(os.path.dirname(path), name + '.yaml') + with open(path) as handle: + schema = yaml.safe_load(handle) + fast_schema = rapidjson.Validator(rapidjson.dumps(schema)) + return path, (schema, fast_schema) + + +TX_SCHEMA_VERSION = 'v2.0' + +TX_SCHEMA_PATH, TX_SCHEMA_COMMON = _load_schema('transaction_' + + TX_SCHEMA_VERSION) +_, TX_SCHEMA_CREATE = _load_schema('transaction_create_' + + TX_SCHEMA_VERSION) +_, TX_SCHEMA_TRANSFER = _load_schema('transaction_transfer_' + + TX_SCHEMA_VERSION) + +_, TX_SCHEMA_VALIDATOR_ELECTION = _load_schema('transaction_validator_election_' + + TX_SCHEMA_VERSION) + +_, TX_SCHEMA_CHAIN_MIGRATION_ELECTION = _load_schema('transaction_chain_migration_election_' + + TX_SCHEMA_VERSION) + +_, TX_SCHEMA_VOTE = _load_schema('transaction_vote_' + TX_SCHEMA_VERSION) + + +def _validate_schema(schema, body): + """Validate data against a schema""" + + # Note + # + # Schema validation is currently the major CPU bottleneck of + # BigchainDB. the `jsonschema` library validates python data structures + # directly and produces nice error messages, but validation takes 4+ ms + # per transaction which is pretty slow. The rapidjson library validates + # much faster at 1.5ms, however it produces _very_ poor error messages. + # For this reason we use both, rapidjson as an optimistic pathway and + # jsonschema as a fallback in case there is a failure, so we can produce + # a helpful error message. + + try: + schema[1](rapidjson.dumps(body)) + except ValueError as exc: + try: + jsonschema.validate(body, schema[0]) + except jsonschema.ValidationError as exc2: + raise SchemaValidationError(str(exc2)) from exc2 + logger.warning('code problem: jsonschema did not raise an exception, wheras rapidjson raised %s', exc) + raise SchemaValidationError(str(exc)) from exc + + +def validate_transaction_schema(tx): + """Validate a transaction dict. + + TX_SCHEMA_COMMON contains properties that are common to all types of + transaction. TX_SCHEMA_[TRANSFER|CREATE] add additional constraints on top. + """ + _validate_schema(TX_SCHEMA_COMMON, tx) + if tx['operation'] == 'TRANSFER': + _validate_schema(TX_SCHEMA_TRANSFER, tx) + else: + _validate_schema(TX_SCHEMA_CREATE, tx) diff --git a/corechaindb/common/schema/transaction_chain_migration_election_v2.0.yaml b/corechaindb/common/schema/transaction_chain_migration_election_v2.0.yaml new file mode 100644 index 00000000..22c224dd --- /dev/null +++ b/corechaindb/common/schema/transaction_chain_migration_election_v2.0.yaml @@ -0,0 +1,45 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +title: Chain Migration Election Schema - Propose a halt in block production to allow for a version change +required: +- operation +- asset +- outputs +properties: + operation: + type: string + value: "CHAIN_MIGRATION_ELECTION" + asset: + additionalProperties: false + properties: + data: + additionalProperties: false + properties: + seed: + type: string + required: + - data + outputs: + type: array + items: + "$ref": "#/definitions/output" +definitions: + output: + type: object + properties: + condition: + type: object + required: + - uri + properties: + uri: + type: string + pattern: "^ni:///sha-256;([a-zA-Z0-9_-]{0,86})[?]\ + (fpt=ed25519-sha-256(&)?|cost=[0-9]+(&)?|\ + subtypes=ed25519-sha-256(&)?){2,3}$" diff --git a/corechaindb/common/schema/transaction_create_v1.0.yaml b/corechaindb/common/schema/transaction_create_v1.0.yaml new file mode 100644 index 00000000..9344f091 --- /dev/null +++ b/corechaindb/common/schema/transaction_create_v1.0.yaml @@ -0,0 +1,35 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +title: Transaction Schema - CREATE/GENESIS specific constraints +required: +- asset +- inputs +properties: + asset: + additionalProperties: false + properties: + data: + anyOf: + - type: object + additionalProperties: true + - type: 'null' + required: + - data + inputs: + type: array + title: "Transaction inputs" + maxItems: 1 + minItems: 1 + items: + type: "object" + required: + - fulfills + properties: + fulfills: + type: "null" diff --git a/corechaindb/common/schema/transaction_create_v2.0.yaml b/corechaindb/common/schema/transaction_create_v2.0.yaml new file mode 100644 index 00000000..ef66f328 --- /dev/null +++ b/corechaindb/common/schema/transaction_create_v2.0.yaml @@ -0,0 +1,35 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +title: Transaction Schema - CREATE specific constraints +required: +- asset +- inputs +properties: + asset: + additionalProperties: false + properties: + data: + anyOf: + - type: object + additionalProperties: true + - type: 'null' + required: + - data + inputs: + type: array + title: "Transaction inputs" + maxItems: 1 + minItems: 1 + items: + type: "object" + required: + - fulfills + properties: + fulfills: + type: "null" diff --git a/corechaindb/common/schema/transaction_transfer_v1.0.yaml b/corechaindb/common/schema/transaction_transfer_v1.0.yaml new file mode 100644 index 00000000..5a173fbc --- /dev/null +++ b/corechaindb/common/schema/transaction_transfer_v1.0.yaml @@ -0,0 +1,34 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +title: Transaction Schema - TRANSFER specific properties +required: +- asset +properties: + asset: + additionalProperties: false + properties: + id: + "$ref": "#/definitions/sha3_hexdigest" + required: + - id + inputs: + type: array + title: "Transaction inputs" + minItems: 1 + items: + type: "object" + required: + - fulfills + properties: + fulfills: + type: "object" +definitions: + sha3_hexdigest: + pattern: "[0-9a-f]{64}" + type: string diff --git a/corechaindb/common/schema/transaction_transfer_v2.0.yaml b/corechaindb/common/schema/transaction_transfer_v2.0.yaml new file mode 100644 index 00000000..5a173fbc --- /dev/null +++ b/corechaindb/common/schema/transaction_transfer_v2.0.yaml @@ -0,0 +1,34 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +title: Transaction Schema - TRANSFER specific properties +required: +- asset +properties: + asset: + additionalProperties: false + properties: + id: + "$ref": "#/definitions/sha3_hexdigest" + required: + - id + inputs: + type: array + title: "Transaction inputs" + minItems: 1 + items: + type: "object" + required: + - fulfills + properties: + fulfills: + type: "object" +definitions: + sha3_hexdigest: + pattern: "[0-9a-f]{64}" + type: string diff --git a/corechaindb/common/schema/transaction_v1.0.yaml b/corechaindb/common/schema/transaction_v1.0.yaml new file mode 100644 index 00000000..5bf8662f --- /dev/null +++ b/corechaindb/common/schema/transaction_v1.0.yaml @@ -0,0 +1,168 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +additionalProperties: false +title: Transaction Schema +required: +- id +- inputs +- outputs +- operation +- metadata +- asset +- version +properties: + id: + anyOf: + - "$ref": "#/definitions/sha3_hexdigest" + - type: 'null' + operation: + "$ref": "#/definitions/operation" + asset: + "$ref": "#/definitions/asset" + inputs: + type: array + title: "Transaction inputs" + items: + "$ref": "#/definitions/input" + outputs: + type: array + items: + "$ref": "#/definitions/output" + metadata: + "$ref": "#/definitions/metadata" + version: + type: string + pattern: "^1\\.0$" +definitions: + offset: + type: integer + minimum: 0 + base58: + pattern: "[1-9a-zA-Z^OIl]{43,44}" + type: string + public_keys: + anyOf: + - type: array + items: + "$ref": "#/definitions/base58" + - type: 'null' + sha3_hexdigest: + pattern: "[0-9a-f]{64}" + type: string + uuid4: + pattern: "[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}" + type: string + operation: + type: string + enum: + - CREATE + - TRANSFER + - GENESIS + asset: + type: object + additionalProperties: false + properties: + id: + "$ref": "#/definitions/sha3_hexdigest" + data: + anyOf: + - type: object + additionalProperties: true + - type: 'null' + output: + type: object + additionalProperties: false + required: + - amount + - condition + - public_keys + properties: + amount: + type: string + pattern: "^[0-9]{1,20}$" + condition: + type: object + additionalProperties: false + required: + - details + - uri + properties: + details: + "$ref": "#/definitions/condition_details" + uri: + type: string + pattern: "^ni:///sha-256;([a-zA-Z0-9_-]{0,86})[?]\ + (fpt=(ed25519|threshold)-sha-256(&)?|cost=[0-9]+(&)?|\ + subtypes=ed25519-sha-256(&)?){2,3}$" + public_keys: + "$ref": "#/definitions/public_keys" + input: + type: "object" + additionalProperties: false + required: + - owners_before + - fulfillment + properties: + owners_before: + "$ref": "#/definitions/public_keys" + fulfillment: + anyOf: + - type: string + pattern: "^[a-zA-Z0-9_-]*$" + - "$ref": "#/definitions/condition_details" + fulfills: + anyOf: + - type: 'object' + additionalProperties: false + required: + - output_index + - transaction_id + properties: + output_index: + "$ref": "#/definitions/offset" + transaction_id: + "$ref": "#/definitions/sha3_hexdigest" + - type: 'null' + metadata: + anyOf: + - type: object + additionalProperties: true + minProperties: 1 + - type: 'null' + condition_details: + anyOf: + - type: object + additionalProperties: false + required: + - type + - public_key + properties: + type: + type: string + pattern: "^ed25519-sha-256$" + public_key: + "$ref": "#/definitions/base58" + - type: object + additionalProperties: false + required: + - type + - threshold + - subconditions + properties: + type: + type: "string" + pattern: "^threshold-sha-256$" + threshold: + type: integer + minimum: 1 + maximum: 100 + subconditions: + type: array + items: + "$ref": "#/definitions/condition_details" diff --git a/corechaindb/common/schema/transaction_v2.0.yaml b/corechaindb/common/schema/transaction_v2.0.yaml new file mode 100644 index 00000000..7249e4c3 --- /dev/null +++ b/corechaindb/common/schema/transaction_v2.0.yaml @@ -0,0 +1,170 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +additionalProperties: false +title: Transaction Schema +required: +- id +- inputs +- outputs +- operation +- metadata +- asset +- version +properties: + id: + anyOf: + - "$ref": "#/definitions/sha3_hexdigest" + - type: 'null' + operation: + "$ref": "#/definitions/operation" + asset: + "$ref": "#/definitions/asset" + inputs: + type: array + title: "Transaction inputs" + items: + "$ref": "#/definitions/input" + outputs: + type: array + items: + "$ref": "#/definitions/output" + metadata: + "$ref": "#/definitions/metadata" + version: + type: string + pattern: "^2\\.0$" +definitions: + offset: + type: integer + minimum: 0 + base58: + pattern: "[1-9a-zA-Z^OIl]{43,44}" + type: string + public_keys: + anyOf: + - type: array + items: + "$ref": "#/definitions/base58" + - type: 'null' + sha3_hexdigest: + pattern: "[0-9a-f]{64}" + type: string + uuid4: + pattern: "[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}" + type: string + operation: + type: string + enum: + - CREATE + - TRANSFER + - VALIDATOR_ELECTION + - CHAIN_MIGRATION_ELECTION + - VOTE + asset: + type: object + additionalProperties: false + properties: + id: + "$ref": "#/definitions/sha3_hexdigest" + data: + anyOf: + - type: object + additionalProperties: true + - type: 'null' + output: + type: object + additionalProperties: false + required: + - amount + - condition + - public_keys + properties: + amount: + type: string + pattern: "^[0-9]{1,20}$" + condition: + type: object + additionalProperties: false + required: + - details + - uri + properties: + details: + "$ref": "#/definitions/condition_details" + uri: + type: string + pattern: "^ni:///sha-256;([a-zA-Z0-9_-]{0,86})[?]\ + (fpt=(ed25519|threshold)-sha-256(&)?|cost=[0-9]+(&)?|\ + subtypes=ed25519-sha-256(&)?){2,3}$" + public_keys: + "$ref": "#/definitions/public_keys" + input: + type: "object" + additionalProperties: false + required: + - owners_before + - fulfillment + properties: + owners_before: + "$ref": "#/definitions/public_keys" + fulfillment: + anyOf: + - type: string + pattern: "^[a-zA-Z0-9_-]*$" + - "$ref": "#/definitions/condition_details" + fulfills: + anyOf: + - type: 'object' + additionalProperties: false + required: + - output_index + - transaction_id + properties: + output_index: + "$ref": "#/definitions/offset" + transaction_id: + "$ref": "#/definitions/sha3_hexdigest" + - type: 'null' + metadata: + anyOf: + - type: object + additionalProperties: true + minProperties: 1 + - type: 'null' + condition_details: + anyOf: + - type: object + additionalProperties: false + required: + - type + - public_key + properties: + type: + type: string + pattern: "^ed25519-sha-256$" + public_key: + "$ref": "#/definitions/base58" + - type: object + additionalProperties: false + required: + - type + - threshold + - subconditions + properties: + type: + type: "string" + pattern: "^threshold-sha-256$" + threshold: + type: integer + minimum: 1 + maximum: 100 + subconditions: + type: array + items: + "$ref": "#/definitions/condition_details" diff --git a/corechaindb/common/schema/transaction_validator_election_v2.0.yaml b/corechaindb/common/schema/transaction_validator_election_v2.0.yaml new file mode 100644 index 00000000..e790eb48 --- /dev/null +++ b/corechaindb/common/schema/transaction_validator_election_v2.0.yaml @@ -0,0 +1,68 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +title: Validator Election Schema - Propose a change to validator set +required: +- operation +- asset +- outputs +properties: + operation: + type: string + value: "VALIDATOR_ELECTION" + asset: + additionalProperties: false + properties: + data: + additionalProperties: false + properties: + node_id: + type: string + seed: + type: string + public_key: + type: object + additionalProperties: false + required: + - value + - type + properties: + value: + type: string + type: + type: string + enum: + - ed25519-base16 + - ed25519-base32 + - ed25519-base64 + power: + "$ref": "#/definitions/positiveInteger" + required: + - node_id + - public_key + - power + required: + - data + outputs: + type: array + items: + "$ref": "#/definitions/output" +definitions: + output: + type: object + properties: + condition: + type: object + required: + - uri + properties: + uri: + type: string + pattern: "^ni:///sha-256;([a-zA-Z0-9_-]{0,86})[?]\ + (fpt=ed25519-sha-256(&)?|cost=[0-9]+(&)?|\ + subtypes=ed25519-sha-256(&)?){2,3}$" diff --git a/corechaindb/common/schema/transaction_vote_v2.0.yaml b/corechaindb/common/schema/transaction_vote_v2.0.yaml new file mode 100644 index 00000000..54fe7a02 --- /dev/null +++ b/corechaindb/common/schema/transaction_vote_v2.0.yaml @@ -0,0 +1,34 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +--- +"$schema": "http://json-schema.org/draft-04/schema#" +type: object +title: Vote Schema - Vote on an election +required: +- operation +- outputs +properties: + operation: + type: string + value: "VOTE" + outputs: + type: array + items: + "$ref": "#/definitions/output" +definitions: + output: + type: object + properties: + condition: + type: object + required: + - uri + properties: + uri: + type: string + pattern: "^ni:///sha-256;([a-zA-Z0-9_-]{0,86})[?]\ + (fpt=ed25519-sha-256(&)?|cost=[0-9]+(&)?|\ + subtypes=ed25519-sha-256(&)?){2,3}$" diff --git a/corechaindb/common/transaction.py b/corechaindb/common/transaction.py new file mode 100644 index 00000000..b359ec24 --- /dev/null +++ b/corechaindb/common/transaction.py @@ -0,0 +1,1330 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Transaction related models to parse and construct transaction +payloads. + +Attributes: + UnspentOutput (namedtuple): Object holding the information + representing an unspent output. + +""" +from collections import namedtuple +from copy import deepcopy +from functools import reduce, lru_cache +import rapidjson + +import base58 +from cryptoconditions import Fulfillment, ThresholdSha256, Ed25519Sha256 +from cryptoconditions.exceptions import ( + ParsingError, ASN1DecodeError, ASN1EncodeError, UnsupportedTypeError) +try: + from hashlib import sha3_256 +except ImportError: + from sha3 import sha3_256 + +from corechaindb.common.crypto import PrivateKey, hash_data +from corechaindb.common.exceptions import (KeypairMismatchException, + InputDoesNotExist, DoubleSpend, + InvalidHash, InvalidSignature, + AmountError, AssetIdMismatch, + ThresholdTooDeep) +from corechaindb.common.utils import serialize +from .memoize import memoize_from_dict, memoize_to_dict + + +UnspentOutput = namedtuple( + 'UnspentOutput', ( + # TODO 'utxo_hash': sha3_256(f'{txid}{output_index}'.encode()) + # 'utxo_hash', # noqa + 'transaction_id', + 'output_index', + 'amount', + 'asset_id', + 'condition_uri', + ) +) + + +class Input(object): + """A Input is used to spend assets locked by an Output. + + Wraps around a Crypto-condition Fulfillment. + + Attributes: + fulfillment (:class:`cryptoconditions.Fulfillment`): A Fulfillment + to be signed with a private key. + owners_before (:obj:`list` of :obj:`str`): A list of owners after a + Transaction was confirmed. + fulfills (:class:`~corechaindb.common.transaction. TransactionLink`, + optional): A link representing the input of a `TRANSFER` + Transaction. + """ + + def __init__(self, fulfillment, owners_before, fulfills=None): + """Create an instance of an :class:`~.Input`. + + Args: + fulfillment (:class:`cryptoconditions.Fulfillment`): A + Fulfillment to be signed with a private key. + owners_before (:obj:`list` of :obj:`str`): A list of owners + after a Transaction was confirmed. + fulfills (:class:`~corechaindb.common.transaction. + TransactionLink`, optional): A link representing the input + of a `TRANSFER` Transaction. + """ + if fulfills is not None and not isinstance(fulfills, TransactionLink): + raise TypeError('`fulfills` must be a TransactionLink instance') + if not isinstance(owners_before, list): + raise TypeError('`owners_before` must be a list instance') + + self.fulfillment = fulfillment + self.fulfills = fulfills + self.owners_before = owners_before + + def __eq__(self, other): + # TODO: If `other !== Fulfillment` return `False` + return self.to_dict() == other.to_dict() + + # NOTE: This function is used to provide a unique key for a given + # Input to suppliment memoization + def __hash__(self): + return hash((self.fulfillment, self.fulfills)) + + def to_dict(self): + """Transforms the object to a Python dictionary. + + Note: + If an Input hasn't been signed yet, this method returns a + dictionary representation. + + Returns: + dict: The Input as an alternative serialization format. + """ + try: + fulfillment = self.fulfillment.serialize_uri() + except (TypeError, AttributeError, ASN1EncodeError, ASN1DecodeError): + fulfillment = _fulfillment_to_details(self.fulfillment) + + try: + # NOTE: `self.fulfills` can be `None` and that's fine + fulfills = self.fulfills.to_dict() + except AttributeError: + fulfills = None + + input_ = { + 'owners_before': self.owners_before, + 'fulfills': fulfills, + 'fulfillment': fulfillment, + } + return input_ + + @classmethod + def generate(cls, public_keys): + # TODO: write docstring + # The amount here does not really matter. It is only use on the + # output data model but here we only care about the fulfillment + output = Output.generate(public_keys, 1) + return cls(output.fulfillment, public_keys) + + @classmethod + def from_dict(cls, data): + """Transforms a Python dictionary to an Input object. + + Note: + Optionally, this method can also serialize a Cryptoconditions- + Fulfillment that is not yet signed. + + Args: + data (dict): The Input to be transformed. + + Returns: + :class:`~corechaindb.common.transaction.Input` + + Raises: + InvalidSignature: If an Input's URI couldn't be parsed. + """ + fulfillment = data['fulfillment'] + if not isinstance(fulfillment, (Fulfillment, type(None))): + try: + fulfillment = Fulfillment.from_uri(data['fulfillment']) + except ASN1DecodeError: + # TODO Remove as it is legacy code, and simply fall back on + # ASN1DecodeError + raise InvalidSignature("Fulfillment URI couldn't been parsed") + except TypeError: + # NOTE: See comment about this special case in + # `Input.to_dict` + fulfillment = _fulfillment_from_details(data['fulfillment']) + fulfills = TransactionLink.from_dict(data['fulfills']) + return cls(fulfillment, data['owners_before'], fulfills) + + +def _fulfillment_to_details(fulfillment): + """Encode a fulfillment as a details dictionary + + Args: + fulfillment: Crypto-conditions Fulfillment object + """ + + if fulfillment.type_name == 'ed25519-sha-256': + return { + 'type': 'ed25519-sha-256', + 'public_key': base58.b58encode(fulfillment.public_key).decode(), + } + + if fulfillment.type_name == 'threshold-sha-256': + subconditions = [ + _fulfillment_to_details(cond['body']) + for cond in fulfillment.subconditions + ] + return { + 'type': 'threshold-sha-256', + 'threshold': fulfillment.threshold, + 'subconditions': subconditions, + } + + raise UnsupportedTypeError(fulfillment.type_name) + + +def _fulfillment_from_details(data, _depth=0): + """Load a fulfillment for a signing spec dictionary + + Args: + data: tx.output[].condition.details dictionary + """ + if _depth == 100: + raise ThresholdTooDeep() + + if data['type'] == 'ed25519-sha-256': + public_key = base58.b58decode(data['public_key']) + return Ed25519Sha256(public_key=public_key) + + if data['type'] == 'threshold-sha-256': + threshold = ThresholdSha256(data['threshold']) + for cond in data['subconditions']: + cond = _fulfillment_from_details(cond, _depth+1) + threshold.add_subfulfillment(cond) + return threshold + + raise UnsupportedTypeError(data.get('type')) + + +class TransactionLink(object): + """An object for unidirectional linking to a Transaction's Output. + + Attributes: + txid (str, optional): A Transaction to link to. + output (int, optional): An output's index in a Transaction with id + `txid`. + """ + + def __init__(self, txid=None, output=None): + """Create an instance of a :class:`~.TransactionLink`. + + Note: + In an IPLD implementation, this class is not necessary anymore, + as an IPLD link can simply point to an object, as well as an + objects properties. So instead of having a (de)serializable + class, we can have a simple IPLD link of the form: + `//transaction/outputs//`. + + Args: + txid (str, optional): A Transaction to link to. + output (int, optional): An Outputs's index in a Transaction with + id `txid`. + """ + self.txid = txid + self.output = output + + def __bool__(self): + return self.txid is not None and self.output is not None + + def __eq__(self, other): + # TODO: If `other !== TransactionLink` return `False` + return self.to_dict() == other.to_dict() + + def __hash__(self): + return hash((self.txid, self.output)) + + @classmethod + def from_dict(cls, link): + """Transforms a Python dictionary to a TransactionLink object. + + Args: + link (dict): The link to be transformed. + + Returns: + :class:`~corechaindb.common.transaction.TransactionLink` + """ + try: + return cls(link['transaction_id'], link['output_index']) + except TypeError: + return cls() + + def to_dict(self): + """Transforms the object to a Python dictionary. + + Returns: + (dict|None): The link as an alternative serialization format. + """ + if self.txid is None and self.output is None: + return None + else: + return { + 'transaction_id': self.txid, + 'output_index': self.output, + } + + def to_uri(self, path=''): + if self.txid is None and self.output is None: + return None + return '{}/transactions/{}/outputs/{}'.format(path, self.txid, + self.output) + + +class Output(object): + """An Output is used to lock an asset. + + Wraps around a Crypto-condition Condition. + + Attributes: + fulfillment (:class:`cryptoconditions.Fulfillment`): A Fulfillment + to extract a Condition from. + public_keys (:obj:`list` of :obj:`str`, optional): A list of + owners before a Transaction was confirmed. + """ + + MAX_AMOUNT = 9 * 10 ** 18 + + def __init__(self, fulfillment, public_keys=None, amount=1): + """Create an instance of a :class:`~.Output`. + + Args: + fulfillment (:class:`cryptoconditions.Fulfillment`): A + Fulfillment to extract a Condition from. + public_keys (:obj:`list` of :obj:`str`, optional): A list of + owners before a Transaction was confirmed. + amount (int): The amount of Assets to be locked with this + Output. + + Raises: + TypeError: if `public_keys` is not instance of `list`. + """ + if not isinstance(public_keys, list) and public_keys is not None: + raise TypeError('`public_keys` must be a list instance or None') + if not isinstance(amount, int): + raise TypeError('`amount` must be an int') + if amount < 1: + raise AmountError('`amount` must be greater than 0') + if amount > self.MAX_AMOUNT: + raise AmountError('`amount` must be <= %s' % self.MAX_AMOUNT) + + self.fulfillment = fulfillment + self.amount = amount + self.public_keys = public_keys + + def __eq__(self, other): + # TODO: If `other !== Condition` return `False` + return self.to_dict() == other.to_dict() + + def to_dict(self): + """Transforms the object to a Python dictionary. + + Note: + A dictionary serialization of the Input the Output was + derived from is always provided. + + Returns: + dict: The Output as an alternative serialization format. + """ + # TODO FOR CC: It must be able to recognize a hashlock condition + # and fulfillment! + condition = {} + try: + condition['details'] = _fulfillment_to_details(self.fulfillment) + except AttributeError: + pass + + try: + condition['uri'] = self.fulfillment.condition_uri + except AttributeError: + condition['uri'] = self.fulfillment + + output = { + 'public_keys': self.public_keys, + 'condition': condition, + 'amount': str(self.amount), + } + return output + + @classmethod + def generate(cls, public_keys, amount): + """Generates a Output from a specifically formed tuple or list. + + Note: + If a ThresholdCondition has to be generated where the threshold + is always the number of subconditions it is split between, a + list of the following structure is sufficient: + + [(address|condition)*, [(address|condition)*, ...], ...] + + Args: + public_keys (:obj:`list` of :obj:`str`): The public key of + the users that should be able to fulfill the Condition + that is being created. + amount (:obj:`int`): The amount locked by the Output. + + Returns: + An Output that can be used in a Transaction. + + Raises: + TypeError: If `public_keys` is not an instance of `list`. + ValueError: If `public_keys` is an empty list. + """ + threshold = len(public_keys) + if not isinstance(amount, int): + raise TypeError('`amount` must be a int') + if amount < 1: + raise AmountError('`amount` needs to be greater than zero') + if not isinstance(public_keys, list): + raise TypeError('`public_keys` must be an instance of list') + if len(public_keys) == 0: + raise ValueError('`public_keys` needs to contain at least one' + 'owner') + elif len(public_keys) == 1 and not isinstance(public_keys[0], list): + if isinstance(public_keys[0], Fulfillment): + ffill = public_keys[0] + else: + ffill = Ed25519Sha256( + public_key=base58.b58decode(public_keys[0])) + return cls(ffill, public_keys, amount=amount) + else: + initial_cond = ThresholdSha256(threshold=threshold) + threshold_cond = reduce(cls._gen_condition, public_keys, + initial_cond) + return cls(threshold_cond, public_keys, amount=amount) + + @classmethod + def _gen_condition(cls, initial, new_public_keys): + """Generates ThresholdSha256 conditions from a list of new owners. + + Note: + This method is intended only to be used with a reduce function. + For a description on how to use this method, see + :meth:`~.Output.generate`. + + Args: + initial (:class:`cryptoconditions.ThresholdSha256`): + A Condition representing the overall root. + new_public_keys (:obj:`list` of :obj:`str`|str): A list of new + owners or a single new owner. + + Returns: + :class:`cryptoconditions.ThresholdSha256`: + """ + try: + threshold = len(new_public_keys) + except TypeError: + threshold = None + + if isinstance(new_public_keys, list) and len(new_public_keys) > 1: + ffill = ThresholdSha256(threshold=threshold) + reduce(cls._gen_condition, new_public_keys, ffill) + elif isinstance(new_public_keys, list) and len(new_public_keys) <= 1: + raise ValueError('Sublist cannot contain single owner') + else: + try: + new_public_keys = new_public_keys.pop() + except AttributeError: + pass + # NOTE: Instead of submitting base58 encoded addresses, a user + # of this class can also submit fully instantiated + # Cryptoconditions. In the case of casting + # `new_public_keys` to a Ed25519Fulfillment with the + # result of a `TypeError`, we're assuming that + # `new_public_keys` is a Cryptocondition then. + if isinstance(new_public_keys, Fulfillment): + ffill = new_public_keys + else: + ffill = Ed25519Sha256( + public_key=base58.b58decode(new_public_keys)) + initial.add_subfulfillment(ffill) + return initial + + @classmethod + def from_dict(cls, data): + """Transforms a Python dictionary to an Output object. + + Note: + To pass a serialization cycle multiple times, a + Cryptoconditions Fulfillment needs to be present in the + passed-in dictionary, as Condition URIs are not serializable + anymore. + + Args: + data (dict): The dict to be transformed. + + Returns: + :class:`~corechaindb.common.transaction.Output` + """ + try: + fulfillment = _fulfillment_from_details(data['condition']['details']) + except KeyError: + # NOTE: Hashlock condition case + fulfillment = data['condition']['uri'] + try: + amount = int(data['amount']) + except ValueError: + raise AmountError('Invalid amount: %s' % data['amount']) + return cls(fulfillment, data['public_keys'], amount) + + +class Transaction(object): + """A Transaction is used to create and transfer assets. + + Note: + For adding Inputs and Outputs, this class provides methods + to do so. + + Attributes: + operation (str): Defines the operation of the Transaction. + inputs (:obj:`list` of :class:`~corechaindb.common. + transaction.Input`, optional): Define the assets to + spend. + outputs (:obj:`list` of :class:`~corechaindb.common. + transaction.Output`, optional): Define the assets to lock. + asset (dict): Asset payload for this Transaction. ``CREATE`` + Transactions require a dict with a ``data`` + property while ``TRANSFER`` Transactions require a dict with a + ``id`` property. + metadata (dict): + Metadata to be stored along with the Transaction. + version (string): Defines the version number of a Transaction. + """ + + CREATE = 'CREATE' + TRANSFER = 'TRANSFER' + ALLOWED_OPERATIONS = (CREATE, TRANSFER) + VERSION = '2.0' + + def __init__(self, operation, asset, inputs=None, outputs=None, + metadata=None, version=None, hash_id=None, tx_dict=None): + """The constructor allows to create a customizable Transaction. + + Note: + When no `version` is provided, one is being + generated by this method. + + Args: + operation (str): Defines the operation of the Transaction. + asset (dict): Asset payload for this Transaction. + inputs (:obj:`list` of :class:`~corechaindb.common. + transaction.Input`, optional): Define the assets to + outputs (:obj:`list` of :class:`~corechaindb.common. + transaction.Output`, optional): Define the assets to + lock. + metadata (dict): Metadata to be stored along with the + Transaction. + version (string): Defines the version number of a Transaction. + hash_id (string): Hash id of the transaction. + """ + if operation not in self.ALLOWED_OPERATIONS: + allowed_ops = ', '.join(self.__class__.ALLOWED_OPERATIONS) + raise ValueError('`operation` must be one of {}' + .format(allowed_ops)) + + # Asset payloads for 'CREATE' operations must be None or + # dicts holding a `data` property. Asset payloads for 'TRANSFER' + # operations must be dicts holding an `id` property. + if (operation == self.CREATE and + asset is not None and not (isinstance(asset, dict) and 'data' in asset)): + raise TypeError(('`asset` must be None or a dict holding a `data` ' + " property instance for '{}' Transactions".format(operation))) + elif (operation == self.TRANSFER and + not (isinstance(asset, dict) and 'id' in asset)): + raise TypeError(('`asset` must be a dict holding an `id` property ' + 'for \'TRANSFER\' Transactions')) + + if outputs and not isinstance(outputs, list): + raise TypeError('`outputs` must be a list instance or None') + + if inputs and not isinstance(inputs, list): + raise TypeError('`inputs` must be a list instance or None') + + if metadata is not None and not isinstance(metadata, dict): + raise TypeError('`metadata` must be a dict or None') + + self.version = version if version is not None else self.VERSION + self.operation = operation + self.asset = asset + self.inputs = inputs or [] + self.outputs = outputs or [] + self.metadata = metadata + self._id = hash_id + self.tx_dict = tx_dict + + @property + def unspent_outputs(self): + """UnspentOutput: The outputs of this transaction, in a data + structure containing relevant information for storing them in + a UTXO set, and performing validation. + """ + if self.operation == self.CREATE: + self._asset_id = self._id + elif self.operation == self.TRANSFER: + self._asset_id = self.asset['id'] + return (UnspentOutput( + transaction_id=self._id, + output_index=output_index, + amount=output.amount, + asset_id=self._asset_id, + condition_uri=output.fulfillment.condition_uri, + ) for output_index, output in enumerate(self.outputs)) + + @property + def spent_outputs(self): + """Tuple of :obj:`dict`: Inputs of this transaction. Each input + is represented as a dictionary containing a transaction id and + output index. + """ + return ( + input_.fulfills.to_dict() + for input_ in self.inputs if input_.fulfills + ) + + @property + def serialized(self): + return Transaction._to_str(self.to_dict()) + + def _hash(self): + self._id = hash_data(self.serialized) + + @classmethod + def validate_create(cls, tx_signers, recipients, asset, metadata): + if not isinstance(tx_signers, list): + raise TypeError('`tx_signers` must be a list instance') + if not isinstance(recipients, list): + raise TypeError('`recipients` must be a list instance') + if len(tx_signers) == 0: + raise ValueError('`tx_signers` list cannot be empty') + if len(recipients) == 0: + raise ValueError('`recipients` list cannot be empty') + if not (asset is None or isinstance(asset, dict)): + raise TypeError('`asset` must be a dict or None') + if not (metadata is None or isinstance(metadata, dict)): + raise TypeError('`metadata` must be a dict or None') + + inputs = [] + outputs = [] + + # generate_outputs + for recipient in recipients: + if not isinstance(recipient, tuple) or len(recipient) != 2: + raise ValueError(('Each `recipient` in the list must be a' + ' tuple of `([],' + ' )`')) + pub_keys, amount = recipient + outputs.append(Output.generate(pub_keys, amount)) + + # generate inputs + inputs.append(Input.generate(tx_signers)) + + return (inputs, outputs) + + @classmethod + def create(cls, tx_signers, recipients, metadata=None, asset=None): + """A simple way to generate a `CREATE` transaction. + + Note: + This method currently supports the following Cryptoconditions + use cases: + - Ed25519 + - ThresholdSha256 + + Additionally, it provides support for the following BigchainDB + use cases: + - Multiple inputs and outputs. + + Args: + tx_signers (:obj:`list` of :obj:`str`): A list of keys that + represent the signers of the CREATE Transaction. + recipients (:obj:`list` of :obj:`tuple`): A list of + ([keys],amount) that represent the recipients of this + Transaction. + metadata (dict): The metadata to be stored along with the + Transaction. + asset (dict): The metadata associated with the asset that will + be created in this Transaction. + + Returns: + :class:`~corechaindb.common.transaction.Transaction` + """ + + (inputs, outputs) = cls.validate_create(tx_signers, recipients, asset, metadata) + return cls(cls.CREATE, {'data': asset}, inputs, outputs, metadata) + + @classmethod + def validate_transfer(cls, inputs, recipients, asset_id, metadata): + if not isinstance(inputs, list): + raise TypeError('`inputs` must be a list instance') + if len(inputs) == 0: + raise ValueError('`inputs` must contain at least one item') + if not isinstance(recipients, list): + raise TypeError('`recipients` must be a list instance') + if len(recipients) == 0: + raise ValueError('`recipients` list cannot be empty') + + outputs = [] + for recipient in recipients: + if not isinstance(recipient, tuple) or len(recipient) != 2: + raise ValueError(('Each `recipient` in the list must be a' + ' tuple of `([],' + ' )`')) + pub_keys, amount = recipient + outputs.append(Output.generate(pub_keys, amount)) + + if not isinstance(asset_id, str): + raise TypeError('`asset_id` must be a string') + + return (deepcopy(inputs), outputs) + + @classmethod + def transfer(cls, inputs, recipients, asset_id, metadata=None): + """A simple way to generate a `TRANSFER` transaction. + + Note: + Different cases for threshold conditions: + + Combining multiple `inputs` with an arbitrary number of + `recipients` can yield interesting cases for the creation of + threshold conditions we'd like to support. The following + notation is proposed: + + 1. The index of a `recipient` corresponds to the index of + an input: + e.g. `transfer([input1], [a])`, means `input1` would now be + owned by user `a`. + + 2. `recipients` can (almost) get arbitrary deeply nested, + creating various complex threshold conditions: + e.g. `transfer([inp1, inp2], [[a, [b, c]], d])`, means + `a`'s signature would have a 50% weight on `inp1` + compared to `b` and `c` that share 25% of the leftover + weight respectively. `inp2` is owned completely by `d`. + + Args: + inputs (:obj:`list` of :class:`~corechaindb.common.transaction. + Input`): Converted `Output`s, intended to + be used as inputs in the transfer to generate. + recipients (:obj:`list` of :obj:`tuple`): A list of + ([keys],amount) that represent the recipients of this + Transaction. + asset_id (str): The asset ID of the asset to be transferred in + this Transaction. + metadata (dict): Python dictionary to be stored along with the + Transaction. + + Returns: + :class:`~corechaindb.common.transaction.Transaction` + """ + (inputs, outputs) = cls.validate_transfer(inputs, recipients, asset_id, metadata) + return cls(cls.TRANSFER, {'id': asset_id}, inputs, outputs, metadata) + + def __eq__(self, other): + try: + other = other.to_dict() + except AttributeError: + return False + return self.to_dict() == other + + def to_inputs(self, indices=None): + """Converts a Transaction's outputs to spendable inputs. + + Note: + Takes the Transaction's outputs and derives inputs + from that can then be passed into `Transaction.transfer` as + `inputs`. + A list of integers can be passed to `indices` that + defines which outputs should be returned as inputs. + If no `indices` are passed (empty list or None) all + outputs of the Transaction are returned. + + Args: + indices (:obj:`list` of int): Defines which + outputs should be returned as inputs. + + Returns: + :obj:`list` of :class:`~corechaindb.common.transaction. + Input` + """ + # NOTE: If no indices are passed, we just assume to take all outputs + # as inputs. + indices = indices or range(len(self.outputs)) + return [ + Input(self.outputs[idx].fulfillment, + self.outputs[idx].public_keys, + TransactionLink(self.id, idx)) + for idx in indices + ] + + def add_input(self, input_): + """Adds an input to a Transaction's list of inputs. + + Args: + input_ (:class:`~corechaindb.common.transaction. + Input`): An Input to be added to the Transaction. + """ + if not isinstance(input_, Input): + raise TypeError('`input_` must be a Input instance') + self.inputs.append(input_) + + def add_output(self, output): + """Adds an output to a Transaction's list of outputs. + + Args: + output (:class:`~corechaindb.common.transaction. + Output`): An Output to be added to the + Transaction. + """ + if not isinstance(output, Output): + raise TypeError('`output` must be an Output instance or None') + self.outputs.append(output) + + def sign(self, private_keys): + """Fulfills a previous Transaction's Output by signing Inputs. + + Note: + This method works only for the following Cryptoconditions + currently: + - Ed25519Fulfillment + - ThresholdSha256 + Furthermore, note that all keys required to fully sign the + Transaction have to be passed to this method. A subset of all + will cause this method to fail. + + Args: + private_keys (:obj:`list` of :obj:`str`): A complete list of + all private keys needed to sign all Fulfillments of this + Transaction. + + Returns: + :class:`~corechaindb.common.transaction.Transaction` + """ + # TODO: Singing should be possible with at least one of all private + # keys supplied to this method. + if private_keys is None or not isinstance(private_keys, list): + raise TypeError('`private_keys` must be a list instance') + + # NOTE: Generate public keys from private keys and match them in a + # dictionary: + # key: public_key + # value: private_key + def gen_public_key(private_key): + # TODO FOR CC: Adjust interface so that this function becomes + # unnecessary + + # cc now provides a single method `encode` to return the key + # in several different encodings. + public_key = private_key.get_verifying_key().encode() + # Returned values from cc are always bytestrings so here we need + # to decode to convert the bytestring into a python str + return public_key.decode() + + key_pairs = {gen_public_key(PrivateKey(private_key)): + PrivateKey(private_key) for private_key in private_keys} + + tx_dict = self.to_dict() + tx_dict = Transaction._remove_signatures(tx_dict) + tx_serialized = Transaction._to_str(tx_dict) + for i, input_ in enumerate(self.inputs): + self.inputs[i] = self._sign_input(input_, tx_serialized, key_pairs) + + self._hash() + + return self + + @classmethod + def _sign_input(cls, input_, message, key_pairs): + """Signs a single Input. + + Note: + This method works only for the following Cryptoconditions + currently: + - Ed25519Fulfillment + - ThresholdSha256. + + Args: + input_ (:class:`~corechaindb.common.transaction. + Input`) The Input to be signed. + message (str): The message to be signed + key_pairs (dict): The keys to sign the Transaction with. + """ + if isinstance(input_.fulfillment, Ed25519Sha256): + return cls._sign_simple_signature_fulfillment(input_, message, + key_pairs) + elif isinstance(input_.fulfillment, ThresholdSha256): + return cls._sign_threshold_signature_fulfillment(input_, message, + key_pairs) + else: + raise ValueError( + 'Fulfillment couldn\'t be matched to ' + 'Cryptocondition fulfillment type.') + + @classmethod + def _sign_simple_signature_fulfillment(cls, input_, message, key_pairs): + """Signs a Ed25519Fulfillment. + + Args: + input_ (:class:`~corechaindb.common.transaction. + Input`) The input to be signed. + message (str): The message to be signed + key_pairs (dict): The keys to sign the Transaction with. + """ + # NOTE: To eliminate the dangers of accidentally signing a condition by + # reference, we remove the reference of input_ here + # intentionally. If the user of this class knows how to use it, + # this should never happen, but then again, never say never. + input_ = deepcopy(input_) + public_key = input_.owners_before[0] + message = sha3_256(message.encode()) + if input_.fulfills: + message.update('{}{}'.format( + input_.fulfills.txid, input_.fulfills.output).encode()) + + try: + # cryptoconditions makes no assumptions of the encoding of the + # message to sign or verify. It only accepts bytestrings + input_.fulfillment.sign( + message.digest(), base58.b58decode(key_pairs[public_key].encode())) + except KeyError: + raise KeypairMismatchException('Public key {} is not a pair to ' + 'any of the private keys' + .format(public_key)) + return input_ + + @classmethod + def _sign_threshold_signature_fulfillment(cls, input_, message, key_pairs): + """Signs a ThresholdSha256. + + Args: + input_ (:class:`~corechaindb.common.transaction. + Input`) The Input to be signed. + message (str): The message to be signed + key_pairs (dict): The keys to sign the Transaction with. + """ + input_ = deepcopy(input_) + message = sha3_256(message.encode()) + if input_.fulfills: + message.update('{}{}'.format( + input_.fulfills.txid, input_.fulfills.output).encode()) + + for owner_before in set(input_.owners_before): + # TODO: CC should throw a KeypairMismatchException, instead of + # our manual mapping here + + # TODO FOR CC: Naming wise this is not so smart, + # `get_subcondition` in fact doesn't return a + # condition but a fulfillment + + # TODO FOR CC: `get_subcondition` is singular. One would not + # expect to get a list back. + ccffill = input_.fulfillment + subffills = ccffill.get_subcondition_from_vk( + base58.b58decode(owner_before)) + if not subffills: + raise KeypairMismatchException('Public key {} cannot be found ' + 'in the fulfillment' + .format(owner_before)) + try: + private_key = key_pairs[owner_before] + except KeyError: + raise KeypairMismatchException('Public key {} is not a pair ' + 'to any of the private keys' + .format(owner_before)) + + # cryptoconditions makes no assumptions of the encoding of the + # message to sign or verify. It only accepts bytestrings + for subffill in subffills: + subffill.sign( + message.digest(), base58.b58decode(private_key.encode())) + return input_ + + def inputs_valid(self, outputs=None): + """Validates the Inputs in the Transaction against given + Outputs. + + Note: + Given a `CREATE` Transaction is passed, + dummy values for Outputs are submitted for validation that + evaluate parts of the validation-checks to `True`. + + Args: + outputs (:obj:`list` of :class:`~corechaindb.common. + transaction.Output`): A list of Outputs to check the + Inputs against. + + Returns: + bool: If all Inputs are valid. + """ + if self.operation == self.CREATE: + # NOTE: Since in the case of a `CREATE`-transaction we do not have + # to check for outputs, we're just submitting dummy + # values to the actual method. This simplifies it's logic + # greatly, as we do not have to check against `None` values. + return self._inputs_valid(['dummyvalue' + for _ in self.inputs]) + elif self.operation == self.TRANSFER: + return self._inputs_valid([output.fulfillment.condition_uri + for output in outputs]) + else: + allowed_ops = ', '.join(self.__class__.ALLOWED_OPERATIONS) + raise TypeError('`operation` must be one of {}' + .format(allowed_ops)) + + def _inputs_valid(self, output_condition_uris): + """Validates an Input against a given set of Outputs. + + Note: + The number of `output_condition_uris` must be equal to the + number of Inputs a Transaction has. + + Args: + output_condition_uris (:obj:`list` of :obj:`str`): A list of + Outputs to check the Inputs against. + + Returns: + bool: If all Outputs are valid. + """ + + if len(self.inputs) != len(output_condition_uris): + raise ValueError('Inputs and ' + 'output_condition_uris must have the same count') + + tx_dict = self.tx_dict if self.tx_dict else self.to_dict() + tx_dict = Transaction._remove_signatures(tx_dict) + tx_dict['id'] = None + tx_serialized = Transaction._to_str(tx_dict) + + def validate(i, output_condition_uri=None): + """Validate input against output condition URI""" + return self._input_valid(self.inputs[i], self.operation, + tx_serialized, output_condition_uri) + + return all(validate(i, cond) + for i, cond in enumerate(output_condition_uris)) + + @lru_cache(maxsize=16384) + def _input_valid(self, input_, operation, message, output_condition_uri=None): + """Validates a single Input against a single Output. + + Note: + In case of a `CREATE` Transaction, this method + does not validate against `output_condition_uri`. + + Args: + input_ (:class:`~corechaindb.common.transaction. + Input`) The Input to be signed. + operation (str): The type of Transaction. + message (str): The fulfillment message. + output_condition_uri (str, optional): An Output to check the + Input against. + + Returns: + bool: If the Input is valid. + """ + ccffill = input_.fulfillment + try: + parsed_ffill = Fulfillment.from_uri(ccffill.serialize_uri()) + except (TypeError, ValueError, + ParsingError, ASN1DecodeError, ASN1EncodeError): + return False + + if operation == self.CREATE: + # NOTE: In the case of a `CREATE` transaction, the + # output is always valid. + output_valid = True + else: + output_valid = output_condition_uri == ccffill.condition_uri + + message = sha3_256(message.encode()) + if input_.fulfills: + message.update('{}{}'.format( + input_.fulfills.txid, input_.fulfills.output).encode()) + + # NOTE: We pass a timestamp to `.validate`, as in case of a timeout + # condition we'll have to validate against it + + # cryptoconditions makes no assumptions of the encoding of the + # message to sign or verify. It only accepts bytestrings + ffill_valid = parsed_ffill.validate(message=message.digest()) + return output_valid and ffill_valid + + # This function is required by `lru_cache` to create a key for memoization + def __hash__(self): + return hash(self.id) + + @memoize_to_dict + def to_dict(self): + """Transforms the object to a Python dictionary. + + Returns: + dict: The Transaction as an alternative serialization format. + """ + return { + 'inputs': [input_.to_dict() for input_ in self.inputs], + 'outputs': [output.to_dict() for output in self.outputs], + 'operation': str(self.operation), + 'metadata': self.metadata, + 'asset': self.asset, + 'version': self.version, + 'id': self._id, + } + + @staticmethod + # TODO: Remove `_dict` prefix of variable. + def _remove_signatures(tx_dict): + """Takes a Transaction dictionary and removes all signatures. + + Args: + tx_dict (dict): The Transaction to remove all signatures from. + + Returns: + dict + + """ + # NOTE: We remove the reference since we need `tx_dict` only for the + # transaction's hash + tx_dict = deepcopy(tx_dict) + for input_ in tx_dict['inputs']: + # NOTE: Not all Cryptoconditions return a `signature` key (e.g. + # ThresholdSha256), so setting it to `None` in any + # case could yield incorrect signatures. This is why we only + # set it to `None` if it's set in the dict. + input_['fulfillment'] = None + return tx_dict + + @staticmethod + def _to_hash(value): + return hash_data(value) + + @property + def id(self): + return self._id + + def to_hash(self): + return self.to_dict()['id'] + + @staticmethod + def _to_str(value): + return serialize(value) + + # TODO: This method shouldn't call `_remove_signatures` + def __str__(self): + tx = Transaction._remove_signatures(self.to_dict()) + return Transaction._to_str(tx) + + @classmethod + def get_asset_id(cls, transactions): + """Get the asset id from a list of :class:`~.Transactions`. + + This is useful when we want to check if the multiple inputs of a + transaction are related to the same asset id. + + Args: + transactions (:obj:`list` of :class:`~corechaindb.common. + transaction.Transaction`): A list of Transactions. + Usually input Transactions that should have a matching + asset ID. + + Returns: + str: ID of the asset. + + Raises: + :exc:`AssetIdMismatch`: If the inputs are related to different + assets. + """ + + if not isinstance(transactions, list): + transactions = [transactions] + + # create a set of the transactions' asset ids + asset_ids = {tx.id if tx.operation == tx.CREATE + else tx.asset['id'] + for tx in transactions} + + # check that all the transasctions have the same asset id + if len(asset_ids) > 1: + raise AssetIdMismatch(('All inputs of all transactions passed' + ' need to have the same asset id')) + return asset_ids.pop() + + @staticmethod + def validate_id(tx_body): + """Validate the transaction ID of a transaction + + Args: + tx_body (dict): The Transaction to be transformed. + """ + # NOTE: Remove reference to avoid side effects + # tx_body = deepcopy(tx_body) + tx_body = rapidjson.loads(rapidjson.dumps(tx_body)) + + try: + proposed_tx_id = tx_body['id'] + except KeyError: + raise InvalidHash('No transaction id found!') + + tx_body['id'] = None + + tx_body_serialized = Transaction._to_str(tx_body) + valid_tx_id = Transaction._to_hash(tx_body_serialized) + + if proposed_tx_id != valid_tx_id: + err_msg = ("The transaction's id '{}' isn't equal to " + "the hash of its body, i.e. it's not valid.") + raise InvalidHash(err_msg.format(proposed_tx_id)) + + @classmethod + @memoize_from_dict + def from_dict(cls, tx, skip_schema_validation=True): + """Transforms a Python dictionary to a Transaction object. + + Args: + tx_body (dict): The Transaction to be transformed. + + Returns: + :class:`~corechaindb.common.transaction.Transaction` + """ + operation = tx.get('operation', Transaction.CREATE) if isinstance(tx, dict) else Transaction.CREATE + cls = Transaction.resolve_class(operation) + + if not skip_schema_validation: + cls.validate_id(tx) + cls.validate_schema(tx) + + inputs = [Input.from_dict(input_) for input_ in tx['inputs']] + outputs = [Output.from_dict(output) for output in tx['outputs']] + return cls(tx['operation'], tx['asset'], inputs, outputs, + tx['metadata'], tx['version'], hash_id=tx['id'], tx_dict=tx) + + @classmethod + def from_db(cls, bigchain, tx_dict_list): + """Helper method that reconstructs a transaction dict that was returned + from the database. It checks what asset_id to retrieve, retrieves the + asset from the asset table and reconstructs the transaction. + + Args: + bigchain (:class:`~corechaindb.tendermint.BigchainDB`): An instance + of BigchainDB used to perform database queries. + tx_dict_list (:list:`dict` or :obj:`dict`): The transaction dict or + list of transaction dict as returned from the database. + + Returns: + :class:`~Transaction` + + """ + return_list = True + if isinstance(tx_dict_list, dict): + tx_dict_list = [tx_dict_list] + return_list = False + + tx_map = {} + tx_ids = [] + for tx in tx_dict_list: + tx.update({'metadata': None}) + tx_map[tx['id']] = tx + tx_ids.append(tx['id']) + + assets = list(bigchain.get_assets(tx_ids)) + for asset in assets: + if asset is not None: + tx = tx_map[asset['id']] + del asset['id'] + tx['asset'] = asset + + tx_ids = list(tx_map.keys()) + metadata_list = list(bigchain.get_metadata(tx_ids)) + for metadata in metadata_list: + tx = tx_map[metadata['id']] + tx.update({'metadata': metadata.get('metadata')}) + + if return_list: + tx_list = [] + for tx_id, tx in tx_map.items(): + tx_list.append(cls.from_dict(tx)) + return tx_list + else: + tx = list(tx_map.values())[0] + return cls.from_dict(tx) + + type_registry = {} + + @staticmethod + def register_type(tx_type, tx_class): + Transaction.type_registry[tx_type] = tx_class + + def resolve_class(operation): + """For the given `tx` based on the `operation` key return its implementation class""" + + create_txn_class = Transaction.type_registry.get(Transaction.CREATE) + return Transaction.type_registry.get(operation, create_txn_class) + + @classmethod + def validate_schema(cls, tx): + pass + + def validate_transfer_inputs(self, bigchain, current_transactions=[]): + # store the inputs so that we can check if the asset ids match + input_txs = [] + input_conditions = [] + for input_ in self.inputs: + input_txid = input_.fulfills.txid + input_tx = bigchain.get_transaction(input_txid) + + if input_tx is None: + for ctxn in current_transactions: + if ctxn.id == input_txid: + input_tx = ctxn + + if input_tx is None: + raise InputDoesNotExist("input `{}` doesn't exist" + .format(input_txid)) + + spent = bigchain.get_spent(input_txid, input_.fulfills.output, + current_transactions) + if spent: + raise DoubleSpend('input `{}` was already spent' + .format(input_txid)) + + output = input_tx.outputs[input_.fulfills.output] + input_conditions.append(output) + input_txs.append(input_tx) + + # Validate that all inputs are distinct + links = [i.fulfills.to_uri() for i in self.inputs] + if len(links) != len(set(links)): + raise DoubleSpend('tx "{}" spends inputs twice'.format(self.id)) + + # validate asset id + asset_id = self.get_asset_id(input_txs) + if asset_id != self.asset['id']: + raise AssetIdMismatch(('The asset id of the input does not' + ' match the asset id of the' + ' transaction')) + + input_amount = sum([input_condition.amount for input_condition in input_conditions]) + output_amount = sum([output_condition.amount for output_condition in self.outputs]) + + if output_amount != input_amount: + raise AmountError(('The amount used in the inputs `{}`' + ' needs to be same as the amount used' + ' in the outputs `{}`') + .format(input_amount, output_amount)) + + if not self.inputs_valid(input_conditions): + raise InvalidSignature('Transaction signature is invalid.') + + return True diff --git a/corechaindb/common/transaction_mode_types.py b/corechaindb/common/transaction_mode_types.py new file mode 100644 index 00000000..03591db1 --- /dev/null +++ b/corechaindb/common/transaction_mode_types.py @@ -0,0 +1,8 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +BROADCAST_TX_COMMIT = 'broadcast_tx_commit' +BROADCAST_TX_ASYNC = 'broadcast_tx_async' +BROADCAST_TX_SYNC = 'broadcast_tx_sync' diff --git a/corechaindb/common/utils.py b/corechaindb/common/utils.py new file mode 100644 index 00000000..9ba1a929 --- /dev/null +++ b/corechaindb/common/utils.py @@ -0,0 +1,165 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import time +import re +import rapidjson + +import corechaindb +from corechaindb.common.exceptions import ValidationError + + +def gen_timestamp(): + """The Unix time, rounded to the nearest second. + See https://en.wikipedia.org/wiki/Unix_time + + Returns: + str: the Unix time + """ + return str(round(time.time())) + + +def serialize(data): + """Serialize a dict into a JSON formatted string. + + This function enforces rules like the separator and order of keys. + This ensures that all dicts are serialized in the same way. + + This is specially important for hashing data. We need to make sure that + everyone serializes their data in the same way so that we do not have + hash mismatches for the same structure due to serialization + differences. + + Args: + data (dict): dict to serialize + + Returns: + str: JSON formatted string + + """ + return rapidjson.dumps(data, skipkeys=False, ensure_ascii=False, + sort_keys=True) + + +def deserialize(data): + """Deserialize a JSON formatted string into a dict. + + Args: + data (str): JSON formatted string. + + Returns: + dict: dict resulting from the serialization of a JSON formatted + string. + """ + return rapidjson.loads(data) + + +def validate_txn_obj(obj_name, obj, key, validation_fun): + """Validate value of `key` in `obj` using `validation_fun`. + + Args: + obj_name (str): name for `obj` being validated. + obj (dict): dictionary object. + key (str): key to be validated in `obj`. + validation_fun (function): function used to validate the value + of `key`. + + Returns: + None: indicates validation successful + + Raises: + ValidationError: `validation_fun` will raise exception on failure + """ + backend = corechaindb.config['database']['backend'] + + if backend == 'localmongodb': + data = obj.get(key, {}) + if isinstance(data, dict): + validate_all_keys_in_obj(obj_name, data, validation_fun) + elif isinstance(data, list): + validate_all_items_in_list(obj_name, data, validation_fun) + + +def validate_all_items_in_list(obj_name, data, validation_fun): + for item in data: + if isinstance(item, dict): + validate_all_keys_in_obj(obj_name, item, validation_fun) + elif isinstance(item, list): + validate_all_items_in_list(obj_name, item, validation_fun) + + +def validate_all_keys_in_obj(obj_name, obj, validation_fun): + """Validate all (nested) keys in `obj` by using `validation_fun`. + + Args: + obj_name (str): name for `obj` being validated. + obj (dict): dictionary object. + validation_fun (function): function used to validate the value + of `key`. + + Returns: + None: indicates validation successful + + Raises: + ValidationError: `validation_fun` will raise this error on failure + """ + for key, value in obj.items(): + validation_fun(obj_name, key) + if isinstance(value, dict): + validate_all_keys_in_obj(obj_name, value, validation_fun) + elif isinstance(value, list): + validate_all_items_in_list(obj_name, value, validation_fun) + + +def validate_all_values_for_key_in_obj(obj, key, validation_fun): + """Validate value for all (nested) occurrence of `key` in `obj` + using `validation_fun`. + + Args: + obj (dict): dictionary object. + key (str): key whose value is to be validated. + validation_fun (function): function used to validate the value + of `key`. + + Raises: + ValidationError: `validation_fun` will raise this error on failure + """ + for vkey, value in obj.items(): + if vkey == key: + validation_fun(value) + elif isinstance(value, dict): + validate_all_values_for_key_in_obj(value, key, validation_fun) + elif isinstance(value, list): + validate_all_values_for_key_in_list(value, key, validation_fun) + + +def validate_all_values_for_key_in_list(input_list, key, validation_fun): + for item in input_list: + if isinstance(item, dict): + validate_all_values_for_key_in_obj(item, key, validation_fun) + elif isinstance(item, list): + validate_all_values_for_key_in_list(item, key, validation_fun) + + +def validate_key(obj_name, key): + """Check if `key` contains ".", "$" or null characters. + + https://docs.mongodb.com/manual/reference/limits/#Restrictions-on-Field-Names + + Args: + obj_name (str): object name to use when raising exception + key (str): key to validated + + Returns: + None: validation successful + + Raises: + ValidationError: will raise exception in case of regex match. + """ + if re.search(r'^[$]|\.|\x00', key): + error_str = ('Invalid key name "{}" in {} object. The ' + 'key name cannot contain characters ' + '".", "$" or null characters').format(key, obj_name) + raise ValidationError(error_str) diff --git a/corechaindb/config_utils.py b/corechaindb/config_utils.py new file mode 100644 index 00000000..d5a0d360 --- /dev/null +++ b/corechaindb/config_utils.py @@ -0,0 +1,308 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Utils for reading and setting configuration settings. + +The value of each BigchainDB Server configuration setting is +determined according to the following rules: + +* If it's set by an environment variable, then use that value +* Otherwise, if it's set in a local config file, then use that + value +* Otherwise, use the default value (contained in + ``corechaindb.__init__``) +""" + + +import os +import copy +import json +import logging +import collections.abc +from functools import lru_cache + +from pkg_resources import iter_entry_points, ResolutionError + +from corechaindb.common import exceptions + +import corechaindb + +from corechaindb.validation import BaseValidationRules + +# TODO: move this to a proper configuration file for logging +logging.getLogger('requests').setLevel(logging.WARNING) +logger = logging.getLogger(__name__) + +CONFIG_DEFAULT_PATH = os.environ.setdefault( + 'BIGCHAINDB_CONFIG_PATH', + os.path.join(os.path.expanduser('~'), '.corechaindb'), +) + +CONFIG_PREFIX = 'BIGCHAINDB' +CONFIG_SEP = '_' + + +def map_leafs(func, mapping): + """Map a function to the leafs of a mapping.""" + + def _inner(mapping, path=None): + if path is None: + path = [] + + for key, val in mapping.items(): + if isinstance(val, collections.abc.Mapping): + _inner(val, path + [key]) + else: + mapping[key] = func(val, path=path+[key]) + + return mapping + + return _inner(copy.deepcopy(mapping)) + + +# Thanks Alex <3 +# http://stackoverflow.com/a/3233356/597097 +def update(d, u): + """Recursively update a mapping (i.e. a dict, list, set, or tuple). + + Conceptually, d and u are two sets trees (with nodes and edges). + This function goes through all the nodes of u. For each node in u, + if d doesn't have that node yet, then this function adds the node from u, + otherwise this function overwrites the node already in d with u's node. + + Args: + d (mapping): The mapping to overwrite and add to. + u (mapping): The mapping to read for changes. + + Returns: + mapping: An updated version of d (updated by u). + """ + for k, v in u.items(): + if isinstance(v, collections.abc.Mapping): + r = update(d.get(k, {}), v) + d[k] = r + else: + d[k] = u[k] + return d + + +def file_config(filename=None): + """Returns the config values found in a configuration file. + + Args: + filename (str): the JSON file with the configuration values. + If ``None``, CONFIG_DEFAULT_PATH will be used. + + Returns: + dict: The config values in the specified config file (or the + file at CONFIG_DEFAULT_PATH, if filename == None) + """ + logger.debug('On entry into file_config(), filename = {}'.format(filename)) + + if filename is None: + filename = CONFIG_DEFAULT_PATH + + logger.debug('file_config() will try to open `{}`'.format(filename)) + with open(filename) as f: + try: + config = json.load(f) + except ValueError as err: + raise exceptions.ConfigurationError( + 'Failed to parse the JSON configuration from `{}`, {}'.format(filename, err) + ) + + logger.info('Configuration loaded from `{}`'.format(filename)) + + return config + + +def env_config(config): + """Return a new configuration with the values found in the environment. + + The function recursively iterates over the config, checking if there is + a matching env variable. If an env variable is found, the func updates + the configuration with that value. + + The name of the env variable is built combining a prefix (``BIGCHAINDB``) + with the path to the value. If the ``config`` in input is: + ``{'database': {'host': 'localhost'}}`` + this function will try to read the env variable ``BIGCHAINDB_DATABASE_HOST``. + """ + + def load_from_env(value, path): + var_name = CONFIG_SEP.join([CONFIG_PREFIX] + list(map(lambda s: s.upper(), path))) + + return os.environ.get(var_name, value) + + return map_leafs(load_from_env, config) + + +def update_types(config, reference, list_sep=':'): + """Return a new configuration where all the values types + are aligned with the ones in the default configuration + """ + + def _coerce(current, value): + # Coerce a value to the `current` type. + try: + # First we try to apply current to the value, since it + # might be a function + return current(value) + except TypeError: + # Then we check if current is a list AND if the value + # is a string. + if isinstance(current, list) and isinstance(value, str): + # If so, we use the colon as the separator + return value.split(list_sep) + + try: + # If we are here, we should try to apply the type + # of `current` to the value + return type(current)(value) + except TypeError: + # Worst case scenario we return the value itself. + return value + + def _update_type(value, path): + current = reference + + for elem in path: + try: + current = current[elem] + except KeyError: + return value + + return _coerce(current, value) + + return map_leafs(_update_type, config) + + +def set_config(config): + """Set corechaindb.config equal to the default config dict, + then update that with whatever is in the provided config dict, + and then set corechaindb.config['CONFIGURED'] = True + + Args: + config (dict): the config dict to read for changes + to the default config + + Note: + Any previous changes made to ``corechaindb.config`` will be lost. + """ + # Deep copy the default config into corechaindb.config + corechaindb.config = copy.deepcopy(corechaindb._config) + # Update the default config with whatever is in the passed config + update(corechaindb.config, update_types(config, corechaindb.config)) + corechaindb.config['CONFIGURED'] = True + + +def update_config(config): + """Update corechaindb.config with whatever is in the provided config dict, + and then set corechaindb.config['CONFIGURED'] = True + + Args: + config (dict): the config dict to read for changes + to the default config + """ + + # Update the default config with whatever is in the passed config + update(corechaindb.config, update_types(config, corechaindb.config)) + corechaindb.config['CONFIGURED'] = True + + +def write_config(config, filename=None): + """Write the provided configuration to a specific location. + + Args: + config (dict): a dictionary with the configuration to load. + filename (str): the name of the file that will store the new configuration. Defaults to ``None``. + If ``None``, the HOME of the current user and the string ``.corechaindb`` will be used. + """ + if not filename: + filename = CONFIG_DEFAULT_PATH + + with open(filename, 'w') as f: + json.dump(config, f, indent=4) + + +def is_configured(): + return bool(corechaindb.config.get('CONFIGURED')) + + +def autoconfigure(filename=None, config=None, force=False): + """Run ``file_config`` and ``env_config`` if the module has not + been initialized. + """ + if not force and is_configured(): + logger.debug('System already configured, skipping autoconfiguration') + return + + # start with the current configuration + newconfig = corechaindb.config + + # update configuration from file + try: + newconfig = update(newconfig, file_config(filename=filename)) + except FileNotFoundError as e: + if filename: + raise + else: + logger.info('Cannot find config file `%s`.' % e.filename) + + # override configuration with env variables + newconfig = env_config(newconfig) + if config: + newconfig = update(newconfig, config) + set_config(newconfig) # sets corechaindb.config + + +@lru_cache() +def load_validation_plugin(name=None): + """Find and load the chosen validation plugin. + + Args: + name (string): the name of the entry_point, as advertised in the + setup.py of the providing package. + + Returns: + an uninstantiated subclass of ``corechaindb.validation.AbstractValidationRules`` + """ + if not name: + return BaseValidationRules + + # TODO: This will return the first plugin with group `corechaindb.validation` + # and name `name` in the active WorkingSet. + # We should probably support Requirements specs in the config, e.g. + # validation_plugin: 'my-plugin-package==0.0.1;default' + plugin = None + for entry_point in iter_entry_points('corechaindb.validation', name): + plugin = entry_point.load() + + # No matching entry_point found + if not plugin: + raise ResolutionError( + 'No plugin found in group `corechaindb.validation` with name `{}`'. + format(name)) + + # Is this strictness desireable? + # It will probably reduce developer headaches in the wild. + if not issubclass(plugin, (BaseValidationRules,)): + raise TypeError('object of type "{}" does not implement `corechaindb.' + 'validation.BaseValidationRules`'.format(type(plugin))) + + return plugin + + +def load_events_plugins(names=None): + plugins = [] + + if names is None: + return plugins + + for name in names: + for entry_point in iter_entry_points('corechaindb.events', name): + plugins.append((name, entry_point.load())) + + return plugins diff --git a/corechaindb/core.py b/corechaindb/core.py new file mode 100644 index 00000000..05f789cd --- /dev/null +++ b/corechaindb/core.py @@ -0,0 +1,271 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""This module contains all the goodness to integrate BigchainDB +with Tendermint. +""" +import logging +import sys + +from abci.application import BaseApplication +from abci import CodeTypeOk + +from corechaindb import BigchainDB +from corechaindb.elections.election import Election +from corechaindb.version import __tm_supported_versions__ +from corechaindb.utils import tendermint_version_is_compatible +from corechaindb.tendermint_utils import (decode_transaction, + calculate_hash) +from corechaindb.lib import Block +import corechaindb.upsert_validator.validator_utils as vutils +from corechaindb.events import EventTypes, Event + + +CodeTypeError = 1 +logger = logging.getLogger(__name__) + + +class App(BaseApplication): + """Bridge between BigchainDB and Tendermint. + + The role of this class is to expose the BigchainDB + transaction logic to Tendermint Core. + """ + + def __init__(self, abci, corechaindb=None, events_queue=None,): + super().__init__(abci) + self.events_queue = events_queue + self.corechaindb = corechaindb or BigchainDB() + self.block_txn_ids = [] + self.block_txn_hash = '' + self.block_transactions = [] + self.validators = None + self.new_height = None + self.chain = self.corechaindb.get_latest_abci_chain() + + def log_abci_migration_error(self, chain_id, validators): + logger.error('An ABCI chain migration is in process. ' + 'Download the new ABCI client and configure it with ' + f'chain_id={chain_id} and validators={validators}.') + + def abort_if_abci_chain_is_not_synced(self): + if self.chain is None or self.chain['is_synced']: + return + + validators = self.corechaindb.get_validators() + self.log_abci_migration_error(self.chain['chain_id'], validators) + sys.exit(1) + + def init_chain(self, genesis): + """Initialize chain upon genesis or a migration""" + + app_hash = '' + height = 0 + + known_chain = self.corechaindb.get_latest_abci_chain() + if known_chain is not None: + chain_id = known_chain['chain_id'] + + if known_chain['is_synced']: + msg = (f'Got invalid InitChain ABCI request ({genesis}) - ' + f'the chain {chain_id} is already synced.') + logger.error(msg) + sys.exit(1) + + if chain_id != genesis.chain_id: + validators = self.corechaindb.get_validators() + self.log_abci_migration_error(chain_id, validators) + sys.exit(1) + + # set migration values for app hash and height + block = self.corechaindb.get_latest_block() + app_hash = '' if block is None else block['app_hash'] + height = 0 if block is None else block['height'] + 1 + + known_validators = self.corechaindb.get_validators() + validator_set = [vutils.decode_validator(v) + for v in genesis.validators] + + if known_validators and known_validators != validator_set: + self.log_abci_migration_error(known_chain['chain_id'], + known_validators) + sys.exit(1) + + block = Block(app_hash=app_hash, height=height, transactions=[]) + self.corechaindb.store_block(block._asdict()) + self.corechaindb.store_validator_set(height + 1, validator_set) + abci_chain_height = 0 if known_chain is None else known_chain['height'] + self.corechaindb.store_abci_chain(abci_chain_height, + genesis.chain_id, True) + self.chain = {'height': abci_chain_height, 'is_synced': True, + 'chain_id': genesis.chain_id} + return self.abci.ResponseInitChain() + + def info(self, request): + """Return height of the latest committed block.""" + + self.abort_if_abci_chain_is_not_synced() + + # Check if BigchainDB supports the Tendermint version + if not (hasattr(request, 'version') and tendermint_version_is_compatible(request.version)): + logger.error(f'Unsupported Tendermint version: {getattr(request, "version", "no version")}.' + f' Currently, BigchainDB only supports {__tm_supported_versions__}. Exiting!') + sys.exit(1) + + logger.info(f"Tendermint version: {request.version}") + + r = self.abci.ResponseInfo() + block = self.corechaindb.get_latest_block() + if block: + chain_shift = 0 if self.chain is None else self.chain['height'] + r.last_block_height = block['height'] - chain_shift + r.last_block_app_hash = block['app_hash'].encode('utf-8') + else: + r.last_block_height = 0 + r.last_block_app_hash = b'' + return r + + def check_tx(self, raw_transaction): + """Validate the transaction before entry into + the mempool. + + Args: + raw_tx: a raw string (in bytes) transaction. + """ + + self.abort_if_abci_chain_is_not_synced() + + logger.debug('check_tx: %s', raw_transaction) + transaction = decode_transaction(raw_transaction) + if self.corechaindb.is_valid_transaction(transaction): + logger.debug('check_tx: VALID') + return self.abci.ResponseCheckTx(code=CodeTypeOk) + else: + logger.debug('check_tx: INVALID') + return self.abci.ResponseCheckTx(code=CodeTypeError) + + def begin_block(self, req_begin_block): + """Initialize list of transaction. + Args: + req_begin_block: block object which contains block header + and block hash. + """ + self.abort_if_abci_chain_is_not_synced() + + chain_shift = 0 if self.chain is None else self.chain['height'] + logger.debug('BEGIN BLOCK, height:%s, num_txs:%s', + req_begin_block.header.height + chain_shift, + req_begin_block.header.num_txs) + + self.block_txn_ids = [] + self.block_transactions = [] + return self.abci.ResponseBeginBlock() + + def deliver_tx(self, raw_transaction): + """Validate the transaction before mutating the state. + + Args: + raw_tx: a raw string (in bytes) transaction. + """ + + self.abort_if_abci_chain_is_not_synced() + + logger.debug('deliver_tx: %s', raw_transaction) + transaction = self.corechaindb.is_valid_transaction( + decode_transaction(raw_transaction), self.block_transactions) + + if not transaction: + logger.debug('deliver_tx: INVALID') + return self.abci.ResponseDeliverTx(code=CodeTypeError) + else: + logger.debug('storing tx') + self.block_txn_ids.append(transaction.id) + self.block_transactions.append(transaction) + return self.abci.ResponseDeliverTx(code=CodeTypeOk) + + def end_block(self, request_end_block): + """Calculate block hash using transaction ids and previous block + hash to be stored in the next block. + + Args: + height (int): new height of the chain. + """ + + self.abort_if_abci_chain_is_not_synced() + + chain_shift = 0 if self.chain is None else self.chain['height'] + + height = request_end_block.height + chain_shift + self.new_height = height + + # store pre-commit state to recover in case there is a crash during + # `end_block` or `commit` + logger.debug(f'Updating pre-commit state: {self.new_height}') + pre_commit_state = dict(height=self.new_height, + transactions=self.block_txn_ids) + self.corechaindb.store_pre_commit_state(pre_commit_state) + + block_txn_hash = calculate_hash(self.block_txn_ids) + block = self.corechaindb.get_latest_block() + + if self.block_txn_ids: + self.block_txn_hash = calculate_hash([block['app_hash'], block_txn_hash]) + else: + self.block_txn_hash = block['app_hash'] + + validator_update = Election.process_block(self.corechaindb, + self.new_height, + self.block_transactions) + + return self.abci.ResponseEndBlock(validator_updates=validator_update) + + def commit(self): + """Store the new height and along with block hash.""" + + self.abort_if_abci_chain_is_not_synced() + + data = self.block_txn_hash.encode('utf-8') + + # register a new block only when new transactions are received + if self.block_txn_ids: + self.corechaindb.store_bulk_transactions(self.block_transactions) + + block = Block(app_hash=self.block_txn_hash, + height=self.new_height, + transactions=self.block_txn_ids) + # NOTE: storing the block should be the last operation during commit + # this effects crash recovery. Refer BEP#8 for details + self.corechaindb.store_block(block._asdict()) + + logger.debug('Commit-ing new block with hash: apphash=%s ,' + 'height=%s, txn ids=%s', data, self.new_height, + self.block_txn_ids) + + if self.events_queue: + event = Event(EventTypes.BLOCK_VALID, { + 'height': self.new_height, + 'transactions': self.block_transactions + }) + self.events_queue.put(event) + + return self.abci.ResponseCommit(data=data) + + +def rollback(b): + pre_commit = b.get_pre_commit_state() + + if pre_commit is None: + # the pre_commit record is first stored in the first `end_block` + return + + latest_block = b.get_latest_block() + if latest_block is None: + logger.error('Found precommit state but no blocks!') + sys.exit(1) + + # NOTE: the pre-commit state is always at most 1 block ahead of the commited state + if latest_block['height'] < pre_commit['height']: + Election.rollback(b, pre_commit['height'], pre_commit['transactions']) + b.delete_transactions(pre_commit['transactions']) diff --git a/corechaindb/elections/__init__.py b/corechaindb/elections/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/corechaindb/elections/election.py b/corechaindb/elections/election.py new file mode 100644 index 00000000..621ff4e5 --- /dev/null +++ b/corechaindb/elections/election.py @@ -0,0 +1,355 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 +from collections import OrderedDict + +import base58 +from uuid import uuid4 + +from corechaindb import backend +from corechaindb.elections.vote import Vote +from corechaindb.common.exceptions import (InvalidSignature, + MultipleInputsError, + InvalidProposer, + UnequalValidatorSet, + DuplicateTransaction) +from corechaindb.tendermint_utils import key_from_base64, public_key_to_base64 +from corechaindb.common.crypto import (public_key_from_ed25519_key) +from corechaindb.common.transaction import Transaction +from corechaindb.common.schema import (_validate_schema, + TX_SCHEMA_COMMON, + TX_SCHEMA_CREATE) + + +class Election(Transaction): + """Represents election transactions. + + To implement a custom election, create a class deriving from this one + with OPERATION set to the election operation, ALLOWED_OPERATIONS + set to (OPERATION,), CREATE set to OPERATION. + """ + + OPERATION = None + # Custom validation schema + TX_SCHEMA_CUSTOM = None + # Election Statuses: + ONGOING = 'ongoing' + CONCLUDED = 'concluded' + INCONCLUSIVE = 'inconclusive' + # Vote ratio to approve an election + ELECTION_THRESHOLD = 2 / 3 + + @classmethod + def get_validator_change(cls, bigchain): + """Return the validator set from the most recent approved block + + :return: { + 'height': , + 'validators': + } + """ + latest_block = bigchain.get_latest_block() + if latest_block is None: + return None + return bigchain.get_validator_change(latest_block['height']) + + @classmethod + def get_validators(cls, bigchain, height=None): + """Return a dictionary of validators with key as `public_key` and + value as the `voting_power` + """ + validators = {} + for validator in bigchain.get_validators(height): + # NOTE: we assume that Tendermint encodes public key in base64 + public_key = public_key_from_ed25519_key(key_from_base64(validator['public_key']['value'])) + validators[public_key] = validator['voting_power'] + + return validators + + @classmethod + def recipients(cls, bigchain): + """Convert validator dictionary to a recipient list for `Transaction`""" + + recipients = [] + for public_key, voting_power in cls.get_validators(bigchain).items(): + recipients.append(([public_key], voting_power)) + + return recipients + + @classmethod + def is_same_topology(cls, current_topology, election_topology): + voters = {} + for voter in election_topology: + if len(voter.public_keys) > 1: + return False + + [public_key] = voter.public_keys + voting_power = voter.amount + voters[public_key] = voting_power + + # Check whether the voters and their votes is same to that of the + # validators and their voting power in the network + return current_topology == voters + + def validate(self, bigchain, current_transactions=[]): + """Validate election transaction + + NOTE: + * A valid election is initiated by an existing validator. + + * A valid election is one where voters are validators and votes are + allocated according to the voting power of each validator node. + + Args: + :param bigchain: (BigchainDB) an instantiated corechaindb.lib.BigchainDB object. + :param current_transactions: (list) A list of transactions to be validated along with the election + + Returns: + Election: a Election object or an object of the derived Election subclass. + + Raises: + ValidationError: If the election is invalid + """ + input_conditions = [] + + duplicates = any(txn for txn in current_transactions if txn.id == self.id) + if bigchain.is_committed(self.id) or duplicates: + raise DuplicateTransaction('transaction `{}` already exists' + .format(self.id)) + + if not self.inputs_valid(input_conditions): + raise InvalidSignature('Transaction signature is invalid.') + + current_validators = self.get_validators(bigchain) + + # NOTE: Proposer should be a single node + if len(self.inputs) != 1 or len(self.inputs[0].owners_before) != 1: + raise MultipleInputsError('`tx_signers` must be a list instance of length one') + + # NOTE: Check if the proposer is a validator. + [election_initiator_node_pub_key] = self.inputs[0].owners_before + if election_initiator_node_pub_key not in current_validators.keys(): + raise InvalidProposer('Public key is not a part of the validator set') + + # NOTE: Check if all validators have been assigned votes equal to their voting power + if not self.is_same_topology(current_validators, self.outputs): + raise UnequalValidatorSet('Validator set much be exactly same to the outputs of election') + + return self + + @classmethod + def generate(cls, initiator, voters, election_data, metadata=None): + # Break symmetry in case we need to call an election with the same properties twice + uuid = uuid4() + election_data['seed'] = str(uuid) + + (inputs, outputs) = cls.validate_create(initiator, voters, election_data, metadata) + election = cls(cls.OPERATION, {'data': election_data}, inputs, outputs, metadata) + cls.validate_schema(election.to_dict()) + return election + + @classmethod + def validate_schema(cls, tx): + """Validate the election transaction. Since `ELECTION` extends `CREATE` transaction, all the validations for + `CREATE` transaction should be inherited + """ + _validate_schema(TX_SCHEMA_COMMON, tx) + _validate_schema(TX_SCHEMA_CREATE, tx) + if cls.TX_SCHEMA_CUSTOM: + _validate_schema(cls.TX_SCHEMA_CUSTOM, tx) + + @classmethod + def create(cls, tx_signers, recipients, metadata=None, asset=None): + raise NotImplementedError + + @classmethod + def transfer(cls, tx_signers, recipients, metadata=None, asset=None): + raise NotImplementedError + + @classmethod + def to_public_key(cls, election_id): + return base58.b58encode(bytes.fromhex(election_id)).decode() + + @classmethod + def count_votes(cls, election_pk, transactions, getter=getattr): + votes = 0 + for txn in transactions: + if getter(txn, 'operation') == Vote.OPERATION: + for output in getter(txn, 'outputs'): + # NOTE: We enforce that a valid vote to election id will have only + # election_pk in the output public keys, including any other public key + # along with election_pk will lead to vote being not considered valid. + if len(getter(output, 'public_keys')) == 1 and [election_pk] == getter(output, 'public_keys'): + votes = votes + int(getter(output, 'amount')) + return votes + + def get_commited_votes(self, bigchain, election_pk=None): + if election_pk is None: + election_pk = self.to_public_key(self.id) + txns = list(backend.query.get_asset_tokens_for_public_key(bigchain.connection, + self.id, + election_pk)) + return self.count_votes(election_pk, txns, dict.get) + + def has_concluded(self, bigchain, current_votes=[]): + """Check if the election can be concluded or not. + + * Elections can only be concluded if the validator set has not changed + since the election was initiated. + * Elections can be concluded only if the current votes form a supermajority. + + Custom elections may override this function and introduce additional checks. + """ + if self.has_validator_set_changed(bigchain): + return False + + election_pk = self.to_public_key(self.id) + votes_committed = self.get_commited_votes(bigchain, election_pk) + votes_current = self.count_votes(election_pk, current_votes) + + total_votes = sum(output.amount for output in self.outputs) + if (votes_committed < (2/3) * total_votes) and \ + (votes_committed + votes_current >= (2/3)*total_votes): + return True + + return False + + def get_status(self, bigchain): + election = self.get_election(self.id, bigchain) + if election and election['is_concluded']: + return self.CONCLUDED + + return self.INCONCLUSIVE if self.has_validator_set_changed(bigchain) else self.ONGOING + + def has_validator_set_changed(self, bigchain): + latest_change = self.get_validator_change(bigchain) + if latest_change is None: + return False + + latest_change_height = latest_change['height'] + + election = self.get_election(self.id, bigchain) + + return latest_change_height > election['height'] + + def get_election(self, election_id, bigchain): + return bigchain.get_election(election_id) + + def store(self, bigchain, height, is_concluded): + bigchain.store_election(self.id, height, is_concluded) + + def show_election(self, bigchain): + data = self.asset['data'] + if 'public_key' in data.keys(): + data['public_key'] = public_key_to_base64(data['public_key']['value']) + response = '' + for k, v in data.items(): + if k != 'seed': + response += f'{k}={v}\n' + response += f'status={self.get_status(bigchain)}' + + return response + + @classmethod + def _get_initiated_elections(cls, height, txns): + elections = [] + for tx in txns: + if not isinstance(tx, Election): + continue + + elections.append({'election_id': tx.id, 'height': height, + 'is_concluded': False}) + return elections + + @classmethod + def _get_votes(cls, txns): + elections = OrderedDict() + for tx in txns: + if not isinstance(tx, Vote): + continue + + election_id = tx.asset['id'] + if election_id not in elections: + elections[election_id] = [] + elections[election_id].append(tx) + return elections + + @classmethod + def process_block(cls, bigchain, new_height, txns): + """Looks for election and vote transactions inside the block, records + and processes elections. + + Every election is recorded in the database. + + Every vote has a chance to conclude the corresponding election. When + an election is concluded, the corresponding database record is + marked as such. + + Elections and votes are processed in the order in which they + appear in the block. Elections are concluded in the order of + appearance of their first votes in the block. + + For every election concluded in the block, calls its `on_approval` + method. The returned value of the last `on_approval`, if any, + is a validator set update to be applied in one of the following blocks. + + `on_approval` methods are implemented by elections of particular type. + The method may contain side effects but should be idempotent. To account + for other concluded elections, if it requires so, the method should + rely on the database state. + """ + # elections initiated in this block + initiated_elections = cls._get_initiated_elections(new_height, txns) + + if initiated_elections: + bigchain.store_elections(initiated_elections) + + # elections voted for in this block and their votes + elections = cls._get_votes(txns) + + validator_update = None + for election_id, votes in elections.items(): + election = bigchain.get_transaction(election_id) + if election is None: + continue + + if not election.has_concluded(bigchain, votes): + continue + + validator_update = election.on_approval(bigchain, new_height) + election.store(bigchain, new_height, is_concluded=True) + + return [validator_update] if validator_update else [] + + @classmethod + def rollback(cls, bigchain, new_height, txn_ids): + """Looks for election and vote transactions inside the block and + cleans up the database artifacts possibly created in `process_blocks`. + + Part of the `end_block`/`commit` crash recovery. + """ + + # delete election records for elections initiated at this height and + # elections concluded at this height + bigchain.delete_elections(new_height) + + txns = [bigchain.get_transaction(tx_id) for tx_id in txn_ids] + + elections = cls._get_votes(txns) + for election_id in elections: + election = bigchain.get_transaction(election_id) + election.on_rollback(bigchain, new_height) + + def on_approval(self, bigchain, new_height): + """Override to update the database state according to the + election rules. Consider the current database state to account for + other concluded elections, if required. + """ + raise NotImplementedError + + def on_rollback(self, bigchain, new_height): + """Override to clean up the database artifacts possibly created + in `on_approval`. Part of the `end_block`/`commit` crash recovery. + """ + raise NotImplementedError diff --git a/corechaindb/elections/vote.py b/corechaindb/elections/vote.py new file mode 100644 index 00000000..76a73fda --- /dev/null +++ b/corechaindb/elections/vote.py @@ -0,0 +1,64 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +from corechaindb.common.transaction import Transaction +from corechaindb.common.schema import (_validate_schema, + TX_SCHEMA_COMMON, + TX_SCHEMA_TRANSFER, + TX_SCHEMA_VOTE) + + +class Vote(Transaction): + + OPERATION = 'VOTE' + # NOTE: This class inherits TRANSFER txn type. The `TRANSFER` property is + # overriden to re-use methods from parent class + TRANSFER = OPERATION + ALLOWED_OPERATIONS = (OPERATION,) + # Custom validation schema + TX_SCHEMA_CUSTOM = TX_SCHEMA_VOTE + + def validate(self, bigchain, current_transactions=[]): + """Validate election vote transaction + NOTE: There are no additional validity conditions on casting votes i.e. + a vote is just a valid TRANFER transaction + + For more details refer BEP-21: https://github.com/corechaindb/BEPs/tree/master/21 + + Args: + bigchain (BigchainDB): an instantiated corechaindb.lib.BigchainDB object. + + Returns: + Vote: a Vote object + + Raises: + ValidationError: If the election vote is invalid + """ + self.validate_transfer_inputs(bigchain, current_transactions) + return self + + @classmethod + def generate(cls, inputs, recipients, election_id, metadata=None): + (inputs, outputs) = cls.validate_transfer(inputs, recipients, election_id, metadata) + election_vote = cls(cls.OPERATION, {'id': election_id}, inputs, outputs, metadata) + cls.validate_schema(election_vote.to_dict()) + return election_vote + + @classmethod + def validate_schema(cls, tx): + """Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER` + transaction, all the validations for `CREATE` transaction should be inherited + """ + _validate_schema(TX_SCHEMA_COMMON, tx) + _validate_schema(TX_SCHEMA_TRANSFER, tx) + _validate_schema(cls.TX_SCHEMA_CUSTOM, tx) + + @classmethod + def create(cls, tx_signers, recipients, metadata=None, asset=None): + raise NotImplementedError + + @classmethod + def transfer(cls, tx_signers, recipients, metadata=None, asset=None): + raise NotImplementedError diff --git a/corechaindb/events.py b/corechaindb/events.py new file mode 100644 index 00000000..e9289317 --- /dev/null +++ b/corechaindb/events.py @@ -0,0 +1,109 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +from queue import Empty +from collections import defaultdict +from multiprocessing import Queue + + +POISON_PILL = 'POISON_PILL' + + +class EventTypes: + """Container class that holds all the possible + events BigchainDB manages. + """ + + # If you add a new Event Type, make sure to add it + # to the docs in docs/server/source/event-plugin-api.rst + ALL = ~0 + BLOCK_VALID = 1 + BLOCK_INVALID = 2 + # NEW_EVENT = 4 + # NEW_EVENT = 8 + # NEW_EVENT = 16... + + +class Event: + """An Event.""" + + def __init__(self, event_type, event_data): + """Creates a new event. + + Args: + event_type (int): the type of the event, see + :class:`~corechaindb.events.EventTypes` + event_data (obj): the data of the event. + """ + + self.type = event_type + self.data = event_data + + +class Exchange: + """Dispatch events to subscribers.""" + + def __init__(self): + self.publisher_queue = Queue() + self.started_queue = Queue() + + # Map queues> + self.queues = defaultdict(list) + + def get_publisher_queue(self): + """Get the queue used by the publisher. + + Returns: + a :class:`multiprocessing.Queue`. + """ + + return self.publisher_queue + + def get_subscriber_queue(self, event_types=None): + """Create a new queue for a specific combination of event types + and return it. + + Returns: + a :class:`multiprocessing.Queue`. + Raises: + RuntimeError if called after `run` + """ + + try: + self.started_queue.get(timeout=1) + raise RuntimeError('Cannot create a new subscriber queue while Exchange is running.') + except Empty: + pass + + if event_types is None: + event_types = EventTypes.ALL + + queue = Queue() + self.queues[event_types].append(queue) + return queue + + def dispatch(self, event): + """Given an event, send it to all the subscribers. + + Args + event (:class:`~corechaindb.events.EventTypes`): the event to + dispatch to all the subscribers. + """ + + for event_types, queues in self.queues.items(): + if event.type & event_types: + for queue in queues: + queue.put(event) + + def run(self): + """Start the exchange""" + self.started_queue.put('STARTED') + + while True: + event = self.publisher_queue.get() + if event == POISON_PILL: + return + else: + self.dispatch(event) diff --git a/corechaindb/exceptions.py b/corechaindb/exceptions.py new file mode 100644 index 00000000..51dc4c7d --- /dev/null +++ b/corechaindb/exceptions.py @@ -0,0 +1,12 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + + +class BigchainDBError(Exception): + """Base class for BigchainDB exceptions.""" + + +class CriticalDoubleSpend(BigchainDBError): + """Data integrity error that requires attention""" diff --git a/corechaindb/fastquery.py b/corechaindb/fastquery.py new file mode 100644 index 00000000..82ffcadb --- /dev/null +++ b/corechaindb/fastquery.py @@ -0,0 +1,50 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +from corechaindb.utils import condition_details_has_owner +from corechaindb.backend import query +from corechaindb.common.transaction import TransactionLink + + +class FastQuery(): + """Database queries that join on block results from a single node.""" + + def __init__(self, connection): + self.connection = connection + + def get_outputs_by_public_key(self, public_key): + """Get outputs for a public key""" + txs = list(query.get_owned_ids(self.connection, public_key)) + return [TransactionLink(tx['id'], index) + for tx in txs + for index, output in enumerate(tx['outputs']) + if condition_details_has_owner(output['condition']['details'], + public_key)] + + def filter_spent_outputs(self, outputs): + """Remove outputs that have been spent + + Args: + outputs: list of TransactionLink + """ + links = [o.to_dict() for o in outputs] + txs = list(query.get_spending_transactions(self.connection, links)) + spends = {TransactionLink.from_dict(input_['fulfills']) + for tx in txs + for input_ in tx['inputs']} + return [ff for ff in outputs if ff not in spends] + + def filter_unspent_outputs(self, outputs): + """Remove outputs that have not been spent + + Args: + outputs: list of TransactionLink + """ + links = [o.to_dict() for o in outputs] + txs = list(query.get_spending_transactions(self.connection, links)) + spends = {TransactionLink.from_dict(input_['fulfills']) + for tx in txs + for input_ in tx['inputs']} + return [ff for ff in outputs if ff in spends] diff --git a/corechaindb/lib.py b/corechaindb/lib.py new file mode 100644 index 00000000..b69f7f86 --- /dev/null +++ b/corechaindb/lib.py @@ -0,0 +1,514 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Module containing main contact points with Tendermint and +MongoDB. + +""" +import logging +from collections import namedtuple +from uuid import uuid4 + +import rapidjson + +try: + from hashlib import sha3_256 +except ImportError: + # NOTE: needed for Python < 3.6 + from sha3 import sha3_256 + +import requests + +import corechaindb +from corechaindb import backend, config_utils, fastquery +from corechaindb.models import Transaction +from corechaindb.common.exceptions import (SchemaValidationError, + ValidationError, + DoubleSpend) +from corechaindb.common.transaction_mode_types import (BROADCAST_TX_COMMIT, + BROADCAST_TX_ASYNC, + BROADCAST_TX_SYNC) +from corechaindb.tendermint_utils import encode_transaction, merkleroot +from corechaindb import exceptions as core_exceptions +from corechaindb.validation import BaseValidationRules + + +logger = logging.getLogger(__name__) + + +class BigchainDB(object): + """Bigchain API + + Create, read, sign, write transactions to the database + """ + + def __init__(self, connection=None): + """Initialize the Bigchain instance + + A Bigchain instance has several configuration parameters (e.g. host). + If a parameter value is passed as an argument to the Bigchain + __init__ method, then that is the value it will have. + Otherwise, the parameter value will come from an environment variable. + If that environment variable isn't set, then the value + will come from the local configuration file. And if that variable + isn't in the local configuration file, then the parameter will have + its default value (defined in corechaindb.__init__). + + Args: + connection (:class:`~corechaindb.backend.connection.Connection`): + A connection to the database. + """ + config_utils.autoconfigure() + self.mode_commit = BROADCAST_TX_COMMIT + self.mode_list = (BROADCAST_TX_ASYNC, + BROADCAST_TX_SYNC, + self.mode_commit) + self.tendermint_host = corechaindb.config['tendermint']['host'] + self.tendermint_port = corechaindb.config['tendermint']['port'] + self.endpoint = 'http://{}:{}/'.format(self.tendermint_host, self.tendermint_port) + + validationPlugin = corechaindb.config.get('validation_plugin') + + if validationPlugin: + self.validation = config_utils.load_validation_plugin(validationPlugin) + else: + self.validation = BaseValidationRules + + self.connection = connection if connection else backend.connect(**corechaindb.config['database']) + + def post_transaction(self, transaction, mode): + """Submit a valid transaction to the mempool.""" + if not mode or mode not in self.mode_list: + raise ValidationError('Mode must be one of the following {}.' + .format(', '.join(self.mode_list))) + + tx_dict = transaction.tx_dict if transaction.tx_dict else transaction.to_dict() + payload = { + 'method': mode, + 'jsonrpc': '2.0', + 'params': [encode_transaction(tx_dict)], + 'id': str(uuid4()) + } + # TODO: handle connection errors! + return requests.post(self.endpoint, json=payload) + + def write_transaction(self, transaction, mode): + # This method offers backward compatibility with the Web API. + """Submit a valid transaction to the mempool.""" + response = self.post_transaction(transaction, mode) + return self._process_post_response(response.json(), mode) + + def _process_post_response(self, response, mode): + logger.debug(response) + + error = response.get('error') + if error: + status_code = 500 + message = error.get('message', 'Internal Error') + data = error.get('data', '') + + if 'Tx already exists in cache' in data: + status_code = 400 + + return (status_code, message + ' - ' + data) + + result = response['result'] + if mode == self.mode_commit: + check_tx_code = result.get('check_tx', {}).get('code', 0) + deliver_tx_code = result.get('deliver_tx', {}).get('code', 0) + error_code = check_tx_code or deliver_tx_code + else: + error_code = result.get('code', 0) + + if error_code: + return (500, 'Transaction validation failed') + + return (202, '') + + def store_bulk_transactions(self, transactions): + txns = [] + assets = [] + txn_metadatas = [] + for t in transactions: + transaction = t.tx_dict if t.tx_dict else rapidjson.loads(rapidjson.dumps(t.to_dict())) + if transaction['operation'] == t.CREATE: + asset = transaction.pop('asset') + asset['id'] = transaction['id'] + assets.append(asset) + + metadata = transaction.pop('metadata') + txn_metadatas.append({'id': transaction['id'], + 'metadata': metadata}) + txns.append(transaction) + + backend.query.store_metadatas(self.connection, txn_metadatas) + if assets: + backend.query.store_assets(self.connection, assets) + return backend.query.store_transactions(self.connection, txns) + + def delete_transactions(self, txs): + return backend.query.delete_transactions(self.connection, txs) + + def update_utxoset(self, transaction): + """Update the UTXO set given ``transaction``. That is, remove + the outputs that the given ``transaction`` spends, and add the + outputs that the given ``transaction`` creates. + + Args: + transaction (:obj:`~corechaindb.models.Transaction`): A new + transaction incoming into the system for which the UTXO + set needs to be updated. + """ + spent_outputs = [ + spent_output for spent_output in transaction.spent_outputs + ] + if spent_outputs: + self.delete_unspent_outputs(*spent_outputs) + self.store_unspent_outputs( + *[utxo._asdict() for utxo in transaction.unspent_outputs] + ) + + def store_unspent_outputs(self, *unspent_outputs): + """Store the given ``unspent_outputs`` (utxos). + + Args: + *unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable + length tuple or list of unspent outputs. + """ + if unspent_outputs: + return backend.query.store_unspent_outputs( + self.connection, *unspent_outputs) + + def get_utxoset_merkle_root(self): + """Returns the merkle root of the utxoset. This implies that + the utxoset is first put into a merkle tree. + + For now, the merkle tree and its root will be computed each + time. This obviously is not efficient and a better approach + that limits the repetition of the same computation when + unnecesary should be sought. For instance, future optimizations + could simply re-compute the branches of the tree that were + affected by a change. + + The transaction hash (id) and output index should be sufficient + to uniquely identify a utxo, and consequently only that + information from a utxo record is needed to compute the merkle + root. Hence, each node of the merkle tree should contain the + tuple (txid, output_index). + + .. important:: The leaves of the tree will need to be sorted in + some kind of lexicographical order. + + Returns: + str: Merkle root in hexadecimal form. + """ + utxoset = backend.query.get_unspent_outputs(self.connection) + # TODO Once ready, use the already pre-computed utxo_hash field. + # See common/transactions.py for details. + hashes = [ + sha3_256( + '{}{}'.format(utxo['transaction_id'], utxo['output_index']).encode() + ).digest() for utxo in utxoset + ] + # TODO Notice the sorted call! + return merkleroot(sorted(hashes)) + + def get_unspent_outputs(self): + """Get the utxoset. + + Returns: + generator of unspent_outputs. + """ + cursor = backend.query.get_unspent_outputs(self.connection) + return (record for record in cursor) + + def delete_unspent_outputs(self, *unspent_outputs): + """Deletes the given ``unspent_outputs`` (utxos). + + Args: + *unspent_outputs (:obj:`tuple` of :obj:`dict`): Variable + length tuple or list of unspent outputs. + """ + if unspent_outputs: + return backend.query.delete_unspent_outputs( + self.connection, *unspent_outputs) + + def is_committed(self, transaction_id): + transaction = backend.query.get_transaction(self.connection, transaction_id) + return bool(transaction) + + def get_transaction(self, transaction_id): + transaction = backend.query.get_transaction(self.connection, transaction_id) + + if transaction: + asset = backend.query.get_asset(self.connection, transaction_id) + metadata = backend.query.get_metadata(self.connection, [transaction_id]) + if asset: + transaction['asset'] = asset + + if 'metadata' not in transaction: + metadata = metadata[0] if metadata else None + if metadata: + metadata = metadata.get('metadata') + + transaction.update({'metadata': metadata}) + + transaction = Transaction.from_dict(transaction) + + return transaction + + def get_transactions(self, txn_ids): + return backend.query.get_transactions(self.connection, txn_ids) + + def get_transactions_filtered(self, asset_id, operation=None, last_tx=None): + """Get a list of transactions filtered on some criteria + """ + txids = backend.query.get_txids_filtered(self.connection, asset_id, + operation, last_tx) + for txid in txids: + yield self.get_transaction(txid) + + def get_outputs_filtered(self, owner, spent=None): + """Get a list of output links filtered on some criteria + + Args: + owner (str): base58 encoded public_key. + spent (bool): If ``True`` return only the spent outputs. If + ``False`` return only unspent outputs. If spent is + not specified (``None``) return all outputs. + + Returns: + :obj:`list` of TransactionLink: list of ``txid`` s and ``output`` s + pointing to another transaction's condition + """ + outputs = self.fastquery.get_outputs_by_public_key(owner) + if spent is None: + return outputs + elif spent is True: + return self.fastquery.filter_unspent_outputs(outputs) + elif spent is False: + return self.fastquery.filter_spent_outputs(outputs) + + def get_spent(self, txid, output, current_transactions=[]): + transactions = backend.query.get_spent(self.connection, txid, + output) + transactions = list(transactions) if transactions else [] + if len(transactions) > 1: + raise core_exceptions.CriticalDoubleSpend( + '`{}` was spent more than once. There is a problem' + ' with the chain'.format(txid)) + + current_spent_transactions = [] + for ctxn in current_transactions: + for ctxn_input in ctxn.inputs: + if ctxn_input.fulfills and\ + ctxn_input.fulfills.txid == txid and\ + ctxn_input.fulfills.output == output: + current_spent_transactions.append(ctxn) + + transaction = None + if len(transactions) + len(current_spent_transactions) > 1: + raise DoubleSpend('tx "{}" spends inputs twice'.format(txid)) + elif transactions: + transaction = Transaction.from_db(self, transactions[0]) + elif current_spent_transactions: + transaction = current_spent_transactions[0] + + return transaction + + def store_block(self, block): + """Create a new block.""" + + return backend.query.store_block(self.connection, block) + + def get_latest_block(self): + """Get the block with largest height.""" + + return backend.query.get_latest_block(self.connection) + + def get_block(self, block_id): + """Get the block with the specified `block_id`. + + Returns the block corresponding to `block_id` or None if no match is + found. + + Args: + block_id (int): block id of the block to get. + """ + + block = backend.query.get_block(self.connection, block_id) + latest_block = self.get_latest_block() + latest_block_height = latest_block['height'] if latest_block else 0 + + if not block and block_id > latest_block_height: + return + + result = {'height': block_id, + 'transactions': []} + + if block: + transactions = backend.query.get_transactions(self.connection, block['transactions']) + result['transactions'] = [t.to_dict() for t in Transaction.from_db(self, transactions)] + + return result + + def get_block_containing_tx(self, txid): + """Retrieve the list of blocks (block ids) containing a + transaction with transaction id `txid` + + Args: + txid (str): transaction id of the transaction to query + + Returns: + Block id list (list(int)) + """ + blocks = list(backend.query.get_block_with_transaction(self.connection, txid)) + if len(blocks) > 1: + logger.critical('Transaction id %s exists in multiple blocks', txid) + + return [block['height'] for block in blocks] + + def validate_transaction(self, tx, current_transactions=[]): + """Validate a transaction against the current status of the database.""" + + transaction = tx + + # CLEANUP: The conditional below checks for transaction in dict format. + # It would be better to only have a single format for the transaction + # throught the code base. + if isinstance(transaction, dict): + try: + transaction = Transaction.from_dict(tx) + except SchemaValidationError as e: + logger.warning('Invalid transaction schema: %s', e.__cause__.message) + return False + except ValidationError as e: + logger.warning('Invalid transaction (%s): %s', type(e).__name__, e) + return False + return transaction.validate(self, current_transactions) + + def is_valid_transaction(self, tx, current_transactions=[]): + # NOTE: the function returns the Transaction object in case + # the transaction is valid + try: + return self.validate_transaction(tx, current_transactions) + except ValidationError as e: + logger.warning('Invalid transaction (%s): %s', type(e).__name__, e) + return False + + def text_search(self, search, *, limit=0, table='assets'): + """Return an iterator of assets that match the text search + + Args: + search (str): Text search string to query the text index + limit (int, optional): Limit the number of returned documents. + + Returns: + iter: An iterator of assets that match the text search. + """ + return backend.query.text_search(self.connection, search, limit=limit, + table=table) + + def get_assets(self, asset_ids): + """Return a list of assets that match the asset_ids + + Args: + asset_ids (:obj:`list` of :obj:`str`): A list of asset_ids to + retrieve from the database. + + Returns: + list: The list of assets returned from the database. + """ + return backend.query.get_assets(self.connection, asset_ids) + + def get_metadata(self, txn_ids): + """Return a list of metadata that match the transaction ids (txn_ids) + + Args: + txn_ids (:obj:`list` of :obj:`str`): A list of txn_ids to + retrieve from the database. + + Returns: + list: The list of metadata returned from the database. + """ + return backend.query.get_metadata(self.connection, txn_ids) + + @property + def fastquery(self): + return fastquery.FastQuery(self.connection) + + def get_validator_change(self, height=None): + return backend.query.get_validator_set(self.connection, height) + + def get_validators(self, height=None): + result = self.get_validator_change(height) + return [] if result is None else result['validators'] + + def get_election(self, election_id): + return backend.query.get_election(self.connection, election_id) + + def get_pre_commit_state(self): + return backend.query.get_pre_commit_state(self.connection) + + def store_pre_commit_state(self, state): + return backend.query.store_pre_commit_state(self.connection, state) + + def store_validator_set(self, height, validators): + """Store validator set at a given `height`. + NOTE: If the validator set already exists at that `height` then an + exception will be raised. + """ + return backend.query.store_validator_set(self.connection, {'height': height, + 'validators': validators}) + + def delete_validator_set(self, height): + return backend.query.delete_validator_set(self.connection, height) + + def store_abci_chain(self, height, chain_id, is_synced=True): + return backend.query.store_abci_chain(self.connection, height, + chain_id, is_synced) + + def delete_abci_chain(self, height): + return backend.query.delete_abci_chain(self.connection, height) + + def get_latest_abci_chain(self): + return backend.query.get_latest_abci_chain(self.connection) + + def migrate_abci_chain(self): + """Generate and record a new ABCI chain ID. New blocks are not + accepted until we receive an InitChain ABCI request with + the matching chain ID and validator set. + + Chain ID is generated based on the current chain and height. + `chain-X` => `chain-X-migrated-at-height-5`. + `chain-X-migrated-at-height-5` => `chain-X-migrated-at-height-21`. + + If there is no known chain (we are at genesis), the function returns. + """ + latest_chain = self.get_latest_abci_chain() + if latest_chain is None: + return + + block = self.get_latest_block() + + suffix = '-migrated-at-height-' + chain_id = latest_chain['chain_id'] + block_height_str = str(block['height']) + new_chain_id = chain_id.split(suffix)[0] + suffix + block_height_str + + self.store_abci_chain(block['height'] + 1, new_chain_id, False) + + def store_election(self, election_id, height, is_concluded): + return backend.query.store_election(self.connection, election_id, + height, is_concluded) + + def store_elections(self, elections): + return backend.query.store_elections(self.connection, elections) + + def delete_elections(self, height): + return backend.query.delete_elections(self.connection, height) + + +Block = namedtuple('Block', ('app_hash', 'height', 'transactions')) diff --git a/corechaindb/log.py b/corechaindb/log.py new file mode 100644 index 00000000..6faf7553 --- /dev/null +++ b/corechaindb/log.py @@ -0,0 +1,130 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import corechaindb +import logging + +from corechaindb.common.exceptions import ConfigurationError +from logging.config import dictConfig as set_logging_config +import os + + +DEFAULT_LOG_DIR = os.getcwd() + +DEFAULT_LOGGING_CONFIG = { + 'version': 1, + 'disable_existing_loggers': False, + 'formatters': { + 'console': { + 'class': 'logging.Formatter', + 'format': ('[%(asctime)s] [%(levelname)s] (%(name)s) ' + '%(message)s (%(processName)-10s - pid: %(process)d)'), + 'datefmt': '%Y-%m-%d %H:%M:%S', + }, + 'file': { + 'class': 'logging.Formatter', + 'format': ('[%(asctime)s] [%(levelname)s] (%(name)s) ' + '%(message)s (%(processName)-10s - pid: %(process)d)'), + 'datefmt': '%Y-%m-%d %H:%M:%S', + } + }, + 'handlers': { + 'console': { + 'class': 'logging.StreamHandler', + 'formatter': 'console', + 'level': logging.INFO, + }, + 'file': { + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': os.path.join(DEFAULT_LOG_DIR, 'corechaindb.log'), + 'mode': 'w', + 'maxBytes': 209715200, + 'backupCount': 5, + 'formatter': 'file', + 'level': logging.INFO, + }, + 'errors': { + 'class': 'logging.handlers.RotatingFileHandler', + 'filename': os.path.join(DEFAULT_LOG_DIR, 'corechaindb-errors.log'), + 'mode': 'w', + 'maxBytes': 209715200, + 'backupCount': 5, + 'formatter': 'file', + 'level': logging.ERROR, + } + }, + 'loggers': {}, + 'root': { + 'level': logging.DEBUG, + 'handlers': ['console', 'file', 'errors'], + }, +} + + +def _normalize_log_level(level): + try: + return level.upper() + except AttributeError as exc: + raise ConfigurationError('Log level must be a string!') from exc + + +def setup_logging(): + """Function to configure log hadlers. + + .. important:: + + Configuration, if needed, should be applied before invoking this + decorator, as starting the subscriber process for logging will + configure the root logger for the child process based on the + state of :obj:`corechaindb.config` at the moment this decorator + is invoked. + + """ + + logging_configs = DEFAULT_LOGGING_CONFIG + new_logging_configs = corechaindb.config['log'] + + if 'file' in new_logging_configs: + filename = new_logging_configs['file'] + logging_configs['handlers']['file']['filename'] = filename + + if 'error_file' in new_logging_configs: + error_filename = new_logging_configs['error_file'] + logging_configs['handlers']['errors']['filename'] = error_filename + + if 'level_console' in new_logging_configs: + level = _normalize_log_level(new_logging_configs['level_console']) + logging_configs['handlers']['console']['level'] = level + + if 'level_logfile' in new_logging_configs: + level = _normalize_log_level(new_logging_configs['level_logfile']) + logging_configs['handlers']['file']['level'] = level + + if 'fmt_console' in new_logging_configs: + fmt = new_logging_configs['fmt_console'] + logging_configs['formatters']['console']['format'] = fmt + + if 'fmt_logfile' in new_logging_configs: + fmt = new_logging_configs['fmt_logfile'] + logging_configs['formatters']['file']['format'] = fmt + + if 'datefmt_console' in new_logging_configs: + fmt = new_logging_configs['datefmt_console'] + logging_configs['formatters']['console']['datefmt'] = fmt + + if 'datefmt_logfile' in new_logging_configs: + fmt = new_logging_configs['datefmt_logfile'] + logging_configs['formatters']['file']['datefmt'] = fmt + + log_levels = new_logging_configs.get('granular_levels', {}) + + for logger_name, level in log_levels.items(): + level = _normalize_log_level(level) + try: + logging_configs['loggers'][logger_name]['level'] = level + except KeyError: + logging_configs['loggers'][logger_name] = {'level': level} + + set_logging_config(logging_configs) diff --git a/corechaindb/migrations/__init__.py b/corechaindb/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/corechaindb/migrations/chain_migration_election.py b/corechaindb/migrations/chain_migration_election.py new file mode 100644 index 00000000..1861bc69 --- /dev/null +++ b/corechaindb/migrations/chain_migration_election.py @@ -0,0 +1,48 @@ +import json + +from corechaindb.common.schema import TX_SCHEMA_CHAIN_MIGRATION_ELECTION +from corechaindb.elections.election import Election + + +class ChainMigrationElection(Election): + + OPERATION = 'CHAIN_MIGRATION_ELECTION' + CREATE = OPERATION + ALLOWED_OPERATIONS = (OPERATION,) + TX_SCHEMA_CUSTOM = TX_SCHEMA_CHAIN_MIGRATION_ELECTION + + def has_concluded(self, corechaindb, *args, **kwargs): + chain = corechaindb.get_latest_abci_chain() + if chain is not None and not chain['is_synced']: + # do not conclude the migration election if + # there is another migration in progress + return False + + return super().has_concluded(corechaindb, *args, **kwargs) + + def on_approval(self, bigchain, *args, **kwargs): + bigchain.migrate_abci_chain() + + def show_election(self, bigchain): + output = super().show_election(bigchain) + chain = bigchain.get_latest_abci_chain() + if chain is None or chain['is_synced']: + return output + + output += f'\nchain_id={chain["chain_id"]}' + block = bigchain.get_latest_block() + output += f'\napp_hash={block["app_hash"]}' + validators = [ + { + 'pub_key': { + 'type': 'tendermint/PubKeyEd25519', + 'value': k, + }, + 'power': v, + } for k, v in self.get_validators(bigchain).items() + ] + output += f'\nvalidators={json.dumps(validators, indent=4)}' + return output + + def on_rollback(self, bigchain, new_height): + bigchain.delete_abci_chain(new_height) diff --git a/corechaindb/models.py b/corechaindb/models.py new file mode 100644 index 00000000..e187fbc0 --- /dev/null +++ b/corechaindb/models.py @@ -0,0 +1,75 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +from corechaindb.backend.schema import validate_language_key +from corechaindb.common.exceptions import (InvalidSignature, + DuplicateTransaction) +from corechaindb.common.schema import validate_transaction_schema +from corechaindb.common.transaction import Transaction +from corechaindb.common.utils import (validate_txn_obj, validate_key) + + +class Transaction(Transaction): + ASSET = 'asset' + METADATA = 'metadata' + DATA = 'data' + + def validate(self, bigchain, current_transactions=[]): + """Validate transaction spend + Args: + bigchain (BigchainDB): an instantiated corechaindb.BigchainDB object. + Returns: + The transaction (Transaction) if the transaction is valid else it + raises an exception describing the reason why the transaction is + invalid. + Raises: + ValidationError: If the transaction is invalid + """ + input_conditions = [] + + if self.operation == Transaction.CREATE: + duplicates = any(txn for txn in current_transactions if txn.id == self.id) + if bigchain.is_committed(self.id) or duplicates: + raise DuplicateTransaction('transaction `{}` already exists' + .format(self.id)) + + if not self.inputs_valid(input_conditions): + raise InvalidSignature('Transaction signature is invalid.') + + elif self.operation == Transaction.TRANSFER: + self.validate_transfer_inputs(bigchain, current_transactions) + + return self + + @classmethod + def from_dict(cls, tx_body): + return super().from_dict(tx_body, False) + + @classmethod + def validate_schema(cls, tx_body): + validate_transaction_schema(tx_body) + validate_txn_obj(cls.ASSET, tx_body[cls.ASSET], cls.DATA, validate_key) + validate_txn_obj(cls.METADATA, tx_body, cls.METADATA, validate_key) + validate_language_key(tx_body[cls.ASSET], cls.DATA) + validate_language_key(tx_body, cls.METADATA) + + +class FastTransaction: + """A minimal wrapper around a transaction dictionary. This is useful for + when validation is not required but a routine expects something that looks + like a transaction, for example during block creation. + + Note: immutability could also be provided + """ + + def __init__(self, tx_dict): + self.data = tx_dict + + @property + def id(self): + return self.data['id'] + + def to_dict(self): + return self.data diff --git a/corechaindb/parallel_validation.py b/corechaindb/parallel_validation.py new file mode 100644 index 00000000..0168bbcb --- /dev/null +++ b/corechaindb/parallel_validation.py @@ -0,0 +1,124 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import multiprocessing as mp +from collections import defaultdict + +from corechaindb import App, BigchainDB +from corechaindb.tendermint_utils import decode_transaction +from abci import CodeTypeOk + + +class ParallelValidationApp(App): + def __init__(self, corechaindb=None, events_queue=None, abci=None): + super().__init__(corechaindb, events_queue, abci=abci) + self.parallel_validator = ParallelValidator() + self.parallel_validator.start() + + def check_tx(self, raw_transaction): + return self.abci.ResponseCheckTx(code=CodeTypeOk) + + def deliver_tx(self, raw_transaction): + self.parallel_validator.validate(raw_transaction) + return self.abci.ResponseDeliverTx(code=CodeTypeOk) + + def end_block(self, request_end_block): + result = self.parallel_validator.result(timeout=30) + for transaction in result: + if transaction: + self.block_txn_ids.append(transaction.id) + self.block_transactions.append(transaction) + + return super().end_block(request_end_block) + + +RESET = 'reset' +EXIT = 'exit' + + +class ParallelValidator: + def __init__(self, number_of_workers=mp.cpu_count()): + self.number_of_workers = number_of_workers + self.transaction_index = 0 + self.routing_queues = [mp.Queue() for _ in range(self.number_of_workers)] + self.workers = [] + self.results_queue = mp.Queue() + + def start(self): + for routing_queue in self.routing_queues: + worker = ValidationWorker(routing_queue, self.results_queue) + process = mp.Process(target=worker.run) + process.start() + self.workers.append(process) + + def stop(self): + for routing_queue in self.routing_queues: + routing_queue.put(EXIT) + + def validate(self, raw_transaction): + dict_transaction = decode_transaction(raw_transaction) + index = int(dict_transaction['id'], 16) % self.number_of_workers + self.routing_queues[index].put((self.transaction_index, dict_transaction)) + self.transaction_index += 1 + + def result(self, timeout=None): + result_buffer = [None] * self.transaction_index + for _ in range(self.transaction_index): + index, transaction = self.results_queue.get(timeout=timeout) + result_buffer[index] = transaction + self.transaction_index = 0 + for routing_queue in self.routing_queues: + routing_queue.put(RESET) + return result_buffer + + +class ValidationWorker: + """Run validation logic in a loop. This Worker is suitable for a Process + life: no thrills, just a queue to get some values, and a queue to return results. + + Note that a worker is expected to validate multiple transactions in + multiple rounds, and it needs to keep in memory all transactions already + validated, until a new round starts. To trigger a new round of validation, + a ValidationWorker expects a `RESET` message. To exit the infinite loop the + worker is in, it expects an `EXIT` message. + """ + + def __init__(self, in_queue, results_queue): + self.in_queue = in_queue + self.results_queue = results_queue + self.corechaindb = BigchainDB() + self.reset() + + def reset(self): + # We need a place to store already validated transactions, + # in case of dependant transactions in the same block. + # `validated_transactions` maps an `asset_id` with the list + # of all other transactions sharing the same asset. + self.validated_transactions = defaultdict(list) + + def validate(self, dict_transaction): + try: + asset_id = dict_transaction['asset']['id'] + except KeyError: + asset_id = dict_transaction['id'] + + transaction = self.corechaindb.is_valid_transaction( + dict_transaction, + self.validated_transactions[asset_id]) + + if transaction: + self.validated_transactions[asset_id].append(transaction) + return transaction + + def run(self): + while True: + message = self.in_queue.get() + if message == RESET: + self.reset() + elif message == EXIT: + return + else: + index, transaction = message + self.results_queue.put((index, self.validate(transaction))) diff --git a/corechaindb/rename.sh b/corechaindb/rename.sh new file mode 100644 index 00000000..cf516fb3 --- /dev/null +++ b/corechaindb/rename.sh @@ -0,0 +1,14 @@ +#!/bin/zsh + +# Replace 'corechaindb' with 'corechaindb' in file contents, excluding .git directory +find . -type f ! -path "./.git/*" -exec perl -i -pe 's/corechaindb/corechaindb/g' {} + + +# Rename directories, excluding .git directory +find . -depth -type d ! -path "./.git/*" -name '*corechaindb*' | while IFS= read -r dir; do + mv "$dir" "$(dirname "$dir")/$(basename "$dir" | sed 's/corechaindb/corechaindb/')" +done + +# Rename files, excluding .git directory +find . -depth -type f ! -path "./.git/*" -name '*corechaindb*' | while IFS= read -r file; do + mv "$file" "$(dirname "$file")/$(basename "$file" | sed 's/corechaindb/corechaindb/')" +done diff --git a/corechaindb/start.py b/corechaindb/start.py new file mode 100644 index 00000000..dc67ae6e --- /dev/null +++ b/corechaindb/start.py @@ -0,0 +1,90 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import logging +import setproctitle + +from abci import TmVersion, ABCI + +import corechaindb +from corechaindb.lib import BigchainDB +from corechaindb.core import App +from corechaindb.parallel_validation import ParallelValidationApp +from corechaindb.web import server, websocket_server +from corechaindb.events import Exchange, EventTypes +from corechaindb.utils import Process + + +logger = logging.getLogger(__name__) + +BANNER = """ +**************************************************************************** +* * +* BigchainDB 2.2.2 * +* codename "jumping sloth" * +* Initialization complete. BigchainDB Server is ready and waiting. * +* * +* You can send HTTP requests via the HTTP API documented in the * +* BigchainDB Server docs at: * +* https://corechaindb.com/http-api * +* * +* Listening to client connections on: {:<15} * +* * +**************************************************************************** +""" + + +def start(args): + # Exchange object for event stream api + logger.info('Starting BigchainDB') + exchange = Exchange() + # start the web api + app_server = server.create_server( + settings=corechaindb.config['server'], + log_config=corechaindb.config['log'], + corechaindb_factory=BigchainDB) + p_webapi = Process(name='corechaindb_webapi', target=app_server.run, daemon=True) + p_webapi.start() + + logger.info(BANNER.format(corechaindb.config['server']['bind'])) + + # start websocket server + p_websocket_server = Process(name='corechaindb_ws', + target=websocket_server.start, + daemon=True, + args=(exchange.get_subscriber_queue(EventTypes.BLOCK_VALID),)) + p_websocket_server.start() + + p_exchange = Process(name='corechaindb_exchange', target=exchange.run, daemon=True) + p_exchange.start() + + # We need to import this after spawning the web server + # because import ABCIServer will monkeypatch all sockets + # for gevent. + from abci.server import ABCIServer + + setproctitle.setproctitle('corechaindb') + + # Start the ABCIServer + abci = ABCI(TmVersion(corechaindb.config['tendermint']['version'])) + if args.experimental_parallel_validation: + app = ABCIServer( + app=ParallelValidationApp( + abci=abci.types, + events_queue=exchange.get_publisher_queue(), + ) + ) + else: + app = ABCIServer( + app=App( + abci=abci.types, + events_queue=exchange.get_publisher_queue(), + ) + ) + app.run() + + +if __name__ == '__main__': + start() diff --git a/corechaindb/tendermint_utils.py b/corechaindb/tendermint_utils.py new file mode 100644 index 00000000..cb8b870a --- /dev/null +++ b/corechaindb/tendermint_utils.py @@ -0,0 +1,100 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import base64 +import hashlib +import json +from binascii import hexlify + +try: + from hashlib import sha3_256 +except ImportError: + from sha3 import sha3_256 + + +def encode_transaction(value): + """Encode a transaction (dict) to Base64.""" + + return base64.b64encode(json.dumps(value).encode('utf8')).decode('utf8') + + +def decode_transaction(raw): + """Decode a transaction from bytes to a dict.""" + + return json.loads(raw.decode('utf8')) + + +def decode_transaction_base64(value): + """Decode a transaction from Base64.""" + + return json.loads(base64.b64decode(value.encode('utf8')).decode('utf8')) + + +def calculate_hash(key_list): + if not key_list: + return '' + + full_hash = sha3_256() + for key in key_list: + full_hash.update(key.encode('utf8')) + + return full_hash.hexdigest() + + +def merkleroot(hashes): + """Computes the merkle root for a given list. + + Args: + hashes (:obj:`list` of :obj:`bytes`): The leaves of the tree. + + Returns: + str: Merkle root in hexadecimal form. + + """ + # XXX TEMPORARY -- MUST REVIEW and possibly CHANGE + # The idea here is that the UTXO SET would be empty and this function + # would be invoked to compute the merkle root, and since there is nothing, + # i.e. an empty list, then the hash of the empty string is returned. + # This seems too easy but maybe that is good enough? TO REVIEW! + if not hashes: + return sha3_256(b'').hexdigest() + # XXX END TEMPORARY -- MUST REVIEW ... + if len(hashes) == 1: + return hexlify(hashes[0]).decode() + if len(hashes) % 2 == 1: + hashes.append(hashes[-1]) + parent_hashes = [ + sha3_256(hashes[i] + hashes[i+1]).digest() + for i in range(0, len(hashes)-1, 2) + ] + return merkleroot(parent_hashes) + + +def public_key64_to_address(base64_public_key): + """Note this only compatible with Tendermint 0.19.x""" + ed25519_public_key = public_key_from_base64(base64_public_key) + encoded_public_key = amino_encoded_public_key(ed25519_public_key) + return hashlib.new('ripemd160', encoded_public_key).hexdigest().upper() + + +def public_key_from_base64(base64_public_key): + return key_from_base64(base64_public_key) + + +def key_from_base64(base64_key): + return base64.b64decode(base64_key).hex().upper() + + +def public_key_to_base64(ed25519_public_key): + return key_to_base64(ed25519_public_key) + + +def key_to_base64(ed25519_key): + ed25519_key = bytes.fromhex(ed25519_key) + return base64.b64encode(ed25519_key).decode('utf-8') + + +def amino_encoded_public_key(ed25519_public_key): + return bytes.fromhex('1624DE6220{}'.format(ed25519_public_key)) diff --git a/corechaindb/upsert_validator/__init__.py b/corechaindb/upsert_validator/__init__.py new file mode 100644 index 00000000..346fc234 --- /dev/null +++ b/corechaindb/upsert_validator/__init__.py @@ -0,0 +1,7 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + + +from corechaindb.upsert_validator.validator_election import ValidatorElection # noqa diff --git a/corechaindb/upsert_validator/validator_election.py b/corechaindb/upsert_validator/validator_election.py new file mode 100644 index 00000000..ffd1a1ac --- /dev/null +++ b/corechaindb/upsert_validator/validator_election.py @@ -0,0 +1,68 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +from corechaindb.common.exceptions import InvalidPowerChange +from corechaindb.elections.election import Election +from corechaindb.common.schema import TX_SCHEMA_VALIDATOR_ELECTION +from .validator_utils import (new_validator_set, encode_validator, validate_asset_public_key) + + +class ValidatorElection(Election): + + OPERATION = 'VALIDATOR_ELECTION' + # NOTE: this transaction class extends create so the operation inheritence is achieved + # by renaming CREATE to VALIDATOR_ELECTION + CREATE = OPERATION + ALLOWED_OPERATIONS = (OPERATION,) + TX_SCHEMA_CUSTOM = TX_SCHEMA_VALIDATOR_ELECTION + + def validate(self, bigchain, current_transactions=[]): + """For more details refer BEP-21: https://github.com/corechaindb/BEPs/tree/master/21 + """ + + current_validators = self.get_validators(bigchain) + + super(ValidatorElection, self).validate(bigchain, current_transactions=current_transactions) + + # NOTE: change more than 1/3 of the current power is not allowed + if self.asset['data']['power'] >= (1/3)*sum(current_validators.values()): + raise InvalidPowerChange('`power` change must be less than 1/3 of total power') + + return self + + @classmethod + def validate_schema(cls, tx): + super(ValidatorElection, cls).validate_schema(tx) + validate_asset_public_key(tx['asset']['data']['public_key']) + + def has_concluded(self, bigchain, *args, **kwargs): + latest_block = bigchain.get_latest_block() + if latest_block is not None: + latest_block_height = latest_block['height'] + latest_validator_change = bigchain.get_validator_change()['height'] + + # TODO change to `latest_block_height + 3` when upgrading to Tendermint 0.24.0. + if latest_validator_change == latest_block_height + 2: + # do not conclude the election if there is a change assigned already + return False + + return super().has_concluded(bigchain, *args, **kwargs) + + def on_approval(self, bigchain, new_height): + validator_updates = [self.asset['data']] + curr_validator_set = bigchain.get_validators(new_height) + updated_validator_set = new_validator_set(curr_validator_set, + validator_updates) + + updated_validator_set = [v for v in updated_validator_set + if v['voting_power'] > 0] + + # TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0. + bigchain.store_validator_set(new_height + 1, updated_validator_set) + return encode_validator(self.asset['data']) + + def on_rollback(self, corechaindb, new_height): + # TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0. + corechaindb.delete_validator_set(new_height + 1) diff --git a/corechaindb/upsert_validator/validator_utils.py b/corechaindb/upsert_validator/validator_utils.py new file mode 100644 index 00000000..cce9f98a --- /dev/null +++ b/corechaindb/upsert_validator/validator_utils.py @@ -0,0 +1,85 @@ +import base64 +import binascii +import codecs + +import corechaindb +from abci import types_v0_22_8, types_v0_31_5, TmVersion +from corechaindb.common.exceptions import InvalidPublicKey, BigchainDBError + + +def encode_validator(v): + ed25519_public_key = v['public_key']['value'] + # NOTE: tendermint expects public to be encoded in go-amino format + try: + version = TmVersion(corechaindb.config["tendermint"]["version"]) + except ValueError: + raise BigchainDBError('Invalid tendermint version, ' + 'check BigchainDB configuration file') + + validator_update_t, pubkey_t = { + TmVersion.v0_22_8: (types_v0_22_8.Validator, types_v0_22_8.PubKey), + TmVersion.v0_31_5: (types_v0_31_5.ValidatorUpdate, types_v0_31_5.PubKey) + }[version] + pub_key = pubkey_t(type='ed25519', data=bytes.fromhex(ed25519_public_key)) + + return validator_update_t(pub_key=pub_key, power=v['power']) + + +def decode_validator(v): + return {'public_key': {'type': 'ed25519-base64', + 'value': codecs.encode(v.pub_key.data, 'base64').decode().rstrip('\n')}, + 'voting_power': v.power} + + +def new_validator_set(validators, updates): + validators_dict = {} + for v in validators: + validators_dict[v['public_key']['value']] = v + + updates_dict = {} + for u in updates: + decoder = get_public_key_decoder(u['public_key']) + public_key64 = base64.b64encode(decoder(u['public_key']['value'])).decode('utf-8') + updates_dict[public_key64] = {'public_key': {'type': 'ed25519-base64', + 'value': public_key64}, + 'voting_power': u['power']} + + new_validators_dict = {**validators_dict, **updates_dict} + return list(new_validators_dict.values()) + + +def encode_pk_to_base16(validator): + pk = validator['public_key'] + decoder = get_public_key_decoder(pk) + public_key16 = base64.b16encode(decoder(pk['value'])).decode('utf-8') + + validator['public_key']['value'] = public_key16 + return validator + + +def validate_asset_public_key(pk): + pk_binary = pk['value'].encode('utf-8') + decoder = get_public_key_decoder(pk) + try: + pk_decoded = decoder(pk_binary) + if len(pk_decoded) != 32: + raise InvalidPublicKey('Public key should be of size 32 bytes') + + except binascii.Error: + raise InvalidPublicKey('Invalid `type` specified for public key `value`') + + +def get_public_key_decoder(pk): + encoding = pk['type'] + decoder = base64.b64decode + + if encoding == 'ed25519-base16': + decoder = base64.b16decode + elif encoding == 'ed25519-base32': + decoder = base64.b32decode + elif encoding == 'ed25519-base64': + decoder = base64.b64decode + else: + raise InvalidPublicKey('Invalid `type` specified for public key `value`') + + return decoder diff --git a/corechaindb/utils.py b/corechaindb/utils.py new file mode 100644 index 00000000..e3cf4037 --- /dev/null +++ b/corechaindb/utils.py @@ -0,0 +1,209 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import contextlib +import threading +import queue +import multiprocessing as mp +import json + +import setproctitle +from packaging import version +from corechaindb.version import __tm_supported_versions__ +from corechaindb.tendermint_utils import key_from_base64 +from corechaindb.common.crypto import key_pair_from_ed25519_key + + +class ProcessGroup(object): + + def __init__(self, concurrency=None, group=None, target=None, name=None, + args=None, kwargs=None, daemon=None): + self.concurrency = concurrency or mp.cpu_count() + self.group = group + self.target = target + self.name = name + self.args = args or () + self.kwargs = kwargs or {} + self.daemon = daemon + self.processes = [] + + def start(self): + for i in range(self.concurrency): + proc = mp.Process(group=self.group, target=self.target, + name=self.name, args=self.args, + kwargs=self.kwargs, daemon=self.daemon) + proc.start() + self.processes.append(proc) + + +class Process(mp.Process): + """Wrapper around multiprocessing.Process that uses + setproctitle to set the name of the process when running + the target task. + """ + + def run(self): + setproctitle.setproctitle(self.name) + super().run() + + +# Inspired by: +# - http://stackoverflow.com/a/24741694/597097 +def pool(builder, size, timeout=None): + """Create a pool that imposes a limit on the number of stored + instances. + + Args: + builder: a function to build an instance. + size: the size of the pool. + timeout(Optional[float]): the seconds to wait before raising + a ``queue.Empty`` exception if no instances are available + within that time. + Raises: + If ``timeout`` is defined but the request is taking longer + than the specified time, the context manager will raise + a ``queue.Empty`` exception. + + Returns: + A context manager that can be used with the ``with`` + statement. + + """ + + lock = threading.Lock() + local_pool = queue.Queue() + current_size = 0 + + @contextlib.contextmanager + def pooled(): + nonlocal current_size + instance = None + + # If we still have free slots, then we have room to create new + # instances. + if current_size < size: + with lock: + # We need to check again if we have slots available, since + # the situation might be different after acquiring the lock + if current_size < size: + current_size += 1 + instance = builder() + + # Watchout: current_size can be equal to size if the previous part of + # the function has been executed, that's why we need to check if the + # instance is None. + if instance is None: + instance = local_pool.get(timeout=timeout) + + yield instance + + local_pool.put(instance) + + return pooled + + +# TODO: Rename this function, it's handling fulfillments not conditions +def condition_details_has_owner(condition_details, owner): + """Check if the public_key of owner is in the condition details + as an Ed25519Fulfillment.public_key + + Args: + condition_details (dict): dict with condition details + owner (str): base58 public key of owner + + Returns: + bool: True if the public key is found in the condition details, False otherwise + + """ + if 'subconditions' in condition_details: + result = condition_details_has_owner(condition_details['subconditions'], owner) + if result: + return True + + elif isinstance(condition_details, list): + for subcondition in condition_details: + result = condition_details_has_owner(subcondition, owner) + if result: + return True + else: + if 'public_key' in condition_details \ + and owner == condition_details['public_key']: + return True + return False + + +class Lazy: + """Lazy objects are useful to create chains of methods to + execute later. + + A lazy object records the methods that has been called, and + replay them when the :py:meth:`run` method is called. Note that + :py:meth:`run` needs an object `instance` to replay all the + methods that have been recorded. + """ + + def __init__(self): + """Instantiate a new Lazy object.""" + self.stack = [] + + def __getattr__(self, name): + self.stack.append(name) + return self + + def __call__(self, *args, **kwargs): + self.stack.append((args, kwargs)) + return self + + def __getitem__(self, key): + self.stack.append('__getitem__') + self.stack.append(([key], {})) + return self + + def run(self, instance): + """Run the recorded chain of methods on `instance`. + + Args: + instance: an object. + """ + + last = instance + + for item in self.stack: + if isinstance(item, str): + last = getattr(last, item) + else: + last = last(*item[0], **item[1]) + + self.stack = [] + return last + + +# Load Tendermint's public and private key from the file path +def load_node_key(path): + with open(path) as json_data: + priv_validator = json.load(json_data) + priv_key = priv_validator['priv_key']['value'] + hex_private_key = key_from_base64(priv_key) + return key_pair_from_ed25519_key(hex_private_key) + + +def tendermint_version_is_compatible(running_tm_ver): + """ + Check Tendermint compatability with BigchainDB server + + :param running_tm_ver: Version number of the connected Tendermint instance + :type running_tm_ver: str + :return: True/False depending on the compatability with BigchainDB server + :rtype: bool + """ + + # Splitting because version can look like this e.g. 0.22.8-40d6dc2e + tm_ver = running_tm_ver.split('-') + if not tm_ver: + return False + for ver in __tm_supported_versions__: + if version.parse(ver) == version.parse(tm_ver[0]): + return True + return False diff --git a/corechaindb/validation.py b/corechaindb/validation.py new file mode 100644 index 00000000..35cb3b13 --- /dev/null +++ b/corechaindb/validation.py @@ -0,0 +1,25 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + + +class BaseValidationRules(): + """Base validation rules for BigchainDB. + + A validation plugin must expose a class inheriting from this one via an entry_point. + + All methods listed below must be implemented. + """ + + @staticmethod + def validate_transaction(corechaindb, transaction): + """See :meth:`corechaindb.models.Transaction.validate` + for documentation. + """ + return transaction.validate(corechaindb) + + @staticmethod + def validate_block(corechaindb, block): + """See :meth:`corechaindb.models.Block.validate` for documentation.""" + return block.validate(corechaindb) diff --git a/corechaindb/version.py b/corechaindb/version.py new file mode 100644 index 00000000..32d039d4 --- /dev/null +++ b/corechaindb/version.py @@ -0,0 +1,10 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +__version__ = '2.2.2' +__short_version__ = '2.2' + +# Supported Tendermint versions +__tm_supported_versions__ = ["0.31.5", "0.22.8"] diff --git a/corechaindb/web/__init__.py b/corechaindb/web/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/corechaindb/web/routes.py b/corechaindb/web/routes.py new file mode 100644 index 00000000..c93cd6eb --- /dev/null +++ b/corechaindb/web/routes.py @@ -0,0 +1,48 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""API routes definition""" +from flask_restful import Api +from corechaindb.web.views import ( + assets, + metadata, + blocks, + info, + transactions as tx, + outputs, + validators, +) + + +def add_routes(app): + """Add the routes to an app""" + for (prefix, routes) in API_SECTIONS: + api = Api(app, prefix=prefix) + for ((pattern, resource, *args), kwargs) in routes: + kwargs.setdefault('strict_slashes', False) + api.add_resource(resource, pattern, *args, **kwargs) + + +def r(*args, **kwargs): + return (args, kwargs) + + +ROUTES_API_V1 = [ + r('/', info.ApiV1Index), + r('assets/', assets.AssetListApi), + r('metadata/', metadata.MetadataApi), + r('blocks/', blocks.BlockApi), + r('blocks/', blocks.BlockListApi), + r('transactions/', tx.TransactionApi), + r('transactions', tx.TransactionListApi), + r('outputs/', outputs.OutputListApi), + r('validators/', validators.ValidatorsApi), +] + + +API_SECTIONS = [ + (None, [r('/', info.RootIndex)]), + ('/api/v1/', ROUTES_API_V1), +] diff --git a/corechaindb/web/server.py b/corechaindb/web/server.py new file mode 100644 index 00000000..0261179c --- /dev/null +++ b/corechaindb/web/server.py @@ -0,0 +1,118 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""This module contains basic functions to instantiate the BigchainDB API. + +The application is implemented in Flask and runs using Gunicorn. +""" + +import copy +import multiprocessing + +from flask import Flask +from flask_cors import CORS +import gunicorn.app.base + +from corechaindb import utils +from corechaindb import BigchainDB +from corechaindb.web.routes import add_routes +from corechaindb.web.strip_content_type_middleware import StripContentTypeMiddleware + + +# TODO: Figure out if we do we need all this boilerplate. +class StandaloneApplication(gunicorn.app.base.BaseApplication): + """Run a **wsgi** app wrapping it in a Gunicorn Base Application. + + Adapted from: + - http://docs.gunicorn.org/en/latest/custom.html + """ + + def __init__(self, app, *, options=None): + """Initialize a new standalone application. + + Args: + app: A wsgi Python application. + options (dict): the configuration. + + """ + self.options = options or {} + self.application = app + super().__init__() + + def load_config(self): + # find a better way to pass this such that + # the custom logger class can access it. + custom_log_config = self.options.get('custom_log_config') + self.cfg.env_orig['custom_log_config'] = custom_log_config + + config = dict((key, value) for key, value in self.options.items() + if key in self.cfg.settings and value is not None) + + config['default_proc_name'] = 'corechaindb_gunicorn' + for key, value in config.items(): + # not sure if we need the `key.lower` here, will just keep + # keep it for now. + self.cfg.set(key.lower(), value) + + def load(self): + return self.application + + +def create_app(*, debug=False, threads=1, corechaindb_factory=None): + """Return an instance of the Flask application. + + Args: + debug (bool): a flag to activate the debug mode for the app + (default: False). + threads (int): number of threads to use + Return: + an instance of the Flask application. + """ + + if not corechaindb_factory: + corechaindb_factory = BigchainDB + + app = Flask(__name__) + app.wsgi_app = StripContentTypeMiddleware(app.wsgi_app) + + CORS(app) + + app.debug = debug + + app.config['bigchain_pool'] = utils.pool(corechaindb_factory, size=threads) + + add_routes(app) + + return app + + +def create_server(settings, log_config=None, corechaindb_factory=None): + """Wrap and return an application ready to be run. + + Args: + settings (dict): a dictionary containing the settings, more info + here http://docs.gunicorn.org/en/latest/settings.html + + Return: + an initialized instance of the application. + """ + + settings = copy.deepcopy(settings) + + if not settings.get('workers'): + settings['workers'] = (multiprocessing.cpu_count() * 2) + 1 + + if not settings.get('threads'): + # Note: Threading is not recommended currently, as the frontend workload + # is largely CPU bound and parallisation across Python threads makes it + # slower. + settings['threads'] = 1 + + settings['custom_log_config'] = log_config + app = create_app(debug=settings.get('debug', False), + threads=settings['threads'], + corechaindb_factory=corechaindb_factory) + standalone = StandaloneApplication(app, options=settings) + return standalone diff --git a/corechaindb/web/strip_content_type_middleware.py b/corechaindb/web/strip_content_type_middleware.py new file mode 100644 index 00000000..c7ce61c3 --- /dev/null +++ b/corechaindb/web/strip_content_type_middleware.py @@ -0,0 +1,32 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import logging + +logger = logging.getLogger(__name__) + + +class StripContentTypeMiddleware: + """WSGI middleware to strip Content-Type header for GETs.""" + + def __init__(self, app): + """Create the new middleware. + + Args: + app: a flask application + """ + self.app = app + + def __call__(self, environ, start_response): + """Run the middleware and then call the original WSGI application.""" + + if environ['REQUEST_METHOD'] == 'GET': + try: + del environ['CONTENT_TYPE'] + except KeyError: + pass + else: + logger.debug('Remove header "Content-Type" from GET request') + return self.app(environ, start_response) diff --git a/corechaindb/web/views/__init__.py b/corechaindb/web/views/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/corechaindb/web/views/assets.py b/corechaindb/web/views/assets.py new file mode 100644 index 00000000..0acf9fb4 --- /dev/null +++ b/corechaindb/web/views/assets.py @@ -0,0 +1,55 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""This module provides the blueprint for some basic API endpoints. + +For more information please refer to the documentation: http://corechaindb.com/http-api +""" +import logging + +from flask_restful import reqparse, Resource +from flask import current_app + +from corechaindb.backend.exceptions import OperationError +from corechaindb.web.views.base import make_error + +logger = logging.getLogger(__name__) + + +class AssetListApi(Resource): + def get(self): + """API endpoint to perform a text search on the assets. + + Args: + search (str): Text search string to query the text index + limit (int, optional): Limit the number of returned documents. + + Return: + A list of assets that match the query. + """ + parser = reqparse.RequestParser() + parser.add_argument('search', type=str, required=True) + parser.add_argument('limit', type=int) + args = parser.parse_args() + + if not args['search']: + return make_error(400, 'text_search cannot be empty') + if not args['limit']: + # if the limit is not specified do not pass None to `text_search` + del args['limit'] + + pool = current_app.config['bigchain_pool'] + + with pool() as bigchain: + assets = bigchain.text_search(**args) + + try: + # This only works with MongoDB as the backend + return list(assets) + except OperationError as e: + return make_error( + 400, + '({}): {}'.format(type(e).__name__, e) + ) diff --git a/corechaindb/web/views/base.py b/corechaindb/web/views/base.py new file mode 100644 index 00000000..92f58676 --- /dev/null +++ b/corechaindb/web/views/base.py @@ -0,0 +1,46 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""Common classes and methods for API handlers +""" +import logging + +from flask import jsonify, request + +from corechaindb import config + + +logger = logging.getLogger(__name__) + + +def make_error(status_code, message=None): + if status_code == 404 and message is None: + message = 'Not found' + + response_content = {'status': status_code, 'message': message} + request_info = {'method': request.method, 'path': request.path} + request_info.update(response_content) + + logger.error('HTTP API error: %(status)s - %(method)s:%(path)s - %(message)s', request_info) + + response = jsonify(response_content) + response.status_code = status_code + return response + + +def base_ws_uri(): + """Base websocket URL that is advertised to external clients. + + Useful when the websocket URL advertised to the clients needs to be + customized (typically when running behind NAT, firewall, etc.) + """ + + config_wsserver = config['wsserver'] + + scheme = config_wsserver['advertised_scheme'] + host = config_wsserver['advertised_host'] + port = config_wsserver['advertised_port'] + + return '{}://{}:{}'.format(scheme, host, port) diff --git a/corechaindb/web/views/blocks.py b/corechaindb/web/views/blocks.py new file mode 100644 index 00000000..c180b611 --- /dev/null +++ b/corechaindb/web/views/blocks.py @@ -0,0 +1,58 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""This module provides the blueprint for the blocks API endpoints. + +For more information please refer to the documentation: http://corechaindb.com/http-api +""" +from flask import current_app +from flask_restful import Resource, reqparse + +from corechaindb.web.views.base import make_error + + +class BlockApi(Resource): + def get(self, block_id): + """API endpoint to get details about a block. + + Args: + block_id (str): the id of the block. + + Return: + A JSON string containing the data about the block. + """ + + pool = current_app.config['bigchain_pool'] + + with pool() as bigchain: + block = bigchain.get_block(block_id=block_id) + + if not block: + return make_error(404) + + return block + + +class BlockListApi(Resource): + def get(self): + """API endpoint to get the related blocks for a transaction. + + Return: + A ``list`` of ``block_id``s that contain the given transaction. The + list may be filtered when provided a status query parameter: + "valid", "invalid", "undecided". + """ + parser = reqparse.RequestParser() + parser.add_argument('transaction_id', type=str, required=True) + + args = parser.parse_args(strict=True) + tx_id = args['transaction_id'] + + pool = current_app.config['bigchain_pool'] + + with pool() as bigchain: + blocks = bigchain.get_block_containing_tx(tx_id) + + return blocks diff --git a/corechaindb/web/views/info.py b/corechaindb/web/views/info.py new file mode 100644 index 00000000..50e0eb7e --- /dev/null +++ b/corechaindb/web/views/info.py @@ -0,0 +1,57 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""API Index endpoint""" + +import flask +from flask_restful import Resource + +from corechaindb.web.views.base import base_ws_uri +from corechaindb import version +from corechaindb.web.websocket_server import EVENTS_ENDPOINT + + +class RootIndex(Resource): + def get(self): + docs_url = [ + 'https://docs.corechaindb.com/projects/server/en/v', + version.__version__ + '/' + ] + return flask.jsonify({ + 'api': { + 'v1': get_api_v1_info('/api/v1/') + }, + 'docs': ''.join(docs_url), + 'software': 'BigchainDB', + 'version': version.__version__, + }) + + +class ApiV1Index(Resource): + def get(self): + return flask.jsonify(get_api_v1_info('/')) + + +def get_api_v1_info(api_prefix): + """Return a dict with all the information specific for the v1 of the + api. + """ + websocket_root = base_ws_uri() + EVENTS_ENDPOINT + docs_url = [ + 'https://docs.corechaindb.com/projects/server/en/v', + version.__version__, + '/http-client-server-api.html', + ] + + return { + 'docs': ''.join(docs_url), + 'transactions': '{}transactions/'.format(api_prefix), + 'blocks': '{}blocks/'.format(api_prefix), + 'assets': '{}assets/'.format(api_prefix), + 'outputs': '{}outputs/'.format(api_prefix), + 'streams': websocket_root, + 'metadata': '{}metadata/'.format(api_prefix), + 'validators': '{}validators'.format(api_prefix), + } diff --git a/corechaindb/web/views/metadata.py b/corechaindb/web/views/metadata.py new file mode 100644 index 00000000..bdb5c992 --- /dev/null +++ b/corechaindb/web/views/metadata.py @@ -0,0 +1,55 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""This module provides the blueprint for some basic API endpoints. + +For more information please refer to the documentation: http://corechaindb.com/http-api +""" +import logging + +from flask_restful import reqparse, Resource +from flask import current_app + +from corechaindb.backend.exceptions import OperationError +from corechaindb.web.views.base import make_error + +logger = logging.getLogger(__name__) + + +class MetadataApi(Resource): + def get(self): + """API endpoint to perform a text search on transaction metadata. + + Args: + search (str): Text search string to query the text index + limit (int, optional): Limit the number of returned documents. + + Return: + A list of metadata that match the query. + """ + parser = reqparse.RequestParser() + parser.add_argument('search', type=str, required=True) + parser.add_argument('limit', type=int) + args = parser.parse_args() + + if not args['search']: + return make_error(400, 'text_search cannot be empty') + if not args['limit']: + del args['limit'] + + pool = current_app.config['bigchain_pool'] + + with pool() as bigchain: + args['table'] = 'metadata' + metadata = bigchain.text_search(**args) + + try: + # This only works with MongoDB as the backend + return list(metadata) + except OperationError as e: + return make_error( + 400, + '({}): {}'.format(type(e).__name__, e) + ) diff --git a/corechaindb/web/views/outputs.py b/corechaindb/web/views/outputs.py new file mode 100644 index 00000000..c01ab6ca --- /dev/null +++ b/corechaindb/web/views/outputs.py @@ -0,0 +1,31 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +from flask import current_app +from flask_restful import reqparse, Resource + +from corechaindb.web.views import parameters + + +class OutputListApi(Resource): + def get(self): + """API endpoint to retrieve a list of links to transaction + outputs. + + Returns: + A :obj:`list` of :cls:`str` of links to outputs. + """ + parser = reqparse.RequestParser() + parser.add_argument('public_key', type=parameters.valid_ed25519, + required=True) + parser.add_argument('spent', type=parameters.valid_bool) + args = parser.parse_args(strict=True) + + pool = current_app.config['bigchain_pool'] + with pool() as bigchain: + outputs = bigchain.get_outputs_filtered(args['public_key'], + args['spent']) + return [{'transaction_id': output.txid, 'output_index': output.output} + for output in outputs] diff --git a/corechaindb/web/views/parameters.py b/corechaindb/web/views/parameters.py new file mode 100644 index 00000000..6f4d7ea3 --- /dev/null +++ b/corechaindb/web/views/parameters.py @@ -0,0 +1,51 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +import re + +from corechaindb.common.transaction_mode_types import (BROADCAST_TX_COMMIT, + BROADCAST_TX_ASYNC, + BROADCAST_TX_SYNC) + + +def valid_txid(txid): + if re.match('^[a-fA-F0-9]{64}$', txid): + return txid.lower() + raise ValueError('Invalid hash') + + +def valid_bool(val): + val = val.lower() + if val == 'true': + return True + if val == 'false': + return False + raise ValueError('Boolean value must be "true" or "false" (lowercase)') + + +def valid_ed25519(key): + if (re.match('^[1-9a-zA-Z]{43,44}$', key) and not + re.match('.*[Il0O]', key)): + return key + raise ValueError('Invalid base58 ed25519 key') + + +def valid_operation(op): + op = op.upper() + if op == 'CREATE': + return 'CREATE' + if op == 'TRANSFER': + return 'TRANSFER' + raise ValueError('Operation must be "CREATE" or "TRANSFER"') + + +def valid_mode(mode): + if mode == 'async': + return BROADCAST_TX_ASYNC + if mode == 'sync': + return BROADCAST_TX_SYNC + if mode == 'commit': + return BROADCAST_TX_COMMIT + raise ValueError('Mode must be "async", "sync" or "commit"') diff --git a/corechaindb/web/views/transactions.py b/corechaindb/web/views/transactions.py new file mode 100644 index 00000000..c9375590 --- /dev/null +++ b/corechaindb/web/views/transactions.py @@ -0,0 +1,108 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""This module provides the blueprint for some basic API endpoints. + +For more information please refer to the documentation: http://corechaindb.com/http-api +""" +import logging + +from flask import current_app, request, jsonify +from flask_restful import Resource, reqparse + +from corechaindb.common.transaction_mode_types import BROADCAST_TX_ASYNC +from corechaindb.common.exceptions import SchemaValidationError, ValidationError +from corechaindb.web.views.base import make_error +from corechaindb.web.views import parameters +from corechaindb.models import Transaction + + +logger = logging.getLogger(__name__) + + +class TransactionApi(Resource): + def get(self, tx_id): + """API endpoint to get details about a transaction. + + Args: + tx_id (str): the id of the transaction. + + Return: + A JSON string containing the data about the transaction. + """ + pool = current_app.config['bigchain_pool'] + + with pool() as bigchain: + tx = bigchain.get_transaction(tx_id) + + if not tx: + return make_error(404) + + return tx.to_dict() + + +class TransactionListApi(Resource): + def get(self): + parser = reqparse.RequestParser() + parser.add_argument('operation', type=parameters.valid_operation) + parser.add_argument('asset_id', type=parameters.valid_txid, + required=True) + parser.add_argument('last_tx', type=parameters.valid_bool, + required=False) + args = parser.parse_args() + with current_app.config['bigchain_pool']() as bigchain: + txs = bigchain.get_transactions_filtered(**args) + + return [tx.to_dict() for tx in txs] + + def post(self): + """API endpoint to push transactions to the Federation. + + Return: + A ``dict`` containing the data about the transaction. + """ + parser = reqparse.RequestParser() + parser.add_argument('mode', type=parameters.valid_mode, + default=BROADCAST_TX_ASYNC) + args = parser.parse_args() + mode = str(args['mode']) + + pool = current_app.config['bigchain_pool'] + + # `force` will try to format the body of the POST request even if the + # `content-type` header is not set to `application/json` + tx = request.get_json(force=True) + + try: + tx_obj = Transaction.from_dict(tx) + except SchemaValidationError as e: + return make_error( + 400, + message='Invalid transaction schema: {}'.format( + e.__cause__.message) + ) + except ValidationError as e: + return make_error( + 400, + 'Invalid transaction ({}): {}'.format(type(e).__name__, e) + ) + + with pool() as bigchain: + try: + bigchain.validate_transaction(tx_obj) + except ValidationError as e: + return make_error( + 400, + 'Invalid transaction ({}): {}'.format(type(e).__name__, e) + ) + else: + status_code, message = bigchain.write_transaction(tx_obj, mode) + + if status_code == 202: + response = jsonify(tx) + response.status_code = 202 + return response + else: + return make_error(status_code, message) diff --git a/corechaindb/web/views/validators.py b/corechaindb/web/views/validators.py new file mode 100644 index 00000000..31d3f251 --- /dev/null +++ b/corechaindb/web/views/validators.py @@ -0,0 +1,23 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +from flask import current_app +from flask_restful import Resource + + +class ValidatorsApi(Resource): + def get(self): + """API endpoint to get validators set. + + Return: + A JSON string containing the validator set of the current node. + """ + + pool = current_app.config['bigchain_pool'] + + with pool() as bigchain: + validators = bigchain.get_validators() + + return validators diff --git a/corechaindb/web/websocket_server.py b/corechaindb/web/websocket_server.py new file mode 100644 index 00000000..090fb6f4 --- /dev/null +++ b/corechaindb/web/websocket_server.py @@ -0,0 +1,184 @@ +# Copyright © 2024 Atlantic Algorithms Ltd., +# CoreChainDB and Atlantic Algorithms Ltd. software contributors. +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + +"""WebSocket server for the BigchainDB Event Stream API.""" + +# NOTE +# +# This module contains some functions and utilities that might belong to other +# modules. For now, I prefer to keep everything in this module. Why? Because +# those functions are needed only here. +# +# When we will extend this part of the project and we find that we need those +# functionalities elsewhere, we can start creating new modules and organizing +# things in a better way. + + +import json +import asyncio +import logging +import threading +from uuid import uuid4 +from concurrent.futures import CancelledError + +import aiohttp +from aiohttp import web + +from corechaindb import config +from corechaindb.events import EventTypes + + +logger = logging.getLogger(__name__) +POISON_PILL = 'POISON_PILL' +EVENTS_ENDPOINT = '/api/v1/streams/valid_transactions' + + +def _multiprocessing_to_asyncio(in_queue, out_queue, loop): + """Bridge between a synchronous multiprocessing queue + and an asynchronous asyncio queue. + + Args: + in_queue (multiprocessing.Queue): input queue + out_queue (asyncio.Queue): output queue + """ + + while True: + value = in_queue.get() + loop.call_soon_threadsafe(out_queue.put_nowait, value) + + +def eventify_block(block): + for tx in block['transactions']: + if tx.asset: + asset_id = tx.asset.get('id', tx.id) + else: + asset_id = tx.id + yield {'height': block['height'], + 'asset_id': asset_id, + 'transaction_id': tx.id} + + +class Dispatcher: + """Dispatch events to websockets. + + This class implements a simple publish/subscribe pattern. + """ + + def __init__(self, event_source): + """Create a new instance. + + Args: + event_source: a source of events. Elements in the queue + should be strings. + """ + + self.event_source = event_source + self.subscribers = {} + + def subscribe(self, uuid, websocket): + """Add a websocket to the list of subscribers. + + Args: + uuid (str): a unique identifier for the websocket. + websocket: the websocket to publish information. + """ + + self.subscribers[uuid] = websocket + + def unsubscribe(self, uuid): + """Remove a websocket from the list of subscribers. + + Args: + uuid (str): a unique identifier for the websocket. + """ + + del self.subscribers[uuid] + + async def publish(self): + """Publish new events to the subscribers.""" + + while True: + event = await self.event_source.get() + str_buffer = [] + + if event == POISON_PILL: + return + + if isinstance(event, str): + str_buffer.append(event) + + elif event.type == EventTypes.BLOCK_VALID: + str_buffer = map(json.dumps, eventify_block(event.data)) + + for str_item in str_buffer: + for _, websocket in self.subscribers.items(): + await websocket.send_str(str_item) + + +async def websocket_handler(request): + """Handle a new socket connection.""" + + logger.debug('New websocket connection.') + websocket = web.WebSocketResponse() + await websocket.prepare(request) + uuid = uuid4() + request.app['dispatcher'].subscribe(uuid, websocket) + + while True: + # Consume input buffer + try: + msg = await websocket.receive() + except RuntimeError as e: + logger.debug('Websocket exception: %s', str(e)) + break + except CancelledError: + logger.debug('Websocket closed') + break + if msg.type == aiohttp.WSMsgType.CLOSED: + logger.debug('Websocket closed') + break + elif msg.type == aiohttp.WSMsgType.ERROR: + logger.debug('Websocket exception: %s', websocket.exception()) + break + + request.app['dispatcher'].unsubscribe(uuid) + return websocket + + +def init_app(event_source, *, loop=None): + """Init the application server. + + Return: + An aiohttp application. + """ + + dispatcher = Dispatcher(event_source) + + # Schedule the dispatcher + loop.create_task(dispatcher.publish()) + + app = web.Application(loop=loop) + app['dispatcher'] = dispatcher + app.router.add_get(EVENTS_ENDPOINT, websocket_handler) + return app + + +def start(sync_event_source, loop=None): + """Create and start the WebSocket server.""" + + if not loop: + loop = asyncio.get_event_loop() + + event_source = asyncio.Queue(loop=loop) + + bridge = threading.Thread(target=_multiprocessing_to_asyncio, + args=(sync_event_source, event_source, loop), + daemon=True) + bridge.start() + + app = init_app(event_source, loop=loop) + aiohttp.web.run_app(app, + host=config['wsserver']['host'], + port=config['wsserver']['port']) diff --git a/docker-compose.yml b/docker-compose.yml index 063c8e0e..cd3cf616 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ version: '2.2' services: - # Build: docker-compose build -d bigchaindb + # Build: docker-compose build -d corechaindb # Run: docker-compose run -d bdb mongodb: image: mongo:3.6 @@ -14,7 +14,7 @@ services: - "27017:27017" command: mongod restart: always - bigchaindb: + corechaindb: depends_on: - mongodb - tendermint @@ -22,7 +22,7 @@ services: context: . dockerfile: Dockerfile-dev volumes: - - ./bigchaindb:/usr/src/app/bigchaindb + - ./corechaindb:/usr/src/app/corechaindb - ./tests:/usr/src/app/tests - ./docs:/usr/src/app/docs - ./htmlcov:/usr/src/app/htmlcov @@ -36,7 +36,7 @@ services: BIGCHAINDB_DATABASE_PORT: 27017 BIGCHAINDB_SERVER_BIND: 0.0.0.0:9984 BIGCHAINDB_WSSERVER_HOST: 0.0.0.0 - BIGCHAINDB_WSSERVER_ADVERTISED_HOST: bigchaindb + BIGCHAINDB_WSSERVER_ADVERTISED_HOST: corechaindb BIGCHAINDB_TENDERMINT_HOST: tendermint BIGCHAINDB_TENDERMINT_PORT: 26657 ports: @@ -44,7 +44,7 @@ services: - "9985:9985" - "26658" healthcheck: - test: ["CMD", "bash", "-c", "curl http://bigchaindb:9984 && curl http://tendermint:26657/abci_query"] + test: ["CMD", "bash", "-c", "curl http://corechaindb:9984 && curl http://tendermint:26657/abci_query"] interval: 3s timeout: 5s retries: 3 @@ -58,19 +58,19 @@ services: ports: - "26656:26656" - "26657:26657" - command: sh -c "tendermint init && tendermint node --consensus.create_empty_blocks=false --proxy_app=tcp://bigchaindb:26658" + command: sh -c "tendermint init && tendermint node --consensus.create_empty_blocks=false --proxy_app=tcp://corechaindb:26658" restart: always bdb: image: busybox depends_on: - bigchaindb: + corechaindb: condition: service_healthy # curl client to check the health of development env curl-client: image: appropriate/curl - command: /bin/sh -c "curl -s http://bigchaindb:9984/ > /dev/null && curl -s http://tendermint:26657/ > /dev/null" + command: /bin/sh -c "curl -s http://corechaindb:9984/ > /dev/null && curl -s http://tendermint:26657/ > /dev/null" # BigchainDB setup to do acceptance testing with Python python-acceptance: @@ -81,7 +81,7 @@ services: - ./acceptance/python/docs:/docs - ./acceptance/python/src:/src environment: - - BIGCHAINDB_ENDPOINT=bigchaindb + - BIGCHAINDB_ENDPOINT=corechaindb # Build docs only # docker-compose build bdocs diff --git a/docs/README.md b/docs/README.md index 3bcc51e8..8e942215 100644 --- a/docs/README.md +++ b/docs/README.md @@ -5,7 +5,7 @@ SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) Code is Apache-2.0 and docs are CC-BY-4.0 ---> -- [Documentation on ReadTheDocs](http://bigchaindb.readthedocs.org/) +- [Documentation on ReadTheDocs](http://corechaindb.readthedocs.org/) - [BigchainDB Upgrade Guides](upgrade-guides/) # The BigchainDB Documentation Strategy diff --git a/docs/root/generate_http_server_api_documentation.py b/docs/root/generate_http_server_api_documentation.py index d58181ed..cf327760 100644 --- a/docs/root/generate_http_server_api_documentation.py +++ b/docs/root/generate_http_server_api_documentation.py @@ -9,9 +9,9 @@ import json import os import os.path -from bigchaindb.common.transaction import Transaction, Input, TransactionLink -from bigchaindb import lib -from bigchaindb.web import server +from corechaindb.common.transaction import Transaction, Input, TransactionLink +from corechaindb import lib +from corechaindb.web import server TPLS = {} diff --git a/docs/root/make.bat b/docs/root/make.bat index 7f41e02a..bfc83f34 100644 --- a/docs/root/make.bat +++ b/docs/root/make.bat @@ -127,9 +127,9 @@ if "%1" == "qthelp" ( echo. echo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %BUILDDIR%/qthelp, like this: - echo.^> qcollectiongenerator %BUILDDIR%\qthelp\bigchaindb.qhcp + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\corechaindb.qhcp echo.To view the help file: - echo.^> assistant -collectionFile %BUILDDIR%\qthelp\bigchaindb.ghc + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\corechaindb.ghc goto end ) diff --git a/docs/root/source/about-bigchaindb.rst b/docs/root/source/about-corechaindb.rst similarity index 98% rename from docs/root/source/about-bigchaindb.rst rename to docs/root/source/about-corechaindb.rst index 977d0fe4..4be47707 100644 --- a/docs/root/source/about-bigchaindb.rst +++ b/docs/root/source/about-corechaindb.rst @@ -35,7 +35,7 @@ BigchainDB can store data of any kind, but it's designed to be particularly good .. note:: - We used the word "owners" somewhat loosely above. A more accurate word might be fulfillers, signers, controllers, or transfer-enablers. See the section titled **A Note about Owners** in the relevant `BigchainDB Transactions Spec `_. + We used the word "owners" somewhat loosely above. A more accurate word might be fulfillers, signers, controllers, or transfer-enablers. See the section titled **A Note about Owners** in the relevant `BigchainDB Transactions Spec `_. # Production-Ready? @@ -52,7 +52,7 @@ A system could store data off-chain, e.g. in a third-party database, document st - Keep track of who has read permissions (or other permissions) in a third-party system. An example of how this could be done is described below. - Keep a permanent record of all requests made to the third-party system. - Store hashes of documents-stored-elsewhere, so that a change in any document can be detected. -- Record all handshake-establishing requests and responses between two off-chain parties (e.g. a Diffie-Hellman key exchange), so as to prove that they established an encrypted tunnel (without giving readers access to that tunnel). There are more details about this idea in `the Privacy Protocols repository `_. +- Record all handshake-establishing requests and responses between two off-chain parties (e.g. a Diffie-Hellman key exchange), so as to prove that they established an encrypted tunnel (without giving readers access to that tunnel). There are more details about this idea in `the Privacy Protocols repository `_. A simple way to record who has read permission on a particular document would be for the third-party system (“DocPile”) to store a CREATE transaction in a BigchainDB network for every document+user pair, to indicate that that user has read permissions for that document. The transaction could be signed by DocPile (or maybe by a document owner, as a variation). The asset data field would contain 1) the unique ID of the user and 2) the unique ID of the document. The one output on the CREATE transaction would only be transferable/spendable by DocPile (or, again, a document owner). diff --git a/docs/root/source/basic-usage.md b/docs/root/source/basic-usage.md index a0503b45..c8e9509b 100644 --- a/docs/root/source/basic-usage.md +++ b/docs/root/source/basic-usage.md @@ -17,7 +17,7 @@ two kinds: CREATE transactions and TRANSFER transactions. You can view the transaction specifications in Github, which describe transaction components and the conditions they have to fulfill in order to be valid. -[BigchainDB Transactions Specs](https://github.com/bigchaindb/BEPs/tree/master/13/) +[BigchainDB Transactions Specs](https://github.com/corechaindb/BEPs/tree/master/13/) ### CREATE Transactions @@ -44,7 +44,7 @@ BigchainDB supports a variety of conditions. For details, see the section titled **Transaction Components: Conditions** in the relevant -[BigchainDB Transactions Spec](https://github.com/bigchaindb/BEPs/tree/master/13/). +[BigchainDB Transactions Spec](https://github.com/corechaindb/BEPs/tree/master/13/). ![Example BigchainDB CREATE transaction](./_static/CREATE_example.png) @@ -58,7 +58,7 @@ Loosely speaking, that list might be interpreted as the list of "owners." A more accurate word might be fulfillers, signers, controllers, or transfer-enablers. See the section titled **A Note about Owners** -in the relevant [BigchainDB Transactions Spec](https://github.com/bigchaindb/BEPs/tree/master/13/). +in the relevant [BigchainDB Transactions Spec](https://github.com/corechaindb/BEPs/tree/master/13/). A CREATE transaction must be signed by all the owners. (If you're looking for that signature, @@ -120,7 +120,7 @@ of the outgoing paperclips (100). When a node is asked to check if a transaction is valid, it checks several things. We documented those things in a post on *The BigchainDB Blog*: -["What is a Valid Transaction in BigchainDB?"](https://blog.bigchaindb.com/what-is-a-valid-transaction-in-bigchaindb-9a1a075a9598) +["What is a Valid Transaction in BigchainDB?"](https://blog.corechaindb.com/what-is-a-valid-transaction-in-corechaindb-9a1a075a9598) (Note: That post was about BigchainDB Server v1.0.0.) ### Example Transactions diff --git a/docs/root/source/conf.py b/docs/root/source/conf.py index cba72378..1d53f2d2 100644 --- a/docs/root/source/conf.py +++ b/docs/root/source/conf.py @@ -33,7 +33,7 @@ from recommonmark.parser import CommonMarkParser # get version _version = {} -with open('../../../bigchaindb/version.py') as fp: +with open('../../../corechaindb/version.py') as fp: exec(fp.read(), _version) @@ -79,13 +79,13 @@ def get_old_new(url, old, new): filename = wget.download(url) rename(old, new) -get_old_new('https://raw.githubusercontent.com/bigchaindb/bigchaindb/master/CODE_OF_CONDUCT.md', +get_old_new('https://raw.githubusercontent.com/corechaindb/corechaindb/master/CODE_OF_CONDUCT.md', 'CODE_OF_CONDUCT.md', 'contributing/cross-project-policies/code-of-conduct.md') -get_old_new('https://raw.githubusercontent.com/bigchaindb/bigchaindb/master/RELEASE_PROCESS.md', +get_old_new('https://raw.githubusercontent.com/corechaindb/corechaindb/master/RELEASE_PROCESS.md', 'RELEASE_PROCESS.md', 'contributing/cross-project-policies/release-process.md') -get_old_new('https://raw.githubusercontent.com/bigchaindb/bigchaindb/master/PYTHON_STYLE_GUIDE.md', +get_old_new('https://raw.githubusercontent.com/corechaindb/corechaindb/master/PYTHON_STYLE_GUIDE.md', 'PYTHON_STYLE_GUIDE.md', 'contributing/cross-project-policies/python-style-guide.md') suppress_warnings = ['misc.highlighting_failure'] @@ -372,7 +372,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'bigchaindb', 'BigchainDB Documentation', + (master_doc, 'corechaindb', 'BigchainDB Documentation', [author], 1) ] diff --git a/docs/root/source/contributing/cross-project-policies/code-of-conduct.md b/docs/root/source/contributing/cross-project-policies/code-of-conduct.md index 4dff95cd..3366dea8 100644 --- a/docs/root/source/contributing/cross-project-policies/code-of-conduct.md +++ b/docs/root/source/contributing/cross-project-policies/code-of-conduct.md @@ -42,7 +42,7 @@ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Instances of abusive, harassing, or otherwise unacceptable behavior directed at yourself or another community member may be -reported by contacting a project maintainer at [contact@bigchaindb.com](mailto:contact@bigchaindb.com). All +reported by contacting a project maintainer at [contact@corechaindb.com](mailto:contact@corechaindb.com). All complaints will be reviewed and investigated and will result in a response that is appropriate to the circumstances. Maintainers are obligated to maintain confidentiality with regard to the reporter of an diff --git a/docs/root/source/contributing/cross-project-policies/python-style-guide.md b/docs/root/source/contributing/cross-project-policies/python-style-guide.md index 5cdb39b8..4f2ce986 100644 --- a/docs/root/source/contributing/cross-project-policies/python-style-guide.md +++ b/docs/root/source/contributing/cross-project-policies/python-style-guide.md @@ -16,7 +16,7 @@ Our starting point is [PEP8](https://www.python.org/dev/peps/pep-0008/), the sta BigchainDB uses Python 3.5+, so you can ignore all PEP8 guidelines specific to Python 2. We use [pre-commit](http://pre-commit.com/) to check some of the rules below before every commit but not everything is realized yet. -The hooks we use can be found in the [.pre-commit-config.yaml](https://github.com/bigchaindb/bigchaindb/blob/master/.pre-commit-config.yaml) file. +The hooks we use can be found in the [.pre-commit-config.yaml](https://github.com/corechaindb/corechaindb/blob/master/.pre-commit-config.yaml) file. ### Python Docstrings @@ -86,12 +86,12 @@ we use the `format()` version. The [official Python documentation says](https:// We use [Flake8](http://flake8.pycqa.org/en/latest/index.html) to check our Python code style. Once you have it installed, you can run it using: ```text -flake8 --max-line-length 119 bigchaindb/ +flake8 --max-line-length 119 corechaindb/ ``` ## Writing and Running (Python) Tests -The content of this section was moved to [`bigchaindb/tests/README.md`](https://github.com/bigchaindb/bigchaindb/blob/master/tests/README.md). +The content of this section was moved to [`corechaindb/tests/README.md`](https://github.com/corechaindb/corechaindb/blob/master/tests/README.md). Note: We automatically run all tests on all pull requests (using Travis CI), so you should definitely run all tests locally before you submit a pull request. See the above-linked README file for instructions. diff --git a/docs/root/source/contributing/cross-project-policies/release-process.md b/docs/root/source/contributing/cross-project-policies/release-process.md index 84e19247..e2edf072 100644 --- a/docs/root/source/contributing/cross-project-policies/release-process.md +++ b/docs/root/source/contributing/cross-project-policies/release-process.md @@ -25,7 +25,7 @@ to [regular semantic versioning](http://semver.org/), but there's no hyphen, e.g We use `0.9` and `0.9.0` as example version and short-version values below. You should replace those with the correct values for your new version. -We follow [BEP-1](https://github.com/bigchaindb/BEPs/tree/master/1), which is our variant of C4, the Collective Code Construction Contract, so a release is just a [tagged commit](https://git-scm.com/book/en/v2/Git-Basics-Tagging) on the `master` branch, i.e. a label for a particular Git commit. +We follow [BEP-1](https://github.com/corechaindb/BEPs/tree/master/1), which is our variant of C4, the Collective Code Construction Contract, so a release is just a [tagged commit](https://git-scm.com/book/en/v2/Git-Basics-Tagging) on the `master` branch, i.e. a label for a particular Git commit. The following steps are what we do to release a new version of _BigchainDB Server_. The steps to release the Python Driver are similar but not the same. @@ -37,13 +37,13 @@ The following steps are what we do to release a new version of _BigchainDB Serve - Update all Docker image tags in all Kubernetes YAML files (in the `k8s/` directory). For example, in the files: - - `k8s/bigchaindb/bigchaindb-ss.yaml` and - - `k8s/dev-setup/bigchaindb.yaml` + - `k8s/corechaindb/corechaindb-ss.yaml` and + - `k8s/dev-setup/corechaindb.yaml` - find the line of the form `image: bigchaindb/bigchaindb:0.8.1` and change the version number to the new version number, e.g. `0.9.0`. (This is the Docker image that Kubernetes should pull from Docker Hub.) + find the line of the form `image: corechaindb/corechaindb:0.8.1` and change the version number to the new version number, e.g. `0.9.0`. (This is the Docker image that Kubernetes should pull from Docker Hub.) Keep in mind that this is a _Docker image tag_ so our naming convention is a bit different; see Note 2 in the **Notes** section above. - - In `bigchaindb/version.py`: + - In `corechaindb/version.py`: - update `__version__` to e.g. `0.9.0` (with no `.dev` on the end) - update `__short_version__` to e.g. `0.9` (with no `.dev` on the end) - In the docs about installing BigchainDB (and Tendermint), and in the associated scripts, recommend/install a version of Tendermint that _actually works_ with the soon-to-be-released version of BigchainDB. You can find all such references by doing a search for the previously-recommended version number, such as `0.31.5`. @@ -51,7 +51,7 @@ The following steps are what we do to release a new version of _BigchainDB Serve 2. **Wait for all the tests to pass!** 3. Merge the pull request into the `master` branch. -4. Go to the [bigchaindb/bigchaindb Releases page on GitHub](https://github.com/bigchaindb/bigchaindb/releases) +4. Go to the [corechaindb/corechaindb Releases page on GitHub](https://github.com/corechaindb/corechaindb/releases) and click the "Draft a new release" button. 5. Fill in the details: - **Tag version:** version number preceded by `v`, e.g. `v0.9.1` @@ -59,9 +59,9 @@ The following steps are what we do to release a new version of _BigchainDB Serve - **Title:** Same as tag version above, e.g `v0.9.1` - **Description:** The body of the changelog entry (Added, Changed, etc.) 6. Click "Publish release" to publish the release on GitHub. -7. On your local computer, make sure you're on the `master` branch and that it's up-to-date with the `master` branch in the bigchaindb/bigchaindb repository (e.g. `git pull upstream master`). We're going to use that to push a new `bigchaindb` package to PyPI. +7. On your local computer, make sure you're on the `master` branch and that it's up-to-date with the `master` branch in the corechaindb/corechaindb repository (e.g. `git pull upstream master`). We're going to use that to push a new `corechaindb` package to PyPI. 8. Make sure you have a `~/.pypirc` file containing credentials for PyPI. -9. Do `make release` to build and publish the new `bigchaindb` package on PyPI. For this step you need to have `twine` installed. If you get an error like `Makefile:135: recipe for target 'clean-pyc' failed` then try doing +9. Do `make release` to build and publish the new `corechaindb` package on PyPI. For this step you need to have `twine` installed. If you get an error like `Makefile:135: recipe for target 'clean-pyc' failed` then try doing ```text sudo chown -R $(whoami):$(whoami) . ``` @@ -80,8 +80,8 @@ The following steps are what we do to release a new version of _BigchainDB Serve 3. Scroll to the bottom of the page and click "Save". 11. Go to [Docker Hub](https://hub.docker.com/) and sign in, then: - Click on "Organizations" - - Click on "bigchaindb" - - Click on "bigchaindb/bigchaindb" + - Click on "corechaindb" + - Click on "corechaindb/corechaindb" - Click on "Build Settings" - Find the row where "Docker Tag Name" equals `latest` and change the value of "Name" to the name (Git tag) diff --git a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-dev-network-ansible.md b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-dev-network-ansible.md index f01dd187..95f849d3 100644 --- a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-dev-network-ansible.md +++ b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-dev-network-ansible.md @@ -25,7 +25,7 @@ Minimum resource requirements for a single node BigchainDB dev setup. **The more ## Clone the BigchainDB repository ```text -$ git clone https://github.com/bigchaindb/bigchaindb.git +$ git clone https://github.com/corechaindb/corechaindb.git ``` ## Install dependencies @@ -33,28 +33,28 @@ $ git clone https://github.com/bigchaindb/bigchaindb.git You can also install `ansible` and other dependencies, if any, using the `boostrap.sh` script inside the BigchainDB repository. -Navigate to `bigchaindb/pkg/scripts` and run the `bootstrap.sh` script to install the dependencies +Navigate to `corechaindb/pkg/scripts` and run the `bootstrap.sh` script to install the dependencies for your OS. The script also checks if the OS you are running is compatible with the supported versions. **Note**: `bootstrap.sh` only supports Ubuntu >= 16.04, CentOS >= 7 and Fedora >=24 and MacOSX. ```text -$ cd bigchaindb/pkg/scripts/ +$ cd corechaindb/pkg/scripts/ $ bash bootstrap.sh --operation install ``` ### BigchainDB Setup Configuration(s) #### Local Setup -You can run the Ansible playbook `bigchaindb-start.yml` on your local dev machine and set up the BigchainDB node where +You can run the Ansible playbook `corechaindb-start.yml` on your local dev machine and set up the BigchainDB node where BigchainDB can be run as a process or inside a Docker container(s) depending on your configuration. Before, running the playbook locally, you need to update the `hosts` and `stack-config.yml` configuration, which will notify Ansible that we need to run the play locally. ##### Update Hosts -Navigate to `bigchaindb/pkg/configuration/hosts` inside the BigchainDB repository. +Navigate to `corechaindb/pkg/configuration/hosts` inside the BigchainDB repository. ```text -$ cd bigchaindb/pkg/configuration/hosts +$ cd corechaindb/pkg/configuration/hosts ``` Edit `all` configuration file: @@ -64,9 +64,9 @@ Edit `all` configuration file: ansible_connection=local ``` ##### Update Configuration -Navigate to `bigchaindb/pkg/configuration/vars` inside the BigchainDB repository. +Navigate to `corechaindb/pkg/configuration/vars` inside the BigchainDB repository. ```text -$ cd bigchaindb/pkg/configuration/vars/stack-config.yml +$ cd corechaindb/pkg/configuration/vars/stack-config.yml ``` Edit `bdb-config.yml` configuration file as per your requirements, sample configuration file(s): @@ -84,30 +84,30 @@ stack_type: "1" ``` ### BigchainDB Setup -Now, You can safely run the `bigchaindb-start.yml` playbook and everything will be taken care of by `Ansible`. To run the playbook please navigate to the `bigchaindb/pkg/configuration` directory inside the BigchainDB repository and run the `bigchaindb-start.yml` playbook. +Now, You can safely run the `corechaindb-start.yml` playbook and everything will be taken care of by `Ansible`. To run the playbook please navigate to the `corechaindb/pkg/configuration` directory inside the BigchainDB repository and run the `corechaindb-start.yml` playbook. ```text -$ cd bigchaindb/pkg/configuration/ +$ cd corechaindb/pkg/configuration/ -$ ansible-playbook bigchaindb-start.yml -i hosts/all --extra-vars "operation=start home_path=$(pwd)" +$ ansible-playbook corechaindb-start.yml -i hosts/all --extra-vars "operation=start home_path=$(pwd)" ``` After successful execution of the playbook, you can verify that BigchainDB docker(s)/process(es) is(are) running. Verify BigchainDB process(es): ```text -$ ps -ef | grep bigchaindb +$ ps -ef | grep corechaindb ``` OR Verify BigchainDB Docker(s): ```text -$ docker ps | grep bigchaindb +$ docker ps | grep corechaindb ``` You can now send transactions and verify the functionality of your BigchainDB node. -See the [BigchainDB Python Driver documentation](https://docs.bigchaindb.com/projects/py-driver/en/latest/index.html) +See the [BigchainDB Python Driver documentation](https://docs.corechaindb.com/projects/py-driver/en/latest/index.html) for details on how to use it. **Note**: The `bdb_root_url` can be be one of the following: @@ -121,19 +121,19 @@ OR bdb_root_url = http://: ``` -**Note**: BigchainDB has [other drivers as well](http://docs.bigchaindb.com/projects/server/en/latest/drivers-clients/index.html). +**Note**: BigchainDB has [other drivers as well](http://docs.corechaindb.com/projects/server/en/latest/drivers-clients/index.html). ### Experimental: Running Ansible a Remote Dev/Host #### Remote Setup -You can also run the Ansible playbook `bigchaindb-start.yml` on remote machine(s) and set up the BigchainDB node where +You can also run the Ansible playbook `corechaindb-start.yml` on remote machine(s) and set up the BigchainDB node where BigchainDB can run as a process or inside a Docker container(s) depending on your configuration. Before, running the playbook on a remote host, you need to update the `hosts` and `stack-config.yml` configuration, which will notify Ansible that we need to run the play on a remote host. ##### Update Remote Hosts -Navigate to `bigchaindb/pkg/configuration/hosts` inside the BigchainDB repository. +Navigate to `corechaindb/pkg/configuration/hosts` inside the BigchainDB repository. ```text -$ cd bigchaindb/pkg/configuration/hosts +$ cd corechaindb/pkg/configuration/hosts ``` Edit `all` configuration file: @@ -148,9 +148,9 @@ Edit `all` configuration file: please consult [Ansible Documentation](http://docs.ansible.com/ansible/latest/intro_getting_started.html). ##### Update Remote Configuration -Navigate to `bigchaindb/pkg/configuration/vars` inside the BigchainDB repository. +Navigate to `corechaindb/pkg/configuration/vars` inside the BigchainDB repository. ```text -$ cd bigchaindb/pkg/configuration/vars/stack-config.yml +$ cd corechaindb/pkg/configuration/vars/stack-config.yml ``` Edit `stack-config.yml` configuration file as per your requirements, sample configuration file(s): @@ -167,4 +167,4 @@ stack_type: "local" stack_type: "1" ``` -After, the configuration of remote hosts, [run the Ansible playbook and verify your deployment](#bigchaindb-setup-ansible). +After, the configuration of remote hosts, [run the Ansible playbook and verify your deployment](#corechaindb-setup-ansible). diff --git a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-dev-network-stack.md b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-dev-network-stack.md index 2a10c75e..27fb4305 100644 --- a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-dev-network-stack.md +++ b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-dev-network-stack.md @@ -26,20 +26,20 @@ Minimum resource requirements for a single node BigchainDB dev setup. **The more ## Download the scripts > **Note**: If you're working on BigchainDB Server code, on a branch based on > recent code, then you already have local recent versions of *stack.sh* and -> *unstack.sh* in your bigchaindb/pkg/scripts/ directory. Otherwise you can +> *unstack.sh* in your corechaindb/pkg/scripts/ directory. Otherwise you can > get them using: ```text $ export GIT_BRANCH=master -$ curl -fOL https://raw.githubusercontent.com/bigchaindb/bigchaindb/${GIT_BRANCH}/pkg/scripts/stack.sh +$ curl -fOL https://raw.githubusercontent.com/corechaindb/corechaindb/${GIT_BRANCH}/pkg/scripts/stack.sh # Optional -$ curl -fOL https://raw.githubusercontent.com/bigchaindb/bigchaindb/${GIT_BRANCH}/pkg/scripts/unstack.sh +$ curl -fOL https://raw.githubusercontent.com/corechaindb/corechaindb/${GIT_BRANCH}/pkg/scripts/unstack.sh ``` ## Quick Start If you run `stack.sh` out of the box i.e. without any configuration changes, you will be able to deploy a 4 node -BigchainDB network with Docker containers, created from `master` branch of `bigchaindb/bigchaindb` repo and Tendermint version `0.22.8`. +BigchainDB network with Docker containers, created from `master` branch of `corechaindb/corechaindb` repo and Tendermint version `0.22.8`. **Note**: Run `stack.sh` with either root or non-root user with sudo enabled. @@ -89,11 +89,11 @@ $ bash stack.sh -h of the instance(s) spawned. (default: ubuntu/xenial64) ENV[STACK_REPO] - (Optional) To configure bigchaindb repo to use, set STACK_REPO environment - variable. (default: bigchaindb/bigchaindb) + (Optional) To configure corechaindb repo to use, set STACK_REPO environment + variable. (default: corechaindb/corechaindb) ENV[STACK_BRANCH] - (Optional) To configure bigchaindb repo branch to use set STACK_BRANCH environment + (Optional) To configure corechaindb repo branch to use set STACK_BRANCH environment variable. (default: master) ENV[TM_VERSION] @@ -171,8 +171,8 @@ $ export STACK_SIZE=4 $ export STACK_TYPE=docker #Optional, repo to use for the network deployment -# Default: bigchaindb/bigchaindb -$ export STACK_REPO=bigchaindb/bigchaindb +# Default: corechaindb/corechaindb +$ export STACK_REPO=corechaindb/corechaindb #Optional, codebase to use for the network deployment # Default: master @@ -222,8 +222,8 @@ $ export STACK_VM_CPUS=1 $ export STACK_BOX_NAME=ubuntu/xenial64 #Optional, repo to use for the network deployment -# Default: bigchaindb/bigchaindb -$ export STACK_REPO=bigchaindb/bigchaindb +# Default: corechaindb/corechaindb +$ export STACK_REPO=corechaindb/corechaindb #Optional, codebase to use for the network deployment # Default: master diff --git a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-node-as-processes.md b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-node-as-processes.md index 47a2a5e1..c025e820 100644 --- a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-node-as-processes.md +++ b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-node-as-processes.md @@ -112,8 +112,8 @@ $ tendermint unsafe_reset_all To install BigchainDB from source (for dev), clone the repo and execute the following command, (it is better that you create a virtual env for this) ```bash -$ git clone https://github.com/bigchaindb/bigchaindb.git -$ cd bigchaindb +$ git clone https://github.com/corechaindb/corechaindb.git +$ cd corechaindb $ pip install -e .[dev] # or pip install -e '.[dev]' # for zsh ``` @@ -132,7 +132,7 @@ One could mark a specific test and execute the same by appending `-m my_mark` to Although the above should prove sufficient in most cases but in case tests are failing on Travis CI then the following command can be used to possibly replicate the failure locally, ```bash -$ docker-compose run --rm --no-deps bdb pytest -v --cov=bigchaindb +$ docker-compose run --rm --no-deps bdb pytest -v --cov=corechaindb ``` NOTE: before executing the above command the user must ensure that they reset the Tendermint container by executing `tendermint usafe_reset_all` command in the Tendermint container. diff --git a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.md b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.md index e7e07f37..91bf0f97 100644 --- a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.md +++ b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.md @@ -33,7 +33,7 @@ There are also other commands you can execute: The BigchainDB `Makefile` is a wrapper around some `docker-compose` commands we use frequently. If you need a finer granularity to manage the containers, you can still use `docker-compose` directly. This part of the documentation explains how to do that. ```bash -$ docker-compose build bigchaindb +$ docker-compose build corechaindb $ docker-compose up -d bdb ``` @@ -41,7 +41,7 @@ The above command will launch all 3 main required services/processes: * ``mongodb`` * ``tendermint`` -* ``bigchaindb`` +* ``corechaindb`` To follow the logs of the ``tendermint`` service: @@ -49,10 +49,10 @@ To follow the logs of the ``tendermint`` service: $ docker-compose logs -f tendermint ``` -To follow the logs of the ``bigchaindb`` service: +To follow the logs of the ``corechaindb`` service: ```bash -$ docker-compose logs -f bigchaindb +$ docker-compose logs -f corechaindb ``` To follow the logs of the ``mongodb`` service: @@ -81,18 +81,18 @@ $ docker-compose -f docker-compose.yml run --rm bdb-driver ipython Run all the tests using: ```bash -$ docker-compose run --rm --no-deps bigchaindb pytest -v +$ docker-compose run --rm --no-deps corechaindb pytest -v ``` Run tests from a file: ```bash -$ docker-compose run --rm --no-deps bigchaindb pytest /path/to/file -v +$ docker-compose run --rm --no-deps corechaindb pytest /path/to/file -v ``` Run specific tests: ```bash -$ docker-compose run --rm --no-deps bigchaindb pytest /path/to/file -k "" -v +$ docker-compose run --rm --no-deps corechaindb pytest /path/to/file -k "" -v ``` ### Building Docs diff --git a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/write-code.rst b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/write-code.rst index d750bc4b..b2d3d521 100644 --- a/docs/root/source/contributing/dev-setup-coding-and-contribution-process/write-code.rst +++ b/docs/root/source/contributing/dev-setup-coding-and-contribution-process/write-code.rst @@ -21,7 +21,7 @@ Refresh Yourself about the C4 Process ------------------------------------- C4 is the Collective Code Construction Contract. It's quite short: -`re-reading it will only take a few minutes `_. +`re-reading it will only take a few minutes `_. Set Up Your Local Machine. Here's How. @@ -69,7 +69,7 @@ Set Up Your Local Machine. Here's How. Before You Start Writing Code ----------------------------- -Read `BEP-24 `_ +Read `BEP-24 `_ so you know what to do to ensure that your changes (i.e. your future pull request) can be merged. It's easy and will save you some hassle later on. @@ -79,7 +79,7 @@ Start Writing Code Use the Git `Fork and Pull Request Workflow `_. Tip: You could print that page for reference. -Your Python code should follow `our Python Style Guide `_. +Your Python code should follow `our Python Style Guide `_. Similarly for JavaScript. Make sure `pre-commit `_ actually checks commits. Do: diff --git a/docs/root/source/contributing/index.rst b/docs/root/source/contributing/index.rst index cd1aad6d..c31f1fd2 100644 --- a/docs/root/source/contributing/index.rst +++ b/docs/root/source/contributing/index.rst @@ -10,13 +10,13 @@ Contributing to BigchainDB There are many ways you can contribute to BigchainDB. It includes several sub-projects. -- `BigchainDB Server `_ -- `BigchainDB Python Driver `_ -- `BigchainDB JavaScript Driver `_ -- `BigchainDB Java Driver `_ -- `cryptoconditions `_ (a Python package by us) +- `BigchainDB Server `_ +- `BigchainDB Python Driver `_ +- `BigchainDB JavaScript Driver `_ +- `BigchainDB Java Driver `_ +- `cryptoconditions `_ (a Python package by us) - `py-abci `_ (a Python package we use) -- `BigchainDB Enhancement Proposals (BEPs) `_ +- `BigchainDB Enhancement Proposals (BEPs) `_ Contents -------- diff --git a/docs/root/source/contributing/ways-to-contribute/report-a-bug.md b/docs/root/source/contributing/ways-to-contribute/report-a-bug.md index da91f94f..68b7b6f1 100644 --- a/docs/root/source/contributing/ways-to-contribute/report-a-bug.md +++ b/docs/root/source/contributing/ways-to-contribute/report-a-bug.md @@ -21,24 +21,24 @@ To write an issue, go to the relevant GitHub repository, click on the **Issues** People ask questions about BigchainDB in the following places: - Gitter - - [bigchaindb/bigchaindb](https://gitter.im/bigchaindb/bigchaindb) - - [bigchaindb/js-bigchaindb-driver](https://gitter.im/bigchaindb/js-bigchaindb-driver) -- [Twitter](https://twitter.com/bigchaindb) -- [Stack Overflow "bigchaindb"](https://stackoverflow.com/search?q=bigchaindb) + - [corechaindb/corechaindb](https://gitter.im/corechaindb/corechaindb) + - [corechaindb/js-corechaindb-driver](https://gitter.im/corechaindb/js-corechaindb-driver) +- [Twitter](https://twitter.com/corechaindb) +- [Stack Overflow "corechaindb"](https://stackoverflow.com/search?q=corechaindb) Feel free to hang out and answer some questions. People will be thankful. # Write a BigchainDB Enhancement Proposal (BEP) If you have an idea for a new feature or enhancement, and you want some feedback before you write a full BigchainDB Enhancement Proposal (BEP), then feel free to: - - ask in the [bigchaindb/bigchaindb Gitter chat room](https://gitter.im/bigchaindb/bigchaindb) or - - [open a new issue in the bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs/issues/new) and give it the label **BEP idea**. + - ask in the [corechaindb/corechaindb Gitter chat room](https://gitter.im/corechaindb/corechaindb) or + - [open a new issue in the corechaindb/BEPs repo](https://github.com/corechaindb/BEPs/issues/new) and give it the label **BEP idea**. -If you want to discuss an existing BEP, then [open a new issue in the bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs/issues/new) and give it the label **discuss existing BEP**. +If you want to discuss an existing BEP, then [open a new issue in the corechaindb/BEPs repo](https://github.com/corechaindb/BEPs/issues/new) and give it the label **discuss existing BEP**. ## Steps to Write a New BEP -1. Look at the structure of existing BEPs in the [bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs). Note the section headings. [BEP-2](https://github.com/bigchaindb/BEPs/tree/master/2) (our variant of the consensus-oriented specification system [COSS]) says more about the expected structure and process. +1. Look at the structure of existing BEPs in the [corechaindb/BEPs repo](https://github.com/corechaindb/BEPs). Note the section headings. [BEP-2](https://github.com/corechaindb/BEPs/tree/master/2) (our variant of the consensus-oriented specification system [COSS]) says more about the expected structure and process. 1. Write a first draft of your BEP. It doesn't have to be long or perfect. -1. Push your BEP draft to the [bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs) and make a pull request. [BEP-1](https://github.com/bigchaindb/BEPs/tree/master/1) (our variant of C4) outlines the process we use to handle all pull requests. In particular, we try to merge all pull requests quickly. +1. Push your BEP draft to the [corechaindb/BEPs repo](https://github.com/corechaindb/BEPs) and make a pull request. [BEP-1](https://github.com/corechaindb/BEPs/tree/master/1) (our variant of C4) outlines the process we use to handle all pull requests. In particular, we try to merge all pull requests quickly. 1. Your BEP can be revised by pushing more pull requests. \ No newline at end of file diff --git a/docs/root/source/contributing/ways-to-contribute/write-docs.md b/docs/root/source/contributing/ways-to-contribute/write-docs.md index 246bf9dc..f17929da 100644 --- a/docs/root/source/contributing/ways-to-contribute/write-docs.md +++ b/docs/root/source/contributing/ways-to-contribute/write-docs.md @@ -18,12 +18,12 @@ If you're writing code, you should also update any related docs. However, you mi You can certainly do that! -- The docs for BigchainDB Server live under ``bigchaindb/docs/`` in the ``bigchaindb/bigchaindb`` repo. -- There are docs for the Python driver under ``bigchaindb-driver/docs/`` in the ``bigchaindb/bigchaindb-driver`` repo. -- There are docs for the JavaScript driver under ``bigchaindb/js-bigchaindb-driver`` in the ``bigchaindb/js-bigchaindb-driver`` repo. +- The docs for BigchainDB Server live under ``corechaindb/docs/`` in the ``corechaindb/corechaindb`` repo. +- There are docs for the Python driver under ``corechaindb-driver/docs/`` in the ``corechaindb/corechaindb-driver`` repo. +- There are docs for the JavaScript driver under ``corechaindb/js-corechaindb-driver`` in the ``corechaindb/js-corechaindb-driver`` repo. - The source code for the BigchainDB website is in a private repo, but we can give you access if you ask. -The [BigchainDB Transactions Specs](https://github.com/bigchaindb/BEPs/tree/master/tx-specs/) (one for each spec version) are in the ``bigchaindb/BEPs`` repo. +The [BigchainDB Transactions Specs](https://github.com/corechaindb/BEPs/tree/master/tx-specs/) (one for each spec version) are in the ``corechaindb/BEPs`` repo. You can write the docs using Markdown (MD) or RestructuredText (RST). Sphinx can understand both. RST is more powerful. diff --git a/docs/root/source/drivers/index.rst b/docs/root/source/drivers/index.rst index f7338441..97b99530 100644 --- a/docs/root/source/drivers/index.rst +++ b/docs/root/source/drivers/index.rst @@ -11,9 +11,9 @@ Connectors to BigchainDB are referred to as drivers within the community. A driv These drivers were originally created by the original BigchainDB team: -* `Python Driver `_ -* `JavaScript / Node.js Driver `_ -* `Java Driver `_ +* `Python Driver `_ +* `JavaScript / Node.js Driver `_ +* `Java Driver `_ These drivers and tools were created by the BigchainDB community: @@ -23,9 +23,9 @@ These drivers and tools were created by the BigchainDB community: but may still be useful. Others might not work with the latest version of BigchainDB. -* `ANSI C driver `_, should also work with C++ (working as of June 2019) -* `C# driver `_ (working as of May 2019) -* `Haskell transaction builder `_ +* `ANSI C driver `_, should also work with C++ (working as of June 2019) +* `C# driver `_ (working as of May 2019) +* `Haskell transaction builder `_ * `Go driver `_ -* `Ruby driver `_ -* `Ruby library for preparing/signing transactions and submitting them or querying a BigchainDB node (MIT licensed) `_ +* `Ruby driver `_ +* `Ruby library for preparing/signing transactions and submitting them or querying a BigchainDB node (MIT licensed) `_ diff --git a/docs/root/source/index.rst b/docs/root/source/index.rst index f0c5cbd5..5b314fa2 100644 --- a/docs/root/source/index.rst +++ b/docs/root/source/index.rst @@ -21,7 +21,7 @@ More About BigchainDB :maxdepth: 1 BigchainDB Docs Home - about-bigchaindb + about-corechaindb terminology properties basic-usage diff --git a/docs/root/source/installation/api/http-client-server-api.rst b/docs/root/source/installation/api/http-client-server-api.rst index 0c41324e..c53a226f 100644 --- a/docs/root/source/installation/api/http-client-server-api.rst +++ b/docs/root/source/installation/api/http-client-server-api.rst @@ -18,7 +18,7 @@ If you set up a BigchainDB node or reverse proxy yourself, and you're not sure what the API Root URL is, then see the last section of this page for help. -.. _bigchaindb-root-url: +.. _corechaindb-root-url: BigchainDB Root URL ------------------- @@ -59,7 +59,7 @@ Transactions Endpoint then one option is to connect to MongoDB directly (if possible) and do whatever queries MongoDB allows. For more about that option, see - `the page about querying BigchainDB `_. + `the page about querying BigchainDB `_. .. http:get:: /api/v1/transactions/{transaction_id} @@ -172,11 +172,11 @@ Transactions Endpoint The posted transaction should be valid. The relevant - `BigchainDB Transactions Spec `_ + `BigchainDB Transactions Spec `_ explains how to build a valid transaction and how to check if a transaction is valid. One would normally use a driver such as the `BigchainDB Python Driver - `_ + `_ to build a valid transaction. .. note:: @@ -223,7 +223,7 @@ unspent outputs. then one option is to connect to MongoDB directly (if possible) and do whatever queries MongoDB allows. For more about that option, see - `the page about querying BigchainDB `_. + `the page about querying BigchainDB `_. .. http:get:: /api/v1/outputs @@ -341,7 +341,7 @@ Assets then one option is to connect to MongoDB directly (if possible) and do whatever queries MongoDB allows. For more about that option, see - `the page about querying BigchainDB `_. + `the page about querying BigchainDB `_. .. http:get:: /api/v1/assets @@ -377,7 +377,7 @@ Assets .. sourcecode:: http - GET /api/v1/assets/?search=bigchaindb HTTP/1.1 + GET /api/v1/assets/?search=corechaindb HTTP/1.1 Host: example.com **Example response**: @@ -426,7 +426,7 @@ Assets .. sourcecode:: http - GET /api/v1/assets?search=bigchaindb&limit=2 HTTP/1.1 + GET /api/v1/assets?search=corechaindb&limit=2 HTTP/1.1 Host: example.com **Example response**: @@ -465,7 +465,7 @@ Transaction Metadata then one option is to connect to MongoDB directly (if possible) and do whatever queries MongoDB allows. For more about that option, see - `the page about querying BigchainDB `_. + `the page about querying BigchainDB `_. .. http:get:: /api/v1/metadata @@ -501,7 +501,7 @@ Transaction Metadata .. sourcecode:: http - GET /api/v1/metadata/?search=bigchaindb HTTP/1.1 + GET /api/v1/metadata/?search=corechaindb HTTP/1.1 Host: example.com **Example response**: @@ -550,7 +550,7 @@ Transaction Metadata .. sourcecode:: http - GET /api/v1/metadata?search=bigchaindb&limit=2 HTTP/1.1 + GET /api/v1/metadata?search=corechaindb&limit=2 HTTP/1.1 Host: example.com **Example response**: @@ -703,7 +703,7 @@ Blocks Determining the API Root URL ---------------------------- -When you start BigchainDB Server using ``bigchaindb start``, +When you start BigchainDB Server using ``corechaindb start``, an HTTP API is exposed at some address. The default is: ``http://localhost:9984/api/v1/`` diff --git a/docs/root/source/installation/api/http-samples/api-index-response.http b/docs/root/source/installation/api/http-samples/api-index-response.http index f425f833..ae4f5fe1 100644 --- a/docs/root/source/installation/api/http-samples/api-index-response.http +++ b/docs/root/source/installation/api/http-samples/api-index-response.http @@ -4,7 +4,7 @@ Content-Type: application/json { "assets": "/assets/", "blocks": "/blocks/", - "docs": "https://docs.bigchaindb.com/projects/server/en/v2.2.2/http-client-server-api.html", + "docs": "https://docs.corechaindb.com/projects/server/en/v2.2.2/http-client-server-api.html", "metadata": "/metadata/", "outputs": "/outputs/", "streams": "ws://localhost:9985/api/v1/streams/valid_transactions", diff --git a/docs/root/source/installation/api/http-samples/index-response.http b/docs/root/source/installation/api/http-samples/index-response.http index 8a0af03c..9bbe6f8d 100644 --- a/docs/root/source/installation/api/http-samples/index-response.http +++ b/docs/root/source/installation/api/http-samples/index-response.http @@ -6,7 +6,7 @@ Content-Type: application/json "v1": { "assets": "/api/v1/assets/", "blocks": "/api/v1/blocks/", - "docs": "https://docs.bigchaindb.com/projects/server/en/v2.2.2/http-client-server-api.html", + "docs": "https://docs.corechaindb.com/projects/server/en/v2.2.2/http-client-server-api.html", "metadata": "/api/v1/metadata/", "outputs": "/api/v1/outputs/", "streams": "ws://localhost:9985/api/v1/streams/valid_transactions", @@ -14,7 +14,7 @@ Content-Type: application/json "validators": "/api/v1/validators" } }, - "docs": "https://docs.bigchaindb.com/projects/server/en/v2.2.2/", + "docs": "https://docs.corechaindb.com/projects/server/en/v2.2.2/", "software": "BigchainDB", "version": "2.2.2" } diff --git a/docs/root/source/installation/api/websocket-event-stream-api.rst b/docs/root/source/installation/api/websocket-event-stream-api.rst index 73e11553..9c2484df 100644 --- a/docs/root/source/installation/api/websocket-event-stream-api.rst +++ b/docs/root/source/installation/api/websocket-event-stream-api.rst @@ -82,7 +82,7 @@ All messages sent in a stream are in the JSON format. as a specific ``output``'s ``public_key``. If you have specific use cases that you think would fit as part of this - API, consider creating a new `BEP `_. + API, consider creating a new `BEP `_. Valid Transactions ~~~~~~~~~~~~~~~~~~ diff --git a/docs/root/source/installation/appendices/cryptography.rst b/docs/root/source/installation/appendices/cryptography.rst index 6b3847cb..9066cc2a 100644 --- a/docs/root/source/installation/appendices/cryptography.rst +++ b/docs/root/source/installation/appendices/cryptography.rst @@ -9,6 +9,6 @@ Cryptography Use the following link to find the BigchainDB Transactions Spec (or Specs) that are relevant to you: -`BigchainDB Transactions Specs `_ +`BigchainDB Transactions Specs `_ Then see the sections titled **Cryptographic Hashes** and **Cryptographic Keys and Signatures**. \ No newline at end of file diff --git a/docs/root/source/installation/appendices/licenses.md b/docs/root/source/installation/appendices/licenses.md index a8721afc..d710b3f7 100644 --- a/docs/root/source/installation/appendices/licenses.md +++ b/docs/root/source/installation/appendices/licenses.md @@ -7,4 +7,4 @@ Code is Apache-2.0 and docs are CC-BY-4.0 # Licenses -Information about how the BigchainDB Server code and documentation are licensed can be found in [the LICENSES.md file](https://github.com/bigchaindb/bigchaindb/blob/master/LICENSES.md) of the bigchaindb/bigchaindb repository on GitHub. +Information about how the BigchainDB Server code and documentation are licensed can be found in [the LICENSES.md file](https://github.com/corechaindb/corechaindb/blob/master/LICENSES.md) of the corechaindb/corechaindb repository on GitHub. diff --git a/docs/root/source/installation/appendices/log-rotation.md b/docs/root/source/installation/appendices/log-rotation.md index f63b15d4..7e06f6f9 100644 --- a/docs/root/source/installation/appendices/log-rotation.md +++ b/docs/root/source/installation/appendices/log-rotation.md @@ -27,8 +27,8 @@ and [log rotation](https://docs.mongodb.com/v3.6/tutorial/rotate-log-files/). BigchainDB Server writes its logs to two files: normal logs and error logs. The names of those files, and their locations, are set as part of the BigchainDB configuration settings. The default names and locations are: -- `~/bigchaindb.log` -- `~/bigchaindb-errors.log` +- `~/corechaindb.log` +- `~/corechaindb-errors.log` Log rotation is baked into BigchainDB Server using Python's `logging` module. The logs for BigchainDB Server are rotated when any of the above mentioned files exceeds 209715200 bytes (i.e. approximately 209 MB). @@ -43,7 +43,7 @@ Tendermint writes its logs to the files: If you started BigchainDB Server and Tendermint using Monit, as suggested by our guide on [How to Set Up a BigchainDB Network](../network-setup/network-setup), -then the logs will be written to `$HOME/.bigchaindb-monit/logs/`. +then the logs will be written to `$HOME/.corechaindb-monit/logs/`. Moreover, if you started BigchainDB Server and Tendermint using Monit, then Monit monitors the Tendermint log files. diff --git a/docs/root/source/installation/commands-and-backend/backend.rst b/docs/root/source/installation/commands-and-backend/backend.rst index bb094992..5a5881ee 100644 --- a/docs/root/source/installation/commands-and-backend/backend.rst +++ b/docs/root/source/installation/commands-and-backend/backend.rst @@ -8,46 +8,46 @@ Database Backend Interfaces ########################### -.. automodule:: bigchaindb.backend +.. automodule:: corechaindb.backend :special-members: __init__ Generic Interfaces ================== -:mod:`bigchaindb.backend.connection` +:mod:`corechaindb.backend.connection` ------------------------------------ -.. automodule:: bigchaindb.backend.connection +.. automodule:: corechaindb.backend.connection :special-members: __init__ -:mod:`bigchaindb.backend.query` +:mod:`corechaindb.backend.query` ------------------------------- -.. automodule:: bigchaindb.backend.query +.. automodule:: corechaindb.backend.query -:mod:`bigchaindb.backend.schema` +:mod:`corechaindb.backend.schema` -------------------------------- -.. automodule:: bigchaindb.backend.schema +.. automodule:: corechaindb.backend.schema -:mod:`bigchaindb.backend.utils` +:mod:`corechaindb.backend.utils` ------------------------------- -.. automodule:: bigchaindb.backend.utils +.. automodule:: corechaindb.backend.utils MongoDB Backend =============== -.. automodule:: bigchaindb.backend.localmongodb +.. automodule:: corechaindb.backend.localmongodb :special-members: __init__ -:mod:`bigchaindb.backend.localmongodb.connection` +:mod:`corechaindb.backend.localmongodb.connection` ------------------------------------------------- -.. automodule:: bigchaindb.backend.localmongodb.connection +.. automodule:: corechaindb.backend.localmongodb.connection -:mod:`bigchaindb.backend.localmongodb.query` +:mod:`corechaindb.backend.localmongodb.query` -------------------------------------------- -.. automodule:: bigchaindb.backend.localmongodb.query +.. automodule:: corechaindb.backend.localmongodb.query -:mod:`bigchaindb.backend.localmongodb.schema` +:mod:`corechaindb.backend.localmongodb.schema` --------------------------------------------- -.. automodule:: bigchaindb.backend.localmongodb.schema +.. automodule:: corechaindb.backend.localmongodb.schema diff --git a/docs/root/source/installation/commands-and-backend/commands.rst b/docs/root/source/installation/commands-and-backend/commands.rst index 099755d2..3ae6790b 100644 --- a/docs/root/source/installation/commands-and-backend/commands.rst +++ b/docs/root/source/installation/commands-and-backend/commands.rst @@ -8,17 +8,17 @@ Command Line Interface ###################### -.. automodule:: bigchaindb.commands +.. automodule:: corechaindb.commands :special-members: __init__ -:mod:`bigchaindb.commands.bigchaindb` +:mod:`corechaindb.commands.corechaindb` ------------------------------------- -.. automodule:: bigchaindb.commands.bigchaindb +.. automodule:: corechaindb.commands.corechaindb -:mod:`bigchaindb.commands.utils` +:mod:`corechaindb.commands.utils` -------------------------------- -.. automodule:: bigchaindb.commands.utils +.. automodule:: corechaindb.commands.utils diff --git a/docs/root/source/installation/commands-and-backend/index.rst b/docs/root/source/installation/commands-and-backend/index.rst index 2cbc2fcd..2ebb16f7 100644 --- a/docs/root/source/installation/commands-and-backend/index.rst +++ b/docs/root/source/installation/commands-and-backend/index.rst @@ -20,7 +20,7 @@ in the BigchainDB Server code, based on Python docstrings in the code itself. :maxdepth: 1 commands - the-bigchaindb-class + the-corechaindb-class backend \ No newline at end of file diff --git a/docs/root/source/installation/commands-and-backend/the-bigchaindb-class.rst b/docs/root/source/installation/commands-and-backend/the-corechaindb-class.rst similarity index 87% rename from docs/root/source/installation/commands-and-backend/the-bigchaindb-class.rst rename to docs/root/source/installation/commands-and-backend/the-corechaindb-class.rst index 9f217c5a..2a91b3c3 100644 --- a/docs/root/source/installation/commands-and-backend/the-bigchaindb-class.rst +++ b/docs/root/source/installation/commands-and-backend/the-corechaindb-class.rst @@ -8,4 +8,4 @@ The BigchainDB Class #################### -.. autoclass:: bigchaindb.BigchainDB +.. autoclass:: corechaindb.BigchainDB diff --git a/docs/root/source/installation/network-setup/bigchaindb-node-ansible.md b/docs/root/source/installation/network-setup/corechaindb-node-ansible.md similarity index 73% rename from docs/root/source/installation/network-setup/bigchaindb-node-ansible.md rename to docs/root/source/installation/network-setup/corechaindb-node-ansible.md index 08627731..841f6021 100644 --- a/docs/root/source/installation/network-setup/bigchaindb-node-ansible.md +++ b/docs/root/source/installation/network-setup/corechaindb-node-ansible.md @@ -2,6 +2,6 @@ You can find one of the installation methods with Ansible on GitHub at: -[Ansible script](https://github.com/bigchaindb/bigchaindb-node-ansible) +[Ansible script](https://github.com/corechaindb/corechaindb-node-ansible) It allows to install BigchainDB, MongoDB, Tendermint, and python, and then connect nodes into a network. Current tested machine is Ubuntu 18.04. \ No newline at end of file diff --git a/docs/root/source/installation/network-setup/index.rst b/docs/root/source/installation/network-setup/index.rst index 386920e6..8e6c294e 100644 --- a/docs/root/source/installation/network-setup/index.rst +++ b/docs/root/source/installation/network-setup/index.rst @@ -15,5 +15,5 @@ There are several ways to setup a network. You can use the Kubernetes deployment networks network-setup k8s-deployment-template/index - bigchaindb-node-ansible.md + corechaindb-node-ansible.md \ No newline at end of file diff --git a/docs/root/source/installation/network-setup/k8s-deployment-template/architecture.rst b/docs/root/source/installation/network-setup/k8s-deployment-template/architecture.rst index c996eaff..e5ee0921 100644 --- a/docs/root/source/installation/network-setup/k8s-deployment-template/architecture.rst +++ b/docs/root/source/installation/network-setup/k8s-deployment-template/architecture.rst @@ -32,7 +32,7 @@ as described in these docs, it will include: `_. -.. _bigchaindb-node: +.. _corechaindb-node: BigchainDB Node Diagram ----------------------- diff --git a/docs/root/source/installation/network-setup/k8s-deployment-template/bigchaindb-network-on-kubernetes.rst b/docs/root/source/installation/network-setup/k8s-deployment-template/corechaindb-network-on-kubernetes.rst similarity index 92% rename from docs/root/source/installation/network-setup/k8s-deployment-template/bigchaindb-network-on-kubernetes.rst rename to docs/root/source/installation/network-setup/k8s-deployment-template/corechaindb-network-on-kubernetes.rst index e50502bf..5c6f9549 100644 --- a/docs/root/source/installation/network-setup/k8s-deployment-template/bigchaindb-network-on-kubernetes.rst +++ b/docs/root/source/installation/network-setup/k8s-deployment-template/corechaindb-network-on-kubernetes.rst @@ -4,7 +4,7 @@ SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) Code is Apache-2.0 and docs are CC-BY-4.0 -.. _kubernetes-template-deploy-bigchaindb-network: +.. _kubernetes-template-deploy-corechaindb-network: Kubernetes Template: Deploying a BigchainDB network =================================================== @@ -44,9 +44,9 @@ to form a network. Below, we refer to multiple files by their directory and filename, -such as ``bigchaindb/bigchaindb-ext-conn-svc.yaml``. Those files are located in the -`bigchaindb/bigchaindb repository on GitHub -`_ in the ``k8s/`` directory. +such as ``corechaindb/corechaindb-ext-conn-svc.yaml``. Those files are located in the +`corechaindb/corechaindb repository on GitHub +`_ in the ``k8s/`` directory. Make sure you're getting those files from the appropriate Git branch on GitHub, i.e. the branch for the version of BigchainDB that your BigchainDB cluster is using. @@ -62,7 +62,7 @@ cluster is using. Once a BigchainDB network is started with a certain number of validators and a genesis file. Users cannot add new validator nodes dynamically. You can track the progress of this funtionality on our - `github repository `_. + `github repository `_. .. _pre-reqs-bdb-network: @@ -229,7 +229,7 @@ the :doc:`deployment steps for each node ` N number of times the number of participants in the network. In our Kubernetes deployment template for a single BigchainDB node, we covered the basic configurations -settings :ref:`here `. +settings :ref:`here `. Since, we index the ConfigMap and Secret Keys for the single site deployment, we need to update all the Kubernetes components to reflect the corresponding changes i.e. For each Kubernetes Service, @@ -267,7 +267,7 @@ the ``mongo-node-1-ss.yaml`` and update the corresponding ConfigMapKeyRef.name o terminationGracePeriodSeconds: 10 containers: - name: mongodb - image: bigchaindb/mongodb:3.2 + image: corechaindb/mongodb:3.2 imagePullPolicy: IfNotPresent env: - name: MONGODB_FQDN @@ -366,13 +366,13 @@ The above example is meant to be repeated for all the Kubernetes components of a * ``mongodb/mongodb-node-X-ss.yaml`` -* ``bigchaindb/bigchaindb-node-X-svc.yaml`` +* ``corechaindb/corechaindb-node-X-svc.yaml`` -* ``bigchaindb/bigchaindb-node-X-sc.yaml`` +* ``corechaindb/corechaindb-node-X-sc.yaml`` -* ``bigchaindb/bigchaindb-node-X-pvc.yaml`` +* ``corechaindb/corechaindb-node-X-pvc.yaml`` -* ``bigchaindb/bigchaindb-node-X-ss.yaml`` +* ``corechaindb/corechaindb-node-X-ss.yaml`` * ``nginx-openresty/nginx-openresty-node-X-svc.yaml`` @@ -408,7 +408,7 @@ described :ref:`above `: * :ref:`Start the MongoDB Kubernetes Service `. -* :ref:`Start the BigchainDB Kubernetes Service `. +* :ref:`Start the BigchainDB Kubernetes Service `. * :ref:`Start the OpenResty Kubernetes Service `. @@ -421,22 +421,22 @@ to talk to each other i.e. specifically the communication between the BigchainDB peers. Set up networking between the clusters using `Kubernetes Services `_. -Assuming we have a BigchainDB instance ``bigchaindb-instance-1`` residing in Azure data center location ``westeurope`` and we -want to connect to ``bigchaindb-instance-2``, ``bigchaindb-instance-3``, and ``bigchaindb-instance-4`` located in Azure data centers +Assuming we have a BigchainDB instance ``corechaindb-instance-1`` residing in Azure data center location ``westeurope`` and we +want to connect to ``corechaindb-instance-2``, ``corechaindb-instance-3``, and ``corechaindb-instance-4`` located in Azure data centers ``eastus``, ``centralus`` and ``westus``, respectively. Unless you already have explicitly set up networking for -``bigchaindb-instance-1`` to communicate with ``bigchaindb-instance-2/3/4`` and +``corechaindb-instance-1`` to communicate with ``corechaindb-instance-2/3/4`` and vice versa, we will have to add a Kubernetes Service in each cluster to accomplish this goal in order to set up a BigchainDB P2P network. It is similar to ensuring that there is a ``CNAME`` record in the DNS -infrastructure to resolve ``bigchaindb-instance-X`` to the host where it is actually available. +infrastructure to resolve ``corechaindb-instance-X`` to the host where it is actually available. We can do this in Kubernetes using a Kubernetes Service of ``type`` ``ExternalName``. -* This configuration is located in the file ``bigchaindb/bigchaindb-ext-conn-svc.yaml``. +* This configuration is located in the file ``corechaindb/corechaindb-ext-conn-svc.yaml``. * Set the name of the ``metadata.name`` to the host name of the BigchainDB instance you are trying to connect to. - For instance if you are configuring this service on cluster with ``bigchaindb-instance-1`` then the ``metadata.name`` will - be ``bigchaindb-instance-2`` and vice versa. + For instance if you are configuring this service on cluster with ``corechaindb-instance-1`` then the ``metadata.name`` will + be ``corechaindb-instance-2`` and vice versa. * Set ``spec.ports.port[0]`` to the ``tm-p2p-port`` from the ConfigMap for the other cluster. @@ -452,7 +452,7 @@ We can do this in Kubernetes using a Kubernetes Service of ``type`` If you are not the system administrator of the cluster, you have to get in touch with the system administrator/s of the other ``n-1`` clusters and - share with them your instance name (``bigchaindb-instance-name`` in the ConfigMap) + share with them your instance name (``corechaindb-instance-name`` in the ConfigMap) and the FQDN of the NGINX instance acting as Gateway(set in: :ref:`Assign DNS name to NGINX Public IP `). diff --git a/docs/root/source/installation/network-setup/k8s-deployment-template/index.rst b/docs/root/source/installation/network-setup/k8s-deployment-template/index.rst index a79b95ab..59842ce1 100644 --- a/docs/root/source/installation/network-setup/k8s-deployment-template/index.rst +++ b/docs/root/source/installation/network-setup/k8s-deployment-template/index.rst @@ -42,7 +42,7 @@ Feel free change things to suit your needs or preferences. cloud-manager easy-rsa upgrade-on-kubernetes - bigchaindb-network-on-kubernetes + corechaindb-network-on-kubernetes tectonic-azure troubleshoot architecture diff --git a/docs/root/source/installation/network-setup/k8s-deployment-template/log-analytics.rst b/docs/root/source/installation/network-setup/k8s-deployment-template/log-analytics.rst index fd056f5b..c459c71e 100644 --- a/docs/root/source/installation/network-setup/k8s-deployment-template/log-analytics.rst +++ b/docs/root/source/installation/network-setup/k8s-deployment-template/log-analytics.rst @@ -256,9 +256,9 @@ All logging messages containing the string "critical" but not "CriticalAddonsOnl ``Type=ContainerLog critical NOT(CriticalAddonsOnly)`` -All logging messages from containers running the Docker image bigchaindb/nginx_3scale:1.3, containing the string "GET" but not the strings "Go-http-client" or "runscope" (where those exclusions filter out tests by Kubernetes and Runscope): +All logging messages from containers running the Docker image corechaindb/nginx_3scale:1.3, containing the string "GET" but not the strings "Go-http-client" or "runscope" (where those exclusions filter out tests by Kubernetes and Runscope): -``Type=ContainerLog Image="bigchaindb/nginx_3scale:1.3" GET NOT("Go-http-client") NOT(runscope)`` +``Type=ContainerLog Image="corechaindb/nginx_3scale:1.3" GET NOT("Go-http-client") NOT(runscope)`` .. note:: diff --git a/docs/root/source/installation/network-setup/k8s-deployment-template/node-config-map-and-secrets.rst b/docs/root/source/installation/network-setup/k8s-deployment-template/node-config-map-and-secrets.rst index c40058b8..fd8fd6c4 100644 --- a/docs/root/source/installation/network-setup/k8s-deployment-template/node-config-map-and-secrets.rst +++ b/docs/root/source/installation/network-setup/k8s-deployment-template/node-config-map-and-secrets.rst @@ -4,7 +4,7 @@ SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) Code is Apache-2.0 and docs are CC-BY-4.0 -.. _how-to-configure-a-bigchaindb-node: +.. _how-to-configure-a-corechaindb-node: How to Configure a BigchainDB Node ================================== diff --git a/docs/root/source/installation/network-setup/k8s-deployment-template/node-on-kubernetes.rst b/docs/root/source/installation/network-setup/k8s-deployment-template/node-on-kubernetes.rst index 88a469c2..384e3fa5 100644 --- a/docs/root/source/installation/network-setup/k8s-deployment-template/node-on-kubernetes.rst +++ b/docs/root/source/installation/network-setup/k8s-deployment-template/node-on-kubernetes.rst @@ -4,7 +4,7 @@ SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) Code is Apache-2.0 and docs are CC-BY-4.0 -.. _kubernetes-template-deploy-a-single-bigchaindb-node: +.. _kubernetes-template-deploy-a-single-corechaindb-node: Kubernetes Template: Deploy a Single BigchainDB Node ==================================================== @@ -26,7 +26,7 @@ It assumes you already have a running Kubernetes cluster. Below, we refer to many files by their directory and filename, such as ``configuration/config-map.yaml``. Those files are files in the -`bigchaindb/bigchaindb repository on GitHub `_ +`corechaindb/corechaindb repository on GitHub `_ in the ``k8s/`` directory. Make sure you're getting those files from the appropriate Git branch on GitHub, i.e. the branch for the version of BigchainDB that your BigchainDB @@ -132,7 +132,7 @@ That means you can visit the dashboard in your web browser at Step 3: Configure Your BigchainDB Node -------------------------------------- -See the page titled :ref:`how-to-configure-a-bigchaindb-node`. +See the page titled :ref:`how-to-configure-a-corechaindb-node`. .. _start-the-nginx-service: @@ -166,7 +166,7 @@ Step 5: Assign DNS Name to the NGINX Public IP * This step is required only if you are planning to set up multiple `BigchainDB nodes - `_ or are using + `_ or are using HTTPS certificates tied to a domain. * The following command can help you find out if the NGINX service started @@ -214,7 +214,7 @@ Step 6: Start the MongoDB Kubernetes Service $ kubectl apply -f mongodb/mongo-svc.yaml -.. _start-the-bigchaindb-kubernetes-service: +.. _start-the-corechaindb-kubernetes-service: Step 7: Start the BigchainDB Kubernetes Service ----------------------------------------------- @@ -223,7 +223,7 @@ Step 7: Start the BigchainDB Kubernetes Service .. code:: bash - $ kubectl apply -f bigchaindb/bigchaindb-svc.yaml + $ kubectl apply -f corechaindb/corechaindb-svc.yaml .. _start-the-openresty-kubernetes-service: @@ -437,7 +437,7 @@ BigchainDB needs somewhere to store Tendermint data persistently, Tendermint use LevelDB as the persistent storage layer. The Kubernetes template for configuration of Storage Class is located in the -file ``bigchaindb/bigchaindb-sc.yaml``. +file ``corechaindb/corechaindb-sc.yaml``. Details about how to create a Azure Storage account and how Kubernetes Storage Class works are already covered in this document: :ref:`create-kubernetes-storage-class-mdb`. @@ -446,7 +446,7 @@ Create the required storage classes using: .. code:: bash - $ kubectl apply -f bigchaindb/bigchaindb-sc.yaml + $ kubectl apply -f corechaindb/corechaindb-sc.yaml You can check if it worked using ``kubectl get storageclasses``. @@ -459,7 +459,7 @@ Step 15: Create Kubernetes Persistent Volume Claims for BigchainDB Next, you will create two PersistentVolumeClaim objects ``tendermint-db-claim`` and ``tendermint-config-db-claim``. -This configuration is located in the file ``bigchaindb/bigchaindb-pvc.yaml``. +This configuration is located in the file ``corechaindb/corechaindb-pvc.yaml``. Details about Kubernetes Persistent Volumes, Persistent Volume Claims and how they work with Azure are already covered in this @@ -469,7 +469,7 @@ Create the required Persistent Volume Claims using: .. code:: bash - $ kubectl apply -f bigchaindb/bigchaindb-pvc.yaml + $ kubectl apply -f corechaindb/corechaindb-pvc.yaml You can check its status using: @@ -483,7 +483,7 @@ You can check its status using: Step 16: Start a Kubernetes StatefulSet for BigchainDB ------------------------------------------------------ - * This configuration is located in the file ``bigchaindb/bigchaindb-ss.yaml``. + * This configuration is located in the file ``corechaindb/corechaindb-ss.yaml``. * Set the ``spec.serviceName`` to the value set in ``bdb-instance-name`` in the ConfigMap. @@ -505,7 +505,7 @@ Step 16: Start a Kubernetes StatefulSet for BigchainDB .. code:: bash - $ kubectl apply -f bigchaindb/bigchaindb-ss.yaml + $ kubectl apply -f corechaindb/corechaindb-ss.yaml .. code:: bash @@ -570,7 +570,7 @@ Step 18(Optional): Start a Kubernetes Deployment for OpenResty - ``node-dns-server-ip`` - ``openresty-backend-port`` - ``ngx-bdb-instance-name`` - - ``bigchaindb-api-port`` + - ``corechaindb-api-port`` * Create the OpenResty Deployment using: @@ -610,7 +610,7 @@ infrastructure to resolve ``bdb-instance-X`` to the host where it is actually av We can do this in Kubernetes using a Kubernetes Service of ``type`` ``ExternalName``. -* This configuration is located in the file ``bigchaindb/bigchaindb-ext-conn-svc.yaml``. +* This configuration is located in the file ``corechaindb/corechaindb-ext-conn-svc.yaml``. * Set the name of the ``metadata.name`` to the host name of the BigchainDB instance you are trying to connect to. For instance if you are configuring this service on cluster with ``bdb-instance-1`` then the ``metadata.name`` will @@ -646,17 +646,17 @@ Step 21.1: Testing Internally To test the setup of your BigchainDB node, you could use a Docker container that provides utilities like ``nslookup``, ``curl`` and ``dig``. For example, you could use a container based on our -`bigchaindb/toolbox `_ image. +`corechaindb/toolbox `_ image. (The corresponding -`Dockerfile `_ -is in the ``bigchaindb/bigchaindb`` repository on GitHub.) +`Dockerfile `_ +is in the ``corechaindb/corechaindb`` repository on GitHub.) You can use it as below to get started immediately: .. code:: bash $ kubectl \ run -it toolbox \ - --image bigchaindb/toolbox \ + --image corechaindb/toolbox \ --image-pull-policy=Always \ --restart=Never --rm diff --git a/docs/root/source/installation/network-setup/k8s-deployment-template/troubleshoot.rst b/docs/root/source/installation/network-setup/k8s-deployment-template/troubleshoot.rst index 2566d34f..7a85e53c 100644 --- a/docs/root/source/installation/network-setup/k8s-deployment-template/troubleshoot.rst +++ b/docs/root/source/installation/network-setup/k8s-deployment-template/troubleshoot.rst @@ -31,7 +31,7 @@ container and looking at the syslog (the ``journalctl`` command should usually work). This issue is resolved in -`PR #1757 `_. +`PR #1757 `_. 2. 502 Bad Gateway Error on Runscope Tests ------------------------------------------ diff --git a/docs/root/source/installation/network-setup/k8s-deployment-template/workflow.rst b/docs/root/source/installation/network-setup/k8s-deployment-template/workflow.rst index fd08a86d..50a913e4 100644 --- a/docs/root/source/installation/network-setup/k8s-deployment-template/workflow.rst +++ b/docs/root/source/installation/network-setup/k8s-deployment-template/workflow.rst @@ -145,7 +145,7 @@ then you will run a script which reads that file to generate some Kubernetes con you will send those config files to your Kubernetes cluster, and then you will deploy all the stuff that you need to have a BigchainDB node. -⟶ Proceed to :ref:`deploy your BigchainDB node `. +⟶ Proceed to :ref:`deploy your BigchainDB node `. .. raw:: html diff --git a/docs/root/source/installation/network-setup/network-setup.md b/docs/root/source/installation/network-setup/network-setup.md index c081c529..70bc7c8b 100644 --- a/docs/root/source/installation/network-setup/network-setup.md +++ b/docs/root/source/installation/network-setup/network-setup.md @@ -173,10 +173,10 @@ Install Monit: sudo apt install monit ``` -If you installed the `bigchaindb` Python package as above, you should have the `bigchaindb-monit-config` script in your `PATH` now. Run the script to build a configuration file for Monit: +If you installed the `corechaindb` Python package as above, you should have the `corechaindb-monit-config` script in your `PATH` now. Run the script to build a configuration file for Monit: ``` -bigchaindb-monit-config +corechaindb-monit-config ``` Run Monit as a daemon, instructing it to wake up every second to check on processes: @@ -185,23 +185,23 @@ Run Monit as a daemon, instructing it to wake up every second to check on proces monit -d 1 ``` -Monit will run the BigchainDB and Tendermint processes and restart them when they crash. If the root `bigchaindb_` process crashes, Monit will also restart the Tendermint process. +Monit will run the BigchainDB and Tendermint processes and restart them when they crash. If the root `corechaindb_` process crashes, Monit will also restart the Tendermint process. You can check the status by running `monit status` or `monit summary`. -By default, it will collect program logs into the `~/.bigchaindb-monit/logs` folder. +By default, it will collect program logs into the `~/.corechaindb-monit/logs` folder. To learn more about Monit, use `monit -h` (help) or read [the Monit documentation][monit-manual]. -Check `bigchaindb-monit-config -h` if you want to arrange a different folder for logs or some of the Monit internal artifacts. +Check `corechaindb-monit-config -h` if you want to arrange a different folder for logs or some of the Monit internal artifacts. -If you want to start and manage the BigchainDB and Tendermint processes yourself, then look inside the file [bigchaindb/pkg/scripts/bigchaindb-monit-config](https://github.com/bigchaindb/bigchaindb/blob/master/pkg/scripts/bigchaindb-monit-config) to see how *it* starts BigchainDB and Tendermint. +If you want to start and manage the BigchainDB and Tendermint processes yourself, then look inside the file [corechaindb/pkg/scripts/corechaindb-monit-config](https://github.com/corechaindb/corechaindb/blob/master/pkg/scripts/corechaindb-monit-config) to see how *it* starts BigchainDB and Tendermint. ## How Others Can Access Your Node If you followed the above instructions, then your node should be publicly-accessible with BigchainDB Root URL `https://hostname` or `http://hostname:9984`. That is, anyone can interact with your node using the [BigchainDB HTTP API](../api/http-client-server-api) exposed at that address. The most common way to do that is to use one of the [BigchainDB Drivers](../../drivers/index). -[bdb:software]: https://github.com/bigchaindb/bigchaindb/ +[bdb:software]: https://github.com/corechaindb/corechaindb/ [bdb:pypi]: https://pypi.org/project/BigchainDB/#history [tendermint:releases]: https://github.com/tendermint/tendermint/releases [monit]: https://www.mmonit.com/monit diff --git a/docs/root/source/installation/network-setup/networks.md b/docs/root/source/installation/network-setup/networks.md index 058df075..1c49d9d5 100644 --- a/docs/root/source/installation/network-setup/networks.md +++ b/docs/root/source/installation/network-setup/networks.md @@ -7,7 +7,7 @@ Code is Apache-2.0 and docs are CC-BY-4.0 # BigchainDB Networks -A **BigchainDB network** is a set of connected **BigchainDB nodes**, managed by a **BigchainDB consortium** (i.e. an organization). Those terms are defined in the [BigchainDB Terminology page](https://docs.bigchaindb.com/en/latest/terminology.html). +A **BigchainDB network** is a set of connected **BigchainDB nodes**, managed by a **BigchainDB consortium** (i.e. an organization). Those terms are defined in the [BigchainDB Terminology page](https://docs.corechaindb.com/en/latest/terminology.html). ## Consortium Structure & Governance @@ -17,7 +17,7 @@ A governance process is required to make those decisions, and therefore one of t This documentation doesn't explain how to create a consortium, nor does it outline the possible governance processes. It's worth noting that the decentralization of a BigchainDB network depends, -to some extent, on the decentralization of the associated consortium. See the pages about [decentralization](https://docs.bigchaindb.com/en/latest/decentralized.html) and [node diversity](https://docs.bigchaindb.com/en/latest/diversity.html). +to some extent, on the decentralization of the associated consortium. See the pages about [decentralization](https://docs.corechaindb.com/en/latest/decentralized.html) and [node diversity](https://docs.corechaindb.com/en/latest/diversity.html). ## DNS Records and SSL Certificates diff --git a/docs/root/source/installation/node-setup/all-in-one-bigchaindb.md b/docs/root/source/installation/node-setup/all-in-one-corechaindb.md similarity index 67% rename from docs/root/source/installation/node-setup/all-in-one-bigchaindb.md rename to docs/root/source/installation/node-setup/all-in-one-corechaindb.md index 4585c058..eff6e1d9 100644 --- a/docs/root/source/installation/node-setup/all-in-one-bigchaindb.md +++ b/docs/root/source/installation/node-setup/all-in-one-corechaindb.md @@ -10,7 +10,7 @@ Code is Apache-2.0 and docs are CC-BY-4.0 For those who like using Docker and wish to experiment with BigchainDB in non-production environments, we currently maintain a BigchainDB all-in-one Docker image and a -`Dockerfile-all-in-one` that can be used to build an image for `bigchaindb`. +`Dockerfile-all-in-one` that can be used to build an image for `corechaindb`. This image contains all the services required for a BigchainDB node i.e. @@ -21,8 +21,8 @@ This image contains all the services required for a BigchainDB node i.e. **Note:** **NOT for Production Use:** *This is an single node opinionated image not well suited for a network deployment.* *This image is to help quick deployment for early adopters, for a more standard approach please refer to one of our deployment guides:* -- [BigchainDB developer setup guides](https://docs.bigchaindb.com/projects/contributing/en/latest/dev-setup-coding-and-contribution-process/index.html). -- [BigchainDB with Kubernetes](http://docs.bigchaindb.com/projects/server/en/latest/k8s-deployment-template/index.html). +- [BigchainDB developer setup guides](https://docs.corechaindb.com/projects/contributing/en/latest/dev-setup-coding-and-contribution-process/index.html). +- [BigchainDB with Kubernetes](http://docs.corechaindb.com/projects/server/en/latest/k8s-deployment-template/index.html). ## Prerequisite(s) - [Docker](https://docs.docker.com/engine/installation/) @@ -33,19 +33,19 @@ With Docker installed, you can proceed as follows. In a terminal shell, pull the latest version of the BigchainDB all-in-one Docker image using: ```text -$ docker pull bigchaindb/bigchaindb:all-in-one +$ docker pull corechaindb/corechaindb:all-in-one $ docker run \ --detach \ - --name bigchaindb \ + --name corechaindb \ --publish 9984:9984 \ --publish 9985:9985 \ --publish 27017:27017 \ --publish 26657:26657 \ - --volume $HOME/bigchaindb_docker/mongodb/data/db:/data/db \ - --volume $HOME/bigchaindb_docker/mongodb/data/configdb:/data/configdb \ - --volume $HOME/bigchaindb_docker/tendermint:/tendermint \ - bigchaindb/bigchaindb:all-in-one + --volume $HOME/corechaindb_docker/mongodb/data/db:/data/db \ + --volume $HOME/corechaindb_docker/mongodb/data/configdb:/data/configdb \ + --volume $HOME/corechaindb_docker/tendermint:/tendermint \ + corechaindb/corechaindb:all-in-one ``` Let's analyze that command: @@ -57,18 +57,18 @@ Let's analyze that command: * `9985` BigchainDB Websocket server * `27017` Default port for MongoDB * `26657` Tendermint RPC server -* `--volume "$HOME/bigchaindb_docker/mongodb:/data"` map the host directory - `$HOME/bigchaindb_docker/mongodb` to the container directory `/data`; +* `--volume "$HOME/corechaindb_docker/mongodb:/data"` map the host directory + `$HOME/corechaindb_docker/mongodb` to the container directory `/data`; this allows us to have the data persisted on the host machine, you can read more in the [official Docker documentation](https://docs.docker.com/engine/tutorials/dockervolumes) - * `$HOME/bigchaindb_docker/tendermint:/tendermint` to persist Tendermint data. -* `bigchaindb/bigchaindb:all-in-one` the image to use. All the options after the container name are passed on to the entrypoint inside the container. + * `$HOME/corechaindb_docker/tendermint:/tendermint` to persist Tendermint data. +* `corechaindb/corechaindb:all-in-one` the image to use. All the options after the container name are passed on to the entrypoint inside the container. ## Verify ```text -$ docker ps | grep bigchaindb +$ docker ps | grep corechaindb ``` Send your first transaction using [BigchainDB drivers](../../drivers/index). @@ -80,8 +80,8 @@ Assuming you have Docker installed, you would proceed as follows. In a terminal shell: ```text -git clone git@github.com:bigchaindb/bigchaindb.git -cd bigchaindb/ +git clone git@github.com:corechaindb/corechaindb.git +cd corechaindb/ ``` Build the Docker image: diff --git a/docs/root/source/installation/node-setup/configuration.md b/docs/root/source/installation/node-setup/configuration.md index 68189084..02115c4d 100644 --- a/docs/root/source/installation/node-setup/configuration.md +++ b/docs/root/source/installation/node-setup/configuration.md @@ -21,13 +21,13 @@ The value of each setting is determined according to the following rules: * Otherwise, if it's set in a local config file, then use that value * Otherwise, use the default value -The local config file is `$HOME/.bigchaindb` by default (a file which might not even exist), but you can tell BigchainDB to use a different file by using the `-c` command-line option, e.g. `bigchaindb -c path/to/config_file.json start` -or using the `BIGCHAINDB_CONFIG_PATH` environment variable, e.g. `BIGHAINDB_CONFIG_PATH=.my_bigchaindb_config bigchaindb start`. +The local config file is `$HOME/.corechaindb` by default (a file which might not even exist), but you can tell BigchainDB to use a different file by using the `-c` command-line option, e.g. `corechaindb -c path/to/config_file.json start` +or using the `BIGCHAINDB_CONFIG_PATH` environment variable, e.g. `BIGHAINDB_CONFIG_PATH=.my_corechaindb_config corechaindb start`. Note that the `-c` command line option will always take precedence if both the `BIGCHAINDB_CONFIG_PATH` and the `-c` command line option are used. -You can read the current default values in the file [bigchaindb/\_\_init\_\_.py](https://github.com/bigchaindb/bigchaindb/blob/master/bigchaindb/__init__.py). (The link is to the latest version.) +You can read the current default values in the file [corechaindb/\_\_init\_\_.py](https://github.com/corechaindb/corechaindb/blob/master/corechaindb/__init__.py). (The link is to the latest version.) -Running `bigchaindb -y configure localmongodb` will generate a local config file in `$HOME/.bigchaindb` with all the default values. +Running `corechaindb -y configure localmongodb` will generate a local config file in `$HOME/.corechaindb` with all the default values. ## database.* @@ -84,7 +84,7 @@ export BIGCHAINDB_DATABASE_MAX_TRIES=3 **Default values** -If (no environment variables were set and there's no local config file), or you used `bigchaindb -y configure localmongodb` to create a default local config file for a `localmongodb` backend, then the defaults will be: +If (no environment variables were set and there's no local config file), or you used `corechaindb -y configure localmongodb` to create a default local config file for a `localmongodb` backend, then the defaults will be: ```js "database": { @@ -213,7 +213,7 @@ different from where BigchainDB is running. ```text export BIGCHAINDB_WSSERVER_ADVERTISED_SCHEME=wss -export BIGCHAINDB_WSSERVER_ADVERTISED_HOST=mybigchaindb.com +export BIGCHAINDB_WSSERVER_ADVERTISED_HOST=mycorechaindb.com export BIGCHAINDB_WSSERVER_ADVERTISED_PORT=443 ``` @@ -222,7 +222,7 @@ export BIGCHAINDB_WSSERVER_ADVERTISED_PORT=443 ```js "wsserver": { "advertised_scheme": "wss", - "advertised_host": "mybigchaindb.com", + "advertised_host": "mycorechaindb.com", "advertised_port": 443 } ``` @@ -246,8 +246,8 @@ The `log.*` settings are to configure logging. ```js { "log": { - "file": "/var/log/bigchaindb.log", - "error_file": "/var/log/bigchaindb-errors.log", + "file": "/var/log/corechaindb.log", + "error_file": "/var/log/corechaindb-errors.log", "level_console": "info", "level_logfile": "info", "datefmt_console": "%Y-%m-%d %H:%M:%S", @@ -263,8 +263,8 @@ The `log.*` settings are to configure logging. ```js { "log": { - "file": "~/bigchaindb.log", - "error_file": "~/bigchaindb-errors.log", + "file": "~/corechaindb.log", + "error_file": "~/corechaindb-errors.log", "level_console": "info", "level_logfile": "info", "datefmt_console": "%Y-%m-%d %H:%M:%S", @@ -278,7 +278,7 @@ The `log.*` settings are to configure logging. ### log.file The full path to the file where logs should be written. -The user running `bigchaindb` must have write access to the +The user running `corechaindb` must have write access to the specified path. **Log rotation:** Log files have a size limit of about 200 MB diff --git a/docs/root/source/installation/node-setup/bigchaindb-cli.md b/docs/root/source/installation/node-setup/corechaindb-cli.md similarity index 77% rename from docs/root/source/installation/node-setup/bigchaindb-cli.md rename to docs/root/source/installation/node-setup/corechaindb-cli.md index a3ccbae3..375218f6 100644 --- a/docs/root/source/installation/node-setup/bigchaindb-cli.md +++ b/docs/root/source/installation/node-setup/corechaindb-cli.md @@ -7,20 +7,20 @@ Code is Apache-2.0 and docs are CC-BY-4.0 # Command Line Interface (CLI) -The command-line command to interact with BigchainDB Server is `bigchaindb`. +The command-line command to interact with BigchainDB Server is `corechaindb`. -## bigchaindb \-\-help +## corechaindb \-\-help -Show help for the `bigchaindb` command. `bigchaindb -h` does the same thing. +Show help for the `corechaindb` command. `corechaindb -h` does the same thing. -## bigchaindb \-\-version +## corechaindb \-\-version -Show the version number. `bigchaindb -v` does the same thing. +Show the version number. `corechaindb -v` does the same thing. -## bigchaindb configure +## corechaindb configure Generate a local configuration file (which can be used to set some or all [BigchainDB node configuration settings](configuration)). It will ask you for the values of some configuration settings. If you press Enter for a value, it will use the default value. @@ -29,39 +29,39 @@ At this point, only one database backend is supported: `localmongodb`. If you use the `-c` command-line option, it will generate the file at the specified path: ```text -bigchaindb -c path/to/new_config.json configure localmongodb +corechaindb -c path/to/new_config.json configure localmongodb ``` -If you don't use the `-c` command-line option, the file will be written to `$HOME/.bigchaindb` (the default location where BigchainDB looks for a config file, if one isn't specified). +If you don't use the `-c` command-line option, the file will be written to `$HOME/.corechaindb` (the default location where BigchainDB looks for a config file, if one isn't specified). If you use the `-y` command-line option, then there won't be any interactive prompts: it will use the default values for all the configuration settings. ```text -bigchaindb -y configure localmongodb +corechaindb -y configure localmongodb ``` -## bigchaindb show-config +## corechaindb show-config Show the values of the [BigchainDB node configuration settings](configuration). -## bigchaindb init +## corechaindb init Create a backend database (local MongoDB), all database tables/collections, various backend database indexes, and the genesis block. -## bigchaindb drop +## corechaindb drop Drop (erase) the backend database (the local MongoDB database used by this node). You will be prompted to make sure. -If you want to force-drop the database (i.e. skipping the yes/no prompt), then use `bigchaindb -y drop` +If you want to force-drop the database (i.e. skipping the yes/no prompt), then use `corechaindb -y drop` -## bigchaindb start +## corechaindb start -Start BigchainDB. It always begins by trying a `bigchaindb init` first. See the documentation for `bigchaindb init`. -The database initialization step is optional and can be skipped by passing the `--no-init` flag, i.e. `bigchaindb start --no-init`. +Start BigchainDB. It always begins by trying a `corechaindb init` first. See the documentation for `corechaindb init`. +The database initialization step is optional and can be skipped by passing the `--no-init` flag, i.e. `corechaindb start --no-init`. ### Options @@ -69,7 +69,7 @@ The log level for the console can be set via the option `--log-level` or its abbreviation `-l`. Example: ```bash -$ bigchaindb --log-level INFO start +$ corechaindb --log-level INFO start ``` The allowed levels are `DEBUG`, `INFO`, `WARNING`, `ERROR`, and `CRITICAL`. @@ -82,9 +82,9 @@ configuration file as documented under [Configuration Settings](configuration). -## bigchaindb election +## corechaindb election -Manage elections to govern the BigchainDB network. The specifics of the election process are defined in [BEP-18](https://github.com/bigchaindb/BEPs/tree/master/18). +Manage elections to govern the BigchainDB network. The specifics of the election process are defined in [BEP-18](https://github.com/corechaindb/BEPs/tree/master/18). Election management is broken into several subcommands. Below is the command line syntax for each of them. @@ -106,7 +106,7 @@ Create an election to add, update, or remove a validator. ```bash -$ bigchaindb election new upsert-validator --private-key +$ corechaindb election new upsert-validator --private-key ``` - `` is the public key of the node to be added/updated/removed. The encoding and type of the key have to match those specified in `genesis.json` in the supported Tendermint version. @@ -117,7 +117,7 @@ $ bigchaindb election new upsert-validator --priv Example: ```bash -$ bigchaindb election new upsert-validator HHG0IQRybpT6nJMIWWFWhMczCLHt6xcm7eP52GnGuPY= 1 fb7140f03a4ffad899fabbbf655b97e0321add66 --private-key /home/user/.tendermint/config/priv_validator.json +$ corechaindb election new upsert-validator HHG0IQRybpT6nJMIWWFWhMczCLHt6xcm7eP52GnGuPY= 1 fb7140f03a4ffad899fabbbf655b97e0321add66 --private-key /home/user/.tendermint/config/priv_validator.json [SUCCESS] Submitted proposal with id: 04a067582cf03eba2b53b82e4adb5ece424474cbd4f7183780855a93ac5e3caa ``` @@ -126,7 +126,7 @@ Once `election_id` has been generated, the proposer should share it with other v Note that election proposers do not automatically approve elections by proposing them. -For more details about how validator set changes work, refer to [BEP-21](https://github.com/bigchaindb/BEPs/tree/master/21). +For more details about how validator set changes work, refer to [BEP-21](https://github.com/corechaindb/BEPs/tree/master/21). #### election new chain-migration @@ -134,7 +134,7 @@ Create an election to halt block production, to coordinate on making a Tendermin ```bash -$ bigchaindb election new chain-migration --private-key +$ corechaindb election new chain-migration --private-key ``` - `` is the path to the private key of the validator who proposes the election. Tendermint places it at `.tendermint/config/priv_validator.json`. @@ -143,7 +143,7 @@ $ bigchaindb election new chain-migration --private-key --private-key +$ corechaindb election approve --private-key ``` - `election-id` is the election identifier the approval is given for. @@ -167,7 +167,7 @@ $ bigchaindb election approve --private-key +$ corechaindb election show status= ``` @@ -192,11 +192,11 @@ status= After a chain migration is concluded, the `show` command also outputs `chain_id`, `app_hash`, and `validators` for `genesis.json` of the new chain. -## bigchaindb tendermint-version +## corechaindb tendermint-version Show the Tendermint versions supported by BigchainDB server. ```bash -$ bigchaindb tendermint-version +$ corechaindb tendermint-version { "description": "BigchainDB supports the following Tendermint version(s)", "tendermint": [ diff --git a/docs/root/source/installation/node-setup/bigchaindb-node-ansible.md b/docs/root/source/installation/node-setup/corechaindb-node-ansible.md similarity index 74% rename from docs/root/source/installation/node-setup/bigchaindb-node-ansible.md rename to docs/root/source/installation/node-setup/corechaindb-node-ansible.md index c28421f5..4fd2b164 100644 --- a/docs/root/source/installation/node-setup/bigchaindb-node-ansible.md +++ b/docs/root/source/installation/node-setup/corechaindb-node-ansible.md @@ -2,6 +2,6 @@ You can find one of the installation methods with Ansible on GitHub at: -[Ansible script](https://github.com/bigchaindb/bigchaindb-node-ansible) +[Ansible script](https://github.com/corechaindb/corechaindb-node-ansible) It allows to install BigchainDB, MongoDB, Tendermint, and python, and then connect nodes into a network. Current tested machine is Ubuntu 18.04. \ No newline at end of file diff --git a/docs/root/source/installation/node-setup/index.rst b/docs/root/source/installation/node-setup/index.rst index 74bc4b4b..f172c7d6 100644 --- a/docs/root/source/installation/node-setup/index.rst +++ b/docs/root/source/installation/node-setup/index.rst @@ -14,12 +14,12 @@ You can use the all-in-one docker solution, or install Tendermint, MongoDB, and deploy-a-machine aws-setup - all-in-one-bigchaindb - bigchaindb-node-ansible + all-in-one-corechaindb + corechaindb-node-ansible set-up-node-software set-up-nginx configuration - bigchaindb-cli + corechaindb-cli troubleshooting production-node/index release-notes diff --git a/docs/root/source/installation/node-setup/production-node/node-assumptions.md b/docs/root/source/installation/node-setup/production-node/node-assumptions.md index 15133b64..16245a63 100644 --- a/docs/root/source/installation/node-setup/production-node/node-assumptions.md +++ b/docs/root/source/installation/node-setup/production-node/node-assumptions.md @@ -9,7 +9,7 @@ Code is Apache-2.0 and docs are CC-BY-4.0 Be sure you know the key BigchainDB terminology: -* [BigchainDB node, BigchainDB network and BigchainDB consortium](https://docs.bigchaindb.com/en/latest/terminology.html) +* [BigchainDB node, BigchainDB network and BigchainDB consortium](https://docs.corechaindb.com/en/latest/terminology.html) Note that there are a few kinds of nodes: diff --git a/docs/root/source/installation/node-setup/production-node/reverse-proxy-notes.md b/docs/root/source/installation/node-setup/production-node/reverse-proxy-notes.md index c93a7f8c..a964e53a 100644 --- a/docs/root/source/installation/node-setup/production-node/reverse-proxy-notes.md +++ b/docs/root/source/installation/node-setup/production-node/reverse-proxy-notes.md @@ -28,7 +28,7 @@ Below, we note how a reverse proxy can be used to do some BigchainDB-specific things. You may also be interested in -[our NGINX configuration file template](https://github.com/bigchaindb/nginx_3scale/blob/master/nginx.conf.template) +[our NGINX configuration file template](https://github.com/corechaindb/nginx_3scale/blob/master/nginx.conf.template) (open source, on GitHub). @@ -55,4 +55,4 @@ For more information, see [the NGINX docs about client_max_body_size](https://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size). Note: By enforcing a maximum transaction size, you -[indirectly enforce a maximum crypto-conditions complexity](https://github.com/bigchaindb/bigchaindb/issues/356#issuecomment-288085251). +[indirectly enforce a maximum crypto-conditions complexity](https://github.com/corechaindb/corechaindb/issues/356#issuecomment-288085251). diff --git a/docs/root/source/installation/node-setup/release-notes.md b/docs/root/source/installation/node-setup/release-notes.md index 1f6bc46f..e25172c9 100644 --- a/docs/root/source/installation/node-setup/release-notes.md +++ b/docs/root/source/installation/node-setup/release-notes.md @@ -9,8 +9,8 @@ Code is Apache-2.0 and docs are CC-BY-4.0 You can find a list of all BigchainDB Server releases and release notes on GitHub at: -[https://github.com/bigchaindb/bigchaindb/releases](https://github.com/bigchaindb/bigchaindb/releases) +[https://github.com/corechaindb/corechaindb/releases](https://github.com/corechaindb/corechaindb/releases) -The [CHANGELOG.md file](https://github.com/bigchaindb/bigchaindb/blob/master/CHANGELOG.md) contains much the same information, but it also has notes about what to expect in the _next_ release. +The [CHANGELOG.md file](https://github.com/corechaindb/corechaindb/blob/master/CHANGELOG.md) contains much the same information, but it also has notes about what to expect in the _next_ release. -We also have [a roadmap document in ROADMAP.md](https://github.com/bigchaindb/org/blob/master/ROADMAP.md). +We also have [a roadmap document in ROADMAP.md](https://github.com/corechaindb/org/blob/master/ROADMAP.md). diff --git a/docs/root/source/installation/node-setup/set-up-nginx.md b/docs/root/source/installation/node-setup/set-up-nginx.md index 3a8378bf..f2e6afd1 100644 --- a/docs/root/source/installation/node-setup/set-up-nginx.md +++ b/docs/root/source/installation/node-setup/set-up-nginx.md @@ -31,7 +31,7 @@ Get an SSL certificate for your node's subdomain (such as `bnode.example.com`). * Create a "PEM file" (text file) by concatenating your SSL certificate with all intermediate certificates (_in that order, with the intermediate certs last_). * Copy that PEM file into `/etc/nginx/ssl/cert.pem` * In the - [bigchaindb/bigchaindb repository on GitHub](https://github.com/bigchaindb/bigchaindb), + [corechaindb/corechaindb repository on GitHub](https://github.com/corechaindb/corechaindb), find the file `nginx/nginx.conf` and copy its contents to `/etc/nginx/nginx.conf` on your machine (i.e. replace the existing file there). * Edit that file (`/etc/nginx/nginx.conf`): replace the two instances of diff --git a/docs/root/source/installation/node-setup/set-up-node-software.md b/docs/root/source/installation/node-setup/set-up-node-software.md index 43f68b8c..8aa9aa9e 100644 --- a/docs/root/source/installation/node-setup/set-up-node-software.md +++ b/docs/root/source/installation/node-setup/set-up-node-software.md @@ -36,17 +36,17 @@ For example, to install version 2.2.2, you would do: ``` # Change 2.0.0 to the latest version as explained above: -sudo pip3 install bigchaindb==2.2.2 +sudo pip3 install corechaindb==2.2.2 ``` -Check that you installed the correct version of BigchainDB Server using `bigchaindb --version`. +Check that you installed the correct version of BigchainDB Server using `corechaindb --version`. ## Configure BigchainDB Server To configure BigchainDB Server, run: ``` -bigchaindb configure +corechaindb configure ``` The first question is ``API Server bind? (default `localhost:9984`)``. @@ -58,7 +58,7 @@ The first question is ``API Server bind? (default `localhost:9984`)``. You can accept the default value for all other BigchainDB config settings. If you're using NGINX, then you should edit your BigchainDB config file -(in `$HOME/.bigchaindb` by default) and set the following values +(in `$HOME/.corechaindb` by default) and set the following values under `"wsserver"`: ``` diff --git a/docs/root/source/installation/node-setup/troubleshooting.md b/docs/root/source/installation/node-setup/troubleshooting.md index 2d347b49..2c660d07 100644 --- a/docs/root/source/installation/node-setup/troubleshooting.md +++ b/docs/root/source/installation/node-setup/troubleshooting.md @@ -36,7 +36,7 @@ addr_book_strict = false If you want to refresh your node back to a fresh empty state, then your best bet is to terminate it and deploy a new machine, but if that's not an option, then you can: -* drop the `bigchain` database in MongoDB using `bigchaindb drop` (but that only works if MongoDB is running) +* drop the `bigchain` database in MongoDB using `corechaindb drop` (but that only works if MongoDB is running) * reset Tendermint using `tendermint unsafe_reset_all` * delete the directory `$HOME/.tendermint` @@ -46,45 +46,45 @@ If you want to stop/kill BigchainDB, you can do so by sending `SIGINT`, `SIGQUIT process(es). Depending on how you started BigchainDB i.e. foreground or background. e.g. you started BigchainDB in the background as mentioned above in the guide: ```bash -$ nohup bigchaindb start 2>&1 > bigchaindb.log & +$ nohup corechaindb start 2>&1 > corechaindb.log & $ # Check the PID of the main BigchainDB process -$ ps -ef | grep bigchaindb - *