Compare commits

...

1016 Commits

Author SHA1 Message Date
yongtheskill
3c89d306ef
Capitalisation mistake (#2734)
Changed "BigchaindB" to "BigchainDB"
2022-05-17 00:30:19 +02:00
Jürgen Eckel
ad83ef1d35
fixed chardet version to 3.0.4 (#2736)
* fixed chardet version to 3.0.4

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

* defined working version of jinga2

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

* removed obsolete doc building commands

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>

* defined werkzeug version explicitly

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2022-05-17 00:29:54 +02:00
Tim Gates
0961aa6b26
docs: fix simple typo, neeeded -> needed (#2717)
There is a small typo in bigchaindb/lib.py, tests/tendermint/test_lib.py.

Should read `needed` rather than `neeeded`.
2021-12-06 14:11:29 +01:00
zzappie
6a6a19207c
[WIP] Maintenance release (#2728)
* Dependencies update

Signed-off-by: David Dashyan <mail@davie.li>

* Dockerfile-dev: update python version + remove system pynacl

Signed-off-by: David Dashyan <mail@davie.li>

* Set dummy_transaction fixture scope to "session"

Signed-off-by: David Dashyan <mail@davie.li>

* Add 3.7 and 3.8 python tests

* setup.py: fix version typo
2021-12-06 14:09:51 +01:00
David Dashyan
caf31647e0 Update priv validator format in k8s to support tm v0.28.0+
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
David Dashyan
8630e74f77 Remove @asyncio.coroutine decorators
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
David Dashyan
5166fa6b46 Update changelog
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
David Dashyan
22cf5f26c3 chmod +x tm_config_gen tm_start
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
David Dashyan
62ae66fef7 Update priv validator format in stack.sh to support tm v0.28.0+
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
Andrijan Ostrun
d77ab60651 Problem: Fixed stack.sh & tendermint's start.yml script (#2708)
* Fixed tendermint start task - fixed parsing of priv_validatorX.json files

* Fixed tendermint start task - fixed parsing of priv_validatorX.json files

Signed-off-by: Andrijan Ostrun <andrijan.ostrun@gmail.com>

Co-authored-by: Andrijan Ostrun <andrijan.ostrun@suprabit.eu>
2020-09-29 12:17:46 +00:00
David Dashyan
af2517b2ae Update k8s container versions
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
David Dashyan
8895d50f5b Version bump
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
David Dashyan
40a92756f9 Update Dockerfile-alpine and losen 'packaging' version
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
David Dashyan
41f7534f3a Update dependencies and fix versions
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
David Dashyan
26cb560bb1 Tidy up setup.py 2020-09-29 12:17:46 +00:00
David Dashyan
2b0babb95b Update email addresses
Signed-off-by: David Dashyan <mail@davie.li>
2020-09-29 12:17:46 +00:00
Amartya Gaur
b272fb342a
owners_before error message correction (#2698)
* owners_before error message correction
Signed-off-by: Amartya Gaur amarkaushik1999@gmail.com

* Changed some formatting
Signed-off-by: Amartya Gaur amarkaushik1999@gmail.com

* Changes essential to pass tests
Signed-off-by: Amartya Gaur amarkaushik1999@gmail.com

* Resolve conflicts with master
Signed-off-by: Amartya Gaur amarkaushik1999@gmail.com
2020-08-12 12:32:33 +00:00
Karthikeyan Singaravelan
e86666b6b3
Import ABC from collections.abc (#2704)
Signed-off-by: Karthikeyan Singaravelan <tir.karthi@gmail.com>
2020-07-22 08:51:58 +00:00
David Dashyan
d9dfa98819
Flask update (#2700)
* Flask security update

The Pallets Project Flask before 1.0 is affected by: unexpected memory
usage. The impact is: denial of service.
The attack vector is: crafted encoded JSON data. The fixed version is:
1. NOTE: this may overlap CVE-2018-1000656.

Signed-off-by: David Dashyan <mail@davie.li>

* Make send_naughty_tx error regex more robust

Signed-off-by: David Dashyan <mail@davie.li>
2020-06-02 14:36:56 +07:00
lana-shanghai
4a008e51e3
[WIP] Documentation re-org (#2694)
* Reorganized docs

* Fixed internal links in basic usage

* fixed the docker-compose command and volume for docs

* fixed docs tests

* fix travis docs test

* tox ini file

* fixed readme localhost links

* edited tox and test docs to previous state

* Fix tests errors related to docs reorganization

Signed-off-by: David Dashyan <mail@davie.li>

* Added ansible script installation option

Signed-off-by: Lana Ivina <lana@ipdb.io>

* Added ansible script to network setup guide

Signed-off-by: Lana Ivina <lana@ipdb.io>

* Hid the non-working button for now. 

Signed-off: Lana Ivina <lana@ipdb.io>

* Try now button

Co-authored-by: David Dashyan <mail@davie.li>
2020-05-18 20:22:26 +07:00
David Dashyan
2accca9ff1
Fix Docker-all-in-one Tendermint download link (#2692)
Resolves issue #2691

Signed-off-by: David Dashyan <mail@davie.li>
2020-05-13 16:13:29 +07:00
David Dashyan
186cd87444
Updated bigchaindb-abci (#2689)
* Updated bigchaindb-abci

Reason: gevent API change breaks BigchainDB installation
Signed-off-by: David Dashyan <mail@davie.li>

* Version bump

Signed-off-by: David Dashyan <mail@davie.li>

* Updated changelog
2020-04-14 23:59:51 +02:00
David Dashyan
9e99c024d3
Replace headers (#2683)
Signed-off-by: David Dashyan <mail@davie.li>
2020-04-06 11:52:18 +02:00
David Dashyan
09391351a4
Version bump to 2.2.0 (#2682)
Signed-off-by: David Dashyan <mail@davie.li>
2020-02-20 16:30:37 +01:00
Zac Hatfield-Dodds
f795301f90 Update Hypothesis (#2678)
Fixes #1738

Signed-off-by: Zac Hatfield-Dodds <zac@zhd.dev>
2020-01-26 22:18:40 +03:00
David Dashyan
7df59994e9 Tendermint v0.22.8 backward compatibility (#2677)
Problem statement:

BigchainDB v2.0.0b9 has been around for quite a while. Recently we have updated
Tendermint supported version to v0.31.5 which has incompatible blockchain.
Despite the fact that we have defined instructions on chain migration, no one
expected to migrate to incompatible chain within patch version range. So there
is a demand for Tendermint v0.22.8 compatibility among BigchainDB users.

Work has been done:

bigchaindb-abci package was upgraded to support multiple API versions.
New configuration field stating tendermint version was added.

Signed-off-by: David Dashyan <mail@davie.li>
2020-01-23 23:17:27 +01:00
Yuliya Palamarchuk
86472157db Fixed not being able to connect to mongo (#2674)
From version 3.6+ mongodb by default binds only to localhost (127.0.0.1) IP. That can be checked with "netstat -tulpn | grep LISTEN" command in container. It will return "127.0.0.1:27017 | 0.0.0.0:* | LISTEN | 15/mongod" for mongod. That causes inability to connect to running mongo from host machine. Proposed change allows mongo to bind to container network interface, thus allowing connections from host machine.
2019-12-02 15:23:10 +03:00
Jürgen Eckel
b54c31539f
Transcation API extension: last_tx parameter (#2667)
* added last_tx switch to the TX get query to only get the latest TX for a given asset.
* extended test case to contain last_tx field
* Add last_tx option in query module
* Fix natural descending cursor sort argument
2019-11-06 23:23:14 +01:00
David Dashyan
ecd6e9cc46 Update issue templates (#2670) 2019-10-28 20:30:14 +01:00
David Dashyan
f12d44ff82 Fix bigchaidb-tendermint version mismatch 2019-10-15 15:24:37 +03:00
Jürgen Eckel
9bcefdf3e2
Tendermint upgrade (#2666)
* migrated to tendermint 0.35.1

* increased bigchaindb_abci version

* fixed API adjustments due to Tendermint upgrade

Signed-off-by: Juergen Eckel <juergen@riddleandcode.com>

* migrated to bigchaindb-abci == py-abci 0.7.1

Signed-off-by: Juergen Eckel <juergen@riddleandcode.com>
2019-10-07 16:32:35 +02:00
Giuseppe Raveduto
16a9888d1e using alpine v3.9 (#2658)
Since version 3.10, Alpine linux has removed mongodb from the available packages.
Using v3.9 it's still possible to build the all-in-one configuration using the provided Dockerfile.

Signed-off-by: Giuseppe Raveduto <giuseppe.raveduto@eng.it>
2019-09-30 09:32:01 +02:00
Simon Pfeifhofer
645d457b7b Add quotes to env-variables (#2662)
Signed-off-by: Simon Pfeifhofer <simon.pfeifhofer@gmail.com>
2019-09-26 13:10:09 +02:00
Nikita Chernyi
2975c372c8 Remove pysha3 for python >= 3.6 (#2652)
* Init pypy support

* Fixed setup
2019-09-25 22:22:51 +02:00
Troy McConaghy
df23bec320 Add a docs link to the ANSI C driver (#2650)
Signed-off-by: Troy McConaghy <troy@bigchaindb.com>
2019-09-25 22:20:02 +02:00
Mike Klimontov
c801c833fc Add unit transaction_mode_types (#2648)
Signed-off-by: Mike Klimontov <klimontovm@gmail.com>
2019-06-12 16:28:24 +02:00
Troy McConaghy
a5452169b9 pip 19+ is now needed to install bigchaindb (#2645)
Signed-off-by: Troy McConaghy <troy@bigchaindb.com>
2019-05-26 22:11:41 +02:00
Troy McConaghy
a24c0f429b Note the new C# driver in the server docs (#2644)
Signed-off-by: Troy McConaghy <troy@bigchaindb.com>
2019-05-20 21:11:00 +02:00
Troy McConaghy
835fdfcf59 Updates for the switch from BEP-16 to BEP-24 (#2641)
Signed-off-by: Troy McConaghy <troy@bigchaindb.com>
2019-04-15 23:47:56 +02:00
manjush08
20a59a9640 Problem: No volume mounted to store tendermint data (#2637)
* Fix: mount volume to store tendermint data

* Fix: mount volume to store tendermint data
2019-03-14 13:38:19 +01:00
manjush08
f0dc9986aa Update main.yml (#2636) 2019-03-13 14:33:36 +01:00
Chuseuiti
6bed80cff3 Restart on sporadic failures on BDB container#2624 (#2634)
To account for sporadic failures on bigchaindb server and container stop, it would be beneficial to include in docker-compose the ability for the containers to restart on failure or docker daemon restart. Issue #2624
2019-02-26 09:57:38 +01:00
Troy McConaghy
7781f5aae8
Remove --no-cache-dir from all pip install cmds (#2628)
because it broke in pip 19
2019-01-29 13:51:29 +01:00
Troy McConaghy
eb2f8ddc73
Sphinx changed how it handles rel links in .md (#2627)
* Sphinx changed how it handles rel links in .md

* Remove all --process-dependency-links everywhere
2019-01-24 14:21:21 +01:00
Troy McConaghy
d8f51d8999
Replace rel link with absolute URL 2019-01-24 13:57:44 +01:00
Troy McConaghy
3b72181b3d
Fix a link in the docs 2019-01-13 14:56:03 +01:00
Troy McConaghy
ca012ae8b6
Update pyyaml, part 2 2019-01-13 14:51:16 +01:00
Troy McConaghy
1a9c5d47e6
Update pyyaml, part 1 2019-01-13 14:50:33 +01:00
Kuro1
edcd59e235 Translate the readme to Chinese (#2615) 2018-12-24 15:51:24 +01:00
Troy McConaghy
11817b9590
Change email to devs@bigchaindb.com (#2612)
* Change email to devs@bigchaindb.com

* Update Travis build badge URL

* Update some other email addresses
2018-12-10 18:10:58 +01:00
Troy McConaghy
d9725d483b
Revised docs based on tips from user (#2611) 2018-12-02 22:07:31 +01:00
xunconnectedx
f0df5bd2e0 corrected the syntax for which an error occurred in the execution stack.sh (#2609) 2018-11-29 11:59:45 +01:00
Troy McConaghy
f8191b0d8e
Last commit before v2.0.0b9 (#2608) 2018-11-27 19:50:05 +01:00
Troy McConaghy
dcfe23f292
Account for values that are arrays/lists (#2607)
when checking if keys are valid.
2018-11-25 20:24:03 +01:00
Troy McConaghy
5de2fef284
Problem: "language" values are not being checked in metadata (#2606)
Check "language" values in metadata too, not just in `asset.data`.
2018-11-25 19:11:35 +01:00
gamjapark
a62cc4e101 Translated docs to Korean (#2603)
Add Korean translations of all the BigchainDB root docs
2018-11-22 09:28:11 +01:00
Troy McConaghy
288c2ecd2a
In NGINX conf files under k8s/: Drop TLSv1 & TLSv1.1, enable TLSv1.3 (#2601)
because TLS v1 and v1.1 are old
2018-11-17 09:23:08 +01:00
Troy McConaghy
fe467fddbd
nginx.conf: Drop TLSv1 & TLSv1.1, enable TLSv1.3
Because TLS v1 and v1.1 are old. See http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_protocols
2018-11-17 09:08:08 +01:00
Troy McConaghy
0b935c09c7
Add extra step to RELEASE_PROCESS.md
because readthedocs.org has gotten even more arcane
2018-11-09 20:21:06 +01:00
Salah Alsasa
1bd5845a83 Fix links in network setup readme file (#2600)
* Fix links in network setup readme file

* Update docs/server/source/simple-deployment-template/network-setup.md

Co-Authored-By: sd189 <salahalsasa@gmail.com>
2018-11-08 11:16:23 +01:00
Troy McConaghy
d85b9df615
Last PR before the release of v2.0.0b8 (#2596) 2018-11-03 18:37:27 +01:00
Troy McConaghy
ff906b0abe
Updated some package version requirements (#2595) 2018-11-03 17:51:52 +01:00
Troy McConaghy
20e6c6a686
Update acceptance Dockerfile to use latest Python driver (#2594)
* Update acceptance Dockerfile to use latest Python driver

* Fixed four Flake8 errors
2018-11-03 17:34:36 +01:00
gamjapark
73afc38697 Translate the readme to Korean (#2592) 2018-11-01 15:17:47 +01:00
Troy McConaghy
c5fea574b5
Updated Python driver version for acceptance tests 2018-10-20 22:03:50 +02:00
Troy McConaghy
ee7bd938dc
Fixed typo in k8s configmap template (#2583)
Thanks to @aberey for pointing this out.
2018-10-18 09:21:02 +02:00
Troy McConaghy
e2b3c78d9c
Edit nginx/nginx.conf to enable CORS (#2580)
* Edit nginx/nginx.conf to enable CORS

* In nginx/nginx.conf, add more allowed headers w/ OPTIONS requests
2018-10-11 09:53:24 +02:00
Troy McConaghy
f1353a3db9
Fixed some docs (#2579)
in the intro page about the Simple Deployment Template:
- removed the note about the BigchainDB Testnet for now
- changed the link to the docs about contributing to BigchainDB from Markdown to RST
2018-10-09 18:10:49 +02:00
Troy McConaghy
c1993c3787
Revised Simple Deployment Template: added NGINX instructions (#2578) 2018-10-09 12:27:06 +02:00
Troy McConaghy
5c1511b479
Add help with make release to release process 2018-09-28 13:35:33 +02:00
Troy McConaghy
3da13eda3d
Last PR before releasing 2.0.0b7 (#2576)
* Updated changelog for 2.0.0b7

* Change 2.0.0b3 to b7 in network-setup.md

* Updated k8s yamls for 2.0.0b7 release

* Updated version.py for 2.0.0b7 release
2018-09-28 13:23:04 +02:00
Lev Berman
0c4d6ec906 Implement crash recovery for elections. (#2566)
1. Save pre-commit state in the beginning of end block. 
2. Provide an interface for custom elections to rollback on crash recovery. 
3. Simplify pre-commit management. 
4. Add crash recovery for updert-validator and chain migration elecitons.
2018-09-28 12:32:45 +02:00
Troy McConaghy
f4d6ccbacf
Added server.bind note re connecting via IPv6 & edited reverse proxy instructions. (#2575) 2018-09-28 10:45:03 +02:00
Troy McConaghy
009cbe4e11
Copy-edited the log rotation page (docs) (#2546)
* Copy-edited the log rotation page (docs)

* Fix and add some hyperlinks re/ logging.

* Add back the section/link to log-rotation.html

* Correct the location of BigchainDB logs. Omit mention of bigchaindb-benchmark.log

* Revive notes re BigchainDB Server log rotation
2018-09-28 09:19:20 +02:00
Troy McConaghy
54ac7adaa9
Changed packaging~=17.0 to 18.0 in four places (#2573) 2018-09-27 15:31:30 +02:00
Troy McConaghy
4f01dd4997
See what happens if packaging~=17.0 in setup.py AND docs/*/requirements.txt (#2572) 2018-09-27 13:30:58 +02:00
Vanshdeep Singh
72d7986a58 Problem: 'packaging' version not pinned (#2571)
Solution: Pin the version
2018-09-26 16:33:23 +02:00
Vanshdeep Singh
78dafce146 Problem: Outputs API responds with incorrect outputs (#2567).
* Problem: Outputs API doesn't respond with correct unspent/spent outputs

Solution: Fix fastquery such that embedded document is queried properly

* Problem: key order agnostic queries not implemented

Solution: get_spent queries embedded documents which respect key order. This is
not expected by the application hence the query should be altered to query any
kind of key order

* Problem: Mongo query for get_spent too complicated

Solution: Simplify query using $elemMatch

* Problem: No test for checking mixed spent outputs

Solution: Add test for `get_spending_transactions` to check that correct
matching is done when querying documents with multiple inputs

* Problem: tranasction ids not assert when getting spent outputs

Solution: assert tranasction ids
2018-09-26 10:17:39 +02:00
Troy McConaghy
bedb1945a9 Added docs & link re/ adding/removing validators (#2570) 2018-09-25 17:33:59 +02:00
Lev Berman
cb74cb43d2 Extend chain migration show command (#2558)
* Extend `election show` with migration data.

* Test chain-migration show.
2018-09-25 11:38:29 +02:00
Lev Berman
40ea961d4a Update elections documentation (#2563)
* Improve election docs. Reference relevant BEPs.

* Fix typos and headings (election docs).

* Enumerate supported election types (election docs).

* Clarify the BEP-42 ref (election docs).
2018-09-25 10:46:30 +02:00
Lev Berman
24ca0b32a9 Separate pending and effective validator updates. (#2556)
* Separate pending and effective validator updates.

- Pending validator updates do not prevent elections from concluding.
- ValidatorElection overrides has_conclude to not conclude when there is a pending update for the matching height.
- Effective validator updates deem past elections inconclusive.

* Problem: Looking for election block is inefficient.

Solution: Record placed elections, update the records upon election conclusion.

* Clarify the conclusion order in Election.process_blocks.

* Insert election records in bulk.

Otherwise, one can significantly slow nodes down by posting a whole bunch of unique elections.

* Change get_election to use find_one.

* Calculate total votes without making extra query.

* Fix the pending valset check.

* Fix election test setup.
2018-09-21 10:51:57 +02:00
Troy McConaghy
39be7a2fdf
Renamed "consensus" to "validation" where relevant (#2561) 2018-09-20 17:17:33 +02:00
Muawia Khan
eb139fba00 Remove benchmark logging (#2565).
* Problem: Benchmark logging is not needed.

* Solution: Clean it up.
2018-09-20 14:30:30 +02:00
codegeschrei
407571ddf4 Problem: send function has a deprecation warning in the driver (#2547)
Solution: replace send with the matching new functions
2018-09-20 10:31:05 +02:00
Troy McConaghy
2f6bbaeb4b
Link to Alberto's tips from Troubleshooting page (#2562)
because they are useful!
2018-09-20 09:54:34 +02:00
Lev Berman
126e90e732 Adjust multiple elections conclusion. (#2553)
- Do not conclude migration election if there is a migration in progress.
- Rewrite election tests to not use mocks and assert many different things.
- Record concluded elections in the `election` collection.
2018-09-18 12:32:16 +02:00
Vanshdeep Singh
cf6fa6b553 Problem: Election type not casted for runnign command (#2551)
Solution: Replace '-' with '_' before running election sub-command
2018-09-17 15:36:38 +02:00
Troy McConaghy
528ba07c68
Last PR before 2.0.0b6 (#2550)
* Update k8s files for 2.0.0b6

* Update version.py for 2.0.0b6
2018-09-17 15:00:26 +02:00
Troy McConaghy
eb0e387b18
Problem: CHANGELOG.md hasn't been updated since Aug. 1 (#2509)
Last update to CHANGELOG.md before 2.0.0b6
2018-09-17 14:43:03 +02:00
Vanshdeep Singh
16355748dd Problem: Docs build fails (#2549)
Solution: Create __init__.py so that migrations can be imported properly
2018-09-17 14:39:00 +02:00
Muawia Khan
e3e95836d0 Problem: bigchaindb not starting because of a module dependency (#2548) 2018-09-17 14:10:22 +02:00
Troy McConaghy
8e5f770707 List the "blocks" endpoint in response to HTTP info requests (#2545)
* Problem: HTTP info endpoints don't include "blocks"

Solution: Add "blocks" to the response to the HTTP info endpoints

* Removed "blocks" endpoints from "Advanced Usage"
because they are really not that advanced
2018-09-17 14:06:48 +02:00
Zachary Bowen
e6893632dc Create migration election class (#2535).
* Problem: We need a way to synchronize a halt to block production to allow for upgrades across breaking changes.

* Solution: Created `MigrationElection`.

* Problem: Need documentation for `migration` elections.

* Solution: Updated the docs.

* Problem: `MigrationElection` needs 'new' CLI method.

* Solution: Updated the definition of `election` to include the new `migration` type.

* Problem: The way `end_block` checks for concluded elections assumes there is only one type of election (so we can't conclude an `upsert-validator` and a `chain-migration` at the same height).

* Solution: Re-engineered the code in `Elections` to conclude multiple elections in the same block. If more than one election change the validator set, only one of them is applied.

* Problem: Tendermint change to store validator changes at height h+2 will break `Election.get_status`.

* Solution: Reworked `get_validator_change` to look at only the latest block height or less.
2018-09-17 13:59:57 +02:00
Troy McConaghy
3cb0f8e2ab
Update the list of MongoDB collections in query.rst (#2543) 2018-09-14 16:25:36 +02:00
Muawia Khan
bd39076522 Problem: Users trying to use an incompatible version of Tendermint (#2541)
-  Hard-wire the supported Tendermint version(s) right in the code of BigchainDB Server. Check the version of Tendermint and disconnect if Tendermint version is an unsupported one.
- Expose a CLI command bigchaindb tendermint-version to display the supported Tendermint versions.
- PR also takes care the long list of warnings we get when we run tests.
    - Updated deprecated pymongo methods
    - Do not call pytest fixtures directly.
    - Also added the doc for the new cli command
2018-09-14 15:37:18 +02:00
Troy McConaghy
754730a045 Update the Quickstart page (#2538)
* Update the Quickstart page

* Add links to docs about how to deploy a local node
2018-09-14 11:47:39 +02:00
Troy McConaghy
5394054132 Add Troubleshooting page to Simple Deployment Template (#2517) 2018-09-13 16:46:02 +02:00
Troy McConaghy
61ce427e1d Problem: Unclear that we want users to use Monit (#2533)
Solution: Edit the "How to Set Up a BigchainDB Network" page
so that the Monit way is the only fully-documented way.
Give a tip for do-it-yourselfers.
2018-09-13 16:43:15 +02:00
Shahbaz Nazir
c68fab6c31 Problem: A duplicate tx may result in HTTP 500.
* Improve parsing of errors received from Tendermint RPC.
2018-09-13 16:03:22 +02:00
Lev Berman
f55f22144f Problem: the skip_id param is redundant. (#2531)
Solution: remove the param; only call validate_id where it is needed.
2018-09-13 15:35:24 +02:00
Troy McConaghy
6a9064196a Make requirements.txt files consistent with setup.py (#2539) 2018-09-13 14:11:15 +02:00
vrde
241aae335d Problem: validation is slow (#2489)
Solution: parallelize the validation of transactions. This patch adds a
new flag for the `start` command, namely
`--experimental-parallel-validation`, that can be used to enable this
experimental feature.
2018-09-13 12:16:45 +02:00
vrde
901b6b9d02 Problem: Sphinx deprecated a config option (#2537)
Solution: Move from `autodoc_default_flags` to
`autodoc_default_options`.

Related issue:
- https://github.com/sphinx-doc/sphinx/issues/5421
2018-09-13 12:05:01 +02:00
vrde
4b54e702f8 Problem: Events API is unreliable (#2529)
Solution: Stop getting events from the Tendermint events API. Get the
event right before returning from the COMMIT phase of Tendermint, and
publish it to the events queue.
2018-09-12 16:55:23 +02:00
Troy McConaghy
0f41869bea Updated the Python Driver version in acceptance/python/Dockerfile (#2532)
* Updated the Python Driver version in acceptance/python/Dockerfile

* Let package manager auto-update to latest patch version
2018-09-12 16:53:07 +02:00
Lev Berman
35e35ecd57 Problem: New collections are not created in existing DB. (#2520)
Solution: Do not abort the initialisation if a collection exists. Unify the index creation.
2018-09-12 14:39:07 +02:00
Zachary Bowen
8a7650c13a Generalize election management commands (#2515)
* Problem: `ValidatorElection` and `MigrationElection` need to inherit from a common `Election` class

Solution: Factored the common logic out of `ValidatorElection` and moved it to `Election` parent class

* Problem: Adding base58 as a requirement seems to break the build...

Solution: Reverting the changes

* Problem: Responding to a suggestion for improved method naming

Solution: Refactored `get_result_by_election_id` to `get_election_result_by_id`

* Problem: No need to store different types of elections in their own tables

Solution: Remove `DB_TABLE` property from `Election` class

* Revert "Problem: No need to store different types of elections in their own tables"

This reverts commit db45374d3c690429d18a25bcc319f8056c016500.

* Problem: Missed a method in `Bigchain` class when updating the naming for an election method

Solution: Finished the refactoring

* Problem: Need a table to store data for all elections

Solution: Created the `elections` table with secondary_index `election_id`

* Problem: `Election` class needs to be updated to store concluded elections in the `elections` table

Solution: Updated the class to use the new table

* Problem: `UpsertValidatorVote` can be generalized to just be `Vote`

Solution: Renamed, refactored and moved the `Vote` class to tie in with the more general `Election` base class

* Problem: Error in docstring return signature

Solution: Fixed the docstring

* Problem: Hardcoded reference to the `VOTE_TYPE` in `Election` base class

Solution: Pointed the reference to the class variable

* Problem: Schema still refers to `ValidatorElectionVote` instead of `Vote`

Solution:  Renamed `TX_SCHEMA_VALIDATOR_ELECTION_VOTE` as `TX_SCHEMA_VOTE`

* Problem: `Election` class variable `ELECTION_TYPE` is overly specific

Solution: Renamed `ELECTION_TYPE` to `OPERATION`

* Problem: Command line options for `upsert-validator` can be generalized to manage any type of election

Solution: Refactored the CLI to manage generalized elections

* Problem: Default for `show_election` not implemented for `Election` class

Solution: Create a default method that work if all fields in the 'asset[data]' can be displayed without additional formatting

* Problem: Multiple small issues with style etc.

Solution: Addressed comments from PR

* Problem: `Election` class variable to `VOTE_TYPE` unnecessary

Solution: Removed the variable and hardcoded everything to use the `Vote` class

* Problem: Minor style issues with PR

Solution: Addressing comments

* Problem: Changes to format for validator keys broke some tests

Solution: Aligned the tests to reflect the changed key format

* Problem: `election show` command displaying the base56 public key

Solution: Cast any public key to base64

* Problem: `election_parser` help message still refers to upsert-validator

Solution: Updated the help message
2018-09-12 13:41:16 +02:00
Muawia Khan
5a440843b6 Problem: No log rotation when BigchainDB and Tendermint started with Monit (#2528)
* Log rotation for tendermint and BigchainDB using Monit

* Change file size from 100KB used for testing to 200 MB for test envs

* Add docs for log rotation

* remove --consensus.create_empty_blocks from monit start

Because already taken care of in the config file

* do not run bigchaindb with debug flag instead use config file

* Address comments I

- Rephrase log rotation to imply monit is not default
- Add statement to explain where bigchaindb log files are created
- Fix HTML comment
- Add log rotation to index

* Address comments II
2018-09-12 11:14:51 +02:00
Lev Berman
b33e3808a6 Problem: Test fails if Tendermint is not up. (#2530)
Solution: Mark the test with the abci mark since it requires running BigchainDB and Tendermint. Fails since the mark cleanup in #2522.
2018-09-11 16:41:27 +02:00
Zachary Bowen
0fe749d830 Create abstract election class (#2498).
* Problem: `ValidatorElection` and `MigrationElection` need to inherit from a common `Election` class.

Solution: Factored the common logic out of `ValidatorElection` and moved it to `Election` parent class.

* Problem: No need to store different types of elections in their own tables

Solution: Remove `DB_TABLE` property from `Election` class.

Solution: Created the `elections` table with secondary_index `election_id`.

* Problem: `UpsertValidatorVote` can be generalized to just be `Vote`

Solution: Renamed, refactored and moved the `Vote` class to tie in with the more general `Election` base class.

* Problem: `election_id` is not unique if two elections have the same properties.

Solution: Added a random `uuid4` seed to enforce uniqueness.
2018-09-11 15:39:46 +02:00
Troy McConaghy
c79848d66a Problem: Docs say install highest Tendermint version (#2524)
Solution: Change the docs to recommend installing a specific Tendermint version.
Also update our release process so we change that version number before a release, if necessary.
2018-09-11 14:28:55 +02:00
codegeschrei
dd84d4eb6f Problem: There are unnecessary markers (#2522)
* Problem: we have unused and outdated fixtures
Solution: clean up fixtures and tests accordingly

* Problem: there are still unused fixtures
Solution: remove Merlin keys

* Problem: There are unnecessary markers
Solution: remove the tendermint marker for tests
2018-09-10 09:53:18 +02:00
Vanshdeep Singh
cbfbfa8fc4 Problem: Public key format not standardized (#2508)
Solution: Add 'type' field to public key so that it can be decoded properly
2018-09-06 16:06:36 +02:00
Lev Berman
699494613f Problem: The commit mode behaves incorrectly. (#2510)
* Problem: The commit mode behaves incorrectly.

Solution: Parse the Tendermint response properly. The functionality was disabled in https://github.com/bigchaindb/bigchaindb/pull/2235/files#diff-c6511560546a7dc577e7e647b5bfdaceL68 and was not fixed since then.

* Add a test case for the sync mode.

* Do not strictly expect deliver_tx in the response.

* Fix post_mock in web/test_transactions.py.

* Check for the error field first.
2018-09-06 15:49:00 +02:00
Vanshdeep Singh
2656302c60 Problem: Bigchaindb crashes when restarted after init chain (#2519)
Solution: Return appropirate height so that Tendermint doesn't execute
init_chain more than once
2018-09-06 11:27:52 +02:00
Lev Berman
9bf09324df Problem: Txs posted in async/sync can be lost. (#2514)
Solution: Document when the transactions posted in the async and sync modes can be lost. Describe how they are stored. Mention that BigchainDB does not store or expose rejected transactions.
2018-09-05 17:18:17 +02:00
vrde
f6bee3b63e Problem: default config is slow (#2516)
Solution: update the suggested `config.toml` file to increase the
allowed network speed, and avoid rechecking transactions.
2018-09-05 16:04:37 +02:00
Zachary Bowen
bee9468bd0 Problem: test_make_sure_we_dont_remove_any_command does not check for upsert-validator show (#2499).
Solution: Extend the test.
2018-09-05 10:51:32 +02:00
Vanshdeep Singh
af2b5424c0 Problem: Cryptoconditions not pinned which is casuing build failure (#2512)
Solution: Pin cryptoconditions so that docs build properly
2018-09-04 15:45:48 +02:00
Vanshdeep Singh
cb22557771 Problem: Validation code not optimized (#2490)
Solution: memoize data
2018-09-04 15:30:52 +02:00
Troy McConaghy
c72c7a4626 Problem: tests/README.md either wrong or redundant (#2479)
The information on that page was either wrong or redundant, so I either deleted it or linked to where to find the same information in the docs about contributing to BigchainDB.
2018-09-04 13:31:00 +02:00
Troy McConaghy
f8bb29535a
Problem: Code Reference docs hidden in appendices (#2473)
Solution: Move the Code Reference docs into their own section
2018-09-04 12:17:27 +02:00
Lev Berman
230a5b2d69 ABCI chain migration conclusion (#2488)
* Problem: No good way to check for val set absence.

Solution: Make get_validator_set/get_validators return None/[] when there are no validators yet.

* Problem: Incompatible ABCI chain upgrades.

Solution: Record known chains and sync through InitChain. Triggering the migration and adjusting other ABCI endpoints will follow.
2018-09-03 15:41:49 +02:00
Lev Berman
fe0a4c494b
Problem: No MongoDB support for election ID index. (#2507)
Solution: Election ID has to be unique but not every validator set record has it. MongoDB does not support partial indexes, does not even allow for multiple Nones. This is a temporary fix since we are introducing an `election` collection to store election IDs in #2498.
2018-09-03 15:09:16 +02:00
Muawia Khan
8e55b11da2 Problem: cyrptoconditions dependency updated because of vulnerability (#2494)
* Problem: cyrptoconditions dependency updated because of vulnerability CVE-2018-10903

* update cc to ~=0.7.2

* Fix test using b58encode

* Fixing some more tests failing because of base58 update
2018-09-03 13:25:58 +02:00
Troy McConaghy
80b6881797 Problem: Docs page 'BigchainDB and Smart Contracts' is stale (#2504)
Solution: Update that page to reflect our current thinking on how BigchainDB relates to smart contracts
2018-09-02 00:23:17 +02:00
Troy McConaghy
905b1a5141
Problem: Root docs page about decentralization has two incorrect sentences (#2505)
Solution: Delete them
2018-08-31 20:43:08 +02:00
Muawia Khan
cf1f253019 Update bigchaindb-driver version -> 0.5.2 in acceptance test (#2503) 2018-08-31 16:56:34 +02:00
Troy McConaghy
96932793b1
Problem: The docs about database.ssl are wrong (#2500)
Solution: Rewrite the docs about the database.ssl config setting
2018-08-31 15:27:35 +02:00
Shahbaz Nazir
2d1f670eec
Problem: BigchainDB has un-necessary code to initialize a replica set and check if MongoDB was started with replicaSet (#2491)
Solution: Remove un-necessary code. Deployment of MongoDB with or without replicaSet should be the responsibility of MongoDB admin which can and cannot be a BigchainDB node operator. As far as BigchainDB is concerned replicaset, if provided in bigchaindb configs, should be used to establish connection with MongoDB.
2018-08-31 13:54:32 +02:00
Shahbaz Nazir
cb418265b6
Problem: No documentation for hosted MongoDB (#2495)
Solution: Add documentation.
2018-08-31 13:24:04 +02:00
Zachary Bowen
cfc2c5900b Rework upsert-validator show status (#2496)
* Problem: We need to store the `election_id` as part of the `validator_update` so we can efficiently check which election was resposible for the change

Solution: Added the parameter to `store_validator_set` and aligned the tests

* Problem: Logic for `upsert-validator show` is convoluted

Solution: Rewrote the function to be much simpler

* Problem: Need a uniqueness constraint for election_id wrt validator changes

Solution: Added a new key to the db schema
2018-08-31 09:47:47 +02:00
Zachary Bowen
7a0b474d11 Problem: Users want to know upsert-validator election status.
Solution: Introduce the `upsert-validator show` command. Soon to be re-implemented via storing and querying identifiers of concluded elections.
2018-08-30 10:47:37 +02:00
Vanshdeep Singh
3cf368aab7 Problem: No unique indexes on transaction id and block height (#2492)
Solution: Created unique indexes when setting up the collections
2018-08-29 17:45:08 +02:00
vrde
3f7b521809 Problem: make unit-test-watch loops forever (#2486)
Solution: BigchainDB by default writes logs in the same directory it is
run. The `looponfail` feature provided by pytest waits for changes in
the current directory, so it is continuously triggered. This patch tells
pytest to only watch the `bigchaindb` and `tests` directories.
2018-08-29 14:14:47 +02:00
vrde
407b771185 Problem: validating create+transfer might crash the system (#2487)
Solution: if a TRANSFER transaction is validated after a CREATE
transaction, the system crashes with `AttributeError: 'NoneType' object
has no attribute 'txid'`.

This happens because querying `get_spent` checks the attributes `txid`
and `output` of `input.fulfills` for every transaction in the current
buffer (`current_transactions`). For a CREATE, `input.fulfills` is None,
so the check would fail.

The solution is to check if `input.fulfills` is defined. If not, then
the current transaction cannot spend any output, so we can safely skip
it.
2018-08-29 14:13:22 +02:00
Vanshdeep Singh
8e97c753eb Problem: upsert-validator 'approve' command does not transfer vote to election public key (#2480)
Solution: Transfer vote to the election public key; generalize implemenation to handle election txn type

* Problem: Upsert valdiator 'new' doesn't accept public in base64 format

Solution: Tendermint stores all keys in base64 format so it would suitable to
abandon base58 encoding in favour of base64 encoding

* Problem: Not test for invalid execution of upsert-validator 'new'

Solution: Write tests to when invalid power or private key path has been supplied

* Problem: Exceptions are not informational when executing upsert-validator

Solution: generate error logs or print statement indicating success
2018-08-28 14:21:59 +02:00
Troy McConaghy
dfadbff60f Problem: All Tendermint docs moved (#2483)
Solution: Update all links to Tendermint docs
2018-08-28 11:13:59 +02:00
Troy McConaghy
d78ff75225 Problem: HTTP API docs wrong regarding the mode parameter (#2481)
Solution: Edit those docs to be accurate
2018-08-27 15:01:55 +02:00
vrde
41a2687b9b Problem: websocket fails with ELECTION transaction (#2482)
Solution: have a more general approach to process transaction types. If
a transaction does *not* contain `asset.id`, then the `id` of the
`asset` is the `id` of the transaction.
2018-08-27 15:00:02 +02:00
codegeschrei
6fdcaf44a7 Problem: we have unused and outdated fixtures (#2476)
* Problem: we have unused and outdated fixtures
Solution: clean up fixtures and tests accordingly
2018-08-27 09:48:20 +02:00
codegeschrei
d31ab9fb40 Problem: There is no way to vote for an election (#2458)
* Problem: `run_upsert_validator_approve` was getting the voting power in a convoluted way

Solution: Changed it to get the voting power from the election outputs

* Problem: `run_upsert_validator_approve` casts votes for *all* voters, not just the user calling the command

Solution: Filter vote txs by the users public key

* Problem: Docs needed a more specific description of how to input the path to the private-key file

Solution: Changed the wording a bit
2018-08-24 09:52:00 +02:00
Troy McConaghy
a16d561f54
Add link to the Java driver in Contributing docs (#2478) 2018-08-23 15:17:05 +02:00
codegeschrei
e2aafb9cf9 Problem: there is a new version of the python driver (#2477)
Solution: update the Dockerfile for acceptance tests
2018-08-23 14:49:04 +02:00
Troy McConaghy
045136f9a6 Problem: Not clear that simple-network-setup (old name) is the analog of Kubernetes Deployment template (#2475)
Solution: Rename it the "Simple Deployment Template" & fix all refs
2018-08-23 09:44:12 +02:00
codegeschrei
90f2fdfc23 Problem: several tests are skipped (#2452)
* Problem: several tests are skipped
Solution: activate or remove tests

* Problem: store_transaction is deprecated
Solution: replace it with store_bulk_transaction

* Problem: we don't test the transaction split
Solution: undelete `test_store_transaction`

* Problem: failing tests
Solution: merge master and change deprecated store_transaction
2018-08-22 10:48:43 +02:00
codegeschrei
55a9151c14 Problem: tests in test_bigchain_api are not activated (#2456)
* Problem: tests in test_bigchain_api are not activated
Solution: remove or active tests

* Problem: TransactionNotInValidBlock was removed
Solution: remove TransactionNotInValidBlock from tests
2018-08-22 09:56:44 +02:00
Troy McConaghy
acc60bcce1 Problem: 'backlog' still referenced by some code & comments (#2474)
Solution: Remove all references to 'backlog'.
Also make the tuple of TABLES common to all backend databases.
2018-08-21 10:27:25 +02:00
Troy McConaghy
4815e75855 Problem: People reading HTTP API docs not told about the option to query MongoDB directly (#2463)
Solution: Tell them
2018-08-21 10:26:39 +02:00
Vanshdeep Singh
01dba7e883 Problem: Cannot conclude validator election (#2445)
Solution: Gather votes and conclude election when supermajority is achieved
2018-08-20 16:57:32 +02:00
Troy McConaghy
a3dce723be
Problem: Config settings docs missing some configs & inconsistent (#2461)
* Problem: Config settings docs missing some configs & inconsistent

Solution: Document some undocumented config settings and make the config settings docs page more consistent

* Problem: No docs about how config setting env var name determined

Solution: Explain and show the relationship between the config-file name and the environment variable name of config settings
2018-08-20 09:34:55 +02:00
Troy McConaghy
bd49a3804f
Problem: Docs say "BigchainDB cluster" but IRL we say "BigchainDB network" (#2471)
Solution: Edit the docs to say "BigchainDB network" instead
2018-08-17 16:04:58 +02:00
Troy McConaghy
423820bcda
Problem: simple-network-setup page getting long (#2464)
Solution: Start refactoring it into a new section
2018-08-17 14:19:58 +02:00
vrde
0142e98dba Problem: Rapid JSON is outdated and slow (#2470)
Solution: Use the last version of Rapid JSON.
2018-08-17 14:08:49 +02:00
Troy McConaghy
abdd23f5a6 Problem: Source files contain no license info (#2455)
* Problem: Source files contain no license info

Solution: Add comments with SPDX license info to source files

* Python 3 files don't need # -*- coding: utf-8 -*-
2018-08-16 12:31:32 +02:00
Zachary Bowen
3092beb995 Reenable test bigchain api - part 1 (#2415)
* Problem: core.py contains an unused class, `Bigchain`

Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.

* Fixed flake8 complaint about too many blank lines

* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...

Sorry in advance!

* Updating from master changed BigchainDB.process_post_response to a private method, so I had to align with that.

* Fixed a couple stale references to bigchaindb.Bigchain in docstrings

* Missed a reference to `Bigchain` in a patch call...

* Problem: Tests in class `TestBigChainAPI` from `tests/db/test_bigchain_api.py` were disabled

Solution: Fixed the tests that still made sense, and deleted the rest.

* Problem: Flake8 style complaints

Solution: Made things prettier

* Problem: Debugging comments were slightly NSFW

Solution: Deleted the debugging comments

* Problem: Stale use of `pytest.mark.genesis` decorator on these tests

Solution: Removed the decorator

* Problem: CriticalDoubleInclusion exception was no longer used anywhere in the code

Solution: Deleted it

* Problem: Unused exception `GenesisBlockAlreadyExistsError`

Solution: Deleted it

* Problem: I removed a test that covered writing to the DB and checking that everything is stored faithfully

Solution: Replaced it and got it working again
2018-08-13 09:54:45 +02:00
Troy McConaghy
bbf5310ac8
Problem: community drivers not working w/ latest BDB (#2443)
Solution: In the docs page listing the Community-Driven Libraries and Tools, make it clear that they might not work with the latest version of BigchainDB. Make it a warning rather than a note.
2018-08-10 11:39:44 +02:00
Zachary Bowen
3760824261 Create dynamic upsert validator commands (#2446)
* Problem: Need a method to initiate a new upsert-validator election

Solution: Added subcommand `new` to `upsert_validator`

* Problem: Changes to upsert-validator needed to be reflected in the docs

Solution: Wrote a section for `upsert-validator new`
2018-08-09 17:29:21 +02:00
Muawia Khan
3011548317 Problem: remove autodraft from download link (#2454) 2018-08-09 15:17:46 +02:00
Troy McConaghy
4636a48918 Problem: Glossary no longer referenced by any docs (#2441)
Solution: Remove Glossary section from the server docs
2018-08-09 11:16:56 +02:00
Troy McConaghy
205e2cf3fd Problem: Immutability page in docs sometimes wrong or controversial (#2435)
Solution: Edit that page
2018-08-09 11:16:05 +02:00
Troy McConaghy
4806b81577 Problem: Inconsistent HTTP API docs (#2403)
- Make the title of the asset search section consistent with the example (and consistent with the metadata search title and example).
- Add a note that one can use `asset?search` or `asset/?search`, and the same for metadata.
2018-08-09 11:14:48 +02:00
Troy McConaghy
65b6040e6b Problem: Codecov shield commented-out in README.md (#2421)
Solution: Uncomment it, since Codecov is working again

![Codecov](https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb/master.svg)
2018-08-08 16:46:23 +02:00
Dan Acristinii
ab41b463d8 fixed validator curl port (#2447) 2018-08-08 15:45:08 +02:00
codegeschrei
44be8f572f Problem: Block parameters are not required anymore (#2374)
* Problem: all blocks are valid
Solution: remove the status from transactions

* Problem: changed the return type of get_transaction_filtered
Solution: return tx class instead of dict
2018-08-08 15:08:34 +02:00
Vanshdeep Singh
54b81d3ae8 Problem: Random failure for event handler test (#2423)
Solution: Random failure of test
`tests/test_events.py::test_event_handler_raises_when_called_after_start` seem
to be because of `get_nowait` which returns way to quickly even when the queue
has data. Increasing timeout seems to fix the issue.
2018-08-08 14:23:07 +02:00
Troy McConaghy
66fd001311
Problem: Doc re/ handling external PRs has moved (#2444)
Solution: Modify the file `HOW_TO_HANDLE_PULL_REQUESTS.md` to point its readers to the new document about how to handle external pull requests: [BEP-16](https://github.com/bigchaindb/BEPs/tree/master/16).
2018-08-08 13:27:48 +02:00
codegeschrei
bdfa059046 Problem: some tests are not activated (#2390)
* Problem: core.py contains an unused class, `Bigchain`

Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.

* Problem: core.py contains an unused class, `Bigchain`

Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.

* Fixed flake8 complaint about too many blank lines

* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...

Sorry in advance!

* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...

Sorry in advance!

* Updating from master changed BigchainDB.process_post_response to a private method, so I had to align with that.

* Fixed a couple stale references to bigchaindb.Bigchain in docstrings

* Missed a reference to `Bigchain` in a patch call...

* Problem: some tests are not activated
Solution: activate and remove or fix tests

* Problem: accidentally un-skipped test_get_blocks_status_containing_tx during merge

Solution: Replaced the skip
2018-08-08 12:17:44 +02:00
Troy McConaghy
9b4273a987
Problem: Docs: 'Production Deployment Template' not a good name anymore (#2440)
Solution: Rename that section to 'Kubernetes Deployment Template'
2018-08-07 13:20:47 +02:00
Troy McConaghy
32b64ccc2a Problem: k8s docs not clear about who they're for (#2439)
Solution: Add a note atop k8s docs pages to clarify who they're for
2018-08-06 15:20:31 +02:00
innoprenuer
01dbb20248
moved java driver to officially supported category 2018-08-06 14:03:36 +02:00
Vanshdeep Singh
2e9a9b1121 Problem: Validator set not tracked by BigchainDB (#2436)
* Problem: Validator set not tracked by BigchainDB

Solution: BigchainDB depends on tendermint's RPC API to get the validator set
which is not avaiable during replay so the validators set should be tracked
inside BigchainDB

* Problem: Unclear code and documentation

Solution: Fix decode_validator and docs strings

* Problem: Doc strings missing

Solution: Add doc string for store_validato_set
2018-08-06 11:37:43 +02:00
Troy McConaghy
e0676306b7 Problem: old page in Appendices is redundant (#2388)
Solution: remove the old Appendices page about installing OS-level dependencies
2018-08-06 11:37:28 +02:00
Troy McConaghy
8090a35676
Problem: Docs say little re/ privacy & handling private data (#2437)
* Problem: Docs should say more about how to handle privacy & private data

Solution: Write a new docs page about that

* Problem: Server docs say little re/ prod. node security & privacy

Solution: Create a new docs page, "Production Node Security & Privacy"

* Address initial comments from @gautamdhameja
2018-08-06 10:15:09 +02:00
Troy McConaghy
d25d806cd8 Problem: pylint's GPL license isn't Apache2-compatible (#2406)
Solution: Remove pylint from setup.py. It occurred nowhere else.
2018-08-02 16:35:07 +02:00
Muawia Khan
66b243a2b4 Problem: People request all-in-one BigchainDB container (#2424).
Solution: Provide a stand-alone all-in-one BigchainDB container.

* Document it.
* Clarify that the image is not suited for joining a network.
2018-08-02 14:05:23 +02:00
Vanshdeep Singh
1a74afa9cd Problem: Node operator cannot vote on a ValidatorElection (#2428)
* Problem: Node operator cannot vote on a ValidatorElection

Solution: Implement validator election voting spec

* Problem: Incorrent code comments

Solution: Update comments with correct context

* Problem: Delegated vote not casted back to election

Solution: Update test to cast votes back to election id and assert their validity
2018-08-02 11:49:59 +02:00
Troy McConaghy
c2e61ae8c1 Problem: simple-network-setup docs trouble Ubuntu 16.04 users (#2432)
Solution: Make that docs page super-clear that it's for Ubuntu 18.04, and give hints for users of other distros
2018-08-02 10:36:04 +02:00
Muawia Khan
49bc495cc4 Last pr before 2.0 beta 5 (#2430)
* Last PR before the release of BigchainDB 2.0 Beta 5

* Fix editing error

* Change development status back to 4 - beta

* Rephrase some fixes I

* Rephrase some fixes II
2018-08-01 15:40:05 +02:00
Muawia Khan
b1c34523ed Problem: Simple network guide outdated, some new parameters required (#2429) 2018-08-01 11:27:20 +02:00
Troy McConaghy
6693a8933a
Change the docs license from CC-BY-SA-4 to CC-BY-4 (#2427) 2018-07-31 17:38:07 +02:00
Muawia Khan
5b05f6505d Upgrade tm_version to 0.22.8 (#2426)
* Upgrade tm_version to 0.22.8

* Fix tendermint download link
2018-07-31 17:27:16 +02:00
Vanshdeep Singh
533030cdae Problem: No test to validate duplicate inputs (#2425)
Solution: Update tests
2018-07-31 14:33:28 +02:00
Vanshdeep Singh
f13c9a9d57 Problem: Stateful validation doesn't raise double spend exception (#2422)
* Problem: Stateful validation doesn't raise double spend exception

Solution: Transaction.validate should raise exception DoubleSpend if the given
transaction is already a part of the database

* Problem: Double spend exception message not accurate

Solution: The exception message should state that the double spend is because of
spending the same input more than once in the transaction
2018-07-31 14:06:21 +02:00
Lev Berman
4795a78d49
Last PR before the release of BigchainDB 2.0 Beta 4 (#2420) 2018-07-30 16:23:00 +02:00
Troy McConaghy
b8ad5d9cec
Problem: Release process instructions for Docker Hub incomplete (#2407)
Solution: Expand the release process instructions for Docker Hub
2018-07-30 15:47:26 +02:00
Vanshdeep Singh
5adc1cac3e Problem: ReadTheDocs build fails. (#2419)
Solution: Move the schema spec for validator election to common directory so
that the yaml schema files can be found
2018-07-30 15:19:51 +02:00
Troy McConaghy
199adc81b6 Problem: Example priv_validator.json is out-of-date in docs (#2416).
Solution: In the simple-network-setup docs page, update the example priv_validator.json contents.
2018-07-27 17:42:35 +02:00
Vanshdeep Singh
7dcdefc58b Problem: There is no way to add new validators (BEP-21) (#2392).
Solution: Start by integrating the new election spec specifed in BEP-21.
2018-07-27 17:38:24 +02:00
Lev Berman
a0670b6d06
Problem: config utils tests are disabled. (#2402)
Solution: enable them back, cleanup no longer relevant parts.
2018-07-27 17:35:44 +02:00
Muawia Khan
c3f5e2a654 Problem: It is cumbersome to manage BigchainDB and Tendermint processes (#2410).
* Introduce a Monit-based setup for managing processes. Add the corresponding section to the network setup guide.
2018-07-27 17:33:55 +02:00
Lev Berman
2f6413fcd0 Problem: Transaction schema tests were disabled. (#2404)
Solution: Re-enable the tests. Remove some no longer relevant parts.
2018-07-26 16:44:56 +02:00
vrde
af2bf61dc8 Problem: websocket might be unresponsive (#2413)
Solution: It might be related on how aiohttp 2.x handles `send_str`.
AFAIK the call `send_str` was not "fully async". In aiohttp 3.x they
[changed it][1]:

> send_str(), send_bytes(), send_json(), ping() and pong() are genuine
async functions now. (#2475)

So this patch adds support for aiohttp 3.x, and uses the `send_str`
coroutine.

[1]: https://github.com/aio-libs/aiohttp/blob/master/HISTORY.rst#deprecations-and-removals-1
2018-07-26 15:30:10 +02:00
vrde
2087f7090f Problem: abruptly closed sockets still in memory (#2408)
Solution: Catch the proper exception and remove socket from memory.
2018-07-26 15:29:53 +02:00
Muawia Khan
0c33b4c211 Problem: Signals do not propagate to child BigchainDB processes (#2395).
Solution: Run child processes as daemons to make the signals propagate. Add a short shutdown description to the setup guide.
2018-07-26 14:42:32 +02:00
Zachary Bowen
2386ca9d71 Refactor tendermint directory to project root (#2401)
* Problem: core.py contains an unused class, `Bigchain`

Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.

* Problem: core.py contains an unused class, `Bigchain`

Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.

* Fixed flake8 complaint about too many blank lines

* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...

Sorry in advance!

* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...

Sorry in advance!

* Updating from master changed BigchainDB.process_post_response to a private method, so I had to align with that.

* Fixed a couple stale references to bigchaindb.Bigchain in docstrings

* Missed a reference to `Bigchain` in a patch call...

* Problem: BigchainDB class should be part of project root

Solution: Removed the /tendermint directory and moved its contents to project root

* Problem: Flake8 complained that imports were not at the top of the file

Solution: Had to play around with the order of imports to avoid cyclic dependencies, but its working and style compliant now

* Problem: Stale reference to /tendermint directory in the index

Solution: Removed the references to /tendermint

* Problem: Flake8 complaining of unused import in __init__.py

Solution: The import is there so I can import App directly from bigchaindb, rather than from bigchaindb.core (which I think improves code readability. I added a # noqa to silence Flake8.

* Problem: Stale references to `bigchaindb.tendermint.BigchainDB` in the rst files cause Sphinx to fail

Solution: Updated the autodoc files to use `bigchaindb.BigchainDB` instead

* Problem: Stale reference to the `tendermint` directory in an @patch in a disabled test

Solution: Updated the @patch for completeness

* Problem: BigchainDB class should be part of project root

Solution: Removed the /tendermint directory and moved its contents to project root

* Problem: Flake8 complained that imports were not at the top of the file

Solution: Had to play around with the order of imports to avoid cyclic dependencies, but its working and style compliant now

* Problem: Stale reference to /tendermint directory in the index

Solution: Removed the references to /tendermint

* Problem: Flake8 complaining of unused import in __init__.py

Solution: The import is there so I can import App directly from bigchaindb, rather than from bigchaindb.core (which I think improves code readability. I added a # noqa to silence Flake8.

* Problem: Stale references to `bigchaindb.tendermint.BigchainDB` in the rst files cause Sphinx to fail

Solution: Updated the autodoc files to use `bigchaindb.BigchainDB` instead

* Problem: Stale reference to the `tendermint` directory in an @patch in a disabled test

Solution: Updated the @patch for completeness
2018-07-25 16:59:25 +02:00
vrde
d0a24ef584 Problem: validation runs redundant queries (#2409)
Solution: when a transaction is stored, the system splits it in three
components, data, metadata, and the other fields of the transaction.
When the system retrieves a transaction, it needs to make three
different queries to reconstruct the original transaction. If a
transaction does not exist, the system does three queries anyway, even
if just one query is enough. This patch fixes this by doing the
additional queries if and only if the transaction exists.
2018-07-25 16:16:06 +02:00
Troy McConaghy
d5dda74643
Dummy PR (#2405)
* Fixed 2 PEP257 compliance errors

* Upgrade Tendermint to 0.19.7 except for Docker image, which is still at 0.19.2
2018-07-25 10:02:55 +02:00
Troy McConaghy
12740686e9
Problem: Docs say Crypto Conditions are part of ILP (#2399)
* Fixed 2 PEP257 compliance errors

* Upgrade Tendermint to 0.19.7 except for Docker image, which is still at 0.19.2

* Problem: Docs say Crypto Conditions are part of ILP

Solution: Edit the docs so they no longer say that
2018-07-23 18:03:21 +02:00
Muawia Khan
75c22141ad
Problem: mongodb repos different for debian and ubuntu (#2385)
* Problem: mongodb repos different for debian and ubuntu

* Ignore errors for checking bdb process
2018-07-23 17:38:24 +02:00
Troy McConaghy
42cc0d0e86 Problem: No troubleshooting help for users of simple-network-setup (#2398)
Solution: Add a Troubleshooting section to the simple-network-setup docs
2018-07-23 16:54:27 +02:00
Troy McConaghy
e681427b75
Problem: The write-a-bep page/process is daunting (#2347)
* Problem: The write-a-bep page/process is daunting

Solution: Make the BEP writing process easier and more approachable

* Problem: BEP should be written uppercase

Solution: Change bigchaindb/BEPs label names to use uppercase "BEP"
2018-07-23 10:42:36 +02:00
Troy McConaghy
abc6db7999
Last PR before the release of BigchainDB 2.0 Beta 3 (#2391)
* Update CHANGELOG.md for 2.0 Beta 3 release

* Update docs re/ installation for 2.0.0b3

* Update version.py and k8s files for 2.0.0b3
2018-07-18 15:20:13 +02:00
codegeschrei
d521a00925 Problem: a valid transaction is detected as double spend (#2389)
Solution: query the wanted data per input
2018-07-18 10:52:33 +02:00
codegeschrei
fdf0283508 Problem: consensus and blocks are deprecated (#2384)
Solution: remove test files for consensus and blocks
2018-07-16 19:21:27 +02:00
Troy McConaghy
b122e7e83b
Last PR before the BigchainDB 2.0 beta 2 release (#2382)
* Updated CHANGELOG.md for the 2.0b2 release

* Update bigchaindb docker image names for k8s for the 2.0b2 release

* Update version.py for the 2.0b2 release

* In CHANGELOG.md, added note re port 46657->26657
2018-07-16 15:39:07 +02:00
Muawia Khan
9cfc1e6f5a Update to tendermint version 0.22.3 (#2380)
* Update to tendermint version 0.22.3 for dev/test deployment docs and scripts

* Update version and parameters for 0.22.3

- Sync docker-compose
- Power should be a "string" not a int,uint
2018-07-11 16:59:42 +02:00
Zachary Bowen
4d2e58416c Problem: Bigchain class is unused and redundant (#2366)
* Problem: core.py contains an unused class, `Bigchain`

Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.

* Problem: core.py contains an unused class, `Bigchain`

Solution: Remove core.py. Refactor BigchainDB Class to remove inheritance from Bigchain.

* Fixed flake8 complaint about too many blank lines

* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...

Sorry in advance!

* Attempting to fix Sphinx docs. This may result in some redundant commits, as I don't know what I'm doing, and I can't experiment without running the CI...

Sorry in advance!

* Updating from master changed BigchainDB.process_post_response to a private method, so I had to align with that.

* Fixed a couple stale references to bigchaindb.Bigchain in docstrings

* Missed a reference to `Bigchain` in a patch call...

* Merge with master and re-do some changes
2018-07-10 17:34:51 +02:00
Zachary Bowen
f243b252ca Problem: we don't have any tests to cover malicious strings (#2334)
* Problem: we don't have any tests for malicious strings

Solution: Use a parameterized test that fuzzes over a library of potentially hazardous strings

* Needed to update the Dockerfile to install blns

* Removed unnecessary import from Dockerfile-dev

* Made the conditions under which the test expects an error more explicit

* Improved reporting in case of a bad status code

* Removed some over-zealous assertions.

* Removed `sent_transaction` from assertation error response

* *Problem: blns was removed as a dependency while fixing a merge conflict

Solution: added it back to the Dockerfile

* *Problem: made a typo when adding blns to the Dockerfile

Solution: fixed the typo
2018-07-10 17:30:00 +02:00
Troy McConaghy
10953a64e7 Problem: "IPDB Transaction Spec" referenced in .../schema/README.md (#2376)
Solution: Update `bigchaindb/common/schema/README.md` to link to the BigchainDB Transactions Specs instead.
2018-07-10 14:19:45 +02:00
Vanshdeep Singh
c7503f5689 Problem: Support for latest Tendermint missing (#2375)
Solution: Upgrade to py-abci 0.5.1 to use latest Tendermint
2018-07-10 14:16:02 +02:00
vrde
1118ddffa2 Problem: performance issue on transaction lookup (#2378)
Solution: create the correct index for transaction id.
Close #2377
2018-07-10 13:51:59 +02:00
Lev Berman
744ab3d5ef Problem: 2 implementations of fastquery exist. (#2365)
* Problem: 2 implementations of fastquery exist.

Solution: Remove the old deprecated implementation. Update the tests.

* Problem: There are still 3 outdated fastquery tests.

Solution: Fix the tests.
2018-06-29 15:48:58 +02:00
Muawia Khan
1bad851e07
Problem: Tendermint configuration not present in BigchainDB config (#2342)
* Problem: Tendermint configuration not present in BigchainDB config

* Handle tendermint configurations properly

- Update docs

* Nitpick

* Missed some conflicts

* Make changes in tendermint/lib.py instead of deprecated core.py

- Also remove redundant info from docs about default values

* Fix docsserver automethod
2018-06-29 18:45:22 +05:00
codegeschrei
af996650c3 Problem: The Block class is deprecated (#2368)
* Problem: docs are not building anymore
Solution: add wget to the requirements for docs

* Problem: The Block class is deprecated
Solution: remove the block class and all occurrences
2018-06-29 15:32:16 +02:00
codegeschrei
278ff1ddb2 Problem: docs are not building anymore (#2360)
Solution: add wget to the requirements for docs
2018-06-28 18:08:55 +02:00
Muawia Khan
00553c8324
Problem: Typos in variable names left during some conflict resolution (#2364) 2018-06-28 17:44:28 +05:00
codegeschrei
7449b026fa Problem: voting code is not used anymore (#2357)
* Problem: voting code is not used anymore
Solution: remove all voting related code

* Problem: Some voting functionality is still present.

Solution: Remove it. Update some of the related tests.

* Problem: some skipped tests are now running
Solution: remove pytest mark to not run them

* Problem: fastquery is not related to votes
Solution: remove it in another PR
2018-06-28 11:30:13 +02:00
Vanshdeep Singh
67c4ce964a Problem: Upsert validator not marked experimental (#2356)
Solution: Update documentation to mark it experimental
2018-06-20 10:15:14 +02:00
codegeschrei
119dcef75f Problem: Code codecoverage does not work (#2355).
* Problem: Code coverage does not work.
* Solution: Fix the code coverage script.
2018-06-19 10:58:12 +02:00
Vanshdeep Singh
971efb5f1c Problem: Bigchaindb processes cannot be recogonized in shell easily (#2354)
Solution: Append 'bigchaindb_' to the name of each process
2018-06-18 14:15:24 +02:00
Troy McConaghy
d0293c5285
Problem: Users need more help querying mongodb (#2352)
* Add info how to connect to MDB & example MDB documents

* Add JS code examples & blogpost link to Query page
2018-06-14 17:21:15 +02:00
Shahbaz Nazir
2da720e542 Problem: There is no logging for benchmark stats (#2349)
* add log level for benchmarking

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* Bug fixes and code re-factor

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* remove un-necessary imports

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* fix failing tests

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* update docs

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* fix typo

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* fix flake8

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* fix flake8 issues

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* nitpic fixes

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-06-14 15:19:26 +02:00
Troy McConaghy
58fbccf3f1 Problem: © year out-of-date in footer of docs (#2353)
Solution: Compute the © year so it's always up-to-date
2018-06-14 13:03:31 +02:00
codegeschrei
181c9a13b5 Problem: there is a new python driver version (#2351)
Solution: update the version for acceptance tests
2018-06-14 11:08:48 +02:00
Lev Berman
6b5fe19036
Problem: Tendermint freezes due to docker-compose bug. (#2341)
Solution: Do not rely on depends_on when running containers in the foreground. Solves #2322.
2018-06-12 10:26:52 +02:00
Troy McConaghy
04514fe17f Problem: No diagrams of transactions in docs (#2346)
Solution: Put some simple diagrams of BigchainDB transactions in the docs
2018-06-11 17:25:27 +02:00
Troy McConaghy
46b3720bf5 Problem: CHANGELOG didn't accurately describe known issues (#2344).
Solution: Revise the CHANGELOG to more accuratly describe all known issues (at the time of the Beta release).
2018-06-11 14:11:11 +02:00
Shahbaz Nazir
bec8d13e36
Problem: Current logging server keeps running in some tear down scenarios (#2304)
Solution: Remove the current pub/sub based logging infra as this model is no longer necessary. This can now be replaced by a simple system level logging config.
2018-06-11 13:08:03 +02:00
Troy McConaghy
d492485357
Fixed a typo in README.md 2018-06-09 09:32:58 +02:00
Troy McConaghy
36930248a4
In README.md, make the shields line up on 1 line 2018-06-09 09:31:52 +02:00
Muawia Khan
1c7d5dcd2a
Problem: Stack installation on Centos 7 caused issues with some packages (#2339) 2018-06-08 15:52:22 +02:00
Muawia Khan
2b39566a4b Problem: Some configurations are defunct (#2338)
* Problem: BigchainDB config has stale/deprecated parameters

- Remove `keyring` and `keypair` from config
- Update tests
- Add `tendermint` config

* Fix flake8

* Update some naming conventions and redundant changes

* Remove redundant routine `fast_query`

* Remove deprecated parameters and descriptions

* remove some more unwanted code

* Problem: Two flake8 errors made Travis fail

Solution: Fix the two flake8 errors

* Address comments

- Remove reference of nodes_except_me and me_private and me
  as attributes of BigchainDB instances
- Update and re-add test(s)
- Do not introduce `tendermint` in configuration instead handle that
  in a separate PR along with docs

* Address comments

- Remove tests that are already covered with 2.0
- Remove tests that are no longer relevant
- Add TODO for more cleanup

* Remove tendermint config from configure command
2018-06-08 15:50:50 +02:00
Troy McConaghy
58a5959170 Problem: README.md is outdated & has broken links (#2340)
Solution: Update README.md and fix broken links & shields
2018-06-08 11:31:10 +02:00
Lev Berman
6f9dc5168b Problem: Tendermint RPC server gets stuck. (#2337)
Solution: Upgrade Tendermint to v0.19.0. Fixes #2322.
2018-06-06 14:18:27 +02:00
Troy McConaghy
cf1202fe0c Copyedit simple-network-setup completeness & grammar (#2312)
* Copyedit simple-network-setup completeness & grammar

* Problem: Member doesn't know their BigchainDB Root URL

Solution: Add a section to tell the Member their BigchainDB Root URL

* Problem: Operator doesn't know how to reset their node

Solution: Add a section with commands an operator can use to reset their node

* Problem: Repeated previous sentence w/o changing it

Solution: Repeat previous sentence but change 'BigchainDB' to 'Tendermint' and delete the parenthetical sentence about MongoDB

* Address the comments by @vrde
2018-06-06 10:03:25 +02:00
Muawia Khan
fa72b722f7 Problem: Docker images of tendermint/tendermint:0.19.7 tagged but not updated in bdb (#2335) 2018-06-04 16:10:50 +02:00
Troy McConaghy
241db4ee48 Problem: backlog_reassign_delay is defunct but still listed (#2332)
* Fixed 2 PEP257 compliance errors

* Upgrade Tendermint to 0.19.7 except for Docker image, which is still at 0.19.2

* Problem: backlog_reassign_delay is defunct but still listed

Solution: remove all mentions of & calls for backlog_reassign_delay
2018-06-04 12:19:24 +02:00
Troy McConaghy
1753a7019b Problem: Appendices page 'The Bigchain Class' not Updated for Tendermint (#2330)
* Fixed 2 PEP257 compliance errors

* Upgrade Tendermint to 0.19.7 except for Docker image, which is still at 0.19.2

* In the Appendices, update page re/ The Bigchain Class
2018-06-04 12:19:04 +02:00
Takanori Hirano
c5b4fa357d Problem: nginx_container document is incorrect (#2331)
Solution
Fixed nginx_container volume path and environment name.
2018-06-04 12:18:03 +02:00
Troy McConaghy
00cb5108ca Problem: vote.yaml & vote schema validation not used anymore (#2319).
Solution: remove vote.yaml & all vote schema validation code.
2018-06-04 10:53:01 +02:00
Troy McConaghy
51fa3155f6
Problem: what if someone agrees to CLA but no PR? (#2313)
Solution: ask them if they meant to agree to the CLA, and if so, where is their PR?
2018-06-01 14:54:51 +02:00
Troy McConaghy
6b0f22aeb8
Last PR before 2.0 beta 1 (#2328)
* Update CHANGELOG.md for 2.0 Beta 1 release

* Changed 2.0.0b1 release date to 2018-06-01

* k8s: Updated bigchaindb docker image tag to 2.0.0-beta1

* Updated version.py for the 2.0 Beta 1 release

* Updated dev status to '4 - Beta' in setup.py for the 2.0 Beta 1 release
2018-06-01 13:49:23 +02:00
Troy McConaghy
02ee8a9ac1
Upgrade Tendermint to 0.19.7, except for Docker image still at 0.19.2 (#2327)
* Fixed 2 PEP257 compliance errors

* Upgrade Tendermint to 0.19.7 except for Docker image, which is still at 0.19.2
2018-06-01 13:29:58 +02:00
Troy McConaghy
ccb7a86428 Copy-edited & updated page on Running a Local Dev Node as Processes (#2324) 2018-06-01 12:46:25 +02:00
Troy McConaghy
54229d1faf Problem: Still using "team bot" after installing Codecov (#2325)
Solution: Remove the "team bot" from the `codecov.yml` file.

I installed Codecov on all "bigchaindb" (GitHub organization) repos today, so we can remove the "team bot", according to [the Codecov docs](https://docs.codecov.io/docs/team-bot), i.e.

> The best way to integrate with Codecov is to Install Codecov's GitHub Integration.

> Once installed, you are done! You do not need to set a Team Bot because Codecov will use the integration to post statuses and comments.
2018-06-01 10:51:35 +02:00
vrde
357c3ee8eb Problem: API returns 404 for existing empty blocks (#2321)
* Problem: API returns 404 for existing empty blocks

Solution: Empty blocks are not store in MongoDB because Tendermint does
not notify BigchainDB about them. In case a user requests a block that
is not in our MongoDB, we check if the requested height is less than or
equal to latest_block_height. If that's the case, we return an empty
block. If the requested height is greater than latest_block_height, then
we return 404.

* Address Lev's comment

* address Lev and Vansh comment
2018-05-31 17:15:17 +02:00
Muawia Khan
10e55aa4e7
Problem: No automated way to set up a dev/test network (#2300)
* Problem: No automated way to set up a dev/test network

* Problem: docs not updated for stack, ansible and docker based dev environments

* Problem: Using apt triggers java runtime installation on MacOS

- Update pre_tasks in ansible
- Update bigchaindb-stop playbook to handle pre_tasks

* Update Tendermint version to 0.19.3 from 0.19.2

* Update tendermint version to 0.19.3 everywhere else

* Problem: Sphinx warns about duplicate section labels

Solution: Don't use sphinx.ext.autosectionlabel

* Problem: Sphinx complains that run-node-with-docker not in any TOC

Solution: Add run-node-with-docker to a TOC (i.e. to an index.rst file)

* Tendermint has not tagged `0.19.3` container

* Problem: Internal hyperlinks to new pages not working

Solution: Add .html to the ends of the filename strings

* Problem: Invalid script imports

* Problem: Invalid comparison for supported OS version

* Addressing comments I

* Problem: No way to configure dev/forked repo for developers

* Problem: Docs not updated with STACK_REPO parameter

* Addressing comments II
2018-05-31 16:56:45 +02:00
Muawia Khan
0f56e4372d Revert: bigchaindb configure does not write the correct configuration (#2323) 2018-05-31 15:18:59 +02:00
Troy McConaghy
f3683854e8 Problem: Can't connect to local MongoDB when make start (#2320)
Solution: Expose MongoDB port 27017 when using `make start`, i.e. when using docker-compose.yml
2018-05-30 15:58:56 +02:00
Troy McConaghy
298ff8a3fd Problem: We continue to be asked about production-readiness (#2316)
Solution: Add more explanation to the docs page about production-readiness
2018-05-29 17:47:59 +02:00
Vanshdeep Singh
a2aa4554c0 Problem: Spending transaction doesn't return properly (#2318)
Solution: Differentiate between stored spent txns and current spending txns
2018-05-29 17:43:42 +02:00
vrde
340d0a2ea1
Problem: no instructions on simple network setup (#2296)
Solution: write a step-by-step tutorial on who should do what.
2018-05-24 01:39:03 +02:00
Troy McConaghy
acc2710d7b Problem: There are old links to the IPDB tx spec (#2290)
Solution: Replace those links with appropriate links to the BigchainDB Transactions Specs
2018-05-24 01:36:43 +02:00
Troy McConaghy
dfa4b70f23 Problem: make doc doesn't build the /contributing docs (#2293)
Solution: Make `make doc` build the docs in docs/contributing as well
2018-05-24 01:35:04 +02:00
Ahmed Muawia Khan
208085e16b
Problem: bigchaindb configure does not write the correct configuration (#2306) 2018-05-23 12:20:18 +02:00
Lev Berman
89b28b8471 Remove unsupported backends (#2289)
* Problem: RethinkDB, change feed, old mongo, admin interface are not supported any longer.

Solution: Remove unsupported functionality. Bring the MongoDB backend implementation completely to the localmongodb package. Fix the test setup.

* Problem: Nothing depends on multipipes any longer.

Solution: Remove multipipes from setup.py.

* Problem: The how-to-run-tests doc uses --database-backend.

Solution: Do not include the --database-backend option into the documented pytest usage.

* Problem: The backends docs are outdated.

Solution: Document MongoDB as the default and only backend for BigchainDB.

* Problem: The inputs fixtures uses old blocks API.

Solution: Change the inputs fixtures to use the new blocks API.

* Problem: rethinkdb package is not used anymore.

Solution: Remove the rethinkdb dependency from setup.py.

* Problem: The abci-marked tests use outdated Mongo conn.

Solution: Replace MongoDBConnection with LocalMongoDBConnection for them.
2018-05-23 11:34:00 +02:00
Troy McConaghy
5403f7bfcc Remove "Post-Release Steps" from release process (#2305)
The release process had some "Post-Release Steps" but I haven't been doing them lately. What were they?

The idea was to change the version number so that someone working on the `master` branch would see a version number reflecting what the `master` branch is. For example, if version 0.9.0 was just released, then the `master` branch would be changed to have the version number 0.10.0.dev, to indicate that it's the in-development version of 0.10.0.

My thinking now is that if someone is developing new code, then they don't need the version number to help them remember what they're doing. Moreover, if someone purposefully changes the docs to view the `master` branch docs, then they probably know what that means, and they don't need help from a version number.
2018-05-18 11:26:37 +02:00
Troy McConaghy
6fd8558bef
Last PR before releasing version 2.0.0a6 (#2301)
* Update CHANGELOG.md for 2.0.0a6

* Update image tags in k8s YAML files for 2.0.0a6

* Update version.py for 2.0.0a6
2018-05-17 15:42:31 +02:00
vrde
f86704bae9 Problem: BigchainDB does not support newer MongoDB (#2298)
* Problem: BigchainDB does not support newer MongoDB

Solution: Update driver to the last version, that is compatible with all
versions of MongoDB

* Update to MongoDB 3.6
2018-05-17 15:19:56 +02:00
vrde
474fe80abb Problem: dev env doesn't allow P2P connections (#2299)
Solution: expose Tendermint P2P port 46656
2018-05-17 15:19:12 +02:00
codegeschrei
e2ab561eef Problem: we don't have enough acceptance tests (#2294)
* Problem: we don't have enough acceptance tests
Solution: test different scenarios for divisible assets
2018-05-16 17:07:43 +02:00
codegeschrei
04b3b15c66 Problem: not all transaction scenarios in acceptance tests (#2291)
Solution: test multiple owners for a transaction
2018-05-16 15:54:54 +02:00
Lev Berman
2e9c20491c Problem: web transaction tests were broken or disabled. (#2278)
Solution: Fix or reenable the tests after the migration to BigchainDB 2.*.
2018-05-16 15:17:33 +02:00
Lev Berman
d44bec1b7d Problem: Pre-commit does not validate acceptance tests. (#2295)
Soluton: Adjust the pre-commit config.
2018-05-16 14:45:34 +02:00
vrde
dbf1b23c43 Problem: acceptance tests are using old pydriver (#2282)
Solution: update to the new driver version, and simplify the code
removing the `mode` parameter.
2018-05-15 11:46:58 +02:00
Lev Berman
89d665c01e Problem: Asset tests are disabled. (#2277)
Solution: Update the tests to work with BigchainDB 2.* and enable them back.
2018-05-15 11:19:47 +02:00
Ahmed Muawia Khan
48cabdd6b9 Problem: Nginx deployment is broken for k8s (#2287) 2018-05-15 10:59:35 +02:00
Lev Berman
2c171312cf Problem: The pipelines library is not used anymore. (#2286)
Solution: Remove pipelines. This is part of the BigchainDB 2.* migration cleanup.
2018-05-14 16:16:57 +02:00
Troy McConaghy
b9bceb7e3a Problem: Broken hyperlink in write-code.rst (#2288)
Solution: Fix the broken link
2018-05-14 09:57:48 +02:00
Ahmed Muawia Khan
ecaffb3308 Problem: Bash renders the quotes around apicast and openresty as variables (#2285) 2018-05-14 09:29:13 +02:00
Troy McConaghy
aeaf9c934d
Last PR before the release of version 2.0 Alpha 5 (#2283)
* Updated CHANGELOG.md for version 2.0 Alpha 5

* Updated image tags in k8s files for 2.0 Alpha 5

* Updated version.py for 2.0 Alpha 5

* Problem: Missing alpha5 image update for test network containers

* Problem: CHANGELOG not updated with 2284

* Problem: Liveness probe frequency change not the important
2018-05-11 15:23:15 +02:00
Ahmed Muawia Khan
bcfb577cfb
Problem: Liveness probe too aggressive (#2284) 2018-05-11 14:58:59 +02:00
Vanshdeep Singh
d2685052a6 Problem: py-abci not upgraded (#2281)
Solution: Upgrade py-abci
2018-05-11 10:32:39 +02:00
vrde
31bae195e7 Problem: acceptance-test suite is not documented (#2267)
* Problem: acceptance-test suite is not documented

Solution: add README.md in the root of the acceptance tests, unify
`Makefile` and commands, remove more cached files when `make clean` is
ran.

* Problem: documentation does not mention Makefile

Solution: update docs with our new and shiny commands
2018-05-11 09:50:08 +02:00
vrde
4a23fa6629 Problem: Python version not check before running (#2179) (#2280)
Solution: Check python version
2018-05-11 09:15:48 +02:00
Troy McConaghy
089cb5d24f
Last PR before the 2.0 Alpha 4 release (#2274)
* Initial CHANGELOG.md edits for the 2.0 Alpha 4 release

* Added PR #2275 to CHANGELOG.md for the 2.0 Alpha 4 release

* Update k8s image tags for the 2.0 Alpha 4 release

* Update version.py for the 2.0 Alpha 4 release
2018-05-09 14:03:19 +02:00
Vanshdeep Singh
7384a49d9a Problem: Invalid transaction posted to Tendermint (#2270)
* Problem: Amount error is not tested on the HTTP level.

Solution: A failed web test to reproduce the problem.

* Problem: Invalid transaction posted to Tendermint

Solution: Pass the exception to HTTP POST handler function

* Problem: DoubleSpend and CriticalDoubleSpend not differentiated

Solution: Handle these exceptions differently in `get_spent`

* Problem: No test for checking exception DoubleSpend and CriticalDoubleSpend

Solution: Add necessary tests

* Problem: find doesn't raise IndexError

Solution: Remove exception handling for IndexError
2018-05-09 13:41:22 +02:00
Ahmed Muawia Khan
97b2d554e9 Problem: abci_info liveness probe check is not enough (#2275) 2018-05-09 11:58:46 +02:00
Troy McConaghy
722401ada9 Problem: How do I store files in BigchainDB? (#2259)
Solution: Write a new root docs page about how to store files in BigchainDB.
2018-05-08 10:35:21 +02:00
Artus Vranken
9020348073 Fixed the doc link to "node-on-kubernetes" (#2263) 2018-05-05 17:12:26 +02:00
Troy McConaghy
a388bd5122
Updated RELEASE_PROCESS.md based on things noticed in the 2.0 Alpha 3 release (#2266) 2018-05-04 12:09:17 +02:00
Lev Berman
3eb0b15aa0 Problem: Tendermint creates empty blocks in the Docker-based setup. See #2204. (#2265)
Solution: Set the --consensus.create_empty_blocks=false option in docker-compose.yml.
2018-05-04 12:02:22 +02:00
Vanshdeep Singh
63635f12fc Problem: Event stream test failing (#2262)
Solution: Extend the wait time for Tendermint to start
2018-05-03 16:42:43 +02:00
Troy McConaghy
b408b57eda
[WIP] Last PR to merge before releasing BigchainDB 2.0 Alpha 3 (#2257)
* Initial CHANGELOG.md updates for 2.0 Alpha 3

* More updates to CHANGELOG.md for 2.0 Alpha 3

* Added note in CHANGELOG.md about the bigchaindb-abci package we're using for now

* Updated Docker image tags to bigchaindb/bigchaindb:2.0.0-alpha3

* Updated version.py for BigchainDB 2.0 Alpha 3
2018-05-03 16:34:05 +02:00
Vanshdeep Singh
551cf58c7c Problem: pypi bigchaindb-abci not used (#2261)
Solution: Migrate to pypi abci
2018-05-03 16:04:16 +02:00
Lev Berman
e271ae9e5b Problem: the Tendermint install instructions are outdated (#2260)
Solution: post the link to the relevant Tendermint documentation page
2018-05-03 15:48:55 +02:00
Vanshdeep Singh
cf36a6fe47 Problem: Multi-threading not enabled (#2258)
Solution: Enable multi-threading
2018-05-03 11:52:54 +02:00
Ahmed Muawia Khan
11c0ea916c
Problem: Acceptance tests on ci failing (#2256) 2018-05-02 18:16:54 +02:00
Ahmed Muawia Khan
82e3f21c9a Merge branch 'alpha-3' 2018-05-02 16:35:49 +02:00
Vanshdeep Singh
920d69b0c4 Problem: Upsert validator not migrated to Tendermint 0.19.0 (#2252)
* Problem: Upsert validator not migrated to Tendermint 0.19.0

Solution: Migrate the same to Tendermint 0.19.0

* Problem: There are no tests for public key encoding/decoding

Solution: Add necessary tests
2018-05-02 16:21:28 +02:00
Ahmed Muawia Khan
fd48abebae
Problem: Tendermint 0.19.0 missing crucial fixes (#2253) 2018-05-02 14:39:41 +02:00
Ahmed Muawia Khan
85683af2eb Problem: BigchainDB liveness probe should be HTTP API (#2251) 2018-05-02 11:41:47 +02:00
Vanshdeep Singh
7b0f6f6322 Problem: py-abci not upgraded (#2250)
Solution: Upgrade py-abci to the latest fix
2018-05-02 10:42:32 +02:00
Ahmed Muawia Khan
5ce0538c61 Problem: Old --p2p.seeds is now --p2p.persistent_peers (#2249)
Solution
As per Tendermint 0.16.0 , --p2p.seeds is now --p2p.persistent_peers. Update bigchaindb/tendermint container to use that configuration. Also disable --p2p.pex, we currently don't want the peer exchange.
2018-04-30 17:42:14 +02:00
Vanshdeep Singh
f81dfc744d Problem: Insufficent logs (#2248)
Solution: Add debug log statements
2018-04-30 15:49:07 +02:00
vrde
8d589d0181
Problem: we don't have acceptance tests (#2216)
Solution: have a simple way to start a node and run scripts against it.
2018-04-30 14:43:39 +02:00
Ahmed Muawia Khan
4e93ede5ad Problem: Nodes cannot exchange pub keys (#2246)
Solution: Open port for communication between nodes to access public key add node_id
2018-04-27 19:15:36 +02:00
Ahmed Muawia Khan
b41c6a6514 Problem: abci dependency not processed (#2245) 2018-04-27 18:54:26 +02:00
Ahmed Muawia Khan
b19465d19a Problem: Unbound variable (#2244) 2018-04-27 17:47:54 +02:00
Ahmed Muawia Khan
2bf53423e7 Problem: BigchainDB instance name is now unique (#2243)
Solution: Use BDB_INSTANCE_NAME from vars instead of static INDEX, to generate configurations for the bdb-instance.
2018-04-27 17:37:52 +02:00
Ahmed Muawia Khan
dbabe94887 Problem: BigchainDB and Tendermint inconsistencies because disjoint services (#2242)
Solution
Since BigchainDB and Tendermint are so tightly coupled we need to introduce a process supervisor to make them act like a single microservice, so that if BigchainDB crashes, Tendermint does as well and both are restarted and Tendermint requests a connection towards the proxy app.

In Kubernetes, they can be exposed as part of a one POD.
For BigchainDB as a system service/process, we need to introduce a process supervisor such as systemd.
This PR only solves the former.

Changes
Upgrade deployment from Tendermint v0.12.0 to v0.19.0
Update some documentation
Fix nginx-http entrypoint issues.
Update generate-configs.sh script to handle config generation without https-certificates.
Update Dockerfile to process dependency links introduced by abci
Integrate BigchainDB and Tendermint as a single microservice.
This required making BigchainDB to be exposed as a statefulset.
Introduce new liveness probe checks.
Issues Resolved
Partially fixes #2232
2018-04-27 15:54:47 +02:00
Shahbaz Nazir
9b71026d4b Problem: Arbitrary max_tries in bigchaindb when connecting to tendermint ws (#2241)
* remove max_tries while connecting to tendermint ws

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* leave healthcheck as is for now

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-04-26 16:50:20 +02:00
Vanshdeep Singh
651573ef77 Problem: Required ABCI fix not available (#2237)
Solution: Use the ABCI release 0.4.3 from kansi/py-abci
2018-04-26 13:53:19 +02:00
Ahmed Muawia Khan
119420785d
Problem: Kubernetes template broken for threescale/apicast deployment (#2206) 2018-04-26 11:37:41 +02:00
Vanshdeep Singh
44f19a398c Problem: Tests failing with py-abci 0.4.1 (#2235)
Solution: Fix tests and Migrate to Tendermint 0.19.0
2018-04-26 11:09:38 +02:00
vrde
e90b5fa5f2 Problem: make test doesn't run tests (#2234)
Solution: patch Makefile to be compatible with the new integration
testing suite. Fix #2230
2018-04-25 09:40:45 +02:00
Vanshdeep Singh
65bb6e5c91 Problem: No integration test for upsert-validator (#2212)
Solution: Write necessary test
2018-04-24 16:17:49 +02:00
Troy McConaghy
d066bfe132
Problem: No docs explaining use of MongoDB for querying (#2193)
* Problem: No docs explaining use of MongoDB for querying

Solution: Start a new root docs page explaining how a node operator can use the full power of MongoDB's query engine, and can expose as much of that as they like to end users.

* Finished first draft of new docs page 'Querying BigchainDB'
2018-04-23 19:30:45 +02:00
Troy McConaghy
99d46605ae Problem: GitHub can't detect the code license (#2227)
Solution: Create a `LICENSE` file in this repo, containing the Apache v2 license, so that GitHub can detect the code license in this repo.

Please leave the `LICENSES.md` file. It also specifies the license on the documentation, and notes that some code is NOT licensed Apache v2 (i.e. the code we got from Runscope and modified).

This pull request was inspired by https://github.com/bigchaindb/bigchaindb-driver/pull/406 by @codegeschrei
2018-04-20 10:23:19 +02:00
Troy McConaghy
389b3e3279
Last PR before release of 2.0.0 Alpha 2 (#2221)
* Initial update to CHANGELOG.md for the 2.0 Alpha 2 release

* Add Known Issues section to 2.0 Alpha 2 changelog

* Update Docker image tag to bigchaindb/bigchaindb:2.0.0-alpha2

* Update version.py for 2.0.0 Alpha 2
2018-04-18 14:51:16 +02:00
Troy McConaghy
9404bad5b5 Problem: RELEASE_PROCESS.md wrong about docker image tags (#2176)
Solution: Fix what RELEASE_PROCESS.md says about how we set docker image tags
2018-04-18 14:14:32 +02:00
Vanshdeep Singh
127ee08053 Problem: No crash recovery mechanism (#2207)
Solution: Add crash recovery logic based on BEP#8
2018-04-18 10:46:16 +02:00
Vanshdeep Singh
1823818315 Problem: Error response not handled in POST transaction to tendermint (#2219)
Solution: Handle the error response
2018-04-17 16:39:43 +02:00
Vanshdeep Singh
0cf0927193 Problem: No debug statement for post transaction (#2213)
Solution: write debug statement for response received from POST transaction
2018-04-16 17:36:37 +02:00
Vanshdeep Singh
a62cd68f8c Problem: No test for reponses from Tendermint during POST txn (#2210)
Solution: write tests
2018-04-16 15:30:02 +02:00
Ahmed Muawia Khan
b97b3842d9 Problem: Not enough logs to debug an issue while developing (#2209) 2018-04-16 14:46:45 +02:00
Vanshdeep Singh
a29e9c6dd9 Problem: Imprecise POST transaction responses (#2198)
Solution: Improve responses
2018-04-16 12:14:15 +02:00
Troy McConaghy
006a0a6a2a
Change license back to Apache v2 again (#2208)
I changed the license from AGPL v3 to Apache v2 in January. See pull request #2020

Somehow, the license got changed back to AGPL without us noticing. It was noticed by @dscook who asked us about it on Gitter, see https://gitter.im/bigchaindb/bigchaindb?at=5ad0cfc66d7e07082bef276b 

This pull request changes the license back to Apache v2, which is what it should have been ever since January.
2018-04-15 10:47:37 +02:00
Ahmed Muawia Khan
160b7334c7 Problem: Empty blocks not being retrieved from BigchainDB (#2205) 2018-04-12 14:08:02 +02:00
Vanshdeep Singh
a4986b7e71 Problem: No queries to store pre-commit state (#2135)
Solution: Add backend logic to store and retireve pre-commit state
2018-04-12 13:36:21 +02:00
Vanshdeep Singh
7f6782e31d Problem: ABCI server not run for tests (#2138)
Solution: Create seperate test mark for which the ABCI server will be running
2018-04-10 17:29:25 +02:00
codegeschrei
6f69f39ff4 Problem: there are no f-strings in python 3.5 (#2185)
Solution: change f-strings to a compatible format for Python 3.5
2018-04-09 17:02:59 +02:00
Ahmed Muawia Khan
d4934b9525
Problem: Websocket connection fails and retries are exhausted (#2188)
* Problem: Websocket connection fails and retries are burnt out

* Fix minor commit `specifiec` to `specified`
2018-04-09 13:47:24 +02:00
codegeschrei
b8f78e34d0 Problem: Python version is not compatible with the Driver (#2183)
Solution: revert commit d28b9019c08495789f86b81ef8283865fb031184.
2018-04-06 11:13:42 +02:00
Ahmed Muawia Khan
8c1ee8329e Problem: Typo with get kube-dns IP (#2181) 2018-04-05 17:56:30 +02:00
Troy McConaghy
c8682a1d89 Problem: bigchaindb upsert-validator labelled "insecure" (#2180)
Solution: Remove the "insecure" label from the docs on `bigchaindb upsert-validator`
2018-04-05 17:47:11 +02:00
Vanshdeep Singh
d28b9019c0 Problem: Python version not check before running (#2179)
Solution: Check python version
2018-04-05 15:29:32 +02:00
vrde
6181e52dbd Problem: Exchange can fail silently (#2177)
Solution: Raise a RuntimeError if Exchange is running and a new
subscriber queue is requested.
2018-04-05 13:57:07 +02:00
Troy McConaghy
cc88b4d286 Final PR Before the Release of 2.0 Alpha (#2175)
* Problem: docker image tag wrong in dev-setup/bigchaindb.yaml

Solution: change the docker image tag to 2.0.0-alpha in that file

* Problem: version.py needed updating for 2.0 Alpha

Solution: Updated the contents of bigchaindb/version.py for the release of 2.0.0 Alpha
2018-04-03 15:37:46 +02:00
Troy McConaghy
07f03dbd5e Problem: CHANGELOG.md isn't updated for the 2.0 Alpha release (#2159)
* Update CHANGELOG.md for the 2.0 release

* Problem: BigchainDB 2.0 Alpha name & tag wrong in CHANGELOG.md

Solution: Name="BigchainDB 2.0 Alpha" tag="v2.0.0a1"

* Problem: Blogpost link missing & no Known Issues

Solution: Hyperlink the blog post with the missing link and
document the Known Issues.

* Problem: The 2.0 Alpha release date in CHANGELOG.md was wrong

Solution: Changed the release date of 2.0 Alpha to April 3, 2018 in CHANGELOG.md
2018-04-03 15:10:03 +02:00
Vanshdeep Singh
ea8ac4b80e Problem: Event stream api crashing (#2173)
Solution: Fix Exchange initialization
2018-04-03 14:57:44 +02:00
Ahmed Muawia Khan
7683ea00fc Problem: Outdated docker image tags for 2.0.0-alpha release (#2174) 2018-04-03 14:52:30 +02:00
Troy McConaghy
58432807a0 Problem: No link back to Root Docs from Contrib. Docs (#2170)
Solution: Add a link back to the Root Docs from the 'Contributing to BigchainDB' Docs
2018-04-03 12:28:47 +02:00
Troy McConaghy
ef7a276aad Problem: Some links in Quickstart page are broken or wrong (#2171)
Solution: Update the links in the Quickstart page of the BigchainDB Server docs
2018-04-03 12:26:47 +02:00
Troy McConaghy
55fafef577 Problem: There were more broken links to CONTRIBUTING.md (#2172)
Solution: Fix those links by linking directly to the new 'Contributing to BigchainDB' docs
2018-04-03 12:17:11 +02:00
Troy McConaghy
ec5f66ba4f Problem: Issue #2217 is unresolved (#2169)
* Problem: Some docs still say to run MongoDB w/ replica set

Solution: Update the relevant docs

* Problem: A docs mention of upsert-validator wasn't linked to BEP-3.

Solution: Link that docs mention to BEP-3 on GitHub.
2018-04-03 12:14:36 +02:00
vrde
8086f75ec8 Problem: there are no events for invalid blocks (#2163)
Solution: update the documentation to reflect this. I've also removed
the documentation about the event plugin API. That part needs to be
refactored to work properly with BigchainDB 2.0. We can reintroduce it
later.
2018-04-03 12:12:33 +02:00
Vanshdeep Singh
25043bc993 Problem: Block height in event stream is string. (#2167) 2018-04-03 12:08:00 +02:00
Vanshdeep Singh
e4e528e5c4 Problem: Changing validators requires a network restart (#2070)
Solution: Allow nodes to add, update, or remove validators at runtime using a new command. Implements BEP3.
2018-03-29 18:25:26 +02:00
Vanshdeep Singh
0f86e7d368 Problem: Multi-threading not configured (#2165)
* Problem: Multi-threading not configured

Solution: Auto-generate multi-threading config with default threads and workers set to 1

* Problem: Documentation not updated for multi-threading

Solution: Updated necessary docs
2018-03-29 16:26:54 +02:00
Ahmed Muawia Khan
b4401d27e4
Merge pull request #2156 from ttmc/reorder-developer-contrib-process-pages
Problem: The order of the dev contrib docs was weird
2018-03-29 12:01:40 +02:00
Ahmed Muawia Khan
7f2ed58de9
Merge pull request #2164 from muawiakh/update-config
Problem: BigchainDB server configuration causing failure
2018-03-28 20:08:47 +02:00
Ahmed Muawia Khan
933e68bf53 Update some configuration for alpha release containers
- Update bigchaindb server threads/workers
- Configure `debug` log-level for tendermint
2018-03-28 19:46:05 +02:00
Troy McConaghy
3000e52795 Problem: RELEASE_PROCESS.md doesn't follow BEP-1 (#2161)
Solution: Update RELEASE_PROCESS.md to use only the `master` branch
to use Git tags (never branches) to identify new versions.
2018-03-28 15:40:30 +02:00
Troy McConaghy
42f9160f46
Merge pull request #2154 from ttmc/update-marketing-copy
Problem: Some marketing copy (text blurbs) was old
2018-03-28 14:33:55 +02:00
Troy McConaghy
e3be475ebd
Merge pull request #2160 from vrde/reintroduce-dist-and-release
Problem: maintainers are not able to do a release
2018-03-28 14:10:46 +02:00
vrde
3ed3334188
Problem: maintainers are not able to do a release
Solution: reintroduce `make dist` and `make release`
2018-03-28 14:02:18 +02:00
Troy McConaghy
03c8f16475
Merge pull request #2106 from kansi/bep/3/get-validators-api
Get validator set from the node
2018-03-28 11:44:09 +02:00
Troy McConaghy
f71818c837
Merge pull request #2158 from muawiakh/invalid-kube-dns-command
Problem: Invalid command to get kube-dns IP
2018-03-27 20:01:11 +02:00
Ahmed Muawia Khan
5162a0a163 Problem: Invalid command to get kube-dns IP 2018-03-27 19:44:00 +02:00
Ahmed Muawia Khan
3cf921b32d
Merge pull request #2157 from muawiakh/fix-arg-parse
Problem: argument not parsed properly while generating configs
2018-03-27 17:04:26 +02:00
Ahmed Muawia Khan
a047838ec3 Problem: argument not parsed properly while generating configs
Solution: Handle all the positional arguments using curly braces
2018-03-27 16:44:45 +02:00
Troy McConaghy
3d1f341c44 Remove accidentally-pasted URL from docs 2018-03-27 16:41:26 +02:00
Troy McConaghy
8ce48f75a1 Renamed 2 files/pages of notes on running a node 2018-03-27 16:38:58 +02:00
Troy McConaghy
75caf76c62 Problem: The order of the dev contrib docs was weird
Solution: Reorder & relabel those pages
2018-03-27 12:02:33 +02:00
Troy McConaghy
3f2d40f670
Merge pull request #2155 from ttmc/clarify-contributing-docs
Problem: Docs re contributing needed editing & reorg
2018-03-27 10:34:15 +02:00
Troy McConaghy
4fb963d149 Don't include docs fetched-at-build-time in Git repo 2018-03-27 10:27:27 +02:00
Troy McConaghy
3566c97873 Problem: Docs re contributing needed editing & reorg
Solution: Edit & reorg them
2018-03-27 10:18:51 +02:00
Troy McConaghy
dea76f7c91
Merge pull request #2141 from muawiakh/update-dns-server
Problem: Cluster DNS and Health check terminology is incorrect
2018-03-26 16:37:49 +02:00
Ahmed Muawia Khan
a8e68c3706 Replace clusters Web UI to k8s cluster web ui 2018-03-26 16:00:25 +02:00
Ahmed Muawia Khan
339078ae68 Address comments
- remove confusion between NODE-IP<->CLUSTER-IP just replace with IP
- remove confusion between node<->cluster just replace with Kubernetes
  cluster
2018-03-26 15:37:05 +02:00
Troy McConaghy
d1bc21809e Problem: Some marketing copy (text blurbs) was old
Solution: Update the marketing copy!
2018-03-25 13:28:21 +02:00
Troy McConaghy
ff62675c01
THE blockchain database. 2018-03-24 06:01:12 +01:00
Troy McConaghy
1d053bbad8
Two fixes to root docs home page
- Added a button to link to the new "Contributing to BigchainDB" docs
- Changed the opening tag line
2018-03-24 05:40:14 +01:00
Vanshdeep Singh
283f685f07 Problem: FastQuery not working (#2153)
Solution: Fix FastQuery Class
2018-03-23 17:16:00 +01:00
Vanshdeep Singh
cffd68f7cf Problem: Event stream test incomplete (#2152)
Solution: Complete the test by checking connection status returned in the 'result' field
2018-03-23 15:39:47 +01:00
Vanshdeep Singh
358899b3b1 Problem: 'TRANSFER' Transaction fails. (#2151)
Solution: The asset storage and retrieval logic leads to different txn bodies
causing a validation error. Concequently the logic has been simplied.
2018-03-23 15:08:30 +01:00
vrde
4c992198db Problem: version doesn't reflect reality (#2150)
Solution: change the version to 2.0.dev, and add a cool banner.

 mmm     mmmm   mmmm  mmmmmm
   #    "   "# "   "#     #"
   #      mmm"   mmm"    m"
   #        "#     "#   m"
 mm#mm  "mmm#" "mmm#"  m"

 #         mm          mmmm
 # mm     m"#  m   m  m"  "m  m mm
 #"  #   #" #   #m#   #  m #  #"  "
 #   #  #mmm#m  m#m   #    #  #
 #   #      #  m" "m   #mm#   #

        #                        #
  mmm   # mm    mmm    mmm    mmm#
 "   #  #"  #  #"  #  "   #  #" "#
 m"""#  #   #  #""""  m"""#  #   #
 "mm"#  #   #  "#mm"  "mm"#  "#m##

:D
2018-03-23 14:41:15 +01:00
vrde
283b664e6a Problem: there is no way to easily reset the DB (#2149)
Solution: Add a `reset` recipe for our Makefile
2018-03-23 14:39:43 +01:00
vrde
f157096699 Problem: No reason to check the BEP (+typo) (#2144)
Solution: Say why there is a link to the BEP, and fix a typo.
2018-03-23 14:39:15 +01:00
Manolo
0e7adb33d2
Merge pull request #2148 from vrde/ignore-vim-swap-files
Problem: vim swap files are not ignored by git
2018-03-22 17:13:16 +01:00
vrde
7a718f78d2 Update Makefile (#2147)
* Problem: it's difficult to run/test/compile docs

Solution: we already have a nice Makefile, but it's outdated. The idea
is to revamp it and make it easy to use.

* Problem: Makefile is not documented

Solution: Add basic instructions on how to use it in the main README.md

* Problem: can't connect to localhost:9984

Solution: make docker expose 9984 by default, so everyone can connect to
localhost:9984.

* Problem: make clean is TMI

Solution: add `@` to remove commands so we don't output all the details
about the cleaning

* Problem: make clean is too shy

Solution: print a message saying that cleaning went well.
2018-03-22 17:12:39 +01:00
Ahmed Muawia Khan
5676a6e088 Problem: No error message/logs if tendermint container cannot find peers (#2146)
Solution: retry every 30 seconds for a maximum of 10 times.
2018-03-22 17:12:21 +01:00
vrde
ee6170ee88
Problem: vim swap files are not ignored by git
Solution: add patterns to ignore them.
2018-03-22 16:00:39 +01:00
Ahmed Muawia Khan
73555b96ff Unwanted env var BIGCHAINDB_START_TENDERMINT (#2145) 2018-03-21 15:19:00 +01:00
vrde
9cdd46c084
Merging development branch to master! 2018-03-21 14:18:23 +01:00
Troy McConaghy
15c16c5a97 Update setup.py for BigchainDB 2.0 (#2126)
* Update setup.py for BigchainDB 2.0

I took the license name from this list of valid PyPI licenses:
https://jlesquembre.github.io/autopilot/license_list.html

* Remove 'Programming Language :: Python :: 3.6'
from `setup.py` since we actually use features from Python 3.6.

* Changed dev status back to 3 - Alpha for now
2018-03-21 14:03:15 +01:00
Ahmed Muawia Khan
9be68c972d Problem: standardize docker-compose workflows (#2130)
- Standardize docker-compose workflow
- Change docker-compose version to 2.1
  - why one might ask? because compose version
    3.0 does not support depends on and inherits
    like we want to and is more aimed towards migration to using
    `docker stack`, for our current strategy `2.1` is a better choice.
- change `bdb` service `bigchaindb` service
  - why? Introduced a new proxy service `bdb` which is just a dummy
    `busybox` image.
    - why? because this ensure via healthcheck of bigchaindb that BigchainDB
      has started properly and makes a `curl` to ensure HTTP API server is up
      and running.
      - why? Because we have had scenarios where BigchainDB is not started
        via docker compose and user has to check out the logs to find out what
        the problem might be. This ensure that bigchaindb is up and running.
- Does this change deployment workflow? No.
  - The only thing change is that if you want to run commands inside a bigchaindb
    container e.g. `pytest` now you have to run the following command:
    `docker-compose run --rm --no-deps bigchaindb pytest -v --cov=bigchaindb`
     as opposed to `docker-compose run --rm --no-deps bdb pytest -v --cov=bigchaindb`
- Remove env variable `BIGCHAINDB_START_TENDERMINT`
- Remove TENDERMINT_INTEGRATION.rst and move to the new docs
- Change mdb -> mongodb because the other services were named with
  full name.
- Add example to run specific tests or from a file
- Update config.toml for tendermint to use `bigchaindb` as proxy app
  instead of `bdb`
- Remove `network` directory because it is deprecated
- Add comment about why PYTHONBUFFERED is used
2018-03-21 12:42:43 +01:00
Ahmed Muawia Khan
cf543d8f41 Problem: docs build failing
Solution: Fix docs build
2018-03-21 11:15:25 +01:00
Vanshdeep Singh
ef26220c7f Problem: Docs for BEP#3 implementation not updated (#2123)
* Problem: Docs for BEP#3 implementation not updated

Solutions: Update docs for #2070 and #2106

* Problem: 'Validator update' docs language not clear

Solution: Re-write the documentation which explains when validators are updated

* Problem: Typos and BEP reference missing

Solution: Fix typos and add BEP reference
2018-03-21 09:23:08 +01:00
Ahmed Muawia Khan
757b4fc14c Remove cluster-dns 2018-03-20 19:34:01 +01:00
Troy McConaghy
59abb358f8
Merge pull request #2133 from bigchaindb/update-contributing-md
Problem: CONTRIBUTING.MD and the 2 GitHub templates were old
2018-03-17 08:49:20 +01:00
Shahbaz Nazir
e8e02cac50 Problem: Bigchaindb startup sometimes fails due genesis block creation during init (#2129)
* removing GENESIS transaction type
* remove GENESIS transaction schema
* all blocks are same in the eyes of GOD no checks needed for genesis blocks
2018-03-16 16:19:12 +01:00
kansi
5b3fab666d Problem: Unkown exceptions being handled
Solution: Handle only known exceptions
2018-03-16 11:47:15 +05:30
Troy McConaghy
c047487523
Merge pull request #2119 from bigchaindb/new-docs-set-on-contributing
New docs set on "Contributing to BigchainDB"
2018-03-15 20:36:58 +01:00
Ahmed Muawia Khan
0125368d8e Problem: K8s deployment with Access Token Authorization expects Access Token for GET calls and others (#2134)
* Fix for access token authorization for GET calls

- Naming inconsistency for cluster-fqdn causing issues
- Change cluster-frontend-port to node-frontend-port

* Change hardcoded 9984 to configurable
2018-03-15 16:20:15 +01:00
Troy McConaghy
24119a1b73 Problem: Was getting Shared Workspace Protocol from old location
Solution: Get it from new location in bigchaindb/BEPs
2018-03-15 13:44:22 +01:00
Vanshdeep Singh
8c32ae798b Problem: UTXO implementation unfinished for release. (#2132)
Solution: Rollback UTXO for the alpha release.
2018-03-14 17:58:05 +01:00
Troy McConaghy
c5054e7239 Problem: Unclear how Travis and Codecov get configured
Solution: Document where Travis and Codecov look for configuration settings and setup.
2018-03-14 13:06:52 +01:00
Troy McConaghy
b9d500ac09 Problem: CONTRIBUTING.MD and the 2 GitHub templates were old
Solution: Update those three files to reflect the new way we do things
2018-03-14 11:22:39 +01:00
Troy McConaghy
f54090af6d Cleanup 'Ways to Contribute' even more 2018-03-14 01:40:05 +01:00
Troy McConaghy
d4e8f415a1 Add JS and Python style guides to policies 2018-03-14 00:48:10 +01:00
Troy McConaghy
8f4bc46e8b
Typo fix good grief 2018-03-14 00:24:29 +01:00
Troy McConaghy
d8893c11e7
Merge pull request #2131 from bigchaindb/quick-fix-to-release-process-for-now
Add note at top how this is old, will be updated
2018-03-14 00:20:41 +01:00
Troy McConaghy
5caa49e945
Add note at top how this is old, will be updated
A more complete fix will have to be done later. This is what we can do for now.
2018-03-14 00:19:02 +01:00
vrde
617f0ba94b Problem: exchange pubsub doesn't start on boot (#2079)
Solution: start it on boot.
2018-03-12 16:48:03 +01:00
Troy McConaghy
0e29517145 Revisions to: Contributing to BigchainDB (docs) 2018-03-12 14:23:49 +01:00
Ahmed Muawia Khan
f537d061d5 Problem: Migrate-CLI changes were reverted because of travis changes (#2121)
* Testing tendermint docker compose for travis

* Typo tendermint*

* Re-do migrate cli changes

* don't skip event stream test

* Fix flake8 and unskip a test skipped during dev

* Revert styling changes made from editor

* skip a failing test case which was already disabled

* Remove reference to 'keypair' in commands
2018-03-09 13:08:37 +01:00
Troy McConaghy
5283c32abb
Under den Linden -> Unter 2018-03-07 12:40:12 +01:00
Troy McConaghy
9180d00282
codding -> coding 2018-03-07 12:37:08 +01:00
Troy McConaghy
cf53ce8d32 First draft of new docset on Contributing to BigchainDB 2018-03-06 23:55:18 +01:00
Ahmed Muawia Khan
60f2ccaead Revert "Migrate cli for tendermint integration" 2018-03-05 15:49:55 +01:00
Troy McConaghy
81c6975501
Merge pull request #2071 from bigchaindb/text-edits-in-http-api-docs
Copy-edited the HTTP API docs
2018-03-05 12:31:56 +01:00
Troy McConaghy
c2fd9e7b7b
Merge pull request #2113 from bigchaindb/rm-stand-alone
Problem: The node-on-kubernetes docs aren't just for a "stand-alone" node
2018-03-05 12:28:34 +01:00
Troy McConaghy
6ee8224491
Merge pull request #2112 from bigchaindb/revise-azure-acs-page
Problem: User gets error about "Service Principal" when they try to deploy a k8s cluster on Azure
2018-03-05 12:27:44 +01:00
Troy McConaghy
cfdb558729
Merge pull request #2111 from bigchaindb/revise-workflow-page
Edited the "Overview" page in Production Deployment Template for clarity
2018-03-05 12:27:29 +01:00
Ahmed Muawia Khan
2a3acecdff
Merge pull request #2108 from bigchaindb/uncomment-storageaccount-in-tendermint-sc
Problem: Inconsistent treatment of storageAccount across two storageClasses
2018-03-05 11:38:36 +01:00
Troy McConaghy
09083f41ef
Merge pull request #2082 from vrde/do-not-start-tendermint-by-default
Problem: tendermint is started by default
2018-03-04 19:53:34 +01:00
Troy McConaghy
7acdb1a565
Problem: The docs aren't just for a "stand-alone" node
Solution: Remove "stand-alone"
2018-03-04 19:34:18 +01:00
Troy McConaghy
5f206acc63 Revised docs re az acs create 2018-03-04 14:36:55 +01:00
Troy McConaghy
95b4647a22 Added instructions for including secret token header in POST requests 2018-03-03 19:15:01 +01:00
Troy McConaghy
74d86cc83e Add example secret token 2018-03-03 15:02:45 +01:00
Troy McConaghy
2304f8cd10 Revisions to Overview page in prod dep. template 2018-03-03 14:55:31 +01:00
Sylvain Bellemare
802cc73d33 Problem: import order does not follow pep8
Solution: follow pep8
2018-03-01 17:50:20 +01:00
Sylvain Bellemare
56dfd9bab0 Problem: represent utxoset state as a hash
Solution: create a merkle tree out of the utxoset and compute its merkle
root
2018-03-01 17:50:20 +01:00
Sylvain Bellemare
2d2182dd19 Problem: unhandled error when deleting zero utxo
Solution: only execute the query if *unspent_outputs is not empty
2018-03-01 15:11:58 +01:00
Sylvain Bellemare
aaec67724a Problem: unhandled error when storing zero utxo
Solution: only execute the query if *unspent_outputs is not empty
2018-03-01 15:11:58 +01:00
Sylvain Bellemare
c85c664215 Problem: fixture with no asset fails
Solution: instantiate the transaction with a dummy asset
2018-03-01 15:11:58 +01:00
Sylvain Bellemare
967d5727e2 Problem: store_metadata was renamed
Solution: perform required update

Note: see #2034
2018-03-01 15:11:58 +01:00
Sylvain Bellemare
51d4f0f2d9 Problem: utxoset needs to be updated
Solution: update utxoset via store_transaction
2018-03-01 15:11:58 +01:00
Ahmed Muawia Khan
00ec69a4bd
Merge pull request #1976 from bigchaindb/proposal/migrate-cli
Proposal: Migrate cli for Tendermint
2018-02-28 14:46:55 +01:00
Ahmed Muawia Khan
5f06ad5493
Merge pull request #2092 from muawiakh/migrate-cli
Migrate cli for tendermint integration
2018-02-28 14:44:43 +01:00
Ahmed Muawia Khan
9cb84b165f
Merge pull request #2093 from muawiakh/migrate-cli-docs
Migrate CLI documentation
2018-02-28 14:44:17 +01:00
Troy McConaghy
5154444cb2
Uncomment storageAccount in tendermint-sc.yaml
In pull request #2107, the `storageAccount` was uncommented in `mongo-sc.yaml`

This pull request does the same in `tendermint-sc.yaml`
2018-02-28 13:32:02 +01:00
vrde
be297f8b4f
Problem: tendermint is an external service
Solution: Do not start tendermint on boot. It's up to the user to decide
how to start tendermint.
2018-02-28 13:13:02 +01:00
Troy McConaghy
36007ec5af
Merge pull request #2107 from muawiakh/update-prod-template-docs
Problem: Production deployment template was not updated after v1.0 automation
2018-02-28 11:04:13 +01:00
Ahmed Muawia Khan
98c939bd29 use mdb-instance-0 as default name for configuring users 2018-02-27 13:35:20 +01:00
Ahmed Muawia Khan
4c6ac6bd19 Update production deployment template after v1 automation 2018-02-27 13:26:51 +01:00
kansi
610e6f00f2 Problem: fake8 errors for handling exceptions
Solution: Handle fake8 error for exception handling by using base Exception class
2018-02-27 13:47:05 +05:30
kansi
375cd0b499 Problem: No tests for GET /api/v1/validators
Solution: Add tests for the same
2018-02-27 13:31:44 +05:30
kansi
2a20e7042e Problem: Get validators api doesn't exist
Solution: Add `GET /api/v1/validators` endpoint
2018-02-27 13:30:56 +05:30
Ahmed Muawia Khan
b752b4cbf2
Merge pull request #2105 from shahbazn/k8s-config-automation-script
Problem: bugs in k8s automation
2018-02-27 02:51:19 +01:00
Ahmed Muawia Khan
a250b90727
Merge pull request #2104 from bigchaindb/revise-beginning-of-overview
Revised intro of Overview page in prod dep template docs
2018-02-27 02:46:24 +01:00
Shahbaz Nazir
517ece3be5 uncomment
Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-02-27 02:45:27 +01:00
Shahbaz Nazir
dc423d80ef Merge branch 'k8s-config-automation-script' of github.com:shahbazn/bigchaindb into k8s-config-automation-script 2018-02-27 02:41:45 +01:00
Shahbaz Nazir
d69c75ee93 fixes for k8s deployment automation
Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-02-27 02:40:59 +01:00
Shahbaz Nazir
4b06378bbf fix nginx https issues
Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-02-27 02:40:59 +01:00
Shahbaz Nazir
287ab88012 fixes for k8s deployment automation
Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-02-27 02:29:44 +01:00
Troy McConaghy
3d0720ce42 Revised intro of Overview page in prod dep template docs 2018-02-27 00:37:59 +01:00
Shahbaz Nazir
e68c77338e fix nginx https issues
Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-02-26 19:46:21 +01:00
Shahbaz Nazir
582025ba3d
Problem: nginx k8s deployment missing parameters (#2102) 2018-02-26 19:11:28 +01:00
Ahmed Muawia Khan
d0874ccf9a
Merge pull request #2101 from muawiakh/mongodb-container-update
Add support for optional users in MongoDB user creation
2018-02-26 18:42:42 +01:00
Shahbaz Nazir
334d4769ca nginx instance fixes
Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-02-26 18:39:02 +01:00
Shahbaz Nazir
5a4378dbb5
fixes for deployment script (#2100) 2018-02-26 18:00:04 +01:00
Ahmed Muawia Khan
8835fd5fd7 Add support for optional users in MongoDB user creation 2018-02-26 17:54:07 +01:00
Shahbaz Nazir
dc447249f5 fixes for deployment script
Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2018-02-26 17:36:42 +01:00
Sylvain Bellemare
06cbd9e2de Problem: docker-compose.docs.yml it outdated
It does not use the Dockerfile for the localmongodb/tendermint backends.

Solution: Use ./compose/bigchaindb-server/Dockerfile
2018-02-26 16:26:40 +01:00
Sylvain Bellemare
f32649d802 Problem: docker-compose.docs.yml version is 2
Solution: Update the version to 3 (latest)
2018-02-26 16:26:40 +01:00
Sylvain Bellemare
12f603b8d2 Problem: There are no docs for the tendermint integration API
Solution: Add docs for the tendermint integration in Appendices for now.
2018-02-26 16:26:40 +01:00
Shahbaz Nazir
c2e9dd6e1c
Problem: Automate k8s deployment configs & secretes (#2096)
We manually add all the required configurations and secretes in config-map.yaml and secret.yaml. There is a need for a wrapper script which takes these generated mongodb certs and also process https certificates and populates config-map.yaml and secret.yaml
2018-02-26 16:25:13 +01:00
Ahmed Muawia Khan
3c290d64a5 re-add f-string to web stream 2018-02-26 15:42:17 +01:00
Ahmed Muawia Khan
847183a7d8
Merge pull request #2099 from muawiakh/check-kubectl-installed
Check if kubectl is installed otherwise exit
2018-02-26 15:28:12 +01:00
Ahmed Muawia Khan
d85396b220 Check if kubectl is installed otherwise exit 2018-02-26 15:07:27 +01:00
Troy McConaghy
6d27cbe868
Merge pull request #2095 from muawiakh/automate-mdb-user-creation
Automate MongoDB user creation for prod/test deployments
2018-02-26 14:58:50 +01:00
Ahmed Muawia Khan
3c09de97b0 remove redundant variable assignment 2018-02-26 14:54:34 +01:00
Ahmed Muawia Khan
7cea7298f0 Update mongodb user configuration
- Update docs for azure cluster deployment template
- Update entrypoint for MongoDB to handle user configuration
  more efficiently
- remove `use admin` in js file, that is an invalid format
2018-02-26 14:45:21 +01:00
Ahmed Muawia Khan
d977753831 Automate MongoDB user creation for prod/test deployments
- Currently, we had to manually log into the MongoDB container
  and create users, this change will configure the relevant users
  from a single script `configure_mdb.sh`
- Improvements can be done but keeping it minimal for the workshop
2018-02-26 03:37:43 +01:00
Troy McConaghy
86e7b2a881 Some minor copy-editing 2018-02-25 18:05:18 +01:00
Shahbaz Nazir
0ddfc62e3b
Problem: No authorization mode without threescale (#2088)
Problem
The current production deployment template uses 3scale to ensure that POST requests to the network (from anyone) only get through if they come from a client with an account (app_id and app_key).

A private network wants to launch so that all HTTP requests (POST and GET) sent to the nodes in the network get be dropped unless they come from a small set of known (and unchanging) clients/sources. They don't need 3scale. They will want a modified version of the production deployment template.

Solution
Generate a special HTTP header and share it with all the known clients/sources.
Have a single NGINX in each node which checks for that HTTP header value. If it's present, let the request pass through to the network. (HTTP headers are encrypted if HTTPS is used.)
Are there other simpler or better options?
2018-02-23 16:00:36 +01:00
Ahmed Muawia Khan
8fd50b23c8 Re-add travis changes
- This actually follows one concern on PR.
2018-02-23 15:33:32 +01:00
Ahmed Muawia Khan
8bfb903d4e [Chandler fix]: Bing -> Bind 2018-02-23 15:31:30 +01:00
Ahmed Muawia Khan
624d4e7459 Revert travis changes
- Follow one concern one PR.
2018-02-23 15:28:35 +01:00
Ahmed Muawia Khan
8e8e328205 Migrate CLI documentation
- Remove documentation for CLI commands that are not needed with
  Tendermint integration.
2018-02-23 14:53:28 +01:00
Ahmed Muawia Khan
d0089ca373 Fixing flake8 2018-02-23 14:43:14 +01:00
Vanshdeep Singh
cdec60a7c0 Rollback crash recovery mechanism (#2091) 2018-02-23 14:35:18 +01:00
Ahmed Muawia Khan
5cea9c28bf Migrate CLI for tendermint integration
- Remove commands that were not required.
  - export-my-pubkey
  - set-shards
  - set-replicas
  - add-replicas
  - remove-replicas
- Update bigchaindb --help, usage description
- Re-enable tests
- Update docker-compose.travis.yml and Dockerfile for travis
  because some env variables are not needed
2018-02-22 21:48:42 +01:00
Troy McConaghy
497e1039ef
Merge branch 'tendermint' into text-edits-in-http-api-docs 2018-02-22 21:02:33 +01:00
Ahmed Muawia Khan
ecee564d21 Remove create the node keypair from bigchaindb configure --help 2018-02-22 16:04:43 +01:00
Ahmed Muawia Khan
8ce01bf4ce Update minor formatting 2018-02-22 15:26:15 +01:00
Ahmed Muawia Khan
7f50003303 Update the migrate-cli proposal
- No need to deprecate commands that are not needed because
  tendermint integrated BigchainDB does not overlap with
  BigchainDB(v1.x)
- Update some sets
- Add more commands and usage.
2018-02-22 12:54:26 +01:00
Troy McConaghy
e6c77d5fcd
Merge pull request #2086 from bigchaindb/helpful-response-to-votes-endpoint
Make votes endpoint return 404 and a helpful message
2018-02-22 12:49:27 +01:00
Troy McConaghy
303c951137 Fixed flake8 errors 2018-02-22 12:41:20 +01:00
Ahmed Muawia Khan
96db5b9f12
Merge pull request #2084 from bigchaindb/update-bdb-docker-image-k8s
Update docker images and Dockerfiles
2018-02-22 12:23:31 +01:00
Troy McConaghy
8e4a2398a7 Make votes endpoint return 404 & helpful msg 2018-02-22 12:02:00 +01:00
Ahmed Muawia Khan
93e2b3bb4c Update imagePullPolicy for unstable images
- Update imagePullPolicy from IfNotPresent to Always
  for all unstable images we are using in k8s template,
  because those images are updated regularly, we will
  keep it unstable until the official release.
- Use Tendermint v0.13 as base docker image, since our current
  integration is based out of v0.13
2018-02-22 11:56:58 +01:00
Shahbaz Nazir
a782fa4635
Hardcode static ports for k8s deployment (#2080)
Description
Currently we manually configure ports in deployment and service files for k8s deployment e.g here. Instead these ports should be constant since these are always the same for each deployment

Issues This PR Fixes
Fixes #2077
2018-02-22 11:52:41 +01:00
Troy McConaghy
1aece3c10d
Merge pull request #2068 from bigchaindb/remove-refs-to-whitepaper-in-tendermint-branch
Remove all refs/links to whitepaper in tendermint branch
2018-02-21 22:04:29 +01:00
Troy McConaghy
77b70c3821
Merge pull request #2067 from bigchaindb/remove-refs-to-whitepaper-in-master
Remove whitepaper refs/links from the master branch
2018-02-21 22:04:09 +01:00
Ahmed Muawia Khan
a8a10edf0e Update Dockerfiles and remove tmt references 2018-02-21 20:31:53 +01:00
Ahmed Muawia Khan
8e6b4332b0 Update mongodb base image 2018-02-21 20:22:38 +01:00
Ahmed Muawia Khan
2978caaee6 Update images used by yaml files
- Using tag `unstable` currently, until BDB+Tendermint is released
2018-02-21 20:17:24 +01:00
Ahmed Muawia Khan
13e750705e
Merge pull request #2083 from bigchaindb/cert-gen-script
Certificate generation script for k8s deployment
2018-02-21 20:08:21 +01:00
Ahmed Muawia Khan
53019ff02a
Merge pull request #1992 from bigchaindb/tendermint-docs-k8s-dep
Template for BigchainDB + Tendermint Kubernetes Deployment
2018-02-21 19:23:14 +01:00
Ahmed Muawia Khan
55f212d885 Certificate generation script for k8s deployment 2018-02-21 19:18:24 +01:00
vrde
14d523efd5 Problem: processes don't have an intelligible name (#2078)
Solution: when a process starts, update the "process title" as well.
2018-02-21 17:54:50 +01:00
Ahmed Muawia Khan
5669514ee7 Fix label docs 2018-02-21 12:13:45 +01:00
Ahmed Muawia Khan
d5f45d4094
Merge pull request #1985 from bigchaindb/tendermint-k8s-dep
Deployment of Tendermint + BigchainDB cluster
2018-02-21 11:48:37 +01:00
Ahmed Muawia Khan
669b2d586b Merge branch 'tendermint' into tendermint-docs-k8s-dep 2018-02-21 11:48:02 +01:00
Ahmed Muawia Khan
df485d0983 Rename docker image tags and names 2018-02-21 11:38:24 +01:00
Ahmed Muawia Khan
de05e5bc3e Merge branch 'tendermint' into tendermint-k8s-dep 2018-02-21 11:32:45 +01:00
Vanshdeep Singh
5bfa8e29d8 Crash recovery mechanism (#2045)
* Crash recovery mechanism

* Propogate exception

* Added docs and crash receovery during block write

* Fix flake8 issue

* Remove approach 1 for crash recovery, recover db on 'bigchiandb start'

* Fix CI build issues

* Remove documentation
2018-02-21 10:50:12 +01:00
Troy McConaghy
55c1509362
Merge pull request #2076 from bigchaindb/patch-master-with-pr-2075-commit
Same as PR #2075 but for master branch
2018-02-20 15:03:41 +01:00
Troy McConaghy
15ce6e99f6 Fix the requirements.txt file for docs/server, update README.md 2018-02-20 14:13:28 +01:00
Troy McConaghy
58c5498d35
Merge pull request #2075 from bigchaindb/fix-issue-2072-http-api-examples
Resolve issue #2072
2018-02-20 13:11:07 +01:00
Troy McConaghy
c5fdaf24ad Fix the requirements.txt file for docs/server, update README.md 2018-02-20 12:58:23 +01:00
Troy McConaghy
8fb0682868
Merge pull request #2063 from bigchaindb/fix-common-schema-readme-md
Some edits to common/schema/README.md
2018-02-20 09:37:50 +01:00
Troy McConaghy
5c783be546
Merge branch 'tendermint' into text-edits-in-http-api-docs 2018-02-19 16:45:03 +01:00
Troy McConaghy
e1bdd41030 Copy-edited the HTTP API docs 2018-02-19 16:33:46 +01:00
Troy McConaghy
0ffcb36b7e
Merge pull request #2065 from bigchaindb/rm-docs-about-votes
Updated (almost) all docs regarding "votes" once Tendermint integrated
2018-02-19 15:21:05 +01:00
Troy McConaghy
5af6c7b7a3
Merge pull request #2069 from bigchaindb/remove-all-statuses-endpoints-for-realz
Remove all code for all /statuses endpoints
2018-02-19 12:31:37 +01:00
Troy McConaghy
1b6d0adc01 removed code for all /statuses endpoints 2018-02-19 12:04:10 +01:00
Troy McConaghy
8b8f137463 Remove all refs/links to whitepaper in tendermint branch 2018-02-19 11:06:06 +01:00
Troy McConaghy
0ae08ad31e Remove whitepaper refs/links from master branch 2018-02-19 10:56:39 +01:00
Troy McConaghy
7f94242f85 Update all docs re/ votes when Tendermint integrated 2018-02-16 16:24:44 +01:00
Troy McConaghy
7a292ba6ec Edits to the common/schema/README.md file 2018-02-16 15:48:12 +01:00
Troy McConaghy
37150c4849
Merge pull request #2059 from bigchaindb/master-branch-equivalent-of-pr2056
Same as PR #2056 but merging into master branch
2018-02-16 15:28:23 +01:00
Troy McConaghy
96f30da875
Merge pull request #2056 from bigchaindb/rm-refs-to-transaction-cli-tool
Problem: Transaction CLI Tool deprecated but linked from some docs
2018-02-16 15:28:10 +01:00
Troy McConaghy
a3c49cc336
Merge pull request #2062 from bigchaindb/docs/2036/three-http-api-endpoints-gone
Remove the HTTP API docs for the /statuses & /votes endpoints
2018-02-16 15:20:57 +01:00
Troy McConaghy
6982dfbe79 Put back the accidentally-removed post-tx-response 2018-02-16 14:54:20 +01:00
Troy McConaghy
7c3d7f4f63 Tidy up some grammar and Tendermint refs 2018-02-16 14:53:30 +01:00
Troy McConaghy
0139e53ab4 rm code to gen example HTTP stuff for /statuses & /votes 2018-02-16 14:35:35 +01:00
Troy McConaghy
9ef2271a5d In HTTP API docs, removed all /statuses & /votes endpoints 2018-02-16 14:31:26 +01:00
kansi
27865d848c Merge branch 'iss/2060/remove-post-txn-resp-header' into tendermint 2018-02-16 18:54:18 +05:30
kansi
6cf86be033 Remove location header from post txn response 2018-02-16 18:42:06 +05:30
Troy McConaghy
0337a4e2eb Remove 2 refs/links to the deprecated Transaction CLI tool 2018-02-16 10:00:46 +01:00
Sylvain Bellemare
1f537b1557 Problem: to get tx utxoset & inputs is cumbersome (#2055)
Solution: add properties to more easily get the utxoset and inputs of a
transaction
2018-02-15 18:23:29 +01:00
Troy McConaghy
46a2909c4d Remove 2 refs/links to the deprecated Transaction CLI tool 2018-02-15 17:34:51 +01:00
Sylvain Bellemare
3542d01893 Update tx version (#2054)
* Problem: common/test_transaction.py is excluded

Solution: add marker to file

* Problem: fixture tx version is outdated

Solution: update the version
2018-02-15 16:19:13 +01:00
Troy McConaghy
63bd698b21 changed constructed/allowed tx 'version' from '1.0' to '2.0' (#2048)
- Created three new JSON Schema files for the v2.0 transaction schema, based on the v1.0 files. The only change is the allowed value of version (from "^1\\.0$" to "^2\\.0$").
- I didn't delete the v1.0 JSON Schema files because we might want those some day (to validate old transactions).
- Updated the __init__.py in the directory with the JSON Schema files so that it now uses the version 2.0 JSON Schema files.
- Updated all relevant tests. I only found one, in tests/validation/test_transaction_structure.py
- Updated VERSION in common/transaction.py
- Checked to make sure the example HTTP API docs show "version" with value "2.0". They do.
- Updated the docs page about "The Transaction Model". It just points to the IPDB Transaction Spec.
- If someone submits a transaction with "version" having value "1.0" then the error message comes from the JSON Schema checker.
2018-02-15 11:07:16 +01:00
vrde
cd6095e854 Problem: test suite doesn't pick up env vars
Solution: call `env_config` from the configuration fixture
2018-02-14 16:43:09 +01:00
vrde
254035150d Problem: default config uses env vars
Solution: this is managed by the function
`bigchaindb.config_utils::env_config`, we don't need to call
`os.environ.get` for each value.
2018-02-14 16:43:09 +01:00
vrde
bf2a1c6a60 Problem: older backends are no longer supported
Solution: when running the command `bigchaindb configure`, configure for
`localmongodb` only.
2018-02-14 16:43:09 +01:00
Sylvain Bellemare
161ccdda5d Implement UTXO set backend (#2033) 2018-02-14 15:37:19 +01:00
Troy McConaghy
8bd39439f2
Merge pull request #2052 from bigchaindb/bug/2049/fix-readthedocs-build
Add yml config for readthedocs build
2018-02-14 15:18:25 +01:00
kansi
e9521aad44 Added build yml for readthedocs 2018-02-14 19:40:36 +05:30
kansi
f483f9c97a Add build config for docs 2018-02-14 14:32:44 +01:00
vrde
55073366ec Problem: new env vars are not managed by the conf
Solution: add `BIGCHAINDB_` to new tendermint vars. Reference:
https://github.com/bigchaindb/bigchaindb/pull/2039#discussion_r167880795
2018-02-14 12:18:59 +01:00
Sylvain Bellemare
6e3f9e8f54 Docker compose for travis (#2039)
* Replace double quotes with single quotes (flake8)

* Test event subscriber to tendermint via ws

* Problem: Tendermint is not part of stack for CI

Solution: Add Tendermint to stack for CI. For simplicity's sake
docker-compose is being used.
2018-02-14 10:19:04 +01:00
vrde
9d720f6d45 Problem: statsd configuration is no longer supported
Solution: remove monitoring code, completes #1138
2018-02-13 14:36:03 +01:00
vrde
4157244df7 Problem: statsd config is no longer supported
Solution: remove monitoring code, completes #1138
2018-02-13 14:35:47 +01:00
Sylvain Bellemare
c35e37be64 Problem: Unpublished ports with docker-compose
Solution: Publish the ports.

Closes #2041.
2018-02-13 12:08:19 +01:00
Sylvain Bellemare
b8a33e0f30 Problem: tmdata tracked files change in dev env
Solution: Only track config.toml and generate the other files such as
genesis.json and priv_validator.json in the container via `tendermint
init`

Related issue: #1997
2018-02-13 12:02:34 +01:00
Sylvain Bellemare
87d74a704b Problem: .pytest_cache is tracked by git
Solution: Put .pytest_cache/ in the .gitignore file.
2018-02-12 18:29:22 +01:00
muawiakh
a4ac9cf308 Address comments
- Update docs for better readability
2018-02-12 14:35:02 +01:00
Troy McConaghy
e7b65410dd
Merge pull request #1993 from bigchaindb/update-ipdb-tx-spec-url-in-docs
Updated all refs to the IPDB Transaction Spec and its URL
2018-02-10 16:52:26 +01:00
Troy McConaghy
ee997359b8
Merge branch 'tendermint' into update-ipdb-tx-spec-url-in-docs 2018-02-09 22:10:53 +01:00
Sylvain Bellemare
1611e6e04b Mount other volumes for docker-compose dev 2018-02-08 16:48:04 +01:00
muawiakh
320e09dee3 Resolved merge conflicts again 2018-02-08 15:57:37 +01:00
Ahmed Muawia Khan
1f172b1b3c
Merge pull request #2029 from bigchaindb/vagrant-fix-ubuntu-xenial
Fixing Vagrant tutorial
2018-02-08 15:57:05 +01:00
muawiakh
d6a7500abc Resolved merge conflicts with tendermint branch 2018-02-08 15:52:31 +01:00
muawiakh
b68c0ccbc0 Addressing comments and removing *-tm* or *-tmt* references 2018-02-08 15:48:45 +01:00
Sylvain Bellemare
5d0463282b Add tendermint marker to pytest.ini 2018-02-08 15:41:44 +01:00
Sylvain Bellemare
cc069fa640 Add db_context fixture 2018-02-08 15:26:50 +01:00
Sylvain Bellemare
b2584dd0fa Order imports as per pep 8 2018-02-08 15:19:47 +01:00
Troy McConaghy
1ba9233310 tendermint-instance-? --> tm-instance-? 2018-02-08 14:52:45 +01:00
muawiakh
1df86234d6 Fix Vagrant tutorial 2018-02-08 14:52:37 +01:00
Vanshdeep Singh
fa33fc26af Integrate get block with transaction id api (#2021)
* Integrate api, get block with transaction id

* Fixed docs and docstrings

* Fix docs

* Remove status from tendermint, fix mongo query
2018-02-08 14:32:21 +01:00
Troy McConaghy
8945dd2332 Re-org headings in Prod. Dep. Template - Overview page 2018-02-08 14:20:50 +01:00
muawiakh
6052043a03 Remove unwanted references 2018-02-08 12:17:40 +01:00
muawiakh
03219a9371 Remove references from BigchainDB 1.x deployment strategy
- Remove references from existing deployment model
- Address comments, fix typos, minor structure changes.
2018-02-08 11:54:57 +01:00
Ahmed Muawia Khan
f88ce7c1eb
Merge pull request #1877 from bigchaindb/template-spec
Add guidelines for new features in BigchainDB
2018-02-06 12:40:05 +01:00
Ahmed Muawia Khan
b4acee0425
Merge pull request #2019 from bigchaindb/storage-engine-fix
Fix storage-engine-cache size issue
2018-02-06 11:51:27 +01:00
muawiakh
75e90c964f Merge branch 'master' into storage-engine-fix 2018-02-05 18:06:25 +01:00
muawiakh
8477392abd Merge branch 'master' into template-spec 2018-02-05 18:03:55 +01:00
Vanshdeep Singh
a7ed8cf4cb Write transactions on commit (#2017)
* Write transacitons on commit

* Fix docs strings, lazy check for duplicates
2018-02-02 14:40:24 +01:00
Ahmed Muawia Khan
4147e59edb
Merge pull request #2023 from sbellem/update-ssl-certs-for-tests
Update SSL certs and keys for tests
2018-02-02 12:03:12 +01:00
Sylvain Bellemare
5cec22d659
Update SSL certs and keys for tests
fixes #2015
2018-02-01 17:24:52 +01:00
muawiakh
1a0c165487 Address comments
- Keep only tendermint specific files, remove reference to older
  deployment strategy
- Update Bigchaindb Dockerfile
2018-02-01 13:02:39 +01:00
Troy McConaghy
402abe72e8
Merge pull request #2020 from bigchaindb/update-main-license-to-apache-v2
Updated main code license to Apache v2 in LICENSES.md
2018-01-31 16:30:33 +01:00
Troy McConaghy
2759320ea3 Updated main code license to Apache v2 in LICENSES.md 2018-01-31 16:15:16 +01:00
muawiakh
6e055c642c Fix storage-engine-cache size issue
- Allow for empty values
- Allow if you don't specify the --storage-engine-cache-size
2018-01-31 15:46:39 +01:00
Vanshdeep Singh
e25d365828 Integrate blocks API (#1970)
* Integrate blocks api

* Update docs

* Fix docs

* Fixed mismatch between code and documentation

* Fixed docs
2018-01-31 14:42:41 +01:00
muawiakh
6a8cb99597 Merge branch 'master' into template-spec 2018-01-30 16:41:01 +01:00
muawiakh
1048d6a170 Update document reference in issue_template 2018-01-30 14:24:50 +01:00
muawiakh
d9f927bcd9 Update minor typos and directory references 2018-01-30 14:21:52 +01:00
vrde
c156d0bfe8
Merge pull request #1996 from bigchaindb/1995-mode-API
add mode parameter to transaction endpoint, fixes #1995
2018-01-29 12:00:32 +01:00
Troy McConaghy
328f2ed193 Some minor copy-editing 2018-01-24 16:43:35 +01:00
muawiakh
0216ffd1e8 minor change
- update formatting in example spec
2018-01-24 13:41:07 +01:00
muawiakh
407935c982 Move bigchaindb/docs/specs to bigchaindb/proposals
- Use *.md for example spec instead of *.rst
2018-01-24 13:32:50 +01:00
codegeschrei
e74fb096fc requested changes 2018-01-24 11:59:50 +01:00
codegeschrei
ff50d243bc Merge branch 'tendermint' into 1995-mode-API 2018-01-24 11:58:13 +01:00
vrde
73ba3f5eb0
Merge pull request #1967 from sbellem/measure-branch-coverage
Closes #1736
2018-01-23 17:28:33 +01:00
muawiakh
0016c86e0b Address comments
- Remove release process changes
- Specs per release will be tracked as part of a different PR
  and proposal
2018-01-17 10:43:35 +01:00
Sylvain Bellemare
8c600e7137 Pin tendermint to 0.13 2018-01-16 14:18:52 +01:00
Sylvain Bellemare
077b7d3589
Merge branch 'master' of github.com:bigchaindb/bigchaindb into tendermint 2018-01-16 12:07:34 +01:00
Sylvain Bellemare
afda1686e6 Upgrade aiohttp
related to https://github.com/aio-libs/aiohttp/pull/2667
2018-01-16 12:05:47 +01:00
Sylvain Bellemare
d2f1282333
Merge branch 'master' of github.com:bigchaindb/bigchaindb into tendermint 2018-01-15 19:29:35 +01:00
Sylvain Bellemare
9bed8f363a Fixes #1930 2018-01-15 19:08:58 +01:00
muawiakh
ab9e1f71c7 Pin yarl version to 0.18.* in setup.py
- We need to pin this dependency because version 1.0.0 of yarl
  does not expose `unquote` and if we do not pin it, the latest
  version >=1.*.* is downloaded and `aiohttp` expects it.
- This can also be fixed on `aiohttp`, but meanwhile :)
2018-01-15 18:55:09 +01:00
codegeschrei
1d99d6e8a8 requested changes 2018-01-15 17:12:17 +01:00
Sylvain Bellemare
2d0e83657e Parametrize host and port used by event stream
closes #1994
2018-01-15 16:19:08 +01:00
Sylvain Bellemare
76ac3b3c6c Order import as per PEP 8 2018-01-15 16:19:08 +01:00
muawiakh
93070bf9fe Update docs II 2018-01-12 18:21:19 +01:00
muawiakh
c4e752d379 Address comments
- Use aafigure to render text -> HTML/image
- Update some docs
2018-01-12 18:16:05 +01:00
codegeschrei
411d1963bb requested changes 2018-01-12 11:06:27 +01:00
codegeschrei
b7d235379a fix tests 2018-01-11 13:44:54 +01:00
codegeschrei
06a091e215 add mode parameter to transaction endpoint, fixes #1995 2018-01-11 13:26:06 +01:00
Ahmed Muawia Khan
f817818770
Merge pull request #1987 from bigchaindb/storage-engine-fix-mongo-k8s
Fix error checking of optional parameter `storage-engine-cache-size`
2018-01-11 12:54:46 +01:00
muawiakh
ffc2878033 Update some misleading doc mistakes 2018-01-11 12:17:55 +01:00
muawiakh
61f36435fc Separate tendermint integration deployment files
- Separate deployments, services, statefulsets etc
  `yaml` files for tendermint based deployment.
- Separate Dockerfiles for mongodb, nginx for
  tendermint integrated BigchainDB.
2018-01-11 12:13:36 +01:00
Troy McConaghy
c0b32213e4 Updated all refs to the IPDB Transaction Spec & its URL 2018-01-10 14:40:34 +01:00
muawiakh
14892fc839 Template for BigchainDB + Tendermint Kubernetes Deployment
- Template doc for BigchainDB + Tendermint single node
- Template doc for BigchainDB + Tendermint network
- Remove autosectionlabel extension from docs/server/source/conf.py
  - Removed this extension because this does not allow two different
    documents to have same headings, because it auto-indexes
- Fix and explicitly label headings and references.
2018-01-10 14:20:32 +01:00
Troy McConaghy
739ca36c2c
Merge pull request #1988 from bigchaindb/update-docs-re-ipdb-test-net
Change "IPDB Testnet" to "BigchainDB Testnet" in docs
2018-01-10 13:52:46 +01:00
muawiakh
688831467e Update naming convention in configMap 2018-01-08 12:50:38 +01:00
Troy McConaghy
31479eb3f3 docs: IPDB Testnet --> BigchainDB Testnet 2018-01-08 11:25:36 +01:00
muawiakh
9d45f735fd Improving code readability 2018-01-04 14:53:23 +01:00
muawiakh
e2316a3de8 Fix error checking of optional parameter storage-engine-cache-size
- Keep the parameter optional
- Remove redundant checking of the same parameter
- Do not exit if the parameter is not specified
2018-01-04 13:58:28 +01:00
Troy McConaghy
0b885efc85
Merge pull request #1984 from r7vme/fix/cache-size-bash
Fix issue with STORAGE_ENGINE_CACHE_SIZE parameter
2018-01-04 12:54:41 +01:00
muawiakh
a348c72696 Deployment of Tendermint + BigchainDB cluster
- Update existing docker-containers to support tendermint integration, nginx,
  mongodb, bigchaindb
- Add tendermint configuration files for statefulset, pvc, pv and service.
- Update some READMEs.
2018-01-02 14:51:23 +01:00
Roman Sokolkov
779d31ef3e
Fix issue with STORAGE_ENGINE_CACHE_SIZE parameter
In mongodb docker image STORAGE_ENGINE_CACHE_SIZE
will always be set to '' (two quotation marks)
and verification will fail. So it's impossible to
run image without --storage-engine-cache-size set.

This change removes double quotes while assigning
default value to STORAGE_ENGINE_CACHE_SIZE.
2017-12-30 17:31:55 +01:00
Sylvain Bellemare
52d0c7024a
Merge branch 'master' into tendermint 2017-12-23 04:58:18 +01:00
Sylvain Bellemare
1ebeaae6d9
Closes #1736 2017-12-22 18:05:36 +01:00
Sylvain Bellemare
8bd8dc02a4 Fixes #1969 2017-12-22 18:03:57 +01:00
Sylvain Bellemare
07ddf69fc2 Add docker-compose file for mongodb ssl tests 2017-12-22 18:03:57 +01:00
Troy McConaghy
f235d42439
Merge pull request #1957 from bigchaindb/simplify-dev-and-test-docs-for-tendermint
Simplify the "Develop & Test BigchainDB Server" section of the docs
2017-12-22 17:14:35 +01:00
kansi
9ce7455228 Migrate cli for Tendermint 2017-12-21 12:23:15 +05:30
vrde
4c5047cb20
Merge pull request #1945 from bigchaindb/update-some-docs-in-the-production-nodes-section
Updated docs in the Production Nodes section for Tendermint
2017-12-20 16:13:13 +01:00
vrde
5957fa2d39
Merge branch 'master' into tendermint 2017-12-20 16:11:00 +01:00
vrde
3a0ce37a7f
Merge pull request #1951 from bigchaindb/proposal/post-txn-mode
Proposal for extending post transaction api
2017-12-20 16:09:47 +01:00
vrde
57d4a8e895
Merge pull request #1928 from bigchaindb/feat/integrate-event-stream
Integrate event stream api
2017-12-20 16:06:16 +01:00
vrde
ab4328fa1f
Merge pull request #1939 from bigchaindb/feat/integrate-metadata-api
integrate metadata api
2017-12-20 16:01:19 +01:00
vrde
fd6b5de91f
Merge pull request #1949 from bigchaindb/proposal-integration-testing
Add proposal for integration testing
2017-12-20 15:58:52 +01:00
vrde
1f21f069dd
Merge branch 'proposal-integration-testing' of github.com:bigchaindb/bigchaindb into proposal-integration-testing 2017-12-20 15:58:11 +01:00
vrde
883ba3832c
Merge branch 'tendermint' into proposal-integration-testing 2017-12-20 15:57:01 +01:00
vrde
59ae92350c
Merge pull request #1964 from bigchaindb/proposal-integration-test-cases
add test cases for integration testing
2017-12-20 15:53:27 +01:00
Troy McConaghy
1ac112b4a0
Merge pull request #1966 from bigchaindb/new-production-ready-page-for-tendermint
New production-ready page for tendermint branch
2017-12-20 14:16:13 +01:00
kansi
f1c11ccfa2 Fix spelling errors 2017-12-19 16:53:40 +05:30
Troy McConaghy
ebb6e84ad0 New page about production-readiness for Tendermint branch 2017-12-18 17:57:13 +01:00
codegeschrei
3057544618 requested changes 2017-12-18 17:15:01 +01:00
codegeschrei
b585efc790 requested changes 2017-12-18 17:03:14 +01:00
vrde
ba8ee3fe83
Fix some typos 2017-12-18 16:06:18 +01:00
codegeschrei
b9a97133d6 add test cases for integration testing 2017-12-13 13:33:03 +01:00
Troy McConaghy
5799ede466
Merge pull request #1952 from bigchaindb/new-style-quickstart-page
Redid the Quickstart page for the tendermint branch
2017-12-13 12:21:11 +01:00
Troy McConaghy
d9850639aa
Merge pull request #1942 from bigchaindb/tendermint-docs/1934/fix-some-broken-links
[tendermint branch] Docs: Fix 5 broken links to IPDB tx spec pages
2017-12-13 11:09:20 +01:00
Troy McConaghy
babf0b173c
Merge pull request #1941 from bigchaindb/docs/1934/fix-broken-links-to-ipdb-tx-spec-pages
[master branch] Docs: Fix 5 broken links to IPDB tx spec pages
2017-12-13 11:06:05 +01:00
kansi
afd643c41d Expand abbrevation "txn" to transaction 2017-12-13 11:05:28 +05:30
kansi
a8d267f429 Fix asyncio compability with python 3.5 2017-12-12 22:34:17 +05:30
Ahmed Muawia Khan
ac2e431d9e
Merge pull request #1959 from bigchaindb/typo-firewall-notes
Typo firewall notes
2017-12-12 13:52:30 +01:00
muawiakh
4792b94201 Fix typo in firewall docs
- inbount -> inbound
2017-12-12 13:37:57 +01:00
Troy McConaghy
caf6724184 docs: made dev-and-test section just point to CONTRIBUTING.md 2017-12-12 10:55:05 +01:00
Troy McConaghy
fbd85301e1
Merge pull request #1921 from bigchaindb/docs/update-firewall-page
Updated the Notes for Firewall Setup page in docs
2017-12-12 10:35:03 +01:00
Shahbaz Nazir
6ddf37dc66
Scripts to bootstrap devstack setup for bigchaindb with tendermint (#1887)
bash scripts to setup dev environment with bigchaindb+tendermint+mongodb
2017-12-11 17:03:32 +01:00
Troy McConaghy
8c0e28ee46
Merge pull request #1947 from bigchaindb/update-contributing-md-file-for-tendermint-branch
Update the CONTRIBUTING.md file (on tendermint branch)
2017-12-11 16:38:52 +01:00
Troy McConaghy
93be14174a Redid the Quickstart page for the tendermint branch 2017-12-08 12:18:20 +01:00
kansi
7cd76c346b Proposal for extending post transaction api 2017-12-08 10:27:11 +05:30
Troy McConaghy
dab64485eb
Merge branch 'tendermint' into update-some-docs-in-the-production-nodes-section 2017-12-07 17:34:36 +01:00
vrde
efc149aaa1
Add proposal for integration testing 2017-12-07 17:30:43 +01:00
Troy McConaghy
d4e880fa36
Merge pull request #1917 from bigchaindb/rm-aws-deployment-tools-and-docs
Removed old AWS testing cluster stuff including docs
2017-12-07 17:04:04 +01:00
Troy McConaghy
b6c06b4ccc Merge remote-tracking branch 'origin/tendermint' into update-contributing-md-file-for-tendermint-branch 2017-12-07 14:28:17 +01:00
Troy McConaghy
3f369eb83c
Merge pull request #1948 from bigchaindb/fix-test-and-rm-pytest-catchlog-on-tendermint-branch
Fixed failing test and removed pytest-catchlog on tendermint branch
2017-12-07 14:26:48 +01:00
Troy McConaghy
7a491bb781 Removed pytest-catchlog from setup.py & fixed one failing test 2017-12-07 13:33:57 +01:00
Troy McConaghy
941445cace Updated the CONTRIBUTING.md file for the tendermint branch 2017-12-07 10:45:52 +01:00
Troy McConaghy
da799b74f6 Updated docs in Production Nodes section for Tendermint 2017-12-06 17:10:37 +01:00
Sylvain Bellemare
cb268a3832
Merge branch 'master' into tendermint 2017-12-06 16:59:26 +01:00
Troy McConaghy
cdb4561805
Merge pull request #1943 from bigchaindb/put-commit-c5443dc-in-master-branch-too
[master branch] Removed Azure Quickstart Template docs
2017-12-06 14:32:36 +01:00
Troy McConaghy
e0b454953c
Merge branch 'tendermint' into rm-aws-deployment-tools-and-docs 2017-12-06 14:14:04 +01:00
Troy McConaghy
47bf3215ea Removed Azure Quickstart Template docs
(cherry picked from commit c5443dc477a0f4018c3785d22760fbbcae06d3a3)
2017-12-06 14:03:45 +01:00
Troy McConaghy
c8e2f59413
Merge pull request #1933 from bigchaindb/docs/1927/remove-azure-quickstart-template-docs
Remove Azure Quickstart Template Docs
2017-12-06 13:56:57 +01:00
Troy McConaghy
d2296af3c8 Docs: Fixed 5 broken links to IPDB tx spec pages
(cherry picked from commit d9f147df6e2a8f11c4de20371954a718a299b832)
2017-12-06 11:34:47 +01:00
Troy McConaghy
d9f147df6e Docs: Fixed 5 broken links to IPDB tx spec pages 2017-12-06 11:23:45 +01:00
kansi
f5b887ac59 Integrate events api 2017-12-06 15:42:45 +05:30
Sylvain Bellemare
138aaaf8fd Remove pytest-catchlog since it is now in the core 2017-12-06 10:57:37 +01:00
kansi
cb92248855 Merge branch 'tendermint' into feat/integrate-metadata-api 2017-12-06 10:26:53 +05:30
kansi
b3f2eeb931 Integrate metadata api 2017-12-06 10:25:52 +05:30
Sylvain Bellemare
9dd2e026b0 Fixes #1891 2017-12-05 19:38:52 +01:00
Troy McConaghy
e201ba7305
Merge pull request #1919 from bigchaindb/remove-defunct-docs-pages
Removed some fully-removeable pages from the Appendices
2017-12-05 14:09:22 +01:00
Troy McConaghy
b36df932a5 Removed appendices/install-latest-pip.md 2017-12-05 13:47:24 +01:00
Troy McConaghy
c5443dc477 Removed Azure Quickstart Template docs 2017-12-05 11:27:08 +01:00
muawiakh
2f8c9d77e8 Update docker compose files for tendermint
- BigchainDB does not use --init flag anymore
- Either we use `bigchaindb init` explicitly or `bigchaindb start --no-init`
  other wise `bigchaindb start` implicitly does an init
2017-12-01 15:37:42 +01:00
Troy McConaghy
1a5bb073e3 Remove rethinkdb-backup.md 2017-12-01 15:27:55 +01:00
Troy McConaghy
b1276020b3 Updated the Notes for Firewall Setup page in docs 2017-12-01 14:26:28 +01:00
kansi
043b0c17ac Merge branch 'tendermint' into feat/upgrade-py-abci 2017-12-01 16:37:39 +05:30
Troy McConaghy
91dcce1a45 Removed some fully-removeable pages from Appendices 2017-12-01 11:16:35 +01:00
vrde
3dcd0ac25c
Merge pull request #1902 from bigchaindb/feat/integrate-output-api
Integrate output search api
2017-12-01 10:51:52 +01:00
kansi
228bd83ae7 Upgrade py-abci 2017-12-01 14:43:17 +05:30
Troy McConaghy
ae5b5fe3b8
Merge pull request #1916 from bigchaindb/update-some-root-docs-for-tendermint
Updated & deleted some root docs in the tendermint branch
2017-12-01 10:11:19 +01:00
kansi
2b3a9fa6f6 Integrate output search api 2017-11-30 23:59:42 +05:30
vrde
1e104ad2c4
Merge branch 'master' into tendermint 2017-11-30 18:17:36 +01:00
Troy McConaghy
b237a021c6 Removed old AWS testing cluster stuff including docs 2017-11-30 17:50:22 +01:00
Troy McConaghy
9c2d04d887 Updated & removed some root docs on tendermint branch 2017-11-30 15:39:45 +01:00
Katha
9d38d3d405
add tests to improve codecov (#1871)
* add tests to improve codecov
2017-11-30 15:07:45 +01:00
Katha
e377fb57af
Pre commit styling (#1914)
* run pre-commit and fix errors

* mention pre-commit in our guides
2017-11-30 15:04:14 +01:00
Katha
7aa1f09588
Merge pull request #1872 from bigchaindb/pre-commit-proposal
pre-commit proposal
2017-11-30 15:03:30 +01:00
codegeschrei
321809622a pre-commit proposal 2017-11-29 18:41:07 +01:00
vrde
044a052644
Merge branch 'master' into tendermint 2017-11-29 17:18:00 +01:00
Sylvain Bellemare
35012a6452 Fix flake8 errors 2017-11-29 16:55:32 +01:00
Troy McConaghy
7bfc665638
Merge pull request #1909 from bigchaindb/docs/point-some-pages-to-ipdb-tx-spec-docs
Changed six docs pages to just point to the IPDB Transaction Spec
2017-11-28 16:32:29 +01:00
Troy McConaghy
b52f094efa Revised several pages to point to replacement in the IPDB Transaction Spec 2017-11-28 12:16:44 +01:00
vrde
b64edf94ab
Merge pull request #1886 from bigchaindb/feat/integrate-asset-search
Integrate asset search
2017-11-24 11:55:42 +01:00
kansi
fcfe577813 Added localmongodb marker 2017-11-24 12:30:57 +05:30
kansi
6c3f176122 Integrate asset search 2017-11-23 21:28:51 +05:30
Troy McConaghy
1de7e55ac3
Merge pull request #1894 from bigchaindb/issue/1875/json-schema-validation-is-ipdb-protocol
Removed appendix page w/ tx JSON Schema files & updated transaction-m…
2017-11-23 16:37:32 +01:00
kansi
00dd16840f Added backend tests, configure app fixture 2017-11-23 16:27:35 +01:00
kansi
95c0f267e0 Integrate api GET "/transactions?asset_id={asset_id}&operation=" 2017-11-23 16:27:35 +01:00
Sylvain Bellemare
13b3d6b464 Add some docs 2017-11-23 16:22:16 +01:00
Sylvain Bellemare
c9380f128e Start tendermint integration with bigchaindb cmd 2017-11-23 16:22:16 +01:00
Sylvain Bellemare
b7ef4caa26 Add dev setup of 4 nodes with docker-compose 2017-11-23 16:22:16 +01:00
Sylvain Bellemare
67c8bba17b Parametrize tendermint endpoint based on env vars 2017-11-23 16:22:16 +01:00
Sylvain Bellemare
9ccf676204 Log debug statements 2017-11-23 16:22:16 +01:00
Sylvain Bellemare
a19361cede Use env var to start or not, tendermint 2017-11-23 16:22:16 +01:00
Sylvain Bellemare
6db3390b95 Log instead of printing the banner 2017-11-23 16:22:16 +01:00
Sylvain Bellemare
9b3d1e1c53 Add docker-compose for tendermint integration dev 2017-11-23 16:22:16 +01:00
Troy McConaghy
374b6301c6 In readme file about JSON Schema files, note provenance and update process 2017-11-23 16:21:19 +01:00
vrde
359efbba15
Merge pull request #1863 from bigchaindb/write-transfer-test
Write transfer test
2017-11-23 16:11:31 +01:00
vrde
f4a6b863fe
Merge branch 'tendermint' into write-transfer-test 2017-11-23 15:55:32 +01:00
vrde
cf2f13aa3c
Remove app reinitialization from tests 2017-11-23 15:53:43 +01:00
Troy McConaghy
f23a2c4042 Removed appendix page w/ tx JSON Schema files & updated transaction-model.rst page 2017-11-23 14:45:23 +01:00
Ahmed Muawia Khan
4e64a37e52
Merge pull request #1890 from bigchaindb/advertise-metadata
Add metadata endpoint to info view
2017-11-23 11:16:50 +01:00
muawiakh
020b6c1ff8 Minor change in docs 2017-11-23 10:43:48 +01:00
muawiakh
b184e83b6a [Doc]: Fix markdown formatting in rst 2017-11-23 10:24:35 +01:00
kansi
5abb6ead8b Update metadata documentation 2017-11-23 10:41:58 +05:30
muawiakh
82cd3a61ed Add metadata endpoint to info view
- Metadata search was recently added and works seamlessly
- The endpoint was not reflected in the info view i.e.
  when someone queries at root / or api/v1 endpoints.
- Handle unit tests for the change as well.
2017-11-22 18:31:35 +01:00
kansi
66601f7fa2 Moved class "Block" to namedtuple, updated tests 2017-11-22 21:38:26 +05:30
Troy McConaghy
dd24bd8fb7
Merge pull request #1878 from bigchaindb/issue/1873/version-the-tx-schema-files
Version the transaction schema files
2017-11-22 16:41:09 +01:00
muawiakh
7220e84e8d Address comments
- Add a release tracking document and example
2017-11-22 12:35:35 +01:00
muawiakh
e3654a9994 Address comments, typos 2017-11-22 11:21:19 +01:00
Troy McConaghy
e50377e801
Merge pull request #1883 from bigchaindb/update-version-py-to-1.4.0.dev
Updated version.py for 1.4.0.dev
2017-11-21 20:16:43 +01:00
Troy McConaghy
bdab5e6219 Updated version.py for 1.4.0.dev 2017-11-21 19:59:09 +01:00
Troy McConaghy
9726cacf54
Merge pull request #1881 from bigchaindb/update-docker-image-to-1.3.0-in-k8s-yamls
Updated Docker image to 1.3.0 in k8s YAML files
2017-11-21 19:00:26 +01:00
Troy McConaghy
61747b138d Updated Docker image to 1.3.0 in k8s YAML files 2017-11-21 18:58:41 +01:00
Troy McConaghy
2590043a7a
Merge pull request #1880 from bigchaindb/update-changelog-for-v1.3-release
Updated the CHANGELOG.md file for the v1.3 release
2017-11-21 18:54:30 +01:00
Troy McConaghy
9d9310d8e5 Updated CHANGELOG.md for the v1.3 release 2017-11-21 18:41:44 +01:00
muawiakh
e0a771dabb Change man days to a gender neutral term
- Now dev days
2017-11-21 16:56:17 +01:00
muawiakh
193807153e Address comments I 2017-11-21 16:41:28 +01:00
Troy McConaghy
dfe072e443 Fixed a Flake8 error 2017-11-21 14:52:15 +01:00
muawiakh
a1d85afe04 Update issue template to reflect bug reports vs new feature 2017-11-21 14:34:48 +01:00
muawiakh
789f0be547 Add changes to release process
- Also no need to `spec-index.rst`
2017-11-21 14:30:12 +01:00
Troy McConaghy
94c77ba658 Removed the line from transaction_v1.0.yaml 2017-11-21 14:13:24 +01:00
Troy McConaghy
35fa8d7d19 Updated all code/docs referencing the transaction schema files by name 2017-11-21 14:12:13 +01:00
Troy McConaghy
8482521a8b Renamed all transaction schema files: added _v1.0 in them 2017-11-21 14:10:14 +01:00
muawiakh
27aa8555aa Add guidelines for new features in BigchainDB
- Template specification document
- Update CONTRIBUTING.md to reflect changes
2017-11-21 14:07:38 +01:00
kansi
f9d8519832 Merge branch 'bug/1592/metadata-text-search' 2017-11-20 19:12:31 +05:30
kansi
c78490f44d Merge branch 'master' into bug/1592/metadata-text-search 2017-11-20 19:12:12 +05:30
Shahbaz Nazir
6c1017510b
Add standard template for creating PRs (#1776)
* Add standard template for creating PRs

Adding a standard template for creating
Pull requests for improved code QA and delegating
dependencies whenever applicable

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* Update developer docs with PR instructions

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>

* Addressing review comments for PR template

Signed-off-by: Shahbaz Nazir <shahbaz@bigchaindb.com>
2017-11-20 14:08:57 +01:00
Shahbaz Nazir
bc4f8fcab5
Fix getstarted undefined referrer issue with IPDB (#1866)
Skip Referer check on preflight request (OPTIONS) and set Referrer-Policy to origin-when-cross-origin in response to OPTIONS request. Once Referrer-Policy is set on the subsequent POST request referrer is set by the browser to expected value.
2017-11-17 20:35:57 +01:00
Troy McConaghy
f53eb1e3e7
Merge pull request #1855 from bigchaindb/update-blocks-and-votes-docs
Updated docs about blocks and votes
2017-11-17 13:32:02 +01:00
Troy McConaghy
01796b0660
Merge branch 'master' into update-blocks-and-votes-docs 2017-11-16 18:27:08 +01:00
Troy McConaghy
5642050276
Merge pull request #1853 from bigchaindb/rm-descriptions-from-yaml-files
Removed all 'description' keys & values from the YAML files
2017-11-16 18:22:52 +01:00
Troy McConaghy
73034794f8 Merge branch 'master' into rm-descriptions-from-yaml-files 2017-11-16 18:06:58 +01:00
codegeschrei
48e38b6713 fix flake8 errors 2017-11-16 17:14:21 +01:00
Ahmed Muawia Khan
7b2b343138
Merge pull request #1790 from bigchaindb/multi-node-automation
Automation of multi node BigchainDB deployment for dev/test
2017-11-16 16:56:21 +01:00
Ahmed Muawia Khan
a99c817030
Merge pull request #1824 from bigchaindb/update-tectonic-docs
Update tectonic installation guide
2017-11-16 16:56:00 +01:00
Ahmed Muawia Khan
3752e13a38
Merge pull request #1825 from bigchaindb/docker-for-mac-quickstart
Update quickstart guide for 'docker for mac' users
2017-11-16 16:55:31 +01:00
muawiakh
cd98591851 Address comments on docs and some typos 2017-11-16 12:53:36 +01:00
muawiakh
2df08430cd Remove docker network creation and use default docker bridge 2017-11-16 12:53:36 +01:00
muawiakh
c285487dfb Revert "Fix flake8 failure"
This reverts commit 5c6e7419a7fa827f1291be3ecbeda895e3a46b58.
2017-11-16 12:53:36 +01:00
muawiakh
0ee0d88da1 Fix flake8 failure 2017-11-16 12:52:35 +01:00
muawiakh
b96a754f9a Update bdb-config 2017-11-16 12:51:46 +01:00
muawiakh
b2b644db3d Fix minor docs comments 2017-11-16 12:51:46 +01:00
muawiakh
20147562f6 Fix docs build issue 2017-11-16 12:51:46 +01:00
muawiakh
0f68c41b89 Addressing comments and updating some documentation 2017-11-16 12:51:46 +01:00
muawiakh
241af47a32 Automation of multi node BigchainDB deployment for dev/test
- Setup single/multi node BigchainDB cluster using
  - Vagrant
  - Ansible
- Updated documentation
2017-11-16 12:51:46 +01:00
muawiakh
977a6426fe Make premium_lrs default 2017-11-16 12:44:21 +01:00
muawiakh
1eb8764e4a Update deployment with tectonic documentation
- Add details about CA configuration
- Update storage class template
2017-11-16 12:44:21 +01:00
muawiakh
b4ca495967 Remove redundant redirections to different docker installation pages(s)
- All the instructions are common now
- Remove redundant files
- address comments
2017-11-16 12:14:11 +01:00
codegeschrei
63f0baf1b7 add double spend test, fix double spend validation 2017-11-16 11:53:14 +01:00
muawiakh
47f872df0f Integrate some other changes 2017-11-16 11:45:46 +01:00
muawiakh
7906edcebf Update quickstart guide for 'docker for mac' users 2017-11-16 11:45:46 +01:00
Ahmed Muawia Khan
a4140e92a6
Merge pull request #1852 from bigchaindb/travis-workaround
[Workaround]: Travis failures
2017-11-16 11:33:54 +01:00
Vanshdeep Singh
e27c1e9cef Return commit hash to tendermint (#1851)
* Aggregate transaction ids for commit hash

* Setup chain and return commit hash to tendermint

* Fix function naming
2017-11-15 15:41:23 +01:00
vrde
7dc7d745ec
Split transaction from asset (#1854)
Close #1827
2017-11-15 15:05:38 +01:00
vrde
b56b1d6364
Use localmongodb as default backend for docker-compose (#1858)
* Use `localmongodb` as default backend for docker-compose

* Remove replica-set
2017-11-15 15:01:07 +01:00
muawiakh
18fed8b1d0 [Workaround]: Travis failures
- Marking test_double_create as serial
- If this works, we don't need to skip the tests
- Finger crossed.
2017-11-15 14:30:01 +01:00
kansi
5590e719ae Merge branch 'fix-readme-dev-test-node-link' 2017-11-15 18:55:27 +05:30
kansi
4d465317b6 Merge branch 'master' into fix-readme-dev-test-node-link 2017-11-15 18:54:54 +05:30
kansi
67c4b8ee3f Fix "Set Up & Run a Dev/Test Node" link 2017-11-15 16:31:46 +05:30
Troy McConaghy
c6c89bfcba Added page about the transaction schema files 2017-11-15 11:18:07 +01:00
Troy McConaghy
b3ccb09e01 Changed title of the page about vote.yaml 2017-11-15 11:17:41 +01:00
Troy McConaghy
31a0bc846b Updated docs about blocks and votes 2017-11-14 15:51:36 +01:00
kansi
860d247aa4 Fixed decouple assets 2017-11-14 19:23:22 +05:30
Troy McConaghy
e86fa1f1bb Removed drop_schema_description() & its test 2017-11-14 14:05:53 +01:00
Troy McConaghy
6291afd0f7 rm all 'description' keys & values from YAML files 2017-11-14 14:05:02 +01:00
Troy McConaghy
c2acefa6f0
Merge pull request #1847 from bigchaindb/no-more-autogen-schema-pages-in-docs
Removed auto-generated tx & vote schema documentation
2017-11-14 11:42:43 +01:00
Troy McConaghy
053b954624 Removed docs/server/source/schema from .gitignore 2017-11-14 10:20:10 +01:00
kansi
f16e30f30b Merge branch 'master' into bug/1592/metadata-text-search 2017-11-14 00:16:28 +05:30
kansi
4eca26782c Change metadata model, fix tests and update docs 2017-11-14 00:13:06 +05:30
Troy McConaghy
f0d4417d02 Removed auto-generation of tx/vote schema documentation 2017-11-13 17:28:06 +01:00
Troy McConaghy
5454b6fcd1
Merge pull request #1843 from bigchaindb/update-version-py-to-1.3.0.dev
Updated to 1.3.0.dev in version.py
2017-11-13 14:54:41 +01:00
Troy McConaghy
9bed27b98f Updated to 1.3.0.dev in version.py 2017-11-13 14:53:25 +01:00
Troy McConaghy
952ba286e6
Merge pull request #1841 from bigchaindb/update-docker-image-version-in-k8s-files
Updated Docker image version to 1.2.0 in k8s YAML files
2017-11-13 13:56:54 +01:00
Troy McConaghy
67c8c6a1cb Updated Docker image version to 1.2.0 in k8s YAML files 2017-11-13 13:54:13 +01:00
Troy McConaghy
21fc364479
Merge pull request #1840 from bigchaindb/update-changelog-for-v1.2-release
Updated the changelog for the v1.2 release
2017-11-13 13:47:50 +01:00
Troy McConaghy
cfa63ae9af Updated the changelog for the v1.2 release 2017-11-13 13:38:00 +01:00
vrde
2192003a5e
Update docs and comments 2017-11-13 00:17:07 +01:00
vrde
db7727a459
Add GET and POST transaction (#1823) 2017-11-11 02:26:50 +01:00
vrde
2815cffcb5
Flat UTXO collection and first integration with Tendermint™ (#1822)
* Remove testing for rethinkdb, mongodb, and Py3.5

* Add first tests

* Add validation

* Add command to start the ABCI Server

* Reuse existing MongoDB Connection class

* Use DuplicateTransaction

* Test only tendermint

* Update travis scripts

* Fix pep8 errors

* Update Makefile
2017-11-10 17:53:57 +01:00
vrde
0c1256b975
Merge pull request #1819 from bigchaindb/improve-ws-reliability
Handle WS CLOSE properly
2017-11-10 11:10:27 +01:00
vrde
e242345327
Remove sample code 2017-11-09 15:59:02 +01:00
kansi
832ecb5e63 Handle metadata table during test setup/tear down 2017-11-09 19:17:23 +05:30
vrde
c4e0a8e1db
Handle WS CLOSE properly 2017-11-09 14:15:46 +01:00
kansi
8939c0f341 Merge branch 'master' into bug/1592/metadata-text-search 2017-11-09 17:39:35 +05:30
kansi
2afdd86752 Merge branch 'update-docs-server-requirements-txt' 2017-11-09 17:37:06 +05:30
kansi
0092270964 Merge branch 'master' into update-docs-server-requirements-txt 2017-11-09 16:31:43 +05:30
kansi
a2ed03dabc Merge branch 'master' into bug/1813/retract-cmd-bigchaindb-flag 2017-11-09 15:41:40 +05:30
kansi
07827186bc Merge branch 'master' into bug/1810/update-asset-docs 2017-11-09 14:30:18 +05:30
kansi
b95dc306d8 Merge branch 'bug/1670/asset-language-api-fix' 2017-11-09 13:41:20 +05:30
kansi
a809a7a620 Merge branch 'master' into bug/1670/asset-language-api-fix 2017-11-09 13:39:55 +05:30
Vanshdeep Singh
5ce2eb1f97 Bypass CI issues for rethinkdb (#1821)
Add custom marker to skip some travis/rdb tests
2017-11-08 19:41:17 +01:00
vrde
b4738e2e61
Start Tendermint integration 2017-11-08 18:53:27 +01:00
Troy McConaghy
e725c23691
Added note about 'make clean-pyc' 2017-11-07 14:24:33 +01:00
kansi
1266c43ff8 Fix docker files 2017-11-07 18:44:51 +05:30
kansi
8aba802425 Fix tests 2017-11-07 15:41:55 +05:30
kansi
220465f701 Added "--no-init" flag for "bigchaindb start" command 2017-11-07 14:55:05 +05:30
Troy McConaghy
6cab2f26e9
Fix command to run tests w/ docker-compose & bdb-rdb 2017-11-07 10:20:41 +01:00
Troy McConaghy
d55004601c
Fix command to run RethinkDB in bg w/ docker-compose 2017-11-07 10:17:21 +01:00
kansi
714c1782ac Support for metadata search api and its testing suite 2017-11-07 12:20:51 +05:30
kansi
94ce03cbec Decouple metadata from transaction 2017-11-07 10:50:07 +05:30
kansi
d9d0585228 Added metadata table for mongodb 2017-11-06 20:20:06 +05:30
Troy McConaghy
cae883e9cb Edited the changes to transaction model docs 2017-11-06 14:30:01 +01:00
Troy McConaghy
636c28d311 Edited changes to the docs about the asset model 2017-11-06 14:22:17 +01:00
Troy McConaghy
c616145a66
pyyaml>=3.12 in docs/server/requirements.txt 2017-11-06 12:12:16 +01:00
kansi
50cc0facef Merge branch 'master' into bug/1810/update-asset-docs 2017-11-06 15:50:07 +05:30
kansi
3cbec5a864 Updated metadata and asset model docs 2017-11-06 12:06:01 +05:30
kansi
7941922ac0 Added type validation for data 2017-11-06 10:43:54 +05:30
kansi
e2c2c4b097 Fix spell errors. 2017-11-03 19:15:32 +05:30
kansi
a29fd7e84f Fix variable type check and docstrings 2017-11-03 18:37:19 +05:30
Trent McConaghy
3b33cdb111
Update bft.md 2017-11-03 13:48:08 +01:00
kansi
99aa38b217 Added "none" to language whitelist 2017-11-03 11:38:38 +05:30
kansi
8310b04b17 Merge branch 'master' into bug/1670/asset-language-api-fix 2017-11-03 11:38:09 +05:30
Troy McConaghy
b93b3d2af8
Merge pull request #1788 from bigchaindb/docs/1752/how-permissions-work
New root docs page about permissions in BigchainDB
2017-11-02 15:21:26 +01:00
kansi
293f7ec9e4 Merge branch 'bug/1702/invalid-asset-data-keys' 2017-11-02 19:34:38 +05:30
kansi
961d7f5b29 Merge branch 'master' into bug/1702/invalid-asset-data-keys 2017-11-02 19:33:32 +05:30
kansi
8fdf8f6ca6 Added docstrings 2017-11-02 18:02:11 +05:30
kansi
d0ca211abc Merge branch 'bug/1656/bigcahin-secondary-index' 2017-11-02 15:59:13 +05:30
kansi
263e9a25f6 Unique index for bigchain collection, fixed test case 2017-11-01 21:23:06 +05:30
kansi
f3da30aea0 Validate nested keys for asset.data and metadata 2017-11-01 17:26:16 +05:30
kansi
cd636101a7 Support abbreviated values for "language" 2017-10-31 16:54:47 +05:30
kansi
1de5375962 Validate asset data keys 2017-10-31 15:16:59 +05:30
kansi
7226584215 Api fix for asset language 2017-10-31 10:12:16 +05:30
kansi
421c67c621 Fixed mongodb tests 2017-10-27 15:31:44 +05:30
Troy McConaghy
97e1a13c7f Updated docs/server/requirements.txt
The `requirements.txt` file in `docs/server` didn't have all the Python packages needed to build the BigchainDB Server docs. I fixed that.
2017-10-27 11:51:02 +02:00
kansi
ddfce61b79 Added secondary index for "id" in bigchain collection. 2017-10-27 15:05:43 +05:30
kansi
ad6dd9a5af Merge branch 'bug/1792/events-api-docs' 2017-10-26 15:04:28 +05:30
kansi
113c408f61 Merge branch 'bug/1661/cmd-start-force-init-database' 2017-10-25 14:09:59 +05:30
kansi
25716261e0 Updated keep-alive section 2017-10-25 13:47:02 +05:30
kansi
cf19a8cb93 Updated docs 2017-10-24 18:29:31 +05:30
kansi
199473178f Fix rethinkdb tests 2017-10-24 18:03:57 +05:30
kansi
5954d6360a Added cmd flag --init to start command 2017-10-24 16:59:10 +05:30
kansi
037dd65186 Merge branch 'bug/1660/logging-server-port-config' 2017-10-24 14:24:45 +05:30
kansi
0b44c385a6 Merge branch 'master' into bug/1660/logging-server-port-config 2017-10-24 10:10:18 +05:30
kansi
76bf05529d Merge branch 'bug/1625/handle-log-env-vars' 2017-10-24 10:00:21 +05:30
kansi
fa345e5441 Updated server configuration docs. 2017-10-23 21:52:30 +05:30
kansi
020d463e8d Modified log port config checks. 2017-10-23 21:08:44 +05:30
kansi
50eb857133 Fix flake8 ambiguous variable "l" issue 2017-10-23 18:06:11 +05:30
kansi
dc00e16fda Apply "log" environment variables to config 2017-10-23 16:00:09 +05:30
kansi
6f5eef97a7 Updated server configuration docs 2017-10-23 14:31:12 +05:30
kansi
01390a8cc0 Fix code coverage 2017-10-23 10:20:56 +05:30
kansi
ce7f575e0e Merge remote-tracking branch 'upstream/master' into bug/1660/logging-server-port-config 2017-10-23 09:22:11 +05:30
kansi
0c0d3049f2 Provide log server port as config paramter 2017-10-23 09:17:58 +05:30
Sylvain Bellemare
788f2f7277 Remove dev related mount of cryptoconditions 2017-10-20 14:24:03 +02:00
Troy McConaghy
fba6e1b30b New root docs page about permissions in BigchainDB 2017-10-18 15:38:46 +02:00
Troy McConaghy
cafbb5c944 Merge pull request #1785 from bigchaindb/refactor-dev-test-node-docs
Refactored the docs on dev/test node setup
2017-10-16 10:18:17 +02:00
Troy McConaghy
ee6f0fa7dd Refactored the docs on dev/test node setup 2017-10-15 13:52:54 +02:00
Shahbaz Nazir
0a8bf89bc6 Add workflow to retain Azure storage disks on PVC or PV delete (#1782) 2017-10-13 23:26:13 +02:00
Michiel Mulders
8385b7d4ef Added Link To JavaScript Driver Docs 2017-10-12 17:23:27 +02:00
Troy McConaghy
bb9e26c694 Markdown-link http://127.0.0.1:9984/ in Quickstart 2017-10-10 09:43:53 +02:00
Troy McConaghy
22af5c8383 Quickstart: BigchainDB Root URL from text-> URL
In the Quickstart page of the docs, the BigchainDB Root URL (http://127.0.0.1:9984/) was being formatted as text (with a $ in front) rather than as an URL. I changed it to format like a clickable (linked) URL.
2017-10-10 09:29:25 +02:00
Ahmed Muawia Khan
6d5136c349 Merge pull request #1775 from bigchaindb/refactor-setup-docs
Refactor installation docs for bigchaindb node
2017-10-04 12:34:01 +02:00
muawiakh
8390cab59a Remove cloud9 pdf 2017-10-04 11:51:22 +02:00
muawiakh
f1ba935476 [refactor docs]: Remove cloud9 deployment guide
- Remove deprecated guides
- Address comments
2017-10-04 11:21:34 +02:00
muawiakh
a9625e0e62 Refactor installation docs for bigchaindb node
- Restructure docs for introduction page.
- Add vagrant and ansible deployment menthod to the list
2017-10-02 15:28:32 +02:00
Krish
44b6376f05 Add Preferred Hostname Troubleshooting steps (#1773) 2017-09-29 11:01:45 +02:00
Shahbaz Nazir
1b9dcb9ffa Change Group ID to Project ID for cloud manager config (#1772)
MongoDB cloud manager UI has been updated and they have changed Group ID to Project ID and merged Settings -> Group Settings into one consolidated panel Settings

This PR updates the k8s docs accordingly
2017-09-29 09:56:58 +02:00
krish7919 (Krish)
c211ef156a Address comments 2017-09-28 16:47:50 +02:00
krish7919 (Krish)
cba933a592 Elaborate on 502 gateway error 2017-09-28 16:47:50 +02:00
krish7919 (Krish)
df2bd10430 Add troubleshooting doc 2017-09-28 16:47:50 +02:00
Ahmed Muawia Khan
2dcc946c0c Merge pull request #1771 from bigchaindb/update_mdb_backup_agent
Update mongodb monitoring agent
2017-09-28 16:12:17 +02:00
muawiakh
9609efbb5e Update mongodb monitoring agent 2017-09-28 15:14:38 +02:00
krish7919 (Krish)
751da63e38 Address comments 2017-09-28 15:14:16 +02:00
krish7919 (Krish)
cebea3e1b8 Update image and address comments 2017-09-28 15:14:16 +02:00
krish7919 (Krish)
1761e94840 Adding high level arch description 2017-09-28 15:14:16 +02:00
krish7919 (Krish)
4ee5b4cfbc Bugfix in nginx-openresty Dockerfile 2017-09-28 15:09:43 +02:00
krish7919 (Krish)
99f5996881 Sanity check for input values 2017-09-28 15:09:29 +02:00
Ahmed Muawia Khan
f62241026c Merge pull request #1767 from bigchaindb/update-nginx-deps
Update nginx-http(s) and mongodb deployments files to use latest vers…
2017-09-28 12:37:08 +02:00
muawiakh
3d2daa3119 Update nginx-http(s) and mongodb deployments files to use latest versions 2017-09-28 10:42:28 +02:00
Ahmed Muawia Khan
f4b5b93f69 Merge pull request #1757 from bigchaindb/mongodb-crash-fix
Adjust resources for MongoDB Stateful Set
2017-09-27 15:45:42 +02:00
Troy McConaghy
060553d02f Merge pull request #1765 from bigchaindb/release-process-revisions-after-releasing-v1.1
Minor revisions to RELEASE_PROCESS.md following the release of v1.1
2017-09-27 14:44:02 +02:00
muawiakh
1e53f13be3 Use config map for storage engine cache size 2017-09-27 14:40:12 +02:00
muawiakh
8b1fd605e2 Address some bugs
- Pushed the wrong codebase in the previous commit
2017-09-27 14:19:31 +02:00
muawiakh
7abdca205a Adjust resource for MongoDB Stateful Set
- Currently, MongoDB container crashed because of resource constaints i.e.
out of memory exception. This change updates the resources and provides
data on how the configure/calculate them(if not following the guide).
- Also, add the ability to specify the storage engine(WiredTiger) cache
size for MongoDB, this configuration also helps with keeping the resources
constrained for MongoDB containers.
- Minor changes in some other documents as well.
2017-09-27 14:19:31 +02:00
Ahmed Muawia Khan
43d8beed99 Merge pull request #1763 from bigchaindb/template-issue-reporting
Add template for issue reporting for BigchainDB and IPDB
2017-09-27 14:16:16 +02:00
Ahmed Muawia Khan
2e6be2a3b8 Merge pull request #1762 from bigchaindb/nginx-update-config
Update nginx config for well being
2017-09-27 14:13:22 +02:00
Troy McConaghy
99156e6a4c Minor revisions to RELEASE_PROCESS.md following the release of v1.1 2017-09-27 13:50:20 +02:00
muawiakh
94fb27be6c Fix typos 2017-09-26 17:24:18 +02:00
muawiakh
93ab1bc38a Add template for issue reporting for BigchainDB and IPDB 2017-09-26 17:08:15 +02:00
muawiakh
9ab6785920 Some more comments 2017-09-26 16:01:14 +02:00
muawiakh
dbddc7c85c Addressing comments 2017-09-26 15:31:37 +02:00
muawiakh
4371a2ce4b Update nginx config for well being
- turned off server tokens so the server does not leak nginx information
  on errors and header
- Added header to turn off cross site scripting
- use stable release of nginx instead of mainline
- limit available methods
- update response code
2017-09-26 14:27:21 +02:00
Troy McConaghy
86ddbc2750 Merge pull request #1761 from bigchaindb/update-version-py-to-1.2.0.dev
Update version.py version to 1.2.0.dev for docs
2017-09-26 11:53:40 +02:00
Troy McConaghy
6648b3473c Update version.py version to 1.2.0.dev for docs 2017-09-26 11:39:47 +02:00
Troy McConaghy
c255f866c8 Merge pull request #1759 from bigchaindb/update-docker-img-ver-for-k8s-to-1.1.0
Update BDB Docker image version for k8s
2017-09-26 10:40:33 +02:00
Troy McConaghy
d852209c4e Updated BDB image version in the k8s YAML of k8s/dev-setup/ 2017-09-26 10:27:05 +02:00
Troy McConaghy
cdfc0a3058 Update BDB Docker image version for k8s
Part of the BigchainDB release process
2017-09-26 10:09:25 +02:00
Troy McConaghy
13379446a7 Set the date of the v1.1 release in CHANGELOG.md
I should have done this in PR #1744 but I forgot.
2017-09-26 10:02:34 +02:00
Troy McConaghy
dee9be3b8e Merge pull request #1744 from bigchaindb/update-changelog-for-v1.1
Updates to the changelog for the v1.1 release
2017-09-26 09:58:39 +02:00
Ahmed Muawia Khan
09bddb9658 Merge pull request #1728 from bigchaindb/move-nginx-3scale-repo
Move the bigchaindb/nginx_3scale repo under bigchaindb/bigchaindb
2017-09-26 09:25:04 +02:00
muawiakh
598d925dd4 Addressing comments
- Update README.md to remove old deployment model.
- Update version number of nginx_3scale.
2017-09-25 16:20:47 +02:00
Troy McConaghy
a1fe3d27ce Edited two LICENSES.md files 2017-09-25 16:20:47 +02:00
Muawia Khan
2cbf6b6a5c [WIP]: Move the bigchaindb/nginx_3scale repo under bigchaindb/bigchaindb
- All files moved to k8s/nginx-3scale with directory structure consistent
with k8s/nginx-http(s)
- Top level LICENCES.md updated
- Renaming entry point script to nginx_openresty_entrypoint.bash
2017-09-25 16:20:47 +02:00
Troy McConaghy
8160190f3a Added notes about new Java driver & Ruby library in CHANGELOG.md 2017-09-25 15:12:54 +02:00
krish7919 (Krish)
a72f971ed2 Documenting the use of ConfigMap and Secret in deployment 2017-09-22 09:59:30 +02:00
Ahmed Muawia Khan
06d5e32d09 Merge pull request #1749 from bigchaindb/single-node-automation
Automation for single node deployment for quickstart
2017-09-19 16:56:59 +02:00
Troy McConaghy
2f38f81ea9 Merge pull request #1747 from bigchaindb/docs/link-to-new-java-driver
Added link to new Java driver in the docs
2017-09-18 17:57:14 +02:00
muawiakh
4235618522 Addressing comments
- support public_network for vagrant box
- using python3-5 for centos based installations
- Revisiting docs.
  - More changes will be incorporated in another PR.
- Parameterize MongoDB host mount path for docker deployments
2017-09-18 15:59:49 +02:00
Troy McConaghy
3cbdc15e91 Only list the new Java driver in the docs 2017-09-14 17:29:23 +02:00
muawiakh
f2e1b4ac80 Automation for single node deployment for quickstart
- Change consists of two deployment models:
  - Using Vagrant(single node, with/without docker)
  - Using Ansible(single node, with/without docker)
- Updated quickstart documentation.
- Some WIP comments, which will be addressed later. Depending on the
  requirements.
2017-09-14 14:00:13 +02:00
krish7919 (Krish)
42b1233834 Doc fixes as per comments 2017-09-13 15:54:09 +02:00
krish7919 (Krish)
197a18e0bb Use Tectonic for Kubernetes 2017-09-13 15:54:09 +02:00
michielmulders
43ac6d72d5 Typo satisified -> satisfied 2017-09-13 11:00:15 +02:00
michielmulders
3dab5ae472 Typo requesing -> requesting 2017-09-13 10:58:40 +02:00
Troy McConaghy
3b40dcc197 Added link to new Java driver in the docs 2017-09-12 22:12:12 +02:00
krish7919 (Krish)
ac0dcd090e Bugfix in Deployment config 2017-09-11 11:57:58 +02:00
krish7919 (Krish)
1307f43306 Add livenessProbe 2017-09-11 11:57:58 +02:00
krish7919 (Krish)
f07df50041 BigchainDB Web Proxy to add headers to requests
Currently, the requests from public websites (like
`bigchaindb.com/getstarted` and tutorials.bigchaindb.com/crab) cannot have the
app_id and app_key required to access IPDB in the web page.

We pass such requests through a web proxy that adds the required headers
to any POST requests from `*.bigchaindb.com`.
2017-09-11 11:57:58 +02:00
Troy McConaghy
f003187777 Initial update to changelog for the v1.1 release 2017-09-09 21:21:26 +02:00
krish7919 (Krish)
5fbc3f4a6c Steps to restore from backup 2017-09-07 11:00:03 +02:00
krish7919 (Krish)
9445647be5 MongoDB data dir config change 2017-09-07 11:00:03 +02:00
Krish
2e40ad96f2 Minor fixes to k8s setup (#1735)
* Fix typo in docs

* Minor documentation fixes.

* Update mongodb monitoring agent to latest version.

* Update mongodb backup agent to latest version.

* Bugfix in mongodb backup agent.
2017-08-31 16:57:41 +02:00
Troy McConaghy
4175feb8b7 Merge pull request #1737 from bigchaindb/link-to-ruby-gem-from-docs
Added link to Ruby Gem by @nileshtrivedi
2017-08-31 15:23:19 +02:00
Troy McConaghy
e21f5e6551 Merge branch 'link-to-ruby-gem-from-docs' of github.com:bigchaindb/bigchaindb into link-to-ruby-gem-from-docs 2017-08-31 15:10:18 +02:00
Troy McConaghy
3c1c72f078 Added link to Ruby Gem by @nileshtrivedi
I added a link to the *bigchaindb* Ruby Gem by @nileshtrivedi 
on the *Drivers & Tools* page.
2017-08-31 15:06:09 +02:00
Sylvain Bellemare
1f42adeac4 Pin hypothesis so that it works with regex
related to #1738
2017-08-31 13:45:47 +02:00
Troy McConaghy
71ead91fbb Added link to Ruby Gem by @nileshtrivedi
I added a link to the *bigchaindb* Ruby Gem by @nileshtrivedi 
on the *Drivers & Tools* page.
2017-08-31 10:53:02 +02:00
Tom Carchrae
6271e4f674 persist mongo data between system restarts (don't use /tmp) (#1731) 2017-08-30 18:29:54 +02:00
Ahmed Muawia Khan
e41a378df4 Merge pull request #1720 from bigchaindb/remove-reclaim-policy-k8s-pvc
Remove persistentVolumeReclaimPolicy from the pvc request
2017-08-17 15:12:40 +02:00
Ahmed Muawia Khan
a05cdb4413 Merge pull request #1723 from bigchaindb/run-mma-mba-non-root
Run mongodb monitoring and backup agents as non-root user
2017-08-17 15:12:19 +02:00
Ahmed Muawia Khan
a3de849820 Merge pull request #1724 from bigchaindb/imporve-error-message-entrypoint
Improve error message for all bdb docker entrypoint scripts
2017-08-17 11:27:20 +02:00
Ahmed Muawia Khan
559b8ef7cf Merge branch 'master' into run-mma-mba-non-root 2017-08-17 11:26:57 +02:00
Ahmed Muawia Khan
ea32694435 Merge pull request #1721 from bigchaindb/common-secret-for-ca
Common secret for CA in secret.yaml
2017-08-17 11:07:35 +02:00
Muawia Khan
7658097221 Use env variables names for error messages
- Address comments
2017-08-17 10:46:19 +02:00
Muawia Khan
7ba6334bfc Fix volumeMounts for monitoring and backup agents 2017-08-17 10:31:03 +02:00
Ahmed Muawia Khan
2fc114a596 Merge pull request #1713 from bigchaindb/fix-multi-node-dep
Verify and fix BDB multi node deployment guide
2017-08-17 10:21:40 +02:00
Muawia Khan
8df38ff31c Fix typo in nginx-http-svc name 2017-08-16 16:35:46 +02:00
Muawia Khan
e446c31a41 More changes to multi-node deployment guide
- Integrating changes suggested by Krish.
- Addressing comments on initial commit.
2017-08-16 13:22:09 +02:00
Muawia Khan
d11c100ab5 Improve error message for all bdb docker entrypoint scripts
- If a mandatory variable is not specified, it will exit with the relevant
code and error message.
- For more verbosity, we will also echo the values for all the mandatory
variables.
2017-08-16 13:15:24 +02:00
Muawia Khan
0cf46b331f Verify and fix BDB multi node deployment guide
- Documentation support to add a new BDB node to an existing
  replica set, using x.509 certificates and SSL/TSL connections, across
  geographically dispersed clusters.
- Fix some documentation issues and add more references i.e.
  specifically about signing of MongoDB member certificates.
- Minor fixes for nginx-https-dep.yaml(invalid configMap var)
- Reconfigure nginx keep_alive between MongoDB front and backend ports.
- Editor removed whitespaces
2017-08-16 10:27:17 +02:00
Muawia Khan
650177c50e Run mongodb monitoring and backup agents as non-root user
- We need to modify the read permissions on the secrets and allow
the mongodb-mms-agent to read the credentials.
2017-08-15 15:59:08 +02:00
Muawia Khan
fbee5db40f Common secret for CA in secret.yaml
- Creating a common secret for CA, since all the members of the replica set
and the clients need to have a common CA, moving all the relevant configuration
to a common secret.
- Modifying Dockerfiles for some components, once changes are approved
we will publish the new images.
- No documentation changes required.
2017-08-15 14:26:47 +02:00
Muawia Khan
04b84f6ab4 Remove persistentVolumeReclaimPolicy from the pvc request
- Reclaim policy can only be specified when we explicitly create
a persistent Volume. Removing this from a persistent volume claim
request yaml.
2017-08-15 10:07:50 +02:00
vrde
e7640feaec
Merge branch 'block-publisher-plugin-arch' 2017-08-11 11:24:07 +02:00
vrde
2ee85d6c4a
Update URL to plugin example 2017-08-10 12:04:33 +02:00
Troy McConaghy
dfd6449342 Update cryptography.md 2017-08-09 18:48:44 +02:00
vrde
229a476aa0
Fix typos 2017-08-09 17:38:44 +02:00
Krish
26f43c15eb Update MongoDB Backup Agent to v5.7.0.641 (#1718) 2017-08-09 17:03:35 +02:00
vrde
0f139a1999
Fix typo 2017-08-09 16:35:12 +02:00
vrde
c4853f54b9
Add more coverage 2017-08-09 16:23:03 +02:00
vrde
05ff9cd61f
Add docs 2017-08-09 16:14:14 +02:00
vrde
a0cbb63db8
Rename things, add tests 2017-08-09 10:51:30 +02:00
Krish
3ce4a3d0c3 User service token instead of provider key in threescale-credentials kubernetes secret (#1717) 2017-08-09 10:41:51 +02:00
Troy McConaghy
1e06bd3aac Merge pull request #1711 from bigchaindb/docs/root-docs-update
Updates to the root docs
2017-08-09 10:31:15 +02:00
Troy McConaghy
2dc92a2851 Added blurb about economic incentives to help achieve immutability 2017-08-09 10:19:32 +02:00
Krish
c2d726d584 Support proper Websocket host and port settings in root API endpoint (#1715)
* Support proper Websocket host and port settings in root API endpoint

* Documentation change
2017-08-09 09:40:41 +02:00
Krish
3ec4153375 Support for advertised host, port, scheme for Websockets (#1703)
* Support for advertised host, port, scheme for Websockets

* Update docs

* Add a docstring

* Set env vars in Dockerfile-dev too
2017-08-08 12:04:58 +02:00
vrde
21a7da1c9d
Plugins can subscribe to specific events 2017-08-08 11:28:35 +02:00
vrde
8d72421d7c
Add PubSub 2017-08-08 11:28:35 +02:00
Troy McConaghy
e929658f14 Updated the page about BDB & smart contracts 2017-08-05 11:37:40 +02:00
Troy McConaghy
01453bc806 Updated text linking to the page about immutability 2017-08-05 11:33:06 +02:00
Troy McConaghy
e3c923958c Updated our stance on BFT in bft.md 2017-08-05 11:27:37 +02:00
Troy McConaghy
5864415d96 Updated page about how BigchainDB is immutable 2017-08-05 11:21:08 +02:00
Troy McConaghy
29776554cf Emphasize MongoDB over RethinkDB in terminology.md 2017-08-05 11:02:01 +02:00
Troy McConaghy
733f52be6c For Python stuff, we follow Python's version of SemVer 2017-08-05 10:59:21 +02:00
Troy McConaghy
74b4628b75 Update decentralized.md 2017-08-03 14:48:08 +02:00
vrde
f5f964d07a Merge pull request #1644 from ketanbhatt/feat/1546/http-api-logger-logs-path-and-method
HTTP API Logger logs request path and method too
2017-08-03 09:53:18 +02:00
vrde
6a020ef49b Merge pull request #1700 from bigchaindb/semver-policy
Update SemVer policy
2017-08-03 09:24:30 +02:00
vrde
ff6f9cf58f
Go back to Python SemVer 2017-08-03 09:07:05 +02:00
vrde
3efc5725b5
Add websocket interface 2017-08-03 09:07:05 +02:00
vrde
bcc4dd4b70
Add configuration defaults 2017-08-03 09:07:05 +02:00
vrde
7756181974
Add configuration to the Public API definition 2017-08-03 09:07:05 +02:00
vrde
7f42e0a3c3
Update SemVer policy 2017-08-03 09:07:04 +02:00
Sylvain Bellemare
024d3ada8f Update docs for docker-compose.rdb.yml change 2017-08-02 17:38:18 +02:00
Sylvain Bellemare
4e2423c3de Use more explicit names for docker-compose files 2017-08-02 17:38:18 +02:00
Sylvain Bellemare
6f1ad664fd Update image for k8s 2017-08-02 16:15:00 +02:00
Troy McConaghy
31c28c5d01 Merge pull request #1691 from bigchaindb/docs/1653/fix-old-http-response-example
Replaced old response to Root URL with a description of what to expect
2017-08-02 10:38:19 +02:00
Troy McConaghy
f2da3e0daa Update RELEASE_PROCESS.md 2017-08-02 10:00:09 +02:00
Troy McConaghy
f0a683df8a Added step to REL 2017-08-02 09:59:04 +02:00
michielmulders
00bbf479ed Merge pull request #1687 from bigchaindb/michielmulders-fix-verification
Update quickstart.md BDB server with verification and note to not close terminal (mongo)
2017-08-01 13:42:03 +02:00
michielmulders
b7426e52b2 Update Quickstart with requested changes
addition of 'but' 
removal trailing phrase inside parentheses
Url replaced with URL as it's still an acronym so it's written with capital letters
2017-08-01 13:40:38 +02:00
Rodolphe Marques
640c9cc5d6 Merge pull request #1643 from ketanbhatt/chore/679/rename-variable-validity
Rename validity to blocks_validity_status
2017-08-01 09:44:58 +02:00
Troy McConaghy
15ee56c114 Merge pull request #1706 from ivanbakel/err_line
Fixed error line missing from transaction.py
2017-07-31 18:28:50 +02:00
Isaac van Bakel
cb5125ecfa Fixed error line missing from transaction.py
The second instance of the recipients error message is missing a line,
making the message meaningless.
2017-07-28 20:35:06 +01:00
Troy McConaghy
7db977cdb5 Added how block order comes from MongoDB 2017-07-26 10:06:24 +02:00
Ahmed Muawia Khan
6f2c61d778 Merge pull request #1699 from bigchaindb/minor-update-k8s-prod-guide
Remove an invalid message in the k8s production deployment guide
2017-07-25 17:30:29 +02:00
Muawia Khan
64a81b3a2b Fix and invalid command in k8s production deployment guide
- The guide is incorrect and expects and error message in the
nginx with https+3scale integration section:
$ curl -X GET https://<cluster-fqdn>
The above command should not return an error since this workflow is supported.
Updating this to the relevant command that will return the expected response
for sanity checking.
$ curl -X GET http://<cluster-fqdn>:27017
2017-07-25 17:08:55 +02:00
Troy McConaghy
53b15aa723 Merge pull request #1654 from bigchaindb/docs/1615/explain-fulfillment-uri
Wrote more about how to calculate a fulfillment string
2017-07-24 16:53:15 +02:00
Troy McConaghy
0f0900102b Merge pull request #1671 from bigchaindb/docs/log-analytics-setup-via-gui
Added docs about OMS logging setup via web browser
2017-07-21 17:18:29 +02:00
Troy McConaghy
a0560fcd4c Merge pull request #1640 from bigchaindb/more-release-process-refinement
More refinements to the release process
2017-07-21 17:17:40 +02:00
Ahmed Muawia Khan
84ff0ad4a5 Merge pull request #1690 from bigchaindb/update-azure-kubernetes-docs
Update guide to setup bdb+kubernetes+azure setup
2017-07-21 15:38:16 +02:00
Muawia Khan
b56f8a6213 Update guide to setup bdb+kubernetes+azure setup
-- Fixed typos in the guide
-- Fixed some syntax errors in commandline instructions
-- Fixed strucuture of sample jsons
-- Fixed bugs in nginx-https-dep file, it was trying to access
an invalid variable in the configmap.
-- Improved some docs to give more clarity for the user.
Atleast all the issues I faced. :)
2017-07-21 15:01:20 +02:00
Ahmed Muawia Khan
f72a35ff11 Merge pull request #1682 from bigchaindb/fix-deps-server-quickstart
Keep minimal number of os-level deps for server quickstart
2017-07-21 14:57:09 +02:00
Muawia Khan
b4d1554612 Keep minimal number of os-level deps for server quickstart
-- Only libffi-dev and libssl-dev are enough for the bdb server
quickstart installation and they pull any dependant packages
recursively via apt.
2017-07-21 14:27:13 +02:00
Krish
a27cfdd89c Updating dependencies (#1692) 2017-07-21 13:36:29 +02:00
Troy McConaghy
5125997b2b Replaced old response to Root URL with a description of what to expect 2017-07-21 12:34:08 +02:00
Troy McConaghy
d323ad73c2 Merge pull request #1686 from bigchaindb/update-changelog-on-master-for-1.0.1
Updated the changelog on master for v1.0.1
2017-07-21 09:08:08 +02:00
michielmulders
21142f1ea0 Update quickstart.md with minor details
At point D, you start the mongo shell which is listening on port 27017 for incoming connections from BDB.
At point E, you don't mention to open a new terminal because you want to keep the mongo shell alive (or run it in background with addition of '&', however I prefer to see the mongo output). Being stupid me, I shut down the terminal which resulted in not being able to start BDB.

Beside that, I added a verification step to make sure that BDB server is running correctly.
2017-07-20 22:56:36 +02:00
Sylvain Bellemare
2f4d9fa171 Update changelog for v1.0.1
(cherry picked from commit 37d9fd72d05cf6aff4d5e22d8932f8b634838262)
2017-07-20 12:45:28 +02:00
Krish
8e6a94e158 Change imagePullPolicy in k8s configs (#1680) 2017-07-19 20:14:56 +02:00
Krish
dad96fe246 Fix broken travis build (#1684)
- Use RethinkDB and MongoDB docker containers rather than manually
install packages.
2017-07-19 18:16:48 +02:00
Krish
4c8b0fc828 Healthchecks for NGINX in nginx-http-dep.yaml and dev-setup/nginx-http.yaml (#1679) 2017-07-17 18:59:11 +02:00
Krish
e0efc2286a Simpler MongoDB Instance Configuration in K8s (#1678)
* Simpler configuration of MongoDB instance in a node

* Update docs for MDB configuration
2017-07-17 17:57:13 +02:00
Krish
9116836e4c Simpler BigchainDB Instance Configuration in K8s (#1677)
* Simpler configuration of BigchainDB instance in a node

* Update docs for BDB configuration

* Changes as per @ttmc's comments
2017-07-17 17:29:51 +02:00
Troy McConaghy
3946ab2f43 Merge pull request #1668 from bigchaindb/docs/1651/explain-condition-contents
New docs page regarding the contents of a condition
2017-07-17 14:48:03 +02:00
Krish
c640313003 Remove 3scale port number from configs (#1676)
* Remove 'threescale-api-port' from all configs in node setup

* Update docs - remove references to threescale-api-port

* Fix typo
2017-07-17 14:46:06 +02:00
Krish
b7e13fd087 Secure WebSocket Support (#1619)
* Remove support for whitelist

* Rename nginx to nginx-api

* Remove websocket support from nginx-api

* Change nginx to nginx-api service
The nginx-api service will proxy requests to the BigchainDB HTTP API.

* Rename ngx-instance-0 to ngx-api-instance-0 in nginx_3scale

* Update nginx-api service base docker image and README

* Add nginx-ws service to support Websocket

* Add config files for simple dev setup

* WS support with split NGINX

* NGINX module as single entrypoint into the cluster.

* Tested HTTP and WS with latest configs

* Openresty as separate service

* Remove upstream api port as configuration parameter

* Changes while testing

* Adding READMEs for nginx-http and nginx-https modules

* Documentation update

* Change 'Openresty' to 'OpenResty'.
2017-07-17 13:46:05 +02:00
Troy McConaghy
f576894b4c Merge pull request #1652 from bigchaindb/resolve-issue-1649
Removed old Terraform & Ansible templates
2017-07-17 12:08:34 +02:00
Krish
6bd6e7fddb Update MongoDB Backup Agent to v5.6.0.624 (#1674) 2017-07-14 10:02:38 +02:00
Troy McConaghy
3c76cd5f77 added docs re OMS logging setup via web browser 2017-07-13 17:21:18 +02:00
Ahmed Muawia Khan
8085f74075 Merge pull request #1663 from bigchaindb/k8s-mongo-memory-limit-fix
Fix for MongoDB hitting memory limit on k8s
2017-07-13 15:42:34 +02:00
Troy McConaghy
d6221b3d78 New docs page re contents of a condition 2017-07-13 12:03:03 +02:00
muawiakh
494e9a071d Fixing installation of bigchaindb 1.0.0 pyPackage for quickstart
- Quick start setup was broken because of a race condition with
using cryptoconditions in setup_requires and install_requires and
for a fresh Ubuntu 16.04 setup initialization of BigchainDB node
the python package installation fails due to package conflicts.
- Rest of the details are captured in the github issue #1657
2017-07-12 18:05:07 +02:00
muawiakh
b0106c0203 Fix for MongoDB hitting memory limit on k8s
- MongoDB StatefulSet hitting memory limit, so k8s restarts it.
We have had multiple instances of restarts lately.
-  Changing it to 3.5 GB, data and reasoning to back it up
is mentioned in the ticket #1655
2017-07-12 16:17:50 +02:00
Ahmed Muawia Khan
690d64cb8d Merge pull request #1648 from bigchaindb/minor-quickstart-doc-fix
Minor changes in quickstart guide
2017-07-12 13:04:32 +02:00
muawiakh
5526335aab Minor changes in quickstart guide
- Add build-essential and libssl-dev as pre-reqs
for bigchaindb installation
2017-07-12 10:12:11 +02:00
Troy McConaghy
66c0f94f78 Merge pull request #1646 from CsterKuroi/bug/1645/add-missing-table-assets
Bug/1645/add missing table assets
2017-07-11 17:39:23 +02:00
Troy McConaghy
ab2b8aee21 Wrote more about how to calculate a fulfillment string 2017-07-11 13:34:48 +02:00
Troy McConaghy
157e2683de Removed old Terraform & Ansible templates 2017-07-11 11:07:43 +02:00
KURO1
3e6948bca4 Add the missing table asset in backend.schema 2017-07-10 17:54:04 +08:00
Ketan Bhatt
684fffe917 HTTP API Logger logs request path and method too 2017-07-09 16:44:21 +05:30
Ketan Bhatt
4056f315ae Rename validity to blocks_validity_status 2017-07-09 12:22:39 +05:30
libscott
e8ee39463f MongoDB socket timeout to handle master re-election (#1638)
* add a socket timeout so that changefeeds can reconnect if theres a re-election

* fix threshold max depth at 100
2017-07-06 19:50:28 +02:00
Sylvain Bellemare
c80ba6f3b5 Fix mistakenly changed MongoDB version 2017-07-06 14:49:21 +02:00
Troy McConaghy
23d0994579 Merge pull request #1639 from bigchaindb/switch-version-in-version-py-to-1.1.0.dev
Switch version in version.py to 1.1.0.dev
2017-07-06 10:09:38 +02:00
Troy McConaghy
6d9cc17861 Push to GitHub, not 'master' 2017-07-05 17:03:35 +02:00
Troy McConaghy
f7f10130c9 More improvements to RELEASE_PROCESS.md 2017-07-05 17:00:17 +02:00
Troy McConaghy
74c57d3e2b Changed version in version.py to 1.1.0.dev 2017-07-05 15:36:22 +02:00
610 changed files with 29803 additions and 23873 deletions

14
.ci/entrypoint.sh Executable file
View File

@ -0,0 +1,14 @@
#!/bin/bash
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
set -e -x
if [[ ${BIGCHAINDB_CI_ABCI} == 'enable' ]]; then
sleep 3600
else
bigchaindb -l DEBUG start
fi

View File

@ -1,7 +1,12 @@
#!/bin/bash
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
set -e -x
if [[ -z ${TOXENV} ]]; then
codecov
if [[ -z ${TOXENV} ]] && [[ ${BIGCHAINDB_CI_ABCI} != 'enable' ]] && [[ ${BIGCHAINDB_ACCEPTANCE_TEST} != 'enable' ]]; then
codecov -v -f htmlcov/coverage.xml
fi

View File

@ -1,6 +1,16 @@
#!/bin/bash
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
apt-get update -qq
wget https://github.com/miloyip/rapidjson/archive/v1.1.0.tar.gz -O /tmp/v1.1.0.tar.gz
tar -xvf /tmp/v1.1.0.tar.gz
cp -r $PWD/rapidjson-1.1.0/include/rapidjson /usr/include/
if [[ -z ${TOXENV} ]]; then
sudo apt-get update
sudo apt-get -y -o Dpkg::Options::="--force-confnew" install docker-ce
sudo rm /usr/local/bin/docker-compose
curl -L https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-`uname -s`-`uname -m` > docker-compose
chmod +x docker-compose
sudo mv docker-compose /usr/local/bin
fi

View File

@ -1,34 +1,18 @@
#!/bin/bash
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
set -e -x
if [[ "${TOXENV}" == *-rdb ]]; then
rethinkdb --daemon
elif [[ "${BIGCHAINDB_DATABASE_BACKEND}" == mongodb && \
-z "${BIGCHAINDB_DATABASE_SSL}" ]]; then
# Connect to MongoDB on port 27017 via a normal, unsecure connection if
# BIGCHAINDB_DATABASE_SSL is unset.
# It is unset in this case in .travis.yml.
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.4.4.tgz -O /tmp/mongodb.tgz
tar -xvf /tmp/mongodb.tgz
mkdir /tmp/mongodb-data
${PWD}/mongodb-linux-x86_64-ubuntu1404-3.4.4/bin/mongod \
--dbpath=/tmp/mongodb-data --replSet=bigchain-rs &> /dev/null &
elif [[ "${BIGCHAINDB_DATABASE_BACKEND}" == mongodb && \
"${BIGCHAINDB_DATABASE_SSL}" == true ]]; then
# Connect to MongoDB on port 27017 via TLS/SSL connection if
# BIGCHAINDB_DATABASE_SSL is set.
# It is set to 'true' here in .travis.yml. Dummy certificates for testing
# are stored under bigchaindb/tests/backend/mongodb-ssl/certs/ directory.
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1404-3.4.4.tgz -O /tmp/mongodb-ssl.tgz
tar -xvf /tmp/mongodb-ssl.tgz
mkdir /tmp/mongodb-ssl-data
${PWD}/mongodb-linux-x86_64-ubuntu1404-3.4.4/bin/mongod \
--dbpath=/tmp/mongodb-ssl-data \
--replSet=bigchain-rs \
--sslAllowInvalidHostnames \
--sslMode=requireSSL \
--sslCAFile=$TRAVIS_BUILD_DIR/tests/backend/mongodb-ssl/certs/ca.crt \
--sslCRLFile=$TRAVIS_BUILD_DIR/tests/backend/mongodb-ssl/certs/crl.pem \
--sslPEMKeyFile=$TRAVIS_BUILD_DIR/tests/backend/mongodb-ssl/certs/test_mdb_ssl_cert_and_key.pem &> /dev/null &
if [[ -z ${TOXENV} ]]; then
if [[ ${BIGCHAINDB_CI_ABCI} == 'enable' ]]; then
docker-compose up -d bigchaindb
else
docker-compose up -d bdb
fi
fi

View File

@ -1,4 +1,9 @@
#!/bin/bash
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
set -e -x
@ -6,7 +11,11 @@ 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
elif [[ $BIGCHAINDB_INTEGRATION_TEST == 'enable' ]]; then
docker-compose build bigchaindb python-driver
else
pip install .[test]
docker-compose build --no-cache bigchaindb
pip install --upgrade codecov
fi

View File

@ -1,17 +1,18 @@
#!/bin/bash
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
set -e -x
if [[ -n ${TOXENV} ]]; then
tox -e ${TOXENV}
elif [[ "${BIGCHAINDB_DATABASE_BACKEND}" == mongodb && \
-z "${BIGCHAINDB_DATABASE_SSL}" ]]; then
# Run the full suite of tests for MongoDB over an unsecure connection
pytest -sv --database-backend=mongodb --cov=bigchaindb
elif [[ "${BIGCHAINDB_DATABASE_BACKEND}" == mongodb && \
"${BIGCHAINDB_DATABASE_SSL}" == true ]]; then
# Run a sub-set of tests over SSL; those marked as 'pytest.mark.bdb_ssl'.
pytest -sv --database-backend=mongodb-ssl --cov=bigchaindb -m bdb_ssl
elif [[ ${BIGCHAINDB_CI_ABCI} == 'enable' ]]; then
docker-compose exec bigchaindb pytest -v -m abci
elif [[ ${BIGCHAINDB_ACCEPTANCE_TEST} == 'enable' ]]; then
./run-acceptance-test.sh
else
pytest -sv -n auto --cov=bigchaindb
docker-compose exec bigchaindb pytest -v --cov=bigchaindb --cov-report xml:htmlcov/coverage.xml
fi

9
.gitattributes vendored
View File

@ -1,9 +0,0 @@
deploy-cluster-aws export-ignore
docs export-ignore
ntools export-ignore
tests export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
*.md export-ignore
codecov.yml export-ignore

14
.github/CONTRIBUTING.md vendored Normal file
View File

@ -0,0 +1,14 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# How to Contribute to the BigchainDB Project
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).
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.

20
.github/ISSUE_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,20 @@
# 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.
# What Should Go in a Bug Report
- What computer are you on (hardware)?
- What operating system are you using, including version. e.g. Ubuntu 14.04? Fedora 23?
- What version of BigchainDB software were you using? Is that the latest version?
- What, exactly, did you do to get to the point where you got stuck? Describe all the steps so we can get there too. Show screenshots or copy-and-paste text to GitHub.
- Show what actually happened.
- Say what you tried to do to resolve the problem.
- Provide details to convince us that it matters to you. Is it for a school project, a job, a contract with a deadline, a child who needs it for Christmas?
We will do our best but please understand that we don't have time to help everyone, especially people who don't care to help us help them. "It doesn't work." is not going to get any reaction from us. We need _details_.
Tip: Use Github code block formatting to make code render pretty in GitHub. To do that, put three backticks followed by a string to set the type of code (e.g. `Python`), then the code, and then end with three backticks. There's more information about [inserting code blocks](https://help.github.com/articles/creating-and-highlighting-code-blocks/) in the GitHub help pages.

30
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
**Expected behavior**
A clear and concise description of what you expected to happen.
**Logs or terminal output**
If applicable, add add textual content to help explain your problem.
**Desktop (please complete the following information):**
- Distribution: [e.g. Ubuntu 18.04]
- Bigchaindb version:
- Tendermint version:
- Mongodb version:
- Python full version: [e.g. Python 3.6.6]
**Additional context**
Add any other context about the problem here.

18
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@ -0,0 +1,18 @@
Make sure the title of this pull request has the form:
**Problem: A short statement of the problem.**
## Solution
A short statement about how this PR solves the **Problem**.
## Issues Resolved
What issues does this PR resolve, if any? Please include lines like the following (i.e. "Resolves #NNNN), so that when this PR gets merged, GitHub will automatically close those issues.
Resolves #NNNN
Resolves #MMMM
## BEPs Implemented
What [BEPs](https://github.com/bigchaindb/beps) does this pull request implement, if any?

37
.gitignore vendored
View File

@ -6,6 +6,21 @@ __pycache__/
# C extensions
*.so
# Swap -- copypasta from https://github.com/github/gitignore/blob/master/Global/Vim.gitignore
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Distribution / packaging
.Python
env/
@ -40,6 +55,7 @@ htmlcov/
.coverage
.coverage.*
.cache
.pytest_cache/
nosetests.xml
coverage.xml
*.cover
@ -65,22 +81,19 @@ target/
# pyenv
.python-version
# Some files created when deploying a cluster on AWS
deploy-cluster-aws/conf/rethinkdb.conf
deploy-cluster-aws/confiles/
deploy-cluster-aws/client_confile
deploy-cluster-aws/hostlist.py
deploy-cluster-aws/ssh_key.py
# Ansible-specific files
ntools/one-m/ansible/hosts
ntools/one-m/ansible/ansible.cfg
# Just in time documentation
docs/server/source/schema
docs/server/source/http-samples
# Terraform state files
# See https://stackoverflow.com/a/41482391
terraform.tfstate
terraform.tfstate.backup
# tendermint data
tmdata/data
network/*/data
# Docs that are fetched at build time
docs/contributing/source/cross-project-policies/*.md
.DS_Store

25
.pre-commit-config.yaml Normal file
View File

@ -0,0 +1,25 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: v1.1.1
hooks:
- id: trailing-whitespace
args: ['--no-markdown-linebreak-ext']
- id: check-merge-conflict
- id: debug-statements
- id: check-added-large-files
- id: flake8
- repo: git://github.com/chewse/pre-commit-mirrors-pydocstyle
sha: v2.1.1
hooks:
- id: pydocstyle
# 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/)'

11
.readthedocs.yml Normal file
View File

@ -0,0 +1,11 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
build:
image: latest
python:
version: 3.6
pip_install: true

View File

@ -1,49 +1,70 @@
# Copyright © 2020, 2021 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
sudo: required
dist: focal
services:
- docker
language: python
cache: pip
python:
- 3.5
- 3.6
- 3.7
- 3.8
env:
- TOXENV=flake8
- TOXENV=docsroot
- TOXENV=docsserver
global:
- DOCKER_COMPOSE_VERSION=1.29.2
matrix:
- TOXENV=flake8
- TOXENV=docsroot
matrix:
fast_finish: true
exclude:
- python: 3.5
env: TOXENV=flake8
- python: 3.5
env: TOXENV=docsroot
- python: 3.5
env: TOXENV=docsserver
include:
- python: 3.5
addons:
rethinkdb: '2.3.5'
env: BIGCHAINDB_DATABASE_BACKEND=rethinkdb
- python: 3.5
- python: 3.6
env:
- BIGCHAINDB_DATABASE_BACKEND=mongodb
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
- BIGCHAINDB_DATABASE_SSL=
- python: 3.6
addons:
rethinkdb: '2.3.5'
env: BIGCHAINDB_DATABASE_BACKEND=rethinkdb
- python: 3.6
env:
- BIGCHAINDB_DATABASE_BACKEND=mongodb
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
- BIGCHAINDB_DATABASE_SSL=
- python: 3.5
env:
- BIGCHAINDB_DATABASE_BACKEND=mongodb
- BIGCHAINDB_DATABASE_SSL=true
- BIGCHAINDB_CI_ABCI=enable
- python: 3.6
env:
- BIGCHAINDB_DATABASE_BACKEND=mongodb
- BIGCHAINDB_DATABASE_SSL=true
- BIGCHAINDB_ACCEPTANCE_TEST=enable
- python: 3.7
env:
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
- BIGCHAINDB_DATABASE_SSL=
- python: 3.7
env:
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
- BIGCHAINDB_DATABASE_SSL=
- BIGCHAINDB_CI_ABCI=enable
- python: 3.7
env:
- BIGCHAINDB_ACCEPTANCE_TEST=enable
- python: 3.8
env:
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
- BIGCHAINDB_DATABASE_SSL=
- python: 3.8
env:
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
- BIGCHAINDB_DATABASE_SSL=
- BIGCHAINDB_CI_ABCI=enable
- python: 3.8
env:
- BIGCHAINDB_ACCEPTANCE_TEST=enable
before_install: sudo .ci/travis-before-install.sh

View File

@ -1,9 +1,18 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# Change Log (Release Notes)
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).
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).
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).
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).
For reference, the possible headings are:
* **Added** for new features.
@ -13,8 +22,439 @@ For reference, the possible headings are:
* **Fixed** for any bug fixes.
* **Security** to invite users to upgrade in case of vulnerabilities.
* **External Contributors** to list contributors outside of BigchainDB GmbH.
* **Known Issues**
* **Notes**
## [2.2.2] - 2020-08-12
### Security
Several dependencies updated including Flask that had vulnerability.
### Fixed
* Updated priv_validator key format in stack script (#2707)
### External Contributors
* @aostrun - [#2708](https://github.com/bigchaindb/bigchaindb/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.
## [2.2.0] - 2020-02-20
### Added
Support for multiple ABCI versions.
## [2.1.0] - 2019-11-06
### Added
Option for last transaction retrieval added.
## [2.0] - 2019-09-26
### Changed
Migrated from Tendermint 0.22.8 to 0.31.5.
## [2.0 Beta 9] - 2018-11-27
### 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)
### 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)
### 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)
## [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)
### Fixed
* Fixed a typo in the Kubernetes ConfigMap template. [Pull Request #2583](https://github.com/bigchaindb/bigchaindb/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)
## [2.0 Beta 7] - 2018-09-28
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)
### 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)
### Removed
Benchmark logs. [Pull request #2565](https://github.com/bigchaindb/bigchaindb/pull/2565)
### Fixed
A bug caused by an incorrect MongoDB query. [Pull request #2567](https://github.com/bigchaindb/bigchaindb/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)
## [2.0 Beta 6] - 2018-09-17
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)
### 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)
### 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)
### 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)
### External Contributors
@danacr - [Pull request #2447](https://github.com/bigchaindb/bigchaindb/pull/2447)
### Notes
The docs section titled "Production Deployment Template" was renamed to "Kubernetes Deployment Template" and we no longer consider it the go-to deployment template. The "Simple Deployment Template" is simpler, easier to understand, and less expensive (unless you are with an organization that already has a big Kubernetes cluster).
## [2.0 Beta 5] - 2018-08-01
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).
### 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).
## [2.0 Beta 4] - 2018-07-30
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).
### 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).
### 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).
## [2.0 Beta 3] - 2018-07-18
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)
## [2.0 Beta 2] - 2018-07-16
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)
### 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)
### Removed
Removed all support and code for the old backlog_reassign_delay setting. [Pull request #2332](https://github.com/bigchaindb/bigchaindb/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)
### External Contributors
@hrntknr - [Pull request #2331](https://github.com/bigchaindb/bigchaindb/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.
### 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)
## [2.0 Beta 1] - 2018-06-01
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)
### 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)
* 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.
* We checked, and BigchainDB 2.0 Beta 1 works with MongoDB 3.6 (and 3.4).
* Support for RethinkDB is completely gone.
## [2.0 Alpha 6] - 2018-05-17
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)
### 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)
### Notes
We ran all our tests using MongoDB 3.6 and they all passed, so it seems safe to use BigchainDB with MongoDB 3.6 from now on.
## [2.0 Alpha 5] - 2018-05-11
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).
## [2.0 Alpha 4] - 2018-05-09
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)
### Fixed
[Pull request #2270](https://github.com/bigchaindb/bigchaindb/pull/2270) resolved [issue #2269](https://github.com/bigchaindb/bigchaindb/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)
## [2.0 Alpha 3] - 2018-05-03
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)
### Fixed
Re-enabled multi-threading. [Pull request #2258](https://github.com/bigchaindb/bigchaindb/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.
### Notes
We were focused on getting the public BigchainDB Testnet stable during the development of BigchainDB 2.0 Alpha 3, and we think we largely succeeded. Because of that focus, we delayed the deployment of an internal test network until later. It would have had the same instabilities as the public BigchainDB Testnet anyway. In the future, we'll always test a new version of BigchainDB on our internal test network before deploying it on the public BigchainDB Testnet. (That wasn't possible this time around, because there was no old/stable version of BigchainDB 2.n to run on the public BigchainDB Testnet while we tested BigchainDB 2.[n+1] internally.)
## [2.0 Alpha 2] - 2018-04-18
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)
### 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)
### Known Issues
* If BigchainDB Server crashes and then is restarted, Tendermint Core won't try to reconnect to BigchainDB Server and so all operations requiring that connection won't work. We only understood this recently. We'll write a blog post explaining what we intend to do about it.
* The known issues in 2.0 Alpha (listed below) are still there.
## [2.0 Alpha] - 2018-04-03
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)
* _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.
### Known Issues
We intend to resolve these issues before releasing the final BigchainDB 2.0:
* There's a known Heisenbug that (sometimes) arises and we found that making the BigchainDB webserver single-threaded prevents that bug from causing problems. We intend to resolve that bug, but in the meantime our temporary workaround is to change the _default_ webserver configuration settings to single-threaded mode, i.e. `BIGCHAINDB_SERVER_WORKERS=1` and `BIGCHAINDB_SERVER_THREADS=1`.
* Issues sometimes happen when a large transaction is sent to a BigchainDB network.
## [1.3] - 2017-11-21
Tag name: v1.3.0
### Added
* Metadata full-text search. [Pull request #1812](https://github.com/bigchaindb/bigchaindb/pull/1812)
### Notes
* Improved documentation about blocks and votes. [Pull request #1855](https://github.com/bigchaindb/bigchaindb/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)
### 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)
### Notes
* Many changes were made to the Kubernetes-based production deployment template and code.
## [1.1] - 2017-09-26
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)
### 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)
### 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)
### 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
* 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)
## [1.0.1] - 2017-07-13
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).
* Changefeed hanging when MongoDB primary node is turned off.
[Pull request #1638](https://github.com/bigchaindb/bigchaindb/pull/1638).
* Missing `assets` tables for RethinkDB backend.
[Pull request #1646](https://github.com/bigchaindb/bigchaindb/pull/1646).
* Cryptoconditions version mismatch.
[Pull request #1659](https://github.com/bigchaindb/bigchaindb/pull/1659).
## [1.0.0] - 2017-07-05
Tag name: v1.0.0
@ -42,7 +482,7 @@ Tag name: v1.0.0rc1
[#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)
* 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)
@ -58,7 +498,7 @@ Tag name: v1.0.0rc1
* 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)
* 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)
@ -98,7 +538,7 @@ Tag name: v0.10.3
Tag name: v0.10.2
### Added
* Add Cross Origin Resource Sharing (CORS) support for the HTTP API.
* Add Cross Origin Resource Sharing (CORS) support for the HTTP API.
[Commit 6cb7596](https://github.com/bigchaindb/bigchaindb/commit/6cb75960b05403c77bdae0fd327612482589efcb)
### Fixed
@ -269,7 +709,7 @@ Tag name: v0.8.1
### Fixed
- Workaround for rapidjson problem with package metadata extraction
(https://github.com/kenrobbins/python-rapidjson/pull/52).
(https://github.com/kenrobbins/python-rapidjson/pull/52).
## [0.8.0] - 2016-11-29
@ -294,7 +734,7 @@ Tag name: v0.8.0
- 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)
- 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
- 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)
@ -362,7 +802,7 @@ committed: Oct 28, 2016, 4:00 PM GMT+2
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/<txid>` 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)
- 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)
### External Contributors
- @MinchinWeb - [Pull Request #696](https://github.com/bigchaindb/bigchaindb/pull/696)
@ -390,11 +830,11 @@ committed: Oct 28, 2016, 4:00 PM GMT+2
[#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),
[#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),
[#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
@ -519,7 +959,7 @@ committed: June 15, 2016, 1:42 PM GMT+2
### 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)
- Updated cryptoconditions API usage: [Pull Request #373](https://github.com/bigchaindb/bigchaindb/pull/373)
## [0.4.1] - 2016-06-13
@ -564,7 +1004,7 @@ committed: May 27, 2016, 1:42 PM GMT+2
### 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
- 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),
@ -612,18 +1052,18 @@ committed: April 26, 2016, 11:09 AM GMT+2
- 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)
- AWS deployment scripts: Pull Requests
- 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)
- Signatures using Ed25519: Pull Requests
- 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)
- HTTP Server & Web API: Pull Requests
- 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),
@ -642,7 +1082,7 @@ committed: April 26, 2016, 11:09 AM GMT+2
- Bug related to running the `bigchaindb-benchmark load` on docker [Pull Request #225](https://github.com/bigchaindb/bigchaindb/pull/225)
## External Contributors
- [@thedoctor](https://github.com/thedoctor): Pull Requests
- [@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)
@ -658,8 +1098,8 @@ committed: April 20, 2016, 3:31 PM GMT+2
## [0.1.4] - 2016-02-22
Tag name: v0.1.4
= commit: c4c850f480bc9ae72df2a54f81c0825b6fb4ed62
Tag name: v0.1.4
= commit: c4c850f480bc9ae72df2a54f81c0825b6fb4ed62
committed: Feb 22, 2016, 11:51 AM GMT+1
### Added
@ -680,8 +1120,8 @@ committed Feb 16, 2016, 11:37 AM GMT+1
## [0.1.2] - 2016-02-15
Tag name: v0.1.2
= commit d2ff24166d69dda68dd7b4a24a88279b1d37e222
Tag name: v0.1.2
= commit d2ff24166d69dda68dd7b4a24a88279b1d37e222
committed Feb 15, 2016, 2:23 PM GMT+1
### Added
@ -691,8 +1131,8 @@ committed Feb 15, 2016, 2:23 PM GMT+1
- Fix exception when running `start`: [Pull Request #32](https://github.com/bigchaindb/bigchaindb/pull/32) resolved [Issue #35]
## [0.1.1] - 2016-02-15
Tag name: v0.1.1
= commit 2a025448b29fe7056760de1039c73bbcfe992461
Tag name: v0.1.1
= commit 2a025448b29fe7056760de1039c73bbcfe992461
committed Feb 15, 2016, 10:48 AM GMT+1
### Added

View File

@ -1,3 +1,10 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# Contributor Code of Conduct
As contributors and maintainers of this project, and in the interest of
@ -35,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 [conduct@bigchaindb.com](mailto:conduct@bigchaindb.com). All
reported by contacting a project maintainer at [contact@bigchaindb.com](mailto:contact@bigchaindb.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

View File

@ -1,163 +0,0 @@
# How to Contribute to the BigchainDB Project
There are many ways you can contribute to the BigchainDB project, some very easy and others more involved. We want to be friendly and welcoming to all potential contributors, so we ask that everyone involved abide by some simple guidelines outlined in our [Code of Conduct](./CODE_OF_CONDUCT.md).
Or, are you interested in contributing full-time? BigchainDB is hiring. See [here](https://github.com/bigchaindb/org/blob/master/engjob.md).
## Easy Ways to Contribute
The BigchainDB community has a Google Group and a Gitter chatroom. Our [Community page](https://www.bigchaindb.com/community) has more information about those.
You can also follow us on Twitter [@BigchainDB](https://twitter.com/BigchainDB) or read [our blog on Medium](https://medium.com/the-bigchaindb-blog).
If you want to file a bug report, suggest a feature, or ask a code-related question, please go to the `bigchaindb/bigchaindb` repository on GitHub and [create a new Issue](https://github.com/bigchaindb/bigchaindb/issues/new). (You will need a [GitHub account](https://github.com/signup/free) (free).) Please describe the issue clearly, including steps to reproduce when it is a bug.
## How to Contribute Code or Documentation
### Step 0 - Decide on an Issue to Resolve, or Create One
We want you to feel like your contributions (pull requests) are welcome, but if you contribute something unnecessary, unwanted, or perplexing, then your experience may be unpleasant. Your pull request may sit gathering dust as everyone scratches their heads wondering what to do with it.
To prevent that situation, we ask that all pull requests should resolve, address, or fix an existing issue. If there is no existing issue, then you should create one first. That way there can be commentary and discussion first, and you can have a better idea of what to expect when you create a corresponding pull request.
When you submit a pull request, please mention the issue (or issues) that it resolves, e.g. "Resolves #123".
Exception: hotfixes and minor changes don't require a pre-existing issue, but please write a thorough pull request description.
### Step 1 - Prepare and Familiarize Yourself
To contribute code or documentation, you need a [GitHub account](https://github.com/signup/free).
Familiarize yourself with how we do coding and documentation in the BigchainDB project, including:
* [our Python Style Guide](PYTHON_STYLE_GUIDE.md)
* [how we write and run tests](./tests/README.md)
* [our documentation strategy](./docs/README.md) (including in-code documentation)
* the GitHub Flow (workflow)
* [GitHub Guide: Understanding the GitHub Flow](https://guides.github.com/introduction/flow/)
* [Scott Chacon's blog post about GitHub Flow](http://scottchacon.com/2011/08/31/github-flow.html)
* [semantic versioning](http://semver.org/)
### Step 2 - Install some Dependencies
* [Install RethinkDB Server](https://rethinkdb.com/docs/install/)
* Make sure you have Python 3.5+ (preferably in a virtualenv)
* [Install BigchaindB Server's OS-level dependencies](https://docs.bigchaindb.com/projects/server/en/latest/appendices/install-os-level-deps.html)
* [Make sure you have the latest Python 3 version of pip and setuptools](https://docs.bigchaindb.com/projects/server/en/latest/appendices/install-latest-pip.html)
### Step 3 - Fork bigchaindb on GitHub
In your web browser, go to [the BigchainDB repository on GitHub](https://github.com/bigchaindb/bigchaindb) and click the `Fork` button in the top right corner. This creates a new Git repository named `bigchaindb` in _your_ GitHub account.
### Step 4 - Clone Your Fork
(This only has to be done once.) In your local terminal, use Git to clone _your_ `bigchaindb` repository to your local computer. Also add the original GitHub bigchaindb/bigchaindb repository as a remote named `upstream` (a convention):
```text
git clone git@github.com:your-github-username/bigchaindb.git
cd bigchaindb
git remote add upstream git@github.com:bigchaindb/bigchaindb.git
```
### Step 5 - Fetch and Merge the Latest from `upstream/master`
Switch to the `master` branch locally, fetch all `upstream` branches, and merge the just-fetched `upstream/master` branch with the local `master` branch:
```text
git checkout master
git fetch upstream
git merge upstream/master
```
### Step 6 - Install the Python module and the CLI
In order to use and run the source you just cloned from your fork, you need to install BigchainDB on your computer.
The core of BigchainDB is a Python module you can install using the standard [Python packaging tools](http://python-packaging-user-guide.readthedocs.org/en/latest/).
We highly suggest you use `pip` and `virtualenv` to manage your local development.
If you need more information on how to do that, refer to the *Python Packaging User Guide* to [install `pip`](http://python-packaging-user-guide.readthedocs.org/en/latest/installing/#requirements-for-installing-packages) and to [create your first `virtualenv`](http://python-packaging-user-guide.readthedocs.org/en/latest/installing/#creating-virtual-environments).
Once you have `pip` installed and (optionally) you are in a virtualenv, go to the root of the repository (i.e. where the `setup.py` file is), and type:
```text
pip install -e .[dev]
```
This will install the BigchainDB Python module, the CLI, and all the dependencies useful for contributing to the development of BigchainDB.
How? Let's split the command down into its components:
- `pip` is the Python command to install packages
- `install` tells pip to use the *install* action
- `-e` installs a project in [editable mode](https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs)
- `.` installs what's in the current directory
- `[dev]` adds some [extra requirements](https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies) to the installation. (If you are curious, open `setup.py` and look for `dev` in the `extras_require` section.)
Aside: An alternative to `pip install -e .[dev]` is `python setup.py develop`.
### Step 7 - Create a New Branch for Each Bug/Feature
If your new branch is to **fix a bug** identified in a specific GitHub Issue with number `ISSNO`, then name your new branch `bug/ISSNO/short-description-here`. For example, `bug/67/fix-leap-year-crash`.
If your new branch is to **add a feature** requested in a specific GitHub Issue with number `ISSNO`, then name your new branch `feat/ISSNO/short-description-here`. For example, `feat/135/blue-background-on-mondays`.
Otherwise, please give your new branch a short, descriptive, all-lowercase name.
```text
git checkout -b new-branch-name
```
### Step 8 - Make Edits, git add, git commit
With your new branch checked out locally, make changes or additions to the code or documentation. Remember to:
* follow [our Python Style Guide](PYTHON_STYLE_GUIDE.md).
* write and run tests for any new or changed code. There's [a README file in the `tests/` folder](./tests/README.md) about how to do that.
* add or update documentation as necessary. Follow [our documentation strategy](./docs/README.md).
As you go, git add and git commit your changes or additions, e.g.
```text
git add new-or-changed-file-1
git add new-or-changed-file-2
git commit -m "Short description of new or changed things"
```
You will want to merge changes from upstream (i.e. the original repository) into your new branch from time to time, using something like:
```text
git fetch upstream
git merge upstream/master
```
Once you're done commiting a set of new things and you're ready to submit them for inclusion, please be sure to run all the tests as per the instructions in [the README file in the `tests/` folder](./tests/README.md).
(When you submit your pull request [following the instructions below], we run all the tests automatically, so we will see if some are failing. If you don't know why some tests are failing, you can still submit your pull request, but be sure to note the failing tests and to ask for help with resolving them.)
### Step 9 - Push Your New Branch to origin
Make sure you've commited all the additions or changes you want to include in your pull request. Then push your new branch to origin (i.e. _your_ remote bigchaindb repository).
```text
git push origin new-branch-name
```
### Step 10 - Create a Pull Request
Go to the GitHub website and to _your_ remote bigchaindb repository (i.e. something like https://github.com/your-user-name/bigchaindb).
See [GitHub's documentation on how to initiate and send a pull request](https://help.github.com/articles/using-pull-requests/). Note that the destination repository should be `bigchaindb/bigchaindb` and the destination branch will be `master` (usually, and if it's not, then we can change that if necessary).
If this is the first time you've submitted a pull request to BigchainDB, then you must read and accept the Contributor License Agreement (CLA) before we can merge your contributions. That can be found at [https://www.bigchaindb.com/cla](https://www.bigchaindb.com/cla).
Once you accept and submit the CLA, we'll email you with further instructions. (We will send you a long random string to put in the comments section of your pull request, along with the text, "I have read and agree to the terms of the BigchainDB Contributor License Agreement.")
Someone will then merge your branch or suggest changes. If we suggest changes, you won't have to open a new pull request, you can just push new code to the same branch (on `origin`) as you did before creating the pull request.
### Tip: Upgrading All BigchainDB Dependencies
Over time, your versions of the Python packages used by BigchainDB will get out of date. You can upgrade them using:
```text
pip install --upgrade -e .[dev]
```
## Quick Links
* [BigchainDB Community links](https://www.bigchaindb.com/community)
* [General GitHub Documentation](https://help.github.com/)
* [Code of Conduct](./CODE_OF_CONDUCT.md)
* [BigchainDB Licenses](./LICENSES.md)
* [Contributor License Agreement](https://www.bigchaindb.com/cla)
(Note: GitHub automatically links to CONTRIBUTING.md when a contributor creates an Issue or opens a Pull Request.)

View File

@ -1,18 +1,24 @@
FROM python:3.6
LABEL maintainer "dev@bigchaindb.com"
LABEL maintainer "contact@ipdb.global"
RUN mkdir -p /usr/src/app
COPY . /usr/src/app/
WORKDIR /usr/src/app
RUN apt-get -qq update \
&& apt-get -y upgrade \
&& pip install --no-cache-dir . \
&& apt-get install -y jq \
&& pip install . \
&& apt-get autoremove \
&& apt-get clean
VOLUME ["/data", "/certs"]
WORKDIR /data
ENV PYTHONUNBUFFERED 0
ENV BIGCHAINDB_CONFIG_PATH /data/.bigchaindb
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"]
CMD ["start"]

51
Dockerfile-all-in-one Normal file
View File

@ -0,0 +1,51 @@
FROM alpine:3.9
LABEL maintainer "contact@ipdb.global"
ARG TM_VERSION=v0.31.5
RUN mkdir -p /usr/src/app
ENV HOME /root
COPY . /usr/src/app/
WORKDIR /usr/src/app
RUN apk --update add sudo bash \
&& apk --update add python3 openssl ca-certificates git \
&& apk --update add --virtual build-dependencies python3-dev \
libffi-dev openssl-dev build-base jq \
&& apk add --no-cache libstdc++ dpkg gnupg \
&& pip3 install --upgrade pip cffi \
&& pip install -e . \
&& apk del build-dependencies \
&& rm -f /var/cache/apk/*
# Install mongodb and monit
RUN apk --update add mongodb monit
# Install Tendermint
RUN wget https://github.com/tendermint/tendermint/releases/download/${TM_VERSION}/tendermint_${TM_VERSION}_linux_amd64.zip \
&& unzip tendermint_${TM_VERSION}_linux_amd64.zip \
&& mv tendermint /usr/local/bin/ \
&& rm tendermint_${TM_VERSION}_linux_amd64.zip
ENV TMHOME=/tendermint
# Set permissions required for mongodb
RUN mkdir -p /data/db /data/configdb \
&& chown -R mongodb:mongodb /data/db /data/configdb
# BigchainDB enviroment variables
ENV BIGCHAINDB_DATABASE_PORT 27017
ENV BIGCHAINDB_DATABASE_BACKEND localmongodb
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_TENDERMINT_PORT 26657
VOLUME /data/db /data/configdb /tendermint
EXPOSE 27017 28017 9984 9985 26656 26657 26658
WORKDIR $HOME
ENTRYPOINT ["/usr/src/app/pkg/scripts/all-in-one.bash"]

30
Dockerfile-alpine Normal file
View File

@ -0,0 +1,30 @@
FROM alpine:latest
LABEL maintainer "contact@ipdb.global"
RUN mkdir -p /usr/src/app
COPY . /usr/src/app/
WORKDIR /usr/src/app
RUN apk --update add sudo \
&& apk --update add python3 py-pip openssl ca-certificates git\
&& apk --update add --virtual build-dependencies python3-dev \
libffi-dev openssl-dev build-base \
&& apk add --no-cache libstdc++ \
&& pip3 install --upgrade pip cffi \
&& pip install -e . \
&& apk del build-dependencies \
&& rm -f /var/cache/apk/*
# When developing with Python in a docker container, we are using PYTHONBUFFERED
# to force stdin, stdout and stderr to be totally unbuffered and to capture logs/outputs
ENV PYTHONUNBUFFERED 0
ENV BIGCHAINDB_DATABASE_PORT 27017
ENV BIGCHAINDB_DATABASE_BACKEND $backend
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_TENDERMINT_PORT 26657
ARG backend
RUN bigchaindb -y configure "$backend"

View File

@ -1,21 +1,35 @@
FROM python:3.6
LABEL maintainer "dev@bigchaindb.com"
ARG python_version=3.6
FROM python:${python_version}
LABEL maintainer "contact@ipdb.global"
RUN apt-get update \
&& apt-get install -y vim \
&& apt-get install -y git \
&& pip install -U pip \
&& pip install pynacl \
&& apt-get autoremove \
&& apt-get clean
ARG backend
ARG abci_status
# When developing with Python in a docker container, we are using PYTHONBUFFERED
# to force stdin, stdout and stderr to be totally unbuffered and to capture logs/outputs
ENV PYTHONUNBUFFERED 0
ENV BIGCHAINDB_DATABASE_PORT 27017
ENV BIGCHAINDB_DATABASE_BACKEND $backend
ENV BIGCHAINDB_SERVER_BIND 0.0.0.0:9984
ENV BIGCHAINDB_WSSERVER_HOST 0.0.0.0
ENV BIGCHAINDB_WSSERVER_SCHEME ws
ARG backend
ENV BIGCHAINDB_WSSERVER_ADVERTISED_HOST 0.0.0.0
ENV BIGCHAINDB_WSSERVER_ADVERTISED_SCHEME ws
ENV BIGCHAINDB_TENDERMINT_PORT 26657
ENV BIGCHAINDB_CI_ABCI ${abci_status}
RUN mkdir -p /usr/src/app
COPY . /usr/src/app/
WORKDIR /usr/src/app
RUN pip install --no-cache-dir -e .[dev]
RUN bigchaindb -y configure "$backend"
RUN pip install -e .[dev]
RUN bigchaindb -y configure

View File

@ -1,65 +0,0 @@
# How to Handle Pull Requests
This document is for whoever has the ability to merge pull requests in the Git repositories associated with BigchainDB.
If the pull request is from an employee of BigchainDB GmbH, then you can ignore this document.
If the pull request is from someone who is _not_ an employee of BigchainDB, then:
* Have they agreed to the Individual Contributor Agreement in the past? (Troy, Greg, and others have a list.) If yes, then you can merge the PR and ignore the rest of this document.
* Do they belong to a company or organization which agreed to the Entity Contributor Agreement in the past, and will they be contributing on behalf of that company or organization? (Troy, Greg, and others have a list.) If yes, then you can merge the PR and ignore the rest of this document.
* Otherwise, go to the pull request in question and post a comment using this template:
Hi @nameofuser
Before we can merge this pull request, we need you or your organization to agree to one of our contributor agreements. One of the big concerns for people using and developing open source software is that someone who contributed to the code might claim the code infringes on their copyright or patent. To guard against this, we ask all our contributors to sign a Contributor License Agreement. This gives us the right to use the code contributed and any patents the contribution relies on. It also gives us and our users comfort that they won't be sued for using open source software. We know it's a hassle, but it makes the project more reliable in the long run. Thank you for your understanding and your contribution!
If you are contributing on behalf of yourself (and not on behalf of your employer or another organization you are part of) then you should:
1. Go to: https://www.bigchaindb.com/cla/
2. Read the Individual Contributor Agreement
3. Fill in the form "For Individuals"
4. Check the box to agree
5. Click the SEND button
If you're contributing as an employee, and/or you want all employees of your employing organization to be covered by our contributor agreement, then someone in your organization with the authority to enter agreements on behalf of all employees must do the following:
1. Go to: https://www.bigchaindb.com/cla/
2. Read the Entity Contributor Agreement
3. Fill in the form "For Organizations”
4. Check the box to agree
5. Click the SEND button
We will email you (or your employer) with further instructions.
(END OF COMMENT)
Once they click SEND, we (BigchainDB) will get an email with the information in the form. (Troy gets those emails for sure, I'm not sure who else.) The next step is to send an email to the email address submitted in the form, saying something like (where the stuff in [square brackets] should be replaced):
Hi [NAME],
The next step is for you to copy the following block of text into the comments of Pull Request #[NN] on GitHub:
BEGIN BLOCK
This is to confirm that I agreed to and accepted the BigchainDB [Entity/Individual] Contributor Agreement at https://www.bigchaindb.com/cla/ and to represent and warrant that I have authority to do so.
[Insert long random string here. One good source of those is https://www.grc.com/passwords.htm ]
END BLOCK
(END OF EMAIL)
The next step is to wait for them to copy that comment into the comments of the indicated pull request. Once they do so, it's safe to merge the pull request.
## How to Handle CLA Agreement Emails with No Associated Pull Request
Reply with an email like this:
Hi [First Name],
Today I got an email (copied below) to tell me that you agreed to the BigchainDB Contributor License Agreement. Did you intend to do that?
If no, then you can ignore this email.
If yes, then there's another step to connect your email address with your GitHub account. To do that, you must first create a pull request in one of the BigchainDB repositories on GitHub. Once you've done that, please reply to this email with a link to the pull request. Then I'll send you a special block of text to paste into the comments on that pull request.

201
LICENSE Normal file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,23 +1,24 @@
# Code Licenses
# Copyrights and Licenses
For all code in this repository, BigchainDB GmbH ("We") either:
## Copyrights
1. owns the copyright, or
2. owns the right to sublicense it (because all external contributors must agree to a Contributor License Agreement).
For all the code and documentation in this repository, the copyright is owned by one or more of the following:
Therefore We can choose how to license all the code in this repository. We can license it to Joe Xname under one license and Company Yname under a different license.
- 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).)
- (Rarely, see the **Exceptions Section** below) A third pary who licensed the code in question under an open source license.
The two general options are:
## Code Licenses
1. You can get it under a commercial license for a fee. We can negotiate the terms of that license. It's not like we have some standard take-it-or-leave it commercial license. If you want to modify it and keep your modifications private, then that's certainly possible. Just ask.
2. You can get it under the AGPLv3 license for free. You don't even have to ask us. That's because all code in _this_ repository is licensed under the GNU Affero General Public License version 3 (AGPLv3), the full text of which can be found at [http://www.gnu.org/licenses/agpl.html](http://www.gnu.org/licenses/agpl.html).
All code in this repository, including short code snippets in the documentation, but not including the **Exceptions** noted below, is licensed under the Apache License, Version 2.0, the full text of which can be found at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).
If you don't like the AGPL license, then just ignore it. It doesn't affect any other license.
For the licenses on all other BigchainDB-related code (i.e. in other repositories), see the LICENSE file in the associated repository.
All short code snippets embedded in the official BigchainDB _documentation_ are also licensed under the Apache License, Version 2.0, the full text of which can be found at [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0).
## Documentation Licenses
For the licenses on all other BigchainDB-related code, see the LICENSE file in the associated repository.
The official BigchainDB documentation, _except for the short code snippets embedded within it_, is licensed under a Creative Commons Attribution 4.0 International license, the full text of which can be found at [http://creativecommons.org/licenses/by/4.0/legalcode](http://creativecommons.org/licenses/by/4.0/legalcode).
# Documentation Licenses
## Exceptions
The official BigchainDB documentation, _except for the short code snippets embedded within it_, is licensed under a Creative Commons Attribution-ShareAlike 4.0 International license, the full text of which can be found at [http://creativecommons.org/licenses/by-sa/4.0/legalcode](http://creativecommons.org/licenses/by-sa/4.0/legalcode).
The contents of the `k8s/nginx-openresty/` directory are licensed as described in the `LICENSE.md` file in that directory.

136
Makefile
View File

@ -1,5 +1,11 @@
.PHONY: clean clean-test clean-pyc clean-build docs help
.PHONY: help run start stop logs test test-unit test-unit-watch test-acceptance cov doc doc-acceptance clean reset release dist check-deps clean-build clean-pyc clean-test
.DEFAULT_GOAL := help
#############################
# Open a URL in the browser #
#############################
define BROWSER_PYSCRIPT
import os, webbrowser, sys
try:
@ -11,64 +17,88 @@ webbrowser.open("file://" + pathname2url(os.path.abspath(sys.argv[1])))
endef
export BROWSER_PYSCRIPT
##################################
# Display help for this makefile #
##################################
define PRINT_HELP_PYSCRIPT
import re, sys
print("BigchainDB 2.0 developer toolbox")
print("--------------------------------")
print("Usage: make COMMAND")
print("")
print("Commands:")
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
print(" %-16s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
##################
# Basic commands #
##################
DOCKER := docker
DC := docker-compose
BROWSER := python -c "$$BROWSER_PYSCRIPT"
HELP := python -c "$$PRINT_HELP_PYSCRIPT"
ECHO := /usr/bin/env echo
help:
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
IS_DOCKER_COMPOSE_INSTALLED := $(shell command -v docker-compose 2> /dev/null)
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
################
# Main targets #
################
help: ## Show this help
@$(HELP) < $(MAKEFILE_LIST)
clean-build: ## remove build artifacts
rm -fr build/
rm -fr dist/
rm -fr .eggs/
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
run: check-deps ## Run BigchainDB from source (stop it with ctrl+c)
# although bigchaindb 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
clean-pyc: ## remove Python file artifacts
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
start: check-deps ## Run BigchainDB from source and daemonize it (stop with `make stop`)
@$(DC) up -d bigchaindb
clean-test: ## remove test and coverage artifacts
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
stop: check-deps ## Stop BigchainDB
@$(DC) stop
lint: ## check style with flake8
flake8 bigchaindb tests
logs: check-deps ## Attach to the logs
@$(DC) logs -f bigchaindb
test: ## run tests quickly with the default Python
pytest -v -n auto
test: check-deps test-unit test-acceptance ## Run unit and acceptance tests
test-all: ## run tests on every Python version with tox
tox
test-unit: check-deps ## Run all tests once
@$(DC) up -d bdb
@$(DC) exec bigchaindb pytest
coverage: ## check code coverage quickly with the default Python
pytest -v -n auto --cov=bigchaindb --cov-report term --cov-report html
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
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
$(BROWSER) htmlcov/index.html
docs: ## generate Sphinx HTML documentation, including API docs
$(MAKE) -C docs/root clean
$(MAKE) -C docs/root html
$(MAKE) -C docs/server clean
$(MAKE) -C docs/server html
$(BROWSER) docs/root/_build/html/index.html
doc: check-deps ## Generate HTML documentation and open it in the browser
@$(DC) run --rm --no-deps bdocs make -C docs/root html
$(BROWSER) docs/root/build/html/index.html
servedocs: docs ## compile the docs watching for changes
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
doc-acceptance: check-deps ## Create documentation for acceptance tests
@$(DC) run --rm python-acceptance pycco -i -s /src -d /docs
$(BROWSER) acceptance/python/docs/index.html
clean: clean-build clean-pyc clean-test ## Remove all build, test, coverage and Python artifacts
@$(ECHO) "Cleaning was successful."
reset: check-deps ## Stop and REMOVE all containers. WARNING: you will LOSE all data stored in BigchainDB.
@$(DC) down
release: dist ## package and upload a release
twine upload dist/*
@ -78,5 +108,35 @@ dist: clean ## builds source (and not for now, wheel package)
# python setup.py bdist_wheel
ls -l dist
install: clean ## install the package to the active Python's site-packages
python setup.py install
###############
# Sub targets #
###############
check-deps:
ifndef IS_DOCKER_COMPOSE_INSTALLED
@$(ECHO) "Error: docker-compose is not installed"
@$(ECHO)
@$(ECHO) "You need docker-compose to run this command. Check out the official docs on how to install it in your system:"
@$(ECHO) "- https://docs.docker.com/compose/install/"
@$(ECHO)
@$(DC) # docker-compose is not installed, so we call it to generate an error and exit
endif
clean-build: # Remove build artifacts
@rm -fr build/
@rm -fr dist/
@rm -fr .eggs/
@find . -name '*.egg-info' -exec rm -fr {} +
@find . -name '*.egg' -exec rm -f {} +
clean-pyc: # Remove Python file artifacts
@find . -name '*.pyc' -exec rm -f {} +
@find . -name '*.pyo' -exec rm -f {} +
@find . -name '*~' -exec rm -f {} +
@find . -name '__pycache__' -exec rm -fr {} +
clean-test: # Remove test and coverage artifacts
@find . -name '.pytest_cache' -exec rm -fr {} +
@rm -fr .tox/
@rm -f .coverage
@rm -fr htmlcov/

View File

@ -1,3 +1,10 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# Python Style Guide
This guide starts out with our general Python coding style guidelines and ends with a section on how we write & run (Python) tests.
@ -8,6 +15,9 @@ 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.
### Python Docstrings
PEP8 says some things about docstrings, but not what to put in them or how to structure them. [PEP257](https://www.python.org/dev/peps/pep-0257/) was one proposal for docstring conventions, but we prefer [Google-style docstrings](https://google.github.io/styleguide/pyguide.html?showone=Comments#Comments) instead: they're easier to read and the [napoleon extension](http://www.sphinx-doc.org/en/stable/ext/napoleon.html) for Sphinx lets us turn them into nice-looking documentation. Here are some references on Google-style docstrings:
@ -82,6 +92,6 @@ flake8 --max-line-length 119 bigchaindb/
## Writing and Running (Python) Tests
The content of this section was moved to [`bigchaindb/tests/README.md`](./tests/README.md).
The content of this section was moved to [`bigchaindb/tests/README.md`](https://github.com/bigchaindb/bigchaindb/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.

View File

@ -1,25 +1,61 @@
[![PyPI](https://img.shields.io/pypi/status/bigchaindb.svg?maxAge=2592000)](https://pypi.python.org/pypi/BigchainDB)
[![PyPI](https://img.shields.io/pypi/v/bigchaindb.svg)](https://pypi.python.org/pypi/BigchainDB)
[![Travis branch](https://img.shields.io/travis/bigchaindb/bigchaindb/master.svg)](https://travis-ci.org/bigchaindb/bigchaindb)
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
<!--- There is no shield to get the latest version
(including pre-release versions) from PyPI,
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)
# BigchainDB Server
BigchainDB is a scalable blockchain database. [The whitepaper](https://www.bigchaindb.com/whitepaper/) explains what that means.
BigchainDB is the blockchain database. This repository is for _BigchainDB Server_.
## Get Started with BigchainDB Server
## The Basics
### [Quickstart](https://docs.bigchaindb.com/projects/server/en/latest/quickstart.html)
### [Set Up & Run a Dev/Test Node](https://docs.bigchaindb.com/projects/server/en/latest/dev-and-test/setup-run-node.html)
### [Run BigchainDB Server with Docker](https://docs.bigchaindb.com/projects/server/en/latest/appendices/run-with-docker.html)
* [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/)
## 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
make run
```
BigchainDB should be reachable now on `http://localhost:9984/`.
There are also other commands you can execute:
* `make start`: Run BigchainDB from source and daemonize it (stop it with `make stop`).
* `make stop`: Stop BigchainDB.
* `make logs`: Attach to the logs.
* `make test`: Run all unit and acceptance tests.
* `make test-unit-watch`: Run all tests and wait. Every time you change code, tests will be run again.
* `make cov`: Check code coverage and open the result in the browser.
* `make doc`: Generate HTML documentation and open it in the browser.
* `make clean`: Remove all build, test, coverage and Python artifacts.
* `make reset`: Stop and REMOVE all containers. WARNING: you will LOSE all data stored in BigchainDB.
To view all commands available, run `make`.
## Links for Everyone
* [BigchainDB.com](https://www.bigchaindb.com/) - the main BigchainDB website, including newsletter signup
* [Whitepaper](https://www.bigchaindb.com/whitepaper/) - outlines the motivations, goals and core algorithms of BigchainDB
* [Roadmap](https://github.com/bigchaindb/org/blob/master/ROADMAP.md)
* [Blog](https://medium.com/the-bigchaindb-blog)
* [Twitter](https://twitter.com/BigchainDB)
@ -28,7 +64,7 @@ BigchainDB is a scalable blockchain database. [The whitepaper](https://www.bigch
* [All BigchainDB Documentation](https://docs.bigchaindb.com/en/latest/)
* [BigchainDB Server Documentation](https://docs.bigchaindb.com/projects/server/en/latest/index.html)
* [CONTRIBUTING.md](CONTRIBUTING.md) - how to contribute
* [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)

77
README_cn.md Normal file
View File

@ -0,0 +1,77 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
<!--- There is no shield to get the latest version
(including pre-release versions) from PyPI,
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)
# BigchainDB 服务器
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/)
## 运行和测试 `master` 分支的 BigchainDB 服务器
运行和测试最新版本的 BigchainDB 服务器非常简单. 确认你有安装最新版本的 [Docker Compose](https://docs.docker.com/compose/install/). 当你准备好了, 打开一个终端并运行:
```text
git clone https://github.com/bigchaindb/bigchaindb.git
cd bigchaindb
make run
```
BigchainDB 应该可以通过 `http://localhost:9984/` 访问.
这里也有一些其他的命令你可以运行:
* `make start`: 通过源码和守护进程的方式运行 BigchainDB (通过 `make stop` 停止).
* `make stop`: 停止运行 BigchainDB.
* `make logs`: 附在日志上.
* `make test`: 运行所有单元和验收测试.
* `make test-unit-watch`: 运行所有测试并等待. 每次更改代码时都会再次运行测试.
* `make cov`: 检查代码覆盖率并在浏览器中打开结果.
* `make doc`: 生成 HTML 文档并在浏览器中打开它.
* `make clean`: 删除所有构建, 测试, 覆盖和 Python 生成物.
* `make reset`: 停止并移除所有容器. 警告: 您将丢失存储在 BigchainDB 中的所有数据.
查看所有可用命令, 请运行 `make`.
## 一般人员链接
* [BigchainDB.com](https://www.bigchaindb.com/) - BigchainDB 主网站, 包括新闻订阅
* [路线图](https://github.com/bigchaindb/org/blob/master/ROADMAP.md)
* [博客](https://medium.com/the-bigchaindb-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](.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)
## 法律声明
* [许可](LICENSES.md) - 开源代码 & 开源内容
* [印记](https://www.bigchaindb.com/imprint/)
* [联系我们](https://www.bigchaindb.com/contact/)

65
README_kor.md Normal file
View File

@ -0,0 +1,65 @@
[![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)
# BigchainDB 서버
BigchaingDB는 블록체인 데이터베이스입니다. 이 저장소는 _BigchaingDB 서버_를 위한 저장소입니다.
### 기본 사항
* [빠른 시작 사용해보기](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/)
### `master` Branch에서 BigchainDB 서버 실행 및 테스트
BigchaingDB 서버의 최신 버전을 실행하고 테스트하는 것은 어렵지 않습니다. [Docker Compose](https://docs.docker.com/compose/install/)의 최신 버전이 설치되어 있는지 확인하십시오. 준비가 되었다면, 터미널에서 다음을 실행하십시오.
```text
git clone https://github.com/bigchaindb/bigchaindb.git
cd bigchaindb
make run
```
이제 BigchainDB는 `http://localhost:9984/`에 연결되어야 합니다.
또한, 실행시키기 위한 다른 명령어들도 있습니다.
* `make start` : 소스로부터 BigchainDB를 실행하고 데몬화합니다. \(이는 `make stop` 을 하면 중지합니다.\)
* `make stop` : BigchainDB를 중지합니다.
* `make logs` : 로그에 첨부합니다.
* `make text` : 모든 유닛과 허가 테스트를 실행합니다.
* `make test-unit-watch` : 모든 테스트를 수행하고 기다립니다. 코드를 변경할 때마다 테스트는 다시 실행될 것입니다.
* `make cov` : 코드 커버리지를 확인하고 브라우저에서 결과를 엽니다.
* `make doc` : HTML 문서를 만들고, 브라우저에서 엽니다.
* `make clean` : 모든 빌드와 테스트, 커버리지 및 파이썬 아티팩트를 제거합니다.
* `make reset` : 모든 컨테이너들을 중지하고 제거합니다. 경고 : BigchainDB에 저장된 모든 데이터를 잃을 수 있습니다.
사용 가능한 모든 명령어를 보기 위해서는 `make` 를 실행하십시오.
### 모두를 위한 링크들
* [BigchainDB.com ](https://www.bigchaindb.com/)- 뉴스 레터 가입을 포함하는 BigchainDB 주요 웹 사이트
* [로드맵](https://github.com/bigchaindb/org/blob/master/ROADMAP.md)
* [블로그](https://medium.com/the-bigchaindb-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)
### 합법
* [라이선스](https://github.com/bigchaindb/bigchaindb/blob/master/LICENSES.md) - 오픈 소스 & 오픈 콘텐츠
* [발행](https://www.bigchaindb.com/imprint/)
* [연락처](https://www.bigchaindb.com/contact/)

View File

@ -1,72 +1,101 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# Our Release Process
The release process for BigchainDB server differs slightly depending on whether it's a minor or a patch release.
## Notes
BigchainDB follows
BigchainDB follows
[the Python form of Semantic Versioning](https://packaging.python.org/tutorials/distributing-packages/#choosing-a-versioning-scheme)
(i.e. MAJOR.MINOR.PATCH),
which is almost identical
to [regular semantic versioning](http://semver.org/)
except release candidates are labelled like
`3.4.5rc2` not `3.4.5-rc2` (with no hyphen).
to [regular semantic versioning](http://semver.org/), but there's no hyphen, e.g.
- `0.9.0` for a typical final release
- `4.5.2a1` not `4.5.2-a1` for the first Alpha release
- `3.4.5rc2` not `3.4.5-rc2` for Release Candidate 2
## Minor release
**Note 1:** For Git tags (which are used to identify releases on GitHub), we append a `v` in front. For example, the Git tag for version `2.0.0a1` was `v2.0.0a1`.
A minor release is preceeded by a feature freeze and created from the 'master' branch. This is a summary of the steps we go through to release a new minor version of BigchainDB Server.
**Note 2:** For Docker image tags (e.g. on Docker Hub), we use longer version names for Alpha, Beta and Release Candidate releases. For example, the Docker image tag for version `2.0.0a2` was `2.0.0-alpha2`.
1. Update the `CHANGELOG.md` file in master
1. In `k8s/bigchaindb/bigchaindb-dep.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.) Commit that change to master
1. Create and checkout a new branch for the minor release, named after the minor version, without a preceeding 'v', e.g. `git checkout -b 0.9` (*not* 0.9.0, this new branch will be for e.g. 0.9.0, 0.9.1, 0.9.2, etc. each of which will be identified by a tagged commit)
1. In `bigchaindb/version.py`, update `__version__` and `__short_version__`, e.g. to `0.9` and `0.9.0` (with no `.dev` on the end)
1. Commit that change, and push the new branch to GitHub
1. On GitHub, use the new branch to create a new pull request and wait for all the tests to pass
1. Follow steps outlined in [Common Steps](#common-steps)
1. In 'master' branch, Edit `bigchaindb/version.py`, increment the minor version to the next planned release, e.g. `0.10.0.dev`. (Exception: If you just released `X.Y.Zrc1` then increment the minor version to `X.Y.Zrc2`.) This step is so people reading the latest docs will know that they're for the latest (master branch) version of BigchainDB Server, not the docs at the time of the most recent release (which are also available).
1. Go to [Docker Hub](https://hub.docker.com/), sign in, go to Settings - Build Settings, and under the build with Docker Tag Name equal to `latest`, change the Name to the number of the new release, e.g. `0.9`
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.
Congratulations, you have released BigchainDB!
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.
## Patch release
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.
A patch release is similar to a minor release, but piggybacks on an existing minor release branch:
## Steps
1. Check out the minor release branch, e.g. `0.9`
1. Apply the changes you want, e.g. using `git cherry-pick`.
1. Update the `CHANGELOG.md` file
1. Increment the patch version in `bigchaindb/version.py`, e.g. `0.9.1`
1. Commit that change
1. In `k8s/bigchaindb/bigchaindb-dep.yaml`, find the line of the form `image: bigchaindb/bigchaindb:0.9.0` and change the version number to the new version number, e.g. `0.9.1`. (This is the Docker image that Kubernetes should pull from Docker Hub.)
1. Commit that change
1. Push the updated minor release branch to GitHub
1. Follow steps outlined in [Common Steps](#common-steps)
1. Cherry-pick the `CHANGELOG.md` update commit (made above) to the `master` branch
1. Create a pull request where you make the following changes:
## Common steps
- Update `CHANGELOG.md`
- Update all Docker image tags in all Kubernetes YAML files (in the `k8s/` directory).
For example, in the files:
These steps are common between minor and patch releases:
- `k8s/bigchaindb/bigchaindb-ss.yaml` and
- `k8s/dev-setup/bigchaindb.yaml`
1. Go to the [bigchaindb/bigchaindb Releases page on GitHub](https://github.com/bigchaindb/bigchaindb/releases)
and click the "Draft a new release" button
1. Fill in the details:
- Tag version: version number preceeded by 'v', e.g. "v0.9.1"
- Target: the release branch that was just pushed
- Title: Same as tag name above, e.g "v0.9.1"
- Description: The body of the changelog entry (Added, Changed, etc.)
1. Click "Publish release" to publish the release on GitHub
1. Make sure your local Git is in the same state as the release: e.g. `git fetch <remote-name>` and `git checkout v0.9.1`
1. Make sure you have a `~/.pypirc` file containing credentials for PyPI
1. Do a `make release` to build and publish the new `bigchaindb` package on PyPI
1. [Login to readthedocs.org](https://readthedocs.org/accounts/login/)
as a maintainer of the BigchainDB Server docs, and:
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.)
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`:
- 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`.
- In `setup.py`, _maybe_ update the development status item in the `classifiers` list. For example, one allowed value is `"Development Status :: 5 - Production/Stable"`. The [allowed values are listed at pypi.python.org](https://pypi.python.org/pypi?%3Aaction=list_classifiers).
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)
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`
- **Target:** the last commit that was just merged. In other words, that commit will get a Git tag with the value given for tag version above.
- **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.
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
```text
sudo chown -R $(whoami):$(whoami) .
```
10. [Log in to readthedocs.org](https://readthedocs.org/accounts/login/) and go to the **BigchainDB Server** project, then:
- Click on "Builds", select "latest" from the drop-down menu, then click the "Build Version:" button.
- Wait for the build of "latest" to finish. This can take a few minutes.
- Go to Admin --> Advanced Settings
and make sure that "Default branch:" (i.e. what "latest" points to)
is set to the new release's tag, e.g. `v0.9.1`.
(Don't miss the 'v' in front.)
(It won't be an option if you didn't wait for the build of "latest" to finish.)
Then scroll to the bottom and click "Save".
- Go to Admin --> Versions
and under **Choose Active Versions**, do these things:
1. Make sure that the new version's tag is "Active" and "Public"
2. Make sure the new version's branch
(without the 'v' in front) is _not_ active.
3. Make sure the **stable** branch is _not_ active.
4. Scroll to the bottom of the page and click the Submit button.
2. Make sure the **stable** branch is _not_ active.
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 "Build Settings"
- Find the row where "Docker Tag Name" equals `latest`
and change the value of "Name" to the name (Git tag)
of the new release, e.g. `v0.9.0`.
- If the release is an Alpha, Beta or Release Candidate release,
then a new row must be added.
You can do that by clicking the green "+" (plus) icon.
The contents of the new row should be similar to the existing rows
of previous releases like that.
- Click on "Tags"
- Delete the "latest" tag (so we can rebuild it)
- Click on "Build Settings" again
- Click on the "Trigger" button for the "latest" tag and make sure it worked by clicking on "Tags" again
- If the release is an Alpha, Beta or Release Candidate release,
then click on the "Trigger" button for that tag as well.
Congratulations, you have released a new version of BigchainDB Server!

View File

@ -1,3 +1,10 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# BigchainDB Roadmap
We moved the BigchainDB Roadmap to the bigchaindb/org repository; see:

27
acceptance/README.md Normal file
View File

@ -0,0 +1,27 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# Acceptance test suite
This directory contains the acceptance test suite for BigchainDB.
The suite uses Docker Compose to set up a single BigchainDB node, run all tests, and finally stop the node. In the future we will add support for a four node network setup.
## Running the tests
It should be as easy as `make test-acceptance`.
Note that `make test-acceptance` will take some time to start the node and shutting it down. If you are developing a test, or you wish to run a specific test in the acceptance test suite, first start the node with `make start`. After the node is running, you can run `pytest` inside the `python-acceptance` container with:
```bash
docker-compose run --rm python-acceptance pytest <use whatever option you need>
```
## Writing and documenting the tests
Tests are sometimes difficult to read. For acceptance tests, we try to be really explicit on what the test is doing, so please write code that is *simple* and easy to understand. We decided to use literate-programming documentation. To generate the documentation run:
```bash
make doc-acceptance
```

1
acceptance/python/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
docs

View File

@ -0,0 +1,9 @@
FROM python:3.6.3
RUN mkdir -p /src
RUN pip install --upgrade \
pycco \
websocket-client~=0.47.0 \
pytest~=3.0 \
bigchaindb-driver~=0.6.2 \
blns

View File

@ -0,0 +1,125 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
# # Basic Acceptance Test
# Here we check that the primitives of the system behave as expected.
# As you will see, this script tests basic stuff like:
#
# - create a transaction
# - check if the transaction is stored
# - check for the outputs of a given public key
# - transfer the transaction to another key
#
# We run a series of checks for each steps, that is retrieving the transaction from
# 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).
# ## Imports
# We need some utils from the `os` package, we will interact with
# env variables.
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
def test_basic():
# ## Set up a connection to BigchainDB
# To use BighainDB we need a connection. Here we create one. By default we
# connect to localhost, but you can override this value using the env variable
# called `BIGCHAINDB_ENDPOINT`, a valid value must include the schema:
# `https://example.com:9984`
bdb = BigchainDB(os.environ.get('BIGCHAINDB_ENDPOINT'))
# ## Create keypairs
# This test requires the interaction between two actors with their own keypair.
# The two keypairs will be called—drum roll—Alice and Bob.
alice, bob = generate_keypair(), generate_keypair()
# ## Alice registers her bike in BigchainDB
# Alice has a nice bike, and here she creates the "digital twin"
# of her bike.
bike = {'data': {'bicycle': {'serial_number': 420420}}}
# She prepares a `CREATE` transaction...
prepared_creation_tx = bdb.transactions.prepare(
operation='CREATE',
signers=alice.public_key,
asset=bike)
# ... and she fulfills it with her private key.
fulfilled_creation_tx = bdb.transactions.fulfill(
prepared_creation_tx,
private_keys=alice.private_key)
# We will use the `id` of this transaction several time, so we store it in
# a variable with a short and easy name
bike_id = fulfilled_creation_tx['id']
# Now she is ready to send it to the BigchainDB Network.
sent_transfer_tx = bdb.transactions.send_commit(fulfilled_creation_tx)
# And just to be 100% sure, she also checks if she can retrieve
# it from the BigchainDB node.
assert bdb.transactions.retrieve(bike_id), 'Cannot find transaction {}'.format(bike_id)
# Alice is now the proud owner of one unspent asset.
assert len(bdb.outputs.get(alice.public_key, spent=False)) == 1
assert bdb.outputs.get(alice.public_key)[0]['transaction_id'] == bike_id
# ## Alice transfers her bike to Bob
# After registering her bike, Alice is ready to transfer it to Bob.
# She needs to create a new `TRANSFER` transaction.
# A `TRANSFER` transaction contains a pointer to the original asset. The original asset
# is identified by the `id` of the `CREATE` transaction that defined it.
transfer_asset = {'id': bike_id}
# Alice wants to spend the one and only output available, the one with index `0`.
output_index = 0
output = fulfilled_creation_tx['outputs'][output_index]
# Here, she defines the `input` of the `TRANSFER` transaction. The `input` contains
# several keys:
#
# - `fulfillment`, taken from the previous `CREATE` transaction.
# - `fulfills`, that specifies which condition she is fulfilling.
# - `owners_before`.
transfer_input = {'fulfillment': output['condition']['details'],
'fulfills': {'output_index': output_index,
'transaction_id': fulfilled_creation_tx['id']},
'owners_before': output['public_keys']}
# Now that all the elements are set, she creates the actual transaction...
prepared_transfer_tx = bdb.transactions.prepare(
operation='TRANSFER',
asset=transfer_asset,
inputs=transfer_input,
recipients=bob.public_key)
# ... and signs it with her private key.
fulfilled_transfer_tx = bdb.transactions.fulfill(
prepared_transfer_tx,
private_keys=alice.private_key)
# She finally sends the transaction to a BigchainDB node.
sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)
# And just to be 100% sure, she also checks if she can retrieve
# it from the BigchainDB node.
assert bdb.transactions.retrieve(fulfilled_transfer_tx['id']) == sent_transfer_tx
# Now Alice has zero unspent transactions.
assert len(bdb.outputs.get(alice.public_key, spent=False)) == 0
# While Bob has one.
assert len(bdb.outputs.get(bob.public_key, spent=False)) == 1
# Bob double checks what he got was the actual bike.
bob_tx_id = bdb.outputs.get(bob.public_key, spent=False)[0]['transaction_id']
assert bdb.transactions.retrieve(bob_tx_id) == sent_transfer_tx

View File

@ -0,0 +1,181 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
# # Divisible assets integration testing
# This test checks if we can successfully divide assets.
# The script tests various things like:
#
# - create a transaction with a divisible asset and issue them to someone
# - check if the transaction is stored and has the right amount of tokens
# - spend some tokens
# - try to spend more tokens than available
#
# We run a series of checks for each step, that is retrieving
# the transaction from the remote system, and also checking the `amount`
# 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).
# ## Imports
# We need some utils from the `os` package, we will interact with
# env variables.
# We need the `pytest` package to catch the `BadRequest` exception properly.
# And of course, we also need the `BadRequest`.
import os
import pytest
from bigchaindb_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
def test_divisible_assets():
# ## Set up a connection to BigchainDB
# Check [test_basic.py](./test_basic.html) to get some more details
# about the endpoint.
bdb = BigchainDB(os.environ.get('BIGCHAINDB_ENDPOINT'))
# Oh look, it is Alice again and she brought her friend Bob along.
alice, bob = generate_keypair(), generate_keypair()
# ## Alice creates a time sharing token
# Alice wants to go on vacation, while Bobs bike just broke down.
# Alice decides to rent her bike to Bob while she is gone.
# So she prepares a `CREATE` transaction to issues 10 tokens.
# First, she prepares an asset for a time sharing token. As you can see in
# the description, Bob and Alice agree that each token can be used to ride
# the bike for one hour.
bike_token = {
'data': {
'token_for': {
'bike': {
'serial_number': 420420
}
},
'description': 'Time share token. Each token equals one hour of riding.',
},
}
# She prepares a `CREATE` transaction and issues 10 tokens.
# Here, Alice defines in a tuple that she wants to assign
# these 10 tokens to Bob.
prepared_token_tx = bdb.transactions.prepare(
operation='CREATE',
signers=alice.public_key,
recipients=[([bob.public_key], 10)],
asset=bike_token)
# She fulfills and sends the transaction.
fulfilled_token_tx = bdb.transactions.fulfill(
prepared_token_tx,
private_keys=alice.private_key)
bdb.transactions.send_commit(fulfilled_token_tx)
# We store the `id` of the transaction to use it later on.
bike_token_id = fulfilled_token_tx['id']
# Let's check if the transaction was successful.
assert bdb.transactions.retrieve(bike_token_id), \
'Cannot find transaction {}'.format(bike_token_id)
# Bob owns 10 tokens now.
assert bdb.transactions.retrieve(bike_token_id)['outputs'][0][
'amount'] == '10'
# ## Bob wants to use the bike
# Now that Bob got the tokens and the sun is shining, he wants to get out
# with the bike for three hours.
# To use the bike he has to send the tokens back to Alice.
# To learn about the details of transferring a transaction check out
# [test_basic.py](./test_basic.html)
transfer_asset = {'id': bike_token_id}
output_index = 0
output = fulfilled_token_tx['outputs'][output_index]
transfer_input = {'fulfillment': output['condition']['details'],
'fulfills': {'output_index': output_index,
'transaction_id': fulfilled_token_tx[
'id']},
'owners_before': output['public_keys']}
# To use the tokens Bob has to reassign 7 tokens to himself and the
# amount he wants to use to Alice.
prepared_transfer_tx = bdb.transactions.prepare(
operation='TRANSFER',
asset=transfer_asset,
inputs=transfer_input,
recipients=[([alice.public_key], 3), ([bob.public_key], 7)])
# He signs and sends the transaction.
fulfilled_transfer_tx = bdb.transactions.fulfill(
prepared_transfer_tx,
private_keys=bob.private_key)
sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)
# First, Bob checks if the transaction was successful.
assert bdb.transactions.retrieve(
fulfilled_transfer_tx['id']) == sent_transfer_tx
# There are two outputs in the transaction now.
# The first output shows that Alice got back 3 tokens...
assert bdb.transactions.retrieve(
fulfilled_transfer_tx['id'])['outputs'][0]['amount'] == '3'
# ... while Bob still has 7 left.
assert bdb.transactions.retrieve(
fulfilled_transfer_tx['id'])['outputs'][1]['amount'] == '7'
# ## Bob wants to ride the bike again
# It's been a week and Bob wants to right the bike again.
# Now he wants to ride for 8 hours, that's a lot Bob!
# He prepares the transaction again.
transfer_asset = {'id': bike_token_id}
# This time we need an `output_index` of 1, since we have two outputs
# in the `fulfilled_transfer_tx` we created before. The first output with
# index 0 is for Alice and the second output is for Bob.
# Since Bob wants to spend more of his tokens he has to provide the
# correct output with the correct amount of tokens.
output_index = 1
output = fulfilled_transfer_tx['outputs'][output_index]
transfer_input = {'fulfillment': output['condition']['details'],
'fulfills': {'output_index': output_index,
'transaction_id': fulfilled_transfer_tx['id']},
'owners_before': output['public_keys']}
# This time Bob only provides Alice in the `recipients` because he wants
# to spend all his tokens
prepared_transfer_tx = bdb.transactions.prepare(
operation='TRANSFER',
asset=transfer_asset,
inputs=transfer_input,
recipients=[([alice.public_key], 8)])
fulfilled_transfer_tx = bdb.transactions.fulfill(
prepared_transfer_tx,
private_keys=bob.private_key)
# Oh Bob, what have you done?! You tried to spend more tokens than you had.
# Remember Bob, last time you spent 3 tokens already,
# so you only have 7 left.
with pytest.raises(BadRequest) as error:
bdb.transactions.send_commit(fulfilled_transfer_tx)
# Now Bob gets an error saying that the amount he wanted to spent is
# higher than the amount of tokens he has left.
assert error.value.args[0] == 400
message = 'Invalid transaction (AmountError): The amount used in the ' \
'inputs `7` needs to be same as the amount used in the ' \
'outputs `8`'
assert error.value.args[2]['message'] == message
# We have to stop this test now, I am sorry, but Bob is pretty upset
# about his mistake. See you next time :)

View File

@ -0,0 +1,48 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
# # Double Spend testing
# This test challenge the system with double spends.
import os
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
def test_double_create():
bdb = BigchainDB(os.environ.get('BIGCHAINDB_ENDPOINT'))
alice = generate_keypair()
results = queue.Queue()
tx = bdb.transactions.fulfill(
bdb.transactions.prepare(
operation='CREATE',
signers=alice.public_key,
asset={'data': {'uuid': str(uuid4())}}),
private_keys=alice.private_key)
def send_and_queue(tx):
try:
bdb.transactions.send_commit(tx)
results.put('OK')
except bigchaindb_driver.exceptions.TransportError as e:
results.put('FAIL')
t1 = Thread(target=send_and_queue, args=(tx, ))
t2 = Thread(target=send_and_queue, args=(tx, ))
t1.start()
t2.start()
results = [results.get(timeout=2), results.get(timeout=2)]
assert results.count('OK') == 1
assert results.count('FAIL') == 1

View File

@ -0,0 +1,126 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
# # Multiple owners integration testing
# This test checks if we can successfully create and transfer a transaction
# with multiple owners.
# The script tests various things like:
#
# - create a transaction with multiple owners
# - check if the transaction is stored and has the right amount of public keys
# - transfer the transaction to a third person
#
# We run a series of checks for each step, that is retrieving
# the transaction from the remote system, and also checking the public keys
# 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).
# ## Imports
# We need some utils from the `os` package, we will interact with
# env variables.
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
def test_multiple_owners():
# ## Set up a connection to BigchainDB
# Check [test_basic.py](./test_basic.html) to get some more details
# about the endpoint.
bdb = BigchainDB(os.environ.get('BIGCHAINDB_ENDPOINT'))
# Hey Alice and Bob, nice to see you again!
alice, bob = generate_keypair(), generate_keypair()
# ## Alice and Bob create a transaction
# Alice and Bob just moved into a shared flat, no one can afford these
# high rents anymore. Bob suggests to get a dish washer for the
# kitchen. Alice agrees and here they go, creating the asset for their
# dish washer.
dw_asset = {
'data': {
'dish washer': {
'serial_number': 1337
}
}
}
# They prepare a `CREATE` transaction. To have multiple owners, both
# Bob and Alice need to be the recipients.
prepared_dw_tx = bdb.transactions.prepare(
operation='CREATE',
signers=alice.public_key,
recipients=(alice.public_key, bob.public_key),
asset=dw_asset)
# Now they both sign the transaction by providing their private keys.
# And send it afterwards.
fulfilled_dw_tx = bdb.transactions.fulfill(
prepared_dw_tx,
private_keys=[alice.private_key, bob.private_key])
bdb.transactions.send_commit(fulfilled_dw_tx)
# We store the `id` of the transaction to use it later on.
dw_id = fulfilled_dw_tx['id']
# Let's check if the transaction was successful.
assert bdb.transactions.retrieve(dw_id), \
'Cannot find transaction {}'.format(dw_id)
# The transaction should have two public keys in the outputs.
assert len(
bdb.transactions.retrieve(dw_id)['outputs'][0]['public_keys']) == 2
# ## Alice and Bob transfer a transaction to Carol.
# Alice and Bob save a lot of money living together. They often go out
# for dinner and don't cook at home. But now they don't have any dishes to
# wash, so they decide to sell the dish washer to their friend Carol.
# Hey Carol, nice to meet you!
carol = generate_keypair()
# Alice and Bob prepare the transaction to transfer the dish washer to
# Carol.
transfer_asset = {'id': dw_id}
output_index = 0
output = fulfilled_dw_tx['outputs'][output_index]
transfer_input = {'fulfillment': output['condition']['details'],
'fulfills': {'output_index': output_index,
'transaction_id': fulfilled_dw_tx[
'id']},
'owners_before': output['public_keys']}
# Now they create the transaction...
prepared_transfer_tx = bdb.transactions.prepare(
operation='TRANSFER',
asset=transfer_asset,
inputs=transfer_input,
recipients=carol.public_key)
# ... and sign it with their private keys, then send it.
fulfilled_transfer_tx = bdb.transactions.fulfill(
prepared_transfer_tx,
private_keys=[alice.private_key, bob.private_key])
sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)
# They check if the transaction was successful.
assert bdb.transactions.retrieve(
fulfilled_transfer_tx['id']) == sent_transfer_tx
# The owners before should include both Alice and Bob.
assert len(
bdb.transactions.retrieve(fulfilled_transfer_tx['id'])['inputs'][0][
'owners_before']) == 2
# While the new owner is Carol.
assert bdb.transactions.retrieve(fulfilled_transfer_tx['id'])[
'outputs'][0]['public_keys'][0] == carol.public_key

View File

@ -0,0 +1,101 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
# ## Testing potentially hazardous strings
# This test uses a library of `naughty` strings (code injections, weird unicode chars., etc.) as both keys and values.
# We look for either a successful tx, or in the case that we use a naughty string as a key, and it violates some key
# constraints, we expect to receive a well formatted error message.
# ## Imports
# We need some utils from the `os` package, we will interact with
# env variables.
import os
# Since the naughty strings get encoded and decoded in odd ways,
# we'll use a regex to sweep those details under the rug.
import re
# We'll use a nice library of naughty strings...
from blns import blns
# And parameterize our test so each one is treated as a separate test case
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
naughty_strings = blns.all()
# This is our base test case, but we'll reuse it to send naughty strings as both keys and values.
def send_naughty_tx(asset, metadata):
# ## Set up a connection to BigchainDB
# Check [test_basic.py](./test_basic.html) to get some more details
# about the endpoint.
bdb = BigchainDB(os.environ.get('BIGCHAINDB_ENDPOINT'))
# Here's Alice.
alice = generate_keypair()
# Alice is in a naughty mood today, so she creates a tx with some naughty strings
prepared_transaction = bdb.transactions.prepare(
operation='CREATE',
signers=alice.public_key,
asset=asset,
metadata=metadata)
# She fulfills the transaction
fulfilled_transaction = bdb.transactions.fulfill(
prepared_transaction,
private_keys=alice.private_key)
# The fulfilled tx gets sent to the BDB network
try:
sent_transaction = bdb.transactions.send_commit(fulfilled_transaction)
except BadRequest as e:
sent_transaction = e
# If her key contained a '.', began with a '$', or contained a NUL character
regex = '.*\..*|\$.*|.*\x00.*'
key = next(iter(metadata))
if re.match(regex, key):
# Then she expects a nicely formatted error code
status_code = sent_transaction.status_code
error = sent_transaction.error
regex = (
r'\{\s*\n*'
r'\s*"message":\s*"Invalid transaction \(ValidationError\):\s*'
r'Invalid key name.*The key name cannot contain characters.*\n*'
r'\s*"status":\s*400\n*'
r'\s*\}\n*')
assert status_code == 400
assert re.fullmatch(regex, error), sent_transaction
# Otherwise, she expects to see her transaction in the database
elif 'id' in sent_transaction.keys():
tx_id = sent_transaction['id']
assert bdb.transactions.retrieve(tx_id)
# If neither condition was true, then something weird happened...
else:
raise TypeError(sent_transaction)
@pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings)
def test_naughty_keys(naughty_string):
asset = {'data': {naughty_string: 'nice_value'}}
metadata = {naughty_string: 'nice_value'}
send_naughty_tx(asset, metadata)
@pytest.mark.parametrize("naughty_string", naughty_strings, ids=naughty_strings)
def test_naughty_values(naughty_string):
asset = {'data': {'nice_key': naughty_string}}
metadata = {'nice_key': naughty_string}
send_naughty_tx(asset, metadata)

View File

@ -0,0 +1,132 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
# # Stream Acceptance Test
# This test checks if the event stream works correctly. The basic idea of this
# test is to generate some random **valid** transaction, send them to a
# BigchainDB node, and expect those transactions to be returned by the valid
# transactions Stream API. During this test, two threads work together,
# sharing a queue to exchange events.
#
# - The *main thread* first creates and sends the transactions to BigchainDB;
# then it run through all events in the shared queue to check if all
# transactions sent have been validated by BigchainDB.
# - The *listen thread* listens to the events coming from BigchainDB and puts
# them in a queue shared with the main thread.
import os
import queue
import json
from threading import Thread, Event
from uuid import uuid4
# For this script, we need to set up a websocket connection, that's the reason
# we import the
# [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
def test_stream():
# ## Set up the test
# We use the env variable `BICHAINDB_ENDPOINT` to know where to connect.
# Check [test_basic.py](./test_basic.html) for more information.
BDB_ENDPOINT = os.environ.get('BIGCHAINDB_ENDPOINT')
# *That's pretty bad, but let's do like this for now.*
WS_ENDPOINT = 'ws://{}:9985/api/v1/streams/valid_transactions'.format(BDB_ENDPOINT.rsplit(':')[0])
bdb = BigchainDB(BDB_ENDPOINT)
# Hello to Alice again, she is pretty active in those tests, good job
# Alice!
alice = generate_keypair()
# We need few variables to keep the state, specifically we need `sent` to
# keep track of all transactions Alice sent to BigchainDB, while `received`
# are the transactions BigchainDB validated and sent back to her.
sent = []
received = queue.Queue()
# In this test we use a websocket. The websocket must be started **before**
# sending transactions to BigchainDB, otherwise we might lose some
# transactions. The `ws_ready` event is used to synchronize the main thread
# with the listen thread.
ws_ready = Event()
# ## Listening to events
# This is the function run by the complementary thread.
def listen():
# First we connect to the remote endpoint using the WebSocket protocol.
ws = create_connection(WS_ENDPOINT)
# After the connection has been set up, we can signal the main thread
# to proceed (continue reading, it should make sense in a second.)
ws_ready.set()
# It's time to consume all events coming from the BigchainDB stream API.
# Every time a new event is received, it is put in the queue shared
# with the main thread.
while True:
result = ws.recv()
received.put(result)
# Put `listen` in a thread, and start it. Note that `listen` is a local
# function and it can access all variables in the enclosing function.
t = Thread(target=listen, daemon=True)
t.start()
# ## Pushing the transactions to BigchainDB
# After starting the listen thread, we wait for it to connect, and then we
# proceed.
ws_ready.wait()
# Here we prepare, sign, and send ten different `CREATE` transactions. To
# make sure each transaction is different from the other, we generate a
# random `uuid`.
for _ in range(10):
tx = bdb.transactions.fulfill(
bdb.transactions.prepare(
operation='CREATE',
signers=alice.public_key,
asset={'data': {'uuid': str(uuid4())}}),
private_keys=alice.private_key)
# We don't want to wait for each transaction to be in a block. By using
# `async` mode, we make sure that the driver returns as soon as the
# transaction is pushed to the BigchainDB API. Remember: we expect all
# transactions to be in the shared queue: this is a two phase test,
# first we send a bunch of transactions, then we check if they are
# valid (and, in this case, they should).
bdb.transactions.send_async(tx)
# The `id` of every sent transaction is then stored in a list.
sent.append(tx['id'])
# ## Check the valid transactions coming from BigchainDB
# Now we are ready to check if BigchainDB did its job. A simple way to
# check if all sent transactions have been processed is to **remove** from
# `sent` the transactions we get from the *listen thread*. At one point in
# time, `sent` should be empty, and we exit the test.
while sent:
# To avoid waiting forever, we have an arbitrary timeout of 5
# seconds: it should be enough time for BigchainDB to create
# blocks, in fact a new block is created every second. If we hit
# the timeout, then game over ¯\\\_(ツ)\_/¯
try:
event = received.get(timeout=5)
txid = json.loads(event)['transaction_id']
except queue.Empty:
assert False, 'Did not receive all expected transactions'
# Last thing is to try to remove the `txid` from the set of sent
# transactions. If this test is running in parallel with others, we
# might get a transaction id of another test, and `remove` can fail.
# It's OK if this happens.
try:
sent.remove(txid)
except ValueError:
pass

View File

@ -1,37 +0,0 @@
version: '2'
services:
bdb:
build:
context: .
dockerfile: Dockerfile-dev
args:
backend: mongodb
volumes:
- ./bigchaindb:/usr/src/app/bigchaindb
- ./tests:/usr/src/app/tests
- ./docs:/usr/src/app/docs
- ./k8s:/usr/src/app/k8s
- ./setup.py:/usr/src/app/setup.py
- ./setup.cfg:/usr/src/app/setup.cfg
- ./pytest.ini:/usr/src/app/pytest.ini
- ./tox.ini:/usr/src/app/tox.ini
- ./scripts:/usr/src/app/scripts
environment:
BIGCHAINDB_DATABASE_BACKEND: mongodb
BIGCHAINDB_DATABASE_HOST: mdb
BIGCHAINDB_DATABASE_PORT: 27017
BIGCHAINDB_SERVER_BIND: 0.0.0.0:9984
BIGCHAINDB_GRAPHITE_HOST: graphite
ports:
- "9984"
command: bigchaindb start
graphite:
image: hopsoft/graphite-statsd
ports:
- "2003-2004"
- "2023-2024"
- "8125/udp"
- "8126"
- "80"

View File

@ -1,22 +1,27 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# Overview
A high-level description of the files and subdirectories of BigchainDB.
There are three database tables which underpin BigchainDB: `backlog`, where incoming transactions are held temporarily until they can be consumed; `bigchain`, where blocks of transactions are written permanently; and `votes`, where votes are written permanently. It is the votes in the `votes` table which must be queried to determine block validity and order. For more in-depth explanation, see [the whitepaper](https://www.bigchaindb.com/whitepaper/).
## Files
### [`core.py`](./core.py)
### [`lib.py`](lib.py)
The `Bigchain` class is defined here. Most operations outlined in the [whitepaper](https://www.bigchaindb.com/whitepaper/) as well as 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.
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.bigchaindb.com/projects/server/en/latest/data-models/index.html), but also include methods for validation and signing.
### [`consensus.py`](./consensus.py)
### [`validation.py`](./validation.py)
Base class for consensus methods (verification of votes, blocks, and transactions). The actual logic is mostly found in `transaction` and `block` models, defined in [`models.py`](./models.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)
@ -28,10 +33,6 @@ Methods for managing the configuration, including loading configuration files, a
## Folders
### [`pipelines`](./pipelines)
Structure and implementation of various subprocesses started in [`processes.py`](./processes.py).
### [`commands`](./commands)
Contains code for the [CLI](https://docs.bigchaindb.com/projects/server/en/latest/server-reference/bigchaindb-cli.html) for BigchainDB.

View File

@ -1,87 +1,80 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
import os
from bigchaindb.log.configs import SUBSCRIBER_LOGGING_CONFIG as log_config
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 functools import reduce
# PORT_NUMBER = reduce(lambda x, y: x * y, map(ord, 'BigchainDB')) % 2**16
# basically, the port number is 9984
_base_database_rethinkdb = {
'host': os.environ.get('BIGCHAINDB_DATABASE_HOST', 'localhost'),
'port': int(os.environ.get('BIGCHAINDB_DATABASE_PORT', 28015)),
'name': os.environ.get('BIGCHAINDB_DATABASE_NAME', 'bigchain'),
}
# The following variable is used by `bigchaindb configure` to
# prompt the user for database values. We cannot rely on
# _base_database_rethinkdb.keys() or _base_database_mongodb.keys()
# because dicts are unordered. I tried to configure
# _base_database_localmongodb.keys() because dicts are unordered.
# I tried to configure
_database_keys_map = {
'mongodb': ('host', 'port', 'name', 'replicaset'),
'rethinkdb': ('host', 'port', 'name')
'localmongodb': ('host', 'port', 'name'),
}
_base_database_mongodb = {
'host': os.environ.get('BIGCHAINDB_DATABASE_HOST', 'localhost'),
'port': int(os.environ.get('BIGCHAINDB_DATABASE_PORT', 27017)),
'name': os.environ.get('BIGCHAINDB_DATABASE_NAME', 'bigchain'),
'replicaset': os.environ.get('BIGCHAINDB_DATABASE_REPLICASET', 'bigchain-rs'),
'login': os.environ.get('BIGCHAINDB_DATABASE_LOGIN'),
'password': os.environ.get('BIGCHAINDB_DATABASE_PASSWORD')
_base_database_localmongodb = {
'host': 'localhost',
'port': 27017,
'name': 'bigchain',
'replicaset': None,
'login': None,
'password': None,
}
_database_rethinkdb = {
'backend': os.environ.get('BIGCHAINDB_DATABASE_BACKEND', 'rethinkdb'),
_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_rethinkdb.update(_base_database_rethinkdb)
_database_mongodb = {
'backend': os.environ.get('BIGCHAINDB_DATABASE_BACKEND', 'mongodb'),
'connection_timeout': 5000,
'max_tries': 3,
'ssl': bool(os.environ.get('BIGCHAINDB_DATABASE_SSL', False)),
'ca_cert': os.environ.get('BIGCHAINDB_DATABASE_CA_CERT'),
'certfile': os.environ.get('BIGCHAINDB_DATABASE_CERTFILE'),
'keyfile': os.environ.get('BIGCHAINDB_DATABASE_KEYFILE'),
'keyfile_passphrase': os.environ.get('BIGCHAINDB_DATABASE_KEYFILE_PASSPHRASE'),
'crlfile': os.environ.get('BIGCHAINDB_DATABASE_CRLFILE')
}
_database_mongodb.update(_base_database_mongodb)
_database_localmongodb.update(_base_database_localmongodb)
_database_map = {
'mongodb': _database_mongodb,
'rethinkdb': _database_rethinkdb
'localmongodb': _database_localmongodb,
}
config = {
'server': {
# Note: this section supports all the Gunicorn settings:
# - http://docs.gunicorn.org/en/stable/settings.html
'bind': os.environ.get('BIGCHAINDB_SERVER_BIND') or 'localhost:9984',
'bind': 'localhost:9984',
'loglevel': logging.getLevelName(
log_config['handlers']['console']['level']).lower(),
'workers': None, # if none, the value will be cpu_count * 2 + 1
'workers': None, # if None, the value will be cpu_count * 2 + 1
},
'wsserver': {
'scheme': os.environ.get('BIGCHAINDB_WSSERVER_SCHEME') or 'ws',
'host': os.environ.get('BIGCHAINDB_WSSERVER_HOST') or 'localhost',
'port': int(os.environ.get('BIGCHAINDB_WSSERVER_PORT', 9985)),
'scheme': 'ws',
'host': 'localhost',
'port': 9985,
'advertised_scheme': 'ws',
'advertised_host': 'localhost',
'advertised_port': 9985,
},
'database': _database_map[
os.environ.get('BIGCHAINDB_DATABASE_BACKEND', 'rethinkdb')
],
'keypair': {
'public': None,
'private': None,
'tendermint': {
'host': 'localhost',
'port': 26657,
'version': 'v0.31.5', # look for __tm_supported_versions__
},
'keyring': [],
'backlog_reassign_delay': 120,
# FIXME: hardcoding to localmongodb for now
'database': _database_map['localmongodb'],
'log': {
'file': log_config['handlers']['file']['filename'],
'error_file': log_config['handlers']['errors']['filename'],
@ -95,14 +88,19 @@ config = {
'fmt_logfile': log_config['formatters']['file']['format'],
'granular_levels': {},
},
'graphite': {
'host': os.environ.get('BIGCHAINDB_GRAPHITE_HOST', 'localhost'),
},
}
# 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``
# for more info.
_config = copy.deepcopy(config)
from bigchaindb.core import Bigchain # noqa
from bigchaindb.version import __version__ # noqa
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
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)

View File

@ -1,14 +1,20 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# Backend Interfaces
## Structure
- [`changefeed.py`](./changefeed.py): Changefeed-related interfaces
- [`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. [RethinkDB's](./rethinkdb)) are provided in sub-directories and
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

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
@ -7,7 +12,6 @@ configuration or the ``BIGCHAINDB_DATABASE_BACKEND`` environment variable.
"""
# Include the backend interfaces
from bigchaindb.backend import admin, changefeed, schema, query # noqa
from bigchaindb.backend import schema, query # noqa
from bigchaindb.backend.connection import connect # noqa
from bigchaindb.backend.changefeed import get_changefeed # noqa

View File

@ -1,34 +0,0 @@
"""Database configuration functions."""
from functools import singledispatch
@singledispatch
def get_config(connection, *, table):
raise NotImplementedError
@singledispatch
def reconfigure(connection, *, table, shards, replicas, **kwargs):
raise NotImplementedError
@singledispatch
def set_shards(connection, *, shards):
raise NotImplementedError
@singledispatch
def set_replicas(connection, *, replicas):
raise NotImplementedError
@singledispatch
def add_replicas(connection, replicas):
raise NotImplementedError('This command is specific to the '
'MongoDB backend.')
@singledispatch
def remove_replicas(connection, replicas):
raise NotImplementedError('This command is specific to the '
'MongoDB backend.')

View File

@ -1,90 +0,0 @@
"""Changefeed interfaces for backends."""
from functools import singledispatch
from multipipes import Node
import bigchaindb
class ChangeFeed(Node):
"""Create a new changefeed.
It extends :class:`multipipes.Node` to make it pluggable in other
Pipelines instances, and makes usage of ``self.outqueue`` to output
the data.
A changefeed is a real time feed on inserts, updates, and deletes, and
is volatile. This class is a helper to create changefeeds. Moreover,
it provides a way to specify a ``prefeed`` of iterable data to output
before the actual changefeed.
"""
INSERT = 1
DELETE = 2
UPDATE = 4
def __init__(self, table, operation, *, prefeed=None, connection=None):
"""Create a new ChangeFeed.
Args:
table (str): name of the table to listen to for changes.
operation (int): can be ChangeFeed.INSERT, ChangeFeed.DELETE, or
ChangeFeed.UPDATE. Combining multiple operations is possible
with the bitwise ``|`` operator
(e.g. ``ChangeFeed.INSERT | ChangeFeed.UPDATE``)
prefeed (:class:`~collections.abc.Iterable`, optional): whatever
set of data you want to be published first.
connection (:class:`~bigchaindb.backend.connection.Connection`, optional): # noqa
A connection to the database. If no connection is provided a
default connection will be created.
"""
super().__init__(name='changefeed')
self.prefeed = prefeed if prefeed else []
self.table = table
self.operation = operation
if connection:
self.connection = connection
else:
self.connection = bigchaindb.backend.connect(
**bigchaindb.config['database'])
def run_forever(self):
"""Main loop of the ``multipipes.Node``
This method is responsible for first feeding the prefeed to the
outqueue and after that starting the changefeed and recovering from any
errors that may occur in the backend.
"""
raise NotImplementedError
def run_changefeed(self):
"""Backend specific method to run the changefeed.
The changefeed is usually a backend cursor that is not closed when all
the results are exausted. Instead it remains open waiting for new
results.
This method should also filter each result based on the ``operation``
and put all matching results on the outqueue of ``multipipes.Node``.
"""
raise NotImplementedError
@singledispatch
def get_changefeed(connection, table, operation, *, prefeed=None):
"""Return a ChangeFeed.
Args:
connection (:class:`~bigchaindb.backend.connection.Connection`):
A connection to the database.
table (str): name of the table to listen to for changes.
operation (int): can be ChangeFeed.INSERT, ChangeFeed.DELETE, or
ChangeFeed.UPDATE. Combining multiple operation is possible
with the bitwise ``|`` operator
(e.g. ``ChangeFeed.INSERT | ChangeFeed.UPDATE``)
prefeed (iterable): whatever set of data you want to be published
first.
"""
raise NotImplementedError

View File

@ -1,15 +1,19 @@
from itertools import repeat
from importlib import import_module
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb
from bigchaindb.common.exceptions import ConfigurationError
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
BACKENDS = {
'mongodb': 'bigchaindb.backend.mongodb.connection.MongoDBConnection',
'rethinkdb': 'bigchaindb.backend.rethinkdb.connection.RethinkDBConnection'
'localmongodb': 'bigchaindb.backend.localmongodb.connection.LocalMongoDBConnection',
}
logger = logging.getLogger(__name__)
@ -44,24 +48,28 @@ def connect(backend=None, host=None, port=None, name=None, max_tries=None,
Authentication failure after connecting to the database.
"""
backend = backend or bigchaindb.config['database']['backend']
host = host or bigchaindb.config['database']['host']
port = port or bigchaindb.config['database']['port']
dbname = name or bigchaindb.config['database']['name']
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')
# 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.
replicaset = replicaset or bigchaindb.config['database'].get('replicaset')
ssl = ssl if ssl is not None else bigchaindb.config['database'].get('ssl', False)
login = login or bigchaindb.config['database'].get('login')
password = password or bigchaindb.config['database'].get('password')
ca_cert = ca_cert or bigchaindb.config['database'].get('ca_cert', None)
certfile = certfile or bigchaindb.config['database'].get('certfile', None)
keyfile = keyfile or bigchaindb.config['database'].get('keyfile', None)
keyfile_passphrase = keyfile_passphrase or bigchaindb.config['database'].get('keyfile_passphrase', None)
crlfile = crlfile or bigchaindb.config['database'].get('crlfile', 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')
try:
module_name, _, class_name = BACKENDS[backend].rpartition('.')
@ -110,7 +118,7 @@ class Connection:
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\
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)

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb.exceptions import BigchainDBError

View File

@ -1,22 +1,28 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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:`~bigchaindb.backend.changefeed`, :mod:`~bigchaindb.backend.query`, and
:mod:`~bigchaindb.backend.schema` interfaces.
:mod:`~bigchaindb.backend.schema` and :mod:`~bigchaindb.backend.query` interfaces.
You can specify BigchainDB to use MongoDB as its database backend by either
setting ``database.backend`` to ``'rethinkdb'`` in your configuration file, or
setting ``database.backend`` to ``'localmongodb'`` in your configuration file, or
setting the ``BIGCHAINDB_DATABASE_BACKEND`` environment variable to
``'rethinkdb'``.
``'localmongodb'``.
MongoDB is the default database backend for BigchainDB.
If configured to use MongoDB, BigchainDB will automatically return instances
of :class:`~bigchaindb.backend.rethinkdb.MongoDBConnection` for
of :class:`~bigchaindb.backend.localmongodb.LocalMongoDBConnection` for
:func:`~bigchaindb.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.mongodb import admin, schema, query, changefeed # noqa
from bigchaindb.backend.localmongodb import schema, query # noqa
# MongoDBConnection should always be accessed via
# ``bigchaindb.backend.connect()``.

View File

@ -0,0 +1,136 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb.backend.connection import Connection
from bigchaindb.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
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_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')
@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,
}

View File

@ -0,0 +1,377 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 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
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)])
)

View File

@ -0,0 +1,90 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb import backend
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.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)

View File

@ -1,86 +0,0 @@
"""Database configuration functions."""
import logging
from pymongo.errors import OperationFailure
from bigchaindb.backend import admin
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.exceptions import OperationError
from bigchaindb.backend.mongodb.connection import MongoDBConnection
logger = logging.getLogger(__name__)
register_admin = module_dispatch_registrar(admin)
@register_admin(MongoDBConnection)
def add_replicas(connection, replicas):
"""Add a set of replicas to the replicaset
Args:
connection (:class:`~bigchaindb.backend.connection.Connection`):
A connection to the database.
replicas (:obj:`list` of :obj:`str`): replica addresses in the
form "hostname:port".
Raises:
OperationError: If the reconfiguration fails due to a MongoDB
:exc:`OperationFailure`
"""
# get current configuration
conf = connection.conn.admin.command('replSetGetConfig')
# MongoDB does not automatically add an id for the members so we need
# to choose one that does not exist yet. The safest way is to use
# incrementing ids, so we first check what is the highest id already in
# the set and continue from there.
cur_id = max([member['_id'] for member in conf['config']['members']])
# add the nodes to the members list of the replica set
for replica in replicas:
cur_id += 1
conf['config']['members'].append({'_id': cur_id, 'host': replica})
# increase the configuration version number
# when reconfiguring, mongodb expects a version number higher than the one
# it currently has
conf['config']['version'] += 1
# apply new configuration
try:
connection.conn.admin.command('replSetReconfig', conf['config'])
except OperationFailure as exc:
raise OperationError(exc.details['errmsg'])
@register_admin(MongoDBConnection)
def remove_replicas(connection, replicas):
"""Remove a set of replicas from the replicaset
Args:
connection (:class:`~bigchaindb.backend.connection.Connection`):
A connection to the database.
replicas (:obj:`list` of :obj:`str`): replica addresses in the
form "hostname:port".
Raises:
OperationError: If the reconfiguration fails due to a MongoDB
:exc:`OperationFailure`
"""
# get the current configuration
conf = connection.conn.admin.command('replSetGetConfig')
# remove the nodes from the members list in the replica set
conf['config']['members'] = list(
filter(lambda member: member['host'] not in replicas,
conf['config']['members'])
)
# increase the configuration version number
conf['config']['version'] += 1
# apply new configuration
try:
connection.conn.admin.command('replSetReconfig', conf['config'])
except OperationFailure as exc:
raise OperationError(exc.details['errmsg'])

View File

@ -1,111 +0,0 @@
import logging
import time
import pymongo
from bigchaindb import backend
from bigchaindb.backend.changefeed import ChangeFeed
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.mongodb.connection import MongoDBConnection
from bigchaindb.backend.exceptions import BackendError
logger = logging.getLogger(__name__)
register_changefeed = module_dispatch_registrar(backend.changefeed)
class MongoDBChangeFeed(ChangeFeed):
"""This class implements a MongoDB changefeed as a multipipes Node.
We emulate the behaviour of the RethinkDB changefeed by using a tailable
cursor that listens for events on the oplog.
"""
def run_forever(self):
for element in self.prefeed:
self.outqueue.put(element)
table = self.table
dbname = self.connection.dbname
# last timestamp in the oplog. We only care for operations happening
# in the future.
last_ts = self.connection.run(
self.connection.query().local.oplog.rs.find()
.sort('$natural', pymongo.DESCENDING).limit(1)
.next()['ts'])
for record in run_changefeed(self.connection, table, last_ts):
is_insert = record['op'] == 'i'
is_delete = record['op'] == 'd'
is_update = record['op'] == 'u'
# mongodb documents uses the `_id` for the primary key.
# We are not using this field at this point and we need to
# remove it to prevent problems with schema validation.
# See https://github.com/bigchaindb/bigchaindb/issues/992
if is_insert and (self.operation & ChangeFeed.INSERT):
record['o'].pop('_id', None)
self.outqueue.put(record['o'])
elif is_delete and (self.operation & ChangeFeed.DELETE):
# on delete it only returns the id of the document
self.outqueue.put(record['o'])
elif is_update and (self.operation & ChangeFeed.UPDATE):
# the oplog entry for updates only returns the update
# operations to apply to the document and not the
# document itself. So here we first read the document
# and then return it.
doc = self.connection.conn[dbname][table].find_one(
{'_id': record['o2']['_id']},
{'_id': False}
)
self.outqueue.put(doc)
logger.debug('Record in changefeed: %s:%s', table, record['op'])
@register_changefeed(MongoDBConnection)
def get_changefeed(connection, table, operation, *, prefeed=None):
"""Return a MongoDB changefeed.
Returns:
An instance of
:class:`~bigchaindb.backend.mongodb.MongoDBChangeFeed`.
"""
return MongoDBChangeFeed(table, operation, prefeed=prefeed,
connection=connection)
_FEED_STOP = False
"""If it's True then the changefeed will return when there are no more items.
"""
def run_changefeed(conn, table, last_ts):
"""Encapsulate operational logic of tailing changefeed from MongoDB
"""
while True:
try:
# XXX: hack to force reconnection, in case the connection
# is lost while waiting on the cursor. See #1154.
conn._conn = None
namespace = conn.dbname + '.' + table
query = conn.query().local.oplog.rs.find(
{'ns': namespace, 'ts': {'$gt': last_ts}},
{'o._id': False},
cursor_type=pymongo.CursorType.TAILABLE_AWAIT
)
cursor = conn.run(query)
logging.debug('Tailing oplog at %s/%s', namespace, last_ts)
while cursor.alive:
try:
record = cursor.next()
yield record
last_ts = record['ts']
except StopIteration:
if _FEED_STOP:
return
except (BackendError, pymongo.errors.ConnectionFailure):
logger.exception('Lost connection while tailing oplog, retrying')
time.sleep(1)

View File

@ -1,258 +0,0 @@
import time
import logging
from ssl import CERT_REQUIRED
import pymongo
import bigchaindb
from bigchaindb.utils import Lazy
from bigchaindb.common.exceptions import ConfigurationError
from bigchaindb.backend.exceptions import (DuplicateKeyError,
OperationError,
ConnectionError)
from bigchaindb.backend.connection import Connection
logger = logging.getLogger(__name__)
class MongoDBConnection(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 bigchaindb.config['database']['replicaset']
self.ssl = ssl if ssl is not None else bigchaindb.config['database'].get('ssl', False)
self.login = login or bigchaindb.config['database'].get('login')
self.password = password or bigchaindb.config['database'].get('password')
self.ca_cert = ca_cert or bigchaindb.config['database'].get('ca_cert', None)
self.certfile = certfile or bigchaindb.config['database'].get('certfile', None)
self.keyfile = keyfile or bigchaindb.config['database'].get('keyfile', None)
self.keyfile_passphrase = keyfile_passphrase or bigchaindb.config['database'].get('keyfile_passphrase', None)
self.crlfile = crlfile or bigchaindb.config['database'].get('crlfile', None)
@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 as exc:
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:
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:
# we should only return a connection if the replica set is
# initialized. initialize_replica_set will check if the
# replica set is initialized else it will initialize it.
initialize_replica_set(self.host,
self.port,
self.connection_timeout,
self.dbname,
self.ssl,
self.login,
self.password,
self.ca_cert,
self.certfile,
self.keyfile,
self.keyfile_passphrase,
self.crlfile)
# 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)
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)
if self.login is not None:
client[self.dbname].authenticate(self.login,
mechanism='MONGODB-X509')
return client
# `initialize_replica_set` might raise `ConnectionFailure`,
# `OperationFailure` or `ConfigurationError`.
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
def initialize_replica_set(host, port, connection_timeout, dbname, ssl, login,
password, ca_cert, certfile, keyfile,
keyfile_passphrase, crlfile):
"""Initialize a replica set. If already initialized skip."""
# Setup a MongoDB connection
# The reason we do this instead of `backend.connect` is that
# `backend.connect` will connect you to a replica set but this fails if
# you try to connect to a replica set that is not yet initialized
try:
# The presence of ca_cert, certfile, keyfile, crlfile implies the
# use of certificates for TLS connectivity.
if ca_cert is None or certfile is None or keyfile is None or \
crlfile is None:
conn = pymongo.MongoClient(host,
port,
serverselectiontimeoutms=connection_timeout,
ssl=ssl)
if login is not None and password is not None:
conn[dbname].authenticate(login, password)
else:
logger.info('Connecting to MongoDB over TLS/SSL...')
conn = pymongo.MongoClient(host,
port,
serverselectiontimeoutms=connection_timeout,
ssl=ssl,
ssl_ca_certs=ca_cert,
ssl_certfile=certfile,
ssl_keyfile=keyfile,
ssl_pem_passphrase=keyfile_passphrase,
ssl_crlfile=crlfile,
ssl_cert_reqs=CERT_REQUIRED)
if login is not None:
logger.info('Authenticating to the database...')
conn[dbname].authenticate(login, mechanism='MONGODB-X509')
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
_check_replica_set(conn)
host = '{}:{}'.format(bigchaindb.config['database']['host'],
bigchaindb.config['database']['port'])
config = {'_id': bigchaindb.config['database']['replicaset'],
'members': [{'_id': 0, 'host': host}]}
try:
conn.admin.command('replSetInitiate', config)
except pymongo.errors.OperationFailure as exc_info:
if exc_info.details['codeName'] == 'AlreadyInitialized':
return
raise
else:
_wait_for_replica_set_initialization(conn)
logger.info('Initialized replica set')
finally:
if conn is not None:
logger.info('Closing initial connection to MongoDB')
conn.close()
def _check_replica_set(conn):
"""Checks if the replSet option was enabled either through the command
line option or config file and if it matches the one provided by
bigchaindb configuration.
Note:
The setting we are looking for will have a different name depending
if it was set by the config file (`replSetName`) or by command
line arguments (`replSet`).
Raise:
:exc:`~ConfigurationError`: If mongod was not started with the
replSet option.
"""
options = conn.admin.command('getCmdLineOpts')
try:
repl_opts = options['parsed']['replication']
repl_set_name = repl_opts.get('replSetName', repl_opts.get('replSet'))
except KeyError:
raise ConfigurationError('mongod was not started with'
' the replSet option.')
bdb_repl_set_name = bigchaindb.config['database']['replicaset']
if repl_set_name != bdb_repl_set_name:
raise ConfigurationError('The replicaset configuration of '
'bigchaindb (`{}`) needs to match '
'the replica set name from MongoDB'
' (`{}`)'.format(bdb_repl_set_name,
repl_set_name))
def _wait_for_replica_set_initialization(conn):
"""Wait for a replica set to finish initialization.
If a replica set is being initialized for the first time it takes some
time. Nodes need to discover each other and an election needs to take
place. During this time the database is not writable so we need to wait
before continuing with the rest of the initialization
"""
# I did not find a better way to do this for now.
# To check if the database is ready we will poll the mongodb logs until
# we find the line that says the database is ready
logger.info('Waiting for mongodb replica set initialization')
while True:
logs = conn.admin.command('getLog', 'rs')['log']
if any('database writes are now permitted' in line for line in logs):
return
time.sleep(0.1)

View File

@ -1,371 +0,0 @@
"""Query implementation for MongoDB"""
from time import time
from pymongo import ReturnDocument
from bigchaindb import backend
from bigchaindb.backend.mongodb.changefeed import run_changefeed
from bigchaindb.common.exceptions import CyclicBlockchainError
from bigchaindb.common.transaction import Transaction
from bigchaindb.backend.exceptions import DuplicateKeyError, OperationError
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.mongodb.connection import MongoDBConnection
register_query = module_dispatch_registrar(backend.query)
@register_query(MongoDBConnection)
def write_transaction(conn, signed_transaction):
try:
return conn.run(
conn.collection('backlog')
.insert_one(signed_transaction))
except DuplicateKeyError:
return
@register_query(MongoDBConnection)
def update_transaction(conn, transaction_id, doc):
# with mongodb we need to add update operators to the doc
doc = {'$set': doc}
return conn.run(
conn.collection('backlog')
.find_one_and_update(
{'id': transaction_id},
doc,
return_document=ReturnDocument.AFTER))
@register_query(MongoDBConnection)
def delete_transaction(conn, *transaction_id):
return conn.run(
conn.collection('backlog')
.delete_many({'id': {'$in': transaction_id}}))
@register_query(MongoDBConnection)
def get_stale_transactions(conn, reassign_delay):
return conn.run(
conn.collection('backlog')
.find({'assignment_timestamp': {'$lt': time() - reassign_delay}},
projection={'_id': False}))
@register_query(MongoDBConnection)
def get_transaction_from_block(conn, transaction_id, block_id):
try:
return conn.run(
conn.collection('bigchain')
.aggregate([
{'$match': {'id': block_id}},
{'$project': {
'block.transactions': {
'$filter': {
'input': '$block.transactions',
'as': 'transaction',
'cond': {
'$eq': ['$$transaction.id', transaction_id]
}
}
}
}}])
.next()['block']['transactions']
.pop())
except (StopIteration, IndexError):
# StopIteration is raised if the block was not found
# IndexError is returned if the block is found but no transactions
# match
return
@register_query(MongoDBConnection)
def get_transaction_from_backlog(conn, transaction_id):
return conn.run(
conn.collection('backlog')
.find_one({'id': transaction_id},
projection={'_id': False,
'assignee': False,
'assignment_timestamp': False}))
@register_query(MongoDBConnection)
def get_blocks_status_from_transaction(conn, transaction_id):
return conn.run(
conn.collection('bigchain')
.find({'block.transactions.id': transaction_id},
projection=['id', 'block.voters']))
@register_query(MongoDBConnection)
def get_txids_filtered(conn, asset_id, operation=None):
match_create = {
'block.transactions.operation': 'CREATE',
'block.transactions.id': asset_id
}
match_transfer = {
'block.transactions.operation': 'TRANSFER',
'block.transactions.asset.id': asset_id
}
if operation == Transaction.CREATE:
match = match_create
elif operation == Transaction.TRANSFER:
match = match_transfer
else:
match = {'$or': [match_create, match_transfer]}
pipeline = [
{'$match': match},
{'$unwind': '$block.transactions'},
{'$match': match},
{'$project': {'block.transactions.id': True}}
]
cursor = conn.run(
conn.collection('bigchain')
.aggregate(pipeline))
return (elem['block']['transactions']['id'] for elem in cursor)
# TODO: This doesn't seem to be used anywhere
@register_query(MongoDBConnection)
def get_asset_by_id(conn, asset_id):
cursor = conn.run(
conn.collection('bigchain')
.aggregate([
{'$match': {
'block.transactions.id': asset_id,
'block.transactions.operation': 'CREATE'
}},
{'$unwind': '$block.transactions'},
{'$match': {
'block.transactions.id': asset_id,
'block.transactions.operation': 'CREATE'
}},
{'$project': {'block.transactions.asset': True}}
]))
# we need to access some nested fields before returning so lets use a
# generator to avoid having to read all records on the cursor at this point
return (elem['block']['transactions'] for elem in cursor)
@register_query(MongoDBConnection)
def get_spent(conn, transaction_id, output):
cursor = conn.run(
conn.collection('bigchain').aggregate([
{'$match': {
'block.transactions.inputs': {
'$elemMatch': {
'fulfills.transaction_id': transaction_id,
'fulfills.output_index': output,
},
},
}},
{'$unwind': '$block.transactions'},
{'$match': {
'block.transactions.inputs': {
'$elemMatch': {
'fulfills.transaction_id': transaction_id,
'fulfills.output_index': output,
},
},
}},
]))
# we need to access some nested fields before returning so lets use a
# generator to avoid having to read all records on the cursor at this point
return (elem['block']['transactions'] for elem in cursor)
@register_query(MongoDBConnection)
def get_spending_transactions(conn, inputs):
cursor = conn.run(
conn.collection('bigchain').aggregate([
{'$match': {
'block.transactions.inputs.fulfills': {
'$in': inputs,
},
}},
{'$unwind': '$block.transactions'},
{'$match': {
'block.transactions.inputs.fulfills': {
'$in': inputs,
},
}},
]))
return ((b['id'], b['block']['transactions']) for b in cursor)
@register_query(MongoDBConnection)
def get_owned_ids(conn, owner):
cursor = conn.run(
conn.collection('bigchain').aggregate([
{'$match': {'block.transactions.outputs.public_keys': owner}},
{'$unwind': '$block.transactions'},
{'$match': {'block.transactions.outputs.public_keys': owner}}
]))
return ((b['id'], b['block']['transactions']) for b in cursor)
@register_query(MongoDBConnection)
def get_votes_by_block_id(conn, block_id):
return conn.run(
conn.collection('votes')
.find({'vote.voting_for_block': block_id},
projection={'_id': False}))
@register_query(MongoDBConnection)
def get_votes_for_blocks_by_voter(conn, block_ids, node_pubkey):
return conn.run(
conn.collection('votes')
.find({'vote.voting_for_block': {'$in': block_ids},
'node_pubkey': node_pubkey},
projection={'_id': False}))
@register_query(MongoDBConnection)
def get_votes_by_block_id_and_voter(conn, block_id, node_pubkey):
return conn.run(
conn.collection('votes')
.find({'vote.voting_for_block': block_id,
'node_pubkey': node_pubkey},
projection={'_id': False}))
@register_query(MongoDBConnection)
def write_block(conn, block_dict):
return conn.run(
conn.collection('bigchain')
.insert_one(block_dict))
@register_query(MongoDBConnection)
def get_block(conn, block_id):
return conn.run(
conn.collection('bigchain')
.find_one({'id': block_id},
projection={'_id': False}))
@register_query(MongoDBConnection)
def write_assets(conn, assets):
try:
# unordered means that all the inserts will be attempted instead of
# stopping after the first error.
return conn.run(
conn.collection('assets')
.insert_many(assets, ordered=False))
# This can happen if we try to write the same asset multiple times.
# One case is when we write the same transaction into multiple blocks due
# to invalid blocks.
# The actual mongodb exception is a BulkWriteError due to a duplicated key
# in one of the inserts.
except OperationError:
return
@register_query(MongoDBConnection)
def get_assets(conn, asset_ids):
return conn.run(
conn.collection('assets')
.find({'id': {'$in': asset_ids}},
projection={'_id': False}))
@register_query(MongoDBConnection)
def count_blocks(conn):
return conn.run(
conn.collection('bigchain')
.count())
@register_query(MongoDBConnection)
def count_backlog(conn):
return conn.run(
conn.collection('backlog')
.count())
@register_query(MongoDBConnection)
def write_vote(conn, vote):
conn.run(conn.collection('votes').insert_one(vote))
vote.pop('_id')
return vote
@register_query(MongoDBConnection)
def get_genesis_block(conn):
return conn.run(
conn.collection('bigchain')
.find_one(
{'block.transactions.0.operation': 'GENESIS'},
{'_id': False}
))
@register_query(MongoDBConnection)
def get_last_voted_block_id(conn, node_pubkey):
last_voted = conn.run(
conn.collection('votes')
.find({'node_pubkey': node_pubkey},
sort=[('vote.timestamp', -1)]))
# pymongo seems to return a cursor even if there are no results
# so we actually need to check the count
if last_voted.count() == 0:
return get_genesis_block(conn)['id']
mapping = {v['vote']['previous_block']: v['vote']['voting_for_block']
for v in last_voted}
last_block_id = list(mapping.values())[0]
explored = set()
while True:
try:
if last_block_id in explored:
raise CyclicBlockchainError()
explored.add(last_block_id)
last_block_id = mapping[last_block_id]
except KeyError:
break
return last_block_id
@register_query(MongoDBConnection)
def get_new_blocks_feed(conn, start_block_id):
namespace = conn.dbname + '.bigchain'
match = {'o.id': start_block_id, 'op': 'i', 'ns': namespace}
# Neccesary to find in descending order since tests may write same block id several times
query = conn.query().local.oplog.rs.find(match).sort('$natural', -1).next()['ts']
last_ts = conn.run(query)
feed = run_changefeed(conn, 'bigchain', last_ts)
return (evt['o'] for evt in feed if evt['op'] == 'i')
@register_query(MongoDBConnection)
def text_search(conn, search, *, language='english', case_sensitive=False,
diacritic_sensitive=False, text_score=False, limit=0):
cursor = conn.run(
conn.collection('assets')
.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(asset) for asset in cursor)
def _remove_text_score(asset):
asset.pop('score', None)
return asset

View File

@ -1,118 +0,0 @@
"""Utils to initialize and drop the database."""
import logging
from pymongo import ASCENDING, DESCENDING, TEXT
from bigchaindb import backend
from bigchaindb.common import exceptions
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.mongodb.connection import MongoDBConnection
logger = logging.getLogger(__name__)
register_schema = module_dispatch_registrar(backend.schema)
@register_schema(MongoDBConnection)
def create_database(conn, dbname):
if dbname in conn.conn.database_names():
raise exceptions.DatabaseAlreadyExists('Database `{}` already exists'
.format(dbname))
logger.info('Create database `%s`.', dbname)
# TODO: read and write concerns can be declared here
conn.conn.get_database(dbname)
@register_schema(MongoDBConnection)
def create_tables(conn, dbname):
for table_name in ['bigchain', 'backlog', 'votes', 'assets']:
logger.info('Create `%s` table.', table_name)
# create the table
# TODO: read and write concerns can be declared here
conn.conn[dbname].create_collection(table_name)
@register_schema(MongoDBConnection)
def create_indexes(conn, dbname):
create_bigchain_secondary_index(conn, dbname)
create_backlog_secondary_index(conn, dbname)
create_votes_secondary_index(conn, dbname)
create_assets_secondary_index(conn, dbname)
@register_schema(MongoDBConnection)
def drop_database(conn, dbname):
conn.conn.drop_database(dbname)
def create_bigchain_secondary_index(conn, dbname):
logger.info('Create `bigchain` secondary index.')
# to order blocks by timestamp
conn.conn[dbname]['bigchain'].create_index([('block.timestamp',
ASCENDING)],
name='block_timestamp')
# to query the bigchain for a transaction id, this field is unique
conn.conn[dbname]['bigchain'].create_index('block.transactions.id',
name='transaction_id')
# secondary index for asset uuid, this field is unique
conn.conn[dbname]['bigchain']\
.create_index('block.transactions.asset.id', name='asset_id')
# secondary index on the public keys of outputs
conn.conn[dbname]['bigchain']\
.create_index('block.transactions.outputs.public_keys',
name='outputs')
# secondary index on inputs/transaction links (transaction_id, output)
conn.conn[dbname]['bigchain']\
.create_index([
('block.transactions.inputs.fulfills.transaction_id', ASCENDING),
('block.transactions.inputs.fulfills.output_index', ASCENDING),
], name='inputs')
def create_backlog_secondary_index(conn, dbname):
logger.info('Create `backlog` secondary index.')
# secondary index on the transaction id with a uniqueness constraint
# to make sure there are no duplicated transactions in the backlog
conn.conn[dbname]['backlog'].create_index('id',
name='transaction_id',
unique=True)
# compound index to read transactions from the backlog per assignee
conn.conn[dbname]['backlog']\
.create_index([('assignee', ASCENDING),
('assignment_timestamp', DESCENDING)],
name='assignee__transaction_timestamp')
def create_votes_secondary_index(conn, dbname):
logger.info('Create `votes` secondary index.')
# is the first index redundant then?
# compound index to order votes by block id and node
conn.conn[dbname]['votes'].create_index([('vote.voting_for_block',
ASCENDING),
('node_pubkey',
ASCENDING)],
name='block_and_voter',
unique=True)
def create_assets_secondary_index(conn, dbname):
logger.info('Create `assets` secondary index.')
# unique index on the id of the asset.
# the id is the txid of the transaction that created the asset
conn.conn[dbname]['assets'].create_index('id',
name='asset_id',
unique=True)
# full text search index
conn.conn[dbname]['assets'].create_index([('$**', TEXT)], name='text')

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
@ -6,11 +11,11 @@ from bigchaindb.backend.exceptions import OperationError
@singledispatch
def write_transaction(connection, signed_transaction):
"""Write a transaction to the backlog table.
def store_asset(connection, asset):
"""Write an asset to the asset table.
Args:
signed_transaction (dict): a signed transaction.
asset (dict): the asset.
Returns:
The result of the operation.
@ -20,104 +25,77 @@ def write_transaction(connection, signed_transaction):
@singledispatch
def update_transaction(connection, transaction_id, doc):
"""Update a transaction in the backlog table.
def store_assets(connection, assets):
"""Write a list of assets to the assets table.
Args:
transaction_id (str): the id of the transaction.
doc (dict): the values to update.
Returns:
The result of the operation.
"""
raise NotImplementedError
@singledispatch
def delete_transaction(connection, *transaction_id):
"""Delete a transaction from the backlog.
Args:
*transaction_id (str): the transaction(s) to delete.
assets (list): a list of assets to write.
Returns:
The database response.
"""
raise NotImplementedError
@singledispatch
def get_stale_transactions(connection, reassign_delay):
"""Get a cursor of stale transactions.
Transactions are considered stale if they have been assigned a node,
but are still in the backlog after some amount of time specified in the
configuration.
def store_metadatas(connection, metadata):
"""Write a list of metadata to metadata table.
Args:
reassign_delay (int): threshold (in seconds) to mark a transaction stale.
metadata (list): list of metadata.
Returns:
A cursor of transactions.
The result of the operation.
"""
raise NotImplementedError
@singledispatch
def get_transaction_from_block(connection, transaction_id, block_id):
"""Get a transaction from a specific block.
Args:
transaction_id (str): the id of the transaction.
block_id (str): the id of the block.
Returns:
The matching transaction.
"""
def store_transactions(connection, signed_transactions):
"""Store the list of transactions."""
raise NotImplementedError
@singledispatch
def get_transaction_from_backlog(connection, transaction_id):
"""Get a transaction from backlog.
def get_transaction(connection, transaction_id):
"""Get a transaction from the transactions table.
Args:
transaction_id (str): the id of the transaction.
Returns:
The matching transaction.
The result of the operation.
"""
raise NotImplementedError
@singledispatch
def get_blocks_status_from_transaction(connection, transaction_id):
"""Retrieve block election information given a secondary index and value.
def get_transactions(connection, transaction_ids):
"""Get transactions from the transactions table.
Args:
value: a value to search (e.g. transaction id string, payload hash string)
index (str): name of a secondary index, e.g. 'transaction_id'
transaction_ids (list): list of transaction ids to fetch
Returns:
:obj:`list` of :obj:`dict`: A list of blocks with with only election information
The result of the operation.
"""
raise NotImplementedError
@singledispatch
def get_asset_by_id(conneciton, asset_id):
"""Returns the asset associated with an asset_id.
def get_asset(connection, asset_id):
"""Get a transaction from the transactions table.
Args:
asset_id (str): The asset id.
asset_id (str): the id of the asset
Returns:
Returns a rethinkdb cursor.
The result of the operation.
"""
raise NotImplementedError
@ -170,63 +148,6 @@ def get_owned_ids(connection, owner):
raise NotImplementedError
@singledispatch
def get_votes_by_block_id(connection, block_id):
"""Get all the votes casted for a specific block.
Args:
block_id (str): the block id to use.
Returns:
A cursor for the matching votes.
"""
raise NotImplementedError
@singledispatch
def get_votes_by_block_id_and_voter(connection, block_id, node_pubkey):
"""Get all the votes casted for a specific block by a specific voter.
Args:
block_id (str): the block id to use.
node_pubkey (str): base58 encoded public key
Returns:
A cursor for the matching votes.
"""
raise NotImplementedError
@singledispatch
def get_votes_for_blocks_by_voter(connection, block_ids, pubkey):
"""Return votes for many block_ids
Args:
block_ids (set): block_ids
pubkey (str): public key of voting node
Returns:
A cursor of votes matching given block_ids and public key
"""
raise NotImplementedError
@singledispatch
def write_block(connection, block):
"""Write a block to the bigchain table.
Args:
block (dict): the block to write.
Returns:
The database response.
"""
raise NotImplementedError
@singledispatch
def get_block(connection, block_id):
"""Get a block from the bigchain table.
@ -242,14 +163,29 @@ def get_block(connection, block_id):
@singledispatch
def write_assets(connection, assets):
"""Write a list of assets to the assets table.
def get_block_with_transaction(connection, txid):
"""Get a block containing transaction id `txid`
Args:
assets (list): a list of assets to write.
txid (str): id of transaction to be searched.
Returns:
The database response.
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
@ -257,83 +193,18 @@ def write_assets(connection, assets):
@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 count_blocks(connection):
"""Count the number of blocks in the bigchain table.
Returns:
The number of blocks.
"""
raise NotImplementedError
@singledispatch
def count_backlog(connection):
"""Count the number of transactions in the backlog table.
Returns:
The number of transactions in the backlog.
"""
raise NotImplementedError
@singledispatch
def write_vote(connection, vote):
"""Write a vote to the votes table.
Args:
vote (dict): the vote to write.
Returns:
The database response.
"""
raise NotImplementedError
@singledispatch
def get_genesis_block(connection):
"""Get the genesis block.
Returns:
The genesis block
"""
raise NotImplementedError
@singledispatch
def get_last_voted_block_id(connection, node_pubkey):
"""Get the last voted block for a specific node.
Args:
node_pubkey (str): base58 encoded public key.
Returns:
The id of the last block the node has voted on. If the node didn't cast
any vote then the genesis block id is returned.
"""
raise NotImplementedError
@singledispatch
def get_txids_filtered(connection, asset_id, operation=None):
"""
Return all transactions for a particular asset id and optional operation.
"""Return all transactions for a particular asset id and optional operation.
Args:
asset_id (str): ID of transaction that defined the asset
@ -343,24 +214,9 @@ def get_txids_filtered(connection, asset_id, operation=None):
raise NotImplementedError
@singledispatch
def get_new_blocks_feed(connection, start_block_id):
"""
Return a generator that yields change events of the blocks feed
Args:
start_block_id (str): ID of block to resume from
Returns:
Generator of change events
"""
raise NotImplementedError
@singledispatch
def text_search(conn, search, *, language='english', case_sensitive=False,
diacritic_sensitive=False, text_score=False, limit=0):
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.
@ -389,3 +245,186 @@ def text_search(conn, search, *, language='english', case_sensitive=False,
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

View File

@ -1,22 +0,0 @@
"""RethinkDB backend implementation.
Contains a RethinkDB-specific implementation of the
:mod:`~bigchaindb.backend.changefeed`, :mod:`~bigchaindb.backend.query`, and
:mod:`~bigchaindb.backend.schema` interfaces.
You can specify BigchainDB to use RethinkDB as its database backend by either
setting ``database.backend`` to ``'rethinkdb'`` in your configuration file, or
setting the ``BIGCHAINDB_DATABASE_BACKEND`` environment variable to
``'rethinkdb'``.
If configured to use RethinkDB, BigchainDB will automatically return instances
of :class:`~bigchaindb.backend.rethinkdb.RethinkDBConnection` for
:func:`~bigchaindb.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.rethinkdb import admin, changefeed, schema, query # noqa
# RethinkDBConnection should always be accessed via
# ``bigchaindb.backend.connect()``.

View File

@ -1,165 +0,0 @@
"""Database configuration functions."""
import logging
import rethinkdb as r
from bigchaindb.backend import admin
from bigchaindb.backend.schema import TABLES
from bigchaindb.backend.exceptions import OperationError
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.rethinkdb.connection import RethinkDBConnection
logger = logging.getLogger(__name__)
register_admin = module_dispatch_registrar(admin)
@register_admin(RethinkDBConnection)
def get_config(connection, *, table):
"""Get the configuration of the given table.
Args:
connection (:class:`~bigchaindb.backend.connection.Connection`):
A connection to the database.
table (str): The name of the table to get the configuration for.
Returns:
dict: The configuration of the given table
"""
return connection.run(r.table(table).config())
@register_admin(RethinkDBConnection)
def reconfigure(connection, *, table, shards, replicas,
primary_replica_tag=None, dry_run=False,
nonvoting_replica_tags=None):
"""Reconfigures the given table.
Args:
connection (:class:`~bigchaindb.backend.connection.Connection`):
A connection to the database.
table (str): The name of the table to reconfigure.
shards (int): The number of shards, an integer from 1-64.
replicas (:obj:`int` | :obj:`dict`):
* If replicas is an integer, it specifies the number of
replicas per shard. Specifying more replicas than there
are servers will return an error.
* If replicas is a dictionary, it specifies key-value pairs
of server tags and the number of replicas to assign to
those servers::
{'africa': 2, 'asia': 4, 'europe': 2, ...}
primary_replica_tag (str): The primary server specified by its
server tag. Required if ``replicas`` is a dictionary. The
tag must be in the ``replicas`` dictionary. This must not be
specified if ``replicas`` is an integer. Defaults to
``None``.
dry_run (bool): If ``True`` the generated configuration will not
be applied to the table, only returned. Defaults to
``False``.
nonvoting_replica_tags (:obj:`list` of :obj:`str`): Replicas
with these server tags will be added to the
``nonvoting_replicas`` list of the resulting configuration.
Defaults to ``None``.
Returns:
dict: A dictionary with possibly three keys:
* ``reconfigured``: the number of tables reconfigured. This
will be ``0`` if ``dry_run`` is ``True``.
* ``config_changes``: a list of new and old table
configuration values.
* ``status_changes``: a list of new and old table status
values.
For more information please consult RethinkDB's
documentation `ReQL command: reconfigure
<https://rethinkdb.com/api/python/reconfigure/>`_.
Raises:
OperationError: If the reconfiguration fails due to a
RethinkDB :exc:`ReqlOpFailedError` or
:exc:`ReqlQueryLogicError`.
"""
params = {
'shards': shards,
'replicas': replicas,
'dry_run': dry_run,
}
if primary_replica_tag:
params.update(
primary_replica_tag=primary_replica_tag,
nonvoting_replica_tags=nonvoting_replica_tags,
)
try:
return connection.run(r.table(table).reconfigure(**params))
except (r.ReqlOpFailedError, r.ReqlQueryLogicError) as e:
raise OperationError('Failed to reconfigure tables.') from e
@register_admin(RethinkDBConnection)
def set_shards(connection, *, shards, dry_run=False):
"""Sets the shards for the tables
:const:`~bigchaindb.backend.schema.TABLES`.
Args:
connection (:class:`~bigchaindb.backend.connection.Connection`):
A connection to the database.
shards (int): The number of shards, an integer from 1-64.
dry_run (bool): If ``True`` the generated configuration will not
be applied to the table, only returned. Defaults to
``False``.
Returns:
dict: A dictionary with the configuration and status changes.
For more details please see :func:`.reconfigure`.
"""
changes = {}
for table in TABLES:
replicas = len(
get_config(connection, table=table)['shards'][0]['replicas'])
change = reconfigure(
connection,
table=table,
shards=shards,
replicas=replicas,
dry_run=dry_run,
)
changes[table] = change
return changes
@register_admin(RethinkDBConnection)
def set_replicas(connection, *, replicas, dry_run=False):
"""Sets the replicas for the tables
:const:`~bigchaindb.backend.schema.TABLES`.
Args:
connection (:class:`~bigchaindb.backend.connection.Connection`):
A connection to the database.
replicas (int): The number of replicas per shard. Specifying
more replicas than there are servers will return an error.
dry_run (bool): If ``True`` the generated configuration will not
be applied to the table, only returned. Defaults to
``False``.
Returns:
dict: A dictionary with the configuration and status changes.
For more details please see :func:`.reconfigure`.
"""
changes = {}
for table in TABLES:
shards = len(get_config(connection, table=table)['shards'])
change = reconfigure(
connection,
table=table,
shards=shards,
replicas=replicas,
dry_run=dry_run,
)
changes[table] = change
return changes

View File

@ -1,59 +0,0 @@
import time
import logging
import rethinkdb as r
from bigchaindb import backend
from bigchaindb.backend.exceptions import BackendError
from bigchaindb.backend.changefeed import ChangeFeed
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.rethinkdb.connection import RethinkDBConnection
logger = logging.getLogger(__name__)
register_changefeed = module_dispatch_registrar(backend.changefeed)
class RethinkDBChangeFeed(ChangeFeed):
"""This class wraps a RethinkDB changefeed as a multipipes Node."""
def run_forever(self):
for element in self.prefeed:
self.outqueue.put(element)
for change in run_changefeed(self.connection, self.table):
is_insert = change['old_val'] is None
is_delete = change['new_val'] is None
is_update = not is_insert and not is_delete
if is_insert and (self.operation & ChangeFeed.INSERT):
self.outqueue.put(change['new_val'])
elif is_delete and (self.operation & ChangeFeed.DELETE):
self.outqueue.put(change['old_val'])
elif is_update and (self.operation & ChangeFeed.UPDATE):
self.outqueue.put(change['new_val'])
def run_changefeed(connection, table):
"""Encapsulate operational logic of tailing changefeed from RethinkDB
"""
while True:
try:
for change in connection.run(r.table(table).changes()):
yield change
break
except (BackendError, r.ReqlDriverError) as exc:
logger.exception('Error connecting to the database, retrying')
time.sleep(1)
@register_changefeed(RethinkDBConnection)
def get_changefeed(connection, table, operation, *, prefeed=None):
"""Return a RethinkDB changefeed.
Returns:
An instance of
:class:`~bigchaindb.backend.rethinkdb.RethinkDBChangeFeed`.
"""
return RethinkDBChangeFeed(table, operation, prefeed=prefeed,
connection=connection)

View File

@ -1,47 +0,0 @@
import rethinkdb as r
from bigchaindb.backend.connection import Connection
from bigchaindb.backend.exceptions import ConnectionError, OperationError
class RethinkDBConnection(Connection):
"""
This class is a proxy to run queries against the database, it is:
- lazy, since it creates a connection only when needed
- resilient, because before raising exceptions it tries
more times to run the query or open a connection.
"""
def run(self, query):
"""Run a RethinkDB query.
Args:
query: the RethinkDB query.
Raises:
:exc:`rethinkdb.ReqlDriverError`: After
:attr:`~.RethinkDBConnection.max_tries`.
"""
try:
return query.run(self.conn)
except r.ReqlDriverError as exc:
raise OperationError from exc
def _connect(self):
"""Set a connection to RethinkDB.
The connection is available via :attr:`~.RethinkDBConnection.conn`.
Raises:
:exc:`rethinkdb.ReqlDriverError`: After
:attr:`~.RethinkDBConnection.max_tries`.
"""
try:
return r.connect(host=self.host,
port=self.port,
db=self.dbname,
timeout=self.connection_timeout)
except (r.ReqlDriverError, r.ReqlTimeoutError) as exc:
raise ConnectionError from exc

View File

@ -1,298 +0,0 @@
from itertools import chain
import logging as logger
from time import time
import rethinkdb as r
from bigchaindb import backend, utils
from bigchaindb.backend.rethinkdb import changefeed
from bigchaindb.common import exceptions
from bigchaindb.common.transaction import Transaction
from bigchaindb.common.utils import serialize
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.rethinkdb.connection import RethinkDBConnection
logger = logger.getLogger(__name__)
READ_MODE = 'majority'
WRITE_DURABILITY = 'hard'
register_query = module_dispatch_registrar(backend.query)
@register_query(RethinkDBConnection)
def write_transaction(connection, signed_transaction):
return connection.run(
r.table('backlog')
.insert(signed_transaction, durability=WRITE_DURABILITY))
@register_query(RethinkDBConnection)
def update_transaction(connection, transaction_id, doc):
return connection.run(
r.table('backlog')
.get(transaction_id)
.update(doc))
@register_query(RethinkDBConnection)
def delete_transaction(connection, *transaction_id):
return connection.run(
r.table('backlog')
.get_all(*transaction_id)
.delete(durability=WRITE_DURABILITY))
@register_query(RethinkDBConnection)
def get_stale_transactions(connection, reassign_delay):
return connection.run(
r.table('backlog')
.filter(lambda tx: time() - tx['assignment_timestamp'] > reassign_delay))
@register_query(RethinkDBConnection)
def get_transaction_from_block(connection, transaction_id, block_id):
return connection.run(
r.table('bigchain', read_mode=READ_MODE)
.get(block_id)
.get_field('block')
.get_field('transactions')
.filter(lambda tx: tx['id'] == transaction_id))[0]
@register_query(RethinkDBConnection)
def get_transaction_from_backlog(connection, transaction_id):
return connection.run(
r.table('backlog')
.get(transaction_id)
.without('assignee', 'assignment_timestamp')
.default(None))
@register_query(RethinkDBConnection)
def get_blocks_status_from_transaction(connection, transaction_id):
return connection.run(
r.table('bigchain', read_mode=READ_MODE)
.get_all(transaction_id, index='transaction_id')
.pluck('votes', 'id', {'block': ['voters']}))
@register_query(RethinkDBConnection)
def get_txids_filtered(connection, asset_id, operation=None):
# here we only want to return the transaction ids since later on when
# we are going to retrieve the transaction with status validation
parts = []
if operation in (Transaction.CREATE, None):
# First find the asset's CREATE transaction
parts.append(connection.run(
_get_asset_create_tx_query(asset_id).get_field('id')))
if operation in (Transaction.TRANSFER, None):
# Then find any TRANSFER transactions related to the asset
parts.append(connection.run(
r.table('bigchain')
.get_all(asset_id, index='asset_id')
.concat_map(lambda block: block['block']['transactions'])
.filter(lambda transaction: transaction['asset']['id'] == asset_id)
.get_field('id')))
return chain(*parts)
@register_query(RethinkDBConnection)
def get_asset_by_id(connection, asset_id):
return connection.run(_get_asset_create_tx_query(asset_id).pluck('asset'))
def _get_asset_create_tx_query(asset_id):
return r.table('bigchain', read_mode=READ_MODE) \
.get_all(asset_id, index='transaction_id') \
.concat_map(lambda block: block['block']['transactions']) \
.filter(lambda transaction: transaction['id'] == asset_id)
@register_query(RethinkDBConnection)
def get_spent(connection, transaction_id, output):
return connection.run(
r.table('bigchain', read_mode=READ_MODE)
.get_all([transaction_id, output], index='inputs')
.concat_map(lambda doc: doc['block']['transactions'])
.filter(lambda transaction: transaction['inputs'].contains(
lambda input_: input_['fulfills'] == {
'transaction_id': transaction_id, 'output_index': output})))
@register_query(RethinkDBConnection)
def get_owned_ids(connection, owner):
query = (r.table('bigchain', read_mode=READ_MODE)
.get_all(owner, index='outputs')
.distinct()
.concat_map(unwind_block_transactions)
.filter(lambda doc: doc['tx']['outputs'].contains(
lambda c: c['public_keys'].contains(owner))))
cursor = connection.run(query)
return ((b['id'], b['tx']) for b in cursor)
@register_query(RethinkDBConnection)
def get_votes_by_block_id(connection, block_id):
return connection.run(
r.table('votes', read_mode=READ_MODE)
.between([block_id, r.minval], [block_id, r.maxval], index='block_and_voter')
.without('id'))
@register_query(RethinkDBConnection)
def get_votes_by_block_id_and_voter(connection, block_id, node_pubkey):
return connection.run(
r.table('votes')
.get_all([block_id, node_pubkey], index='block_and_voter')
.without('id'))
@register_query(RethinkDBConnection)
def write_block(connection, block_dict):
return connection.run(
r.table('bigchain')
.insert(r.json(serialize(block_dict)), durability=WRITE_DURABILITY))
@register_query(RethinkDBConnection)
def get_block(connection, block_id):
return connection.run(r.table('bigchain').get(block_id))
@register_query(RethinkDBConnection)
def write_assets(connection, assets):
return connection.run(
r.table('assets')
.insert(assets, durability=WRITE_DURABILITY))
@register_query(RethinkDBConnection)
def get_assets(connection, asset_ids):
return connection.run(
r.table('assets', read_mode=READ_MODE)
.get_all(*asset_ids))
@register_query(RethinkDBConnection)
def count_blocks(connection):
return connection.run(
r.table('bigchain', read_mode=READ_MODE)
.count())
@register_query(RethinkDBConnection)
def count_backlog(connection):
return connection.run(
r.table('backlog', read_mode=READ_MODE)
.count())
@register_query(RethinkDBConnection)
def write_vote(connection, vote):
return connection.run(
r.table('votes')
.insert(vote))
@register_query(RethinkDBConnection)
def get_genesis_block(connection):
return connection.run(
r.table('bigchain', read_mode=READ_MODE)
.filter(utils.is_genesis_block)
.nth(0))
@register_query(RethinkDBConnection)
def get_last_voted_block_id(connection, node_pubkey):
try:
# get the latest value for the vote timestamp (over all votes)
max_timestamp = connection.run(
r.table('votes', read_mode=READ_MODE)
.filter(r.row['node_pubkey'] == node_pubkey)
.max(r.row['vote']['timestamp']))['vote']['timestamp']
last_voted = list(connection.run(
r.table('votes', read_mode=READ_MODE)
.filter(r.row['vote']['timestamp'] == max_timestamp)
.filter(r.row['node_pubkey'] == node_pubkey)))
except r.ReqlNonExistenceError:
# return last vote if last vote exists else return Genesis block
return get_genesis_block(connection)['id']
# Now the fun starts. Since the resolution of timestamp is a second,
# we might have more than one vote per timestamp. If this is the case
# then we need to rebuild the chain for the blocks that have been retrieved
# to get the last one.
# Given a block_id, mapping returns the id of the block pointing at it.
mapping = {v['vote']['previous_block']: v['vote']['voting_for_block']
for v in last_voted}
# Since we follow the chain backwards, we can start from a random
# point of the chain and "move up" from it.
last_block_id = list(mapping.values())[0]
# We must be sure to break the infinite loop. This happens when:
# - the block we are currenty iterating is the one we are looking for.
# This will trigger a KeyError, breaking the loop
# - we are visiting again a node we already explored, hence there is
# a loop. This might happen if a vote points both `previous_block`
# and `voting_for_block` to the same `block_id`
explored = set()
while True:
try:
if last_block_id in explored:
raise exceptions.CyclicBlockchainError()
explored.add(last_block_id)
last_block_id = mapping[last_block_id]
except KeyError:
break
return last_block_id
@register_query(RethinkDBConnection)
def get_new_blocks_feed(connection, start_block_id): # pragma: no cover
logger.warning('RethinkDB changefeed unable to resume from given block: %s',
start_block_id)
# In order to get blocks in the correct order, it may be acceptable to
# look in the votes table to see what order other nodes have used.
for change in changefeed.run_changefeed(connection, 'bigchain'):
yield change['new_val']
@register_query(RethinkDBConnection)
def get_votes_for_blocks_by_voter(connection, block_ids, node_pubkey):
return connection.run(
r.table('votes')
.filter(lambda row: r.expr(block_ids).contains(row['vote']['voting_for_block']))
.filter(lambda row: row['node_pubkey'] == node_pubkey))
def unwind_block_transactions(block):
""" Yield a block for each transaction in given block """
return block['block']['transactions'].map(lambda tx: block.merge({'tx': tx}))
@register_query(RethinkDBConnection)
def get_spending_transactions(connection, links):
query = (
r.table('bigchain')
.get_all(*[(l['transaction_id'], l['output_index']) for l in links],
index='inputs')
.concat_map(unwind_block_transactions)
# filter transactions spending output
.filter(lambda doc: r.expr(links).set_intersection(
doc['tx']['inputs'].map(lambda i: i['fulfills'])))
)
cursor = connection.run(query)
return ((b['id'], b['tx']) for b in cursor)

View File

@ -1,130 +0,0 @@
import logging
import rethinkdb as r
from bigchaindb import backend
from bigchaindb.common import exceptions
from bigchaindb.backend.utils import module_dispatch_registrar
from bigchaindb.backend.rethinkdb.connection import RethinkDBConnection
logger = logging.getLogger(__name__)
register_schema = module_dispatch_registrar(backend.schema)
@register_schema(RethinkDBConnection)
def create_database(connection, dbname):
if connection.run(r.db_list().contains(dbname)):
raise exceptions.DatabaseAlreadyExists('Database `{}` already exists'.format(dbname))
logger.info('Create database `%s`.', dbname)
connection.run(r.db_create(dbname))
@register_schema(RethinkDBConnection)
def create_tables(connection, dbname):
for table_name in ['bigchain', 'backlog', 'votes', 'assets']:
logger.info('Create `%s` table.', table_name)
connection.run(r.db(dbname).table_create(table_name))
@register_schema(RethinkDBConnection)
def create_indexes(connection, dbname):
create_bigchain_secondary_index(connection, dbname)
create_backlog_secondary_index(connection, dbname)
create_votes_secondary_index(connection, dbname)
@register_schema(RethinkDBConnection)
def drop_database(connection, dbname):
try:
logger.info('Drop database `%s`', dbname)
connection.run(r.db_drop(dbname))
logger.info('Done.')
except r.ReqlOpFailedError:
raise exceptions.DatabaseDoesNotExist('Database `{}` does not exist'.format(dbname))
def create_bigchain_secondary_index(connection, dbname):
logger.info('Create `bigchain` secondary index.')
# to order blocks by timestamp
connection.run(
r.db(dbname)
.table('bigchain')
.index_create('block_timestamp', r.row['block']['timestamp']))
# to query the bigchain for a transaction id
connection.run(
r.db(dbname)
.table('bigchain')
.index_create('transaction_id', r.row['block']['transactions']['id'], multi=True))
# secondary index for asset links (in TRANSFER transactions)
connection.run(
r.db(dbname)
.table('bigchain')
.index_create('asset_id', r.row['block']['transactions']['asset']['id'], multi=True))
# secondary index on the public keys of outputs
# the last reduce operation is to return a flatten list of public_keys
# without it we would need to match exactly the public_keys list.
# For instance querying for `pk1` would not match documents with
# `public_keys: [pk1, pk2, pk3]`
connection.run(
r.db(dbname)
.table('bigchain')
.index_create('outputs',
r.row['block']['transactions']
.concat_map(lambda tx: tx['outputs']['public_keys'])
.reduce(lambda l, r: l + r), multi=True))
# secondary index on inputs/transaction links (transaction_id, output)
connection.run(
r.db(dbname)
.table('bigchain')
.index_create('inputs',
r.row['block']['transactions']
.concat_map(lambda tx: tx['inputs']['fulfills'])
.with_fields('transaction_id', 'output_index')
.map(lambda fulfills: [fulfills['transaction_id'],
fulfills['output_index']]),
multi=True))
# wait for rethinkdb to finish creating secondary indexes
connection.run(
r.db(dbname)
.table('bigchain')
.index_wait())
def create_backlog_secondary_index(connection, dbname):
logger.info('Create `backlog` secondary index.')
# compound index to read transactions from the backlog per assignee
connection.run(
r.db(dbname)
.table('backlog')
.index_create('assignee__transaction_timestamp', [r.row['assignee'], r.row['assignment_timestamp']]))
# wait for rethinkdb to finish creating secondary indexes
connection.run(
r.db(dbname)
.table('backlog')
.index_wait())
def create_votes_secondary_index(connection, dbname):
logger.info('Create `votes` secondary index.')
# compound index to order votes by block id and node
connection.run(
r.db(dbname)
.table('votes')
.index_create('block_and_voter', [r.row['vote']['voting_for_block'], r.row['node_pubkey']]))
# wait for rethinkdb to finish creating secondary indexes
connection.run(
r.db(dbname)
.table('votes')
.index_wait())

View File

@ -1,25 +1,29 @@
"""Database creation and schema-providing interfaces for backends.
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
Attributes:
TABLES (tuple): The three standard tables BigchainDB relies on:
* ``backlog`` for incoming transactions awaiting to be put into
a block.
* ``bigchain`` for blocks.
* ``votes`` to store votes for each block by each federation
node.
"""
"""Database creation and schema-providing interfaces for backends."""
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
logger = logging.getLogger(__name__)
TABLES = ('bigchain', 'backlog', 'votes')
# 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
@ -28,10 +32,6 @@ def create_database(connection, dbname):
Args:
dbname (str): the name of the database to create.
Raises:
:exc:`~DatabaseAlreadyExists`: If the given :attr:`dbname` already
exists as a database.
"""
raise NotImplementedError
@ -48,17 +48,6 @@ def create_tables(connection, dbname):
raise NotImplementedError
@singledispatch
def create_indexes(connection, dbname):
"""Create the indexes to be used by BigchainDB.
Args:
dbname (str): the name of the database to create indexes for.
"""
raise NotImplementedError
@singledispatch
def drop_database(connection, dbname):
"""Drop the database used by BigchainDB.
@ -87,10 +76,6 @@ def init_database(connection=None, dbname=None):
dbname (str): the name of the database to create.
Defaults to the database name given in the BigchainDB
configuration.
Raises:
:exc:`~DatabaseAlreadyExists`: If the given :attr:`dbname` already
exists as a database.
"""
connection = connection or connect()
@ -98,4 +83,46 @@ def init_database(connection=None, dbname=None):
create_database(connection, dbname)
create_tables(connection, dbname)
create_indexes(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 = bigchaindb.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)

View File

@ -1,6 +1,15 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb
class ModuleDispatchRegistrationError(Exception):
"""Raised when there is a problem registering dispatched functions for a
module"""
module
"""
def module_dispatch_registrar(module):
@ -15,6 +24,16 @@ def module_dispatch_registrar(module):
('`{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
func=func_name, module=module.__name__)) from ex
return wrapper
return dispatch_wrapper
def get_bigchaindb_config_value(key, default_value=None):
return bigchaindb.config['database'].get(key, default_value)
def get_bigchaindb_config_value_or_key_error(key):
return bigchaindb.config['database'][key]

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 `bigchaindb` command,
the command-line interface (CLI) for BigchainDB Server.
"""
@ -9,25 +14,24 @@ import copy
import json
import sys
from bigchaindb.common import crypto
from bigchaindb.common.exceptions import (StartupError,
DatabaseAlreadyExists,
KeypairNotFoundException,
DatabaseDoesNotExist)
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,
ValidationError)
from bigchaindb.elections.vote import Vote
import bigchaindb
from bigchaindb import backend, processes
from bigchaindb import (backend, ValidatorElection,
BigchainDB)
from bigchaindb.backend import schema
from bigchaindb.backend.admin import (set_replicas, set_shards, add_replicas,
remove_replicas)
from bigchaindb.backend.exceptions import OperationError
from bigchaindb.commands import utils
from bigchaindb.commands.messages import (
CANNOT_START_KEYPAIR_NOT_FOUND,
RETHINKDB_STARTUP_ERROR,
)
from bigchaindb.commands.utils import (
configure_bigchaindb, start_logging_process, input_on_stderr)
from bigchaindb.commands.utils import (configure_bigchaindb,
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__
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
@ -47,17 +51,12 @@ def run_show_config(args):
# configure the system.
config = copy.deepcopy(bigchaindb.config)
del config['CONFIGURED']
private_key = config['keypair']['private']
config['keypair']['private'] = 'x' * 45 if private_key else None
print(json.dumps(config, indent=4, sort_keys=True))
def run_configure(args, skip_if_exists=False):
"""Run a script to configure the current node.
Args:
skip_if_exists (bool): skip the function if a config file already exists
"""
@configure_bigchaindb
def run_configure(args):
"""Run a script to configure the current node."""
config_path = args.config or bigchaindb.config_utils.CONFIG_DEFAULT_PATH
config_file_exists = False
@ -65,9 +64,6 @@ def run_configure(args, skip_if_exists=False):
if config_path != '-':
config_file_exists = os.path.exists(config_path)
if config_file_exists and skip_if_exists:
return
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))
@ -76,15 +72,6 @@ def run_configure(args, skip_if_exists=False):
conf = copy.deepcopy(bigchaindb.config)
# Patch the default configuration with the new values
conf = bigchaindb.config_utils.update(
conf,
bigchaindb.config_utils.env_config(bigchaindb.config))
print('Generating keypair', file=sys.stderr)
conf['keypair']['private'], conf['keypair']['public'] = \
crypto.generate_key_pair()
# select the correct config defaults based on the backend
print('Generating default configuration for backend {}'
.format(args.backend), file=sys.stderr)
@ -104,9 +91,9 @@ def run_configure(args, skip_if_exists=False):
val = conf['database'][key]
conf['database'][key] = input_on_stderr('Database {}? (default `{}`): '.format(key, val), val)
val = conf['backlog_reassign_delay']
conf['backlog_reassign_delay'] = input_on_stderr(
'Stale transaction reassignment delay (in seconds)? (default `{}`): '.format(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 != '-':
bigchaindb.config_utils.write_config(conf, config_path)
@ -117,41 +104,152 @@ def run_configure(args, skip_if_exists=False):
@configure_bigchaindb
def run_export_my_pubkey(args):
"""Export this node's public key to standard output
"""
pubkey = bigchaindb.config['keypair']['public']
if pubkey is not None:
print(pubkey)
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:
sys.exit("This node's public key wasn't set anywhere "
"so it can't be exported")
# raises SystemExit exception
# message is sent to stderr
# exits with exit code 1 (signals tha an error happened)
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():
# Try to access the keypair, throws an exception if it does not exist
b = bigchaindb.Bigchain()
bdb = bigchaindb.BigchainDB()
schema.init_database(connection=b.connection)
b.create_genesis_block()
logger.info('Genesis block created.')
schema.init_database(connection=bdb.connection)
@configure_bigchaindb
def run_init(args):
"""Initialize the database"""
# TODO Provide mechanism to:
# 1. prompt the user to inquire whether they wish to drop the db
# 2. force the init, (e.g., via -f flag)
try:
_run_init()
except DatabaseAlreadyExists:
print('The database already exists.', file=sys.stderr)
print('If you wish to re-initialize it, first drop it.', file=sys.stderr)
_run_init()
@configure_bigchaindb
@ -165,90 +263,42 @@ def run_drop(args):
return
conn = backend.connect()
dbname = bigchaindb.config['database']['name']
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_bigchaindb
@start_logging_process
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())
if args.allow_temp_keypair:
if not (bigchaindb.config['keypair']['private'] or
bigchaindb.config['keypair']['public']):
private_key, public_key = crypto.generate_key_pair()
bigchaindb.config['keypair']['private'] = private_key
bigchaindb.config['keypair']['public'] = public_key
else:
logger.warning('Keypair found, no need to create one on the fly.')
if args.start_rethinkdb:
try:
proc = utils.start_rethinkdb()
except StartupError as e:
sys.exit(RETHINKDB_STARTUP_ERROR.format(e))
logger.info('RethinkDB started with PID %s' % proc.pid)
try:
if not args.skip_initialize_database:
logger.info('Initializing database')
_run_init()
except DatabaseAlreadyExists:
pass
except KeypairNotFoundException:
sys.exit(CANNOT_START_KEYPAIR_NOT_FOUND)
logger.info('Starting BigchainDB main process with public key %s',
bigchaindb.config['keypair']['public'])
processes.start()
logger.info('Starting BigchainDB main process.')
from bigchaindb.start import start
start(args)
@configure_bigchaindb
def run_set_shards(args):
conn = backend.connect()
try:
set_shards(conn, shards=args.num_shards)
except OperationError as e:
sys.exit(str(e))
@configure_bigchaindb
def run_set_replicas(args):
conn = backend.connect()
try:
set_replicas(conn, replicas=args.num_replicas)
except OperationError as e:
sys.exit(str(e))
@configure_bigchaindb
def run_add_replicas(args):
# Note: This command is specific to MongoDB
conn = backend.connect()
try:
add_replicas(conn, args.replicas)
except (OperationError, NotImplementedError) as e:
sys.exit(str(e))
else:
print('Added {} to the replicaset.'.format(args.replicas))
@configure_bigchaindb
def run_remove_replicas(args):
# Note: This command is specific to MongoDB
conn = backend.connect()
try:
remove_replicas(conn, args.replicas)
except (OperationError, NotImplementedError) as e:
sys.exit(str(e))
else:
print('Removed {} from the replicaset.'.format(args.replicas))
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():
@ -265,20 +315,56 @@ def create_parser():
# parser for writing a config file
config_parser = subparsers.add_parser('configure',
help='Prepare the config file '
'and create the node keypair')
help='Prepare the config file.')
config_parser.add_argument('backend',
choices=['rethinkdb', 'mongodb'],
help='The backend to use. It can be either '
'rethinkdb or mongodb.')
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 <some_election_type> <args>...
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')
subparsers.add_parser('export-my-pubkey',
help="Export this node's public key")
# parser for database-level commands
subparsers.add_parser('init',
help='Init the database')
@ -290,57 +376,21 @@ def create_parser():
start_parser = subparsers.add_parser('start',
help='Start BigchainDB')
start_parser.add_argument('--dev-allow-temp-keypair',
dest='allow_temp_keypair',
start_parser.add_argument('--no-init',
dest='skip_initialize_database',
default=False,
action='store_true',
help='Generate a random keypair on start')
help='Skip database initialization')
start_parser.add_argument('--dev-start-rethinkdb',
dest='start_rethinkdb',
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='Run RethinkDB on start')
help='💀 EXPERIMENTAL: parallelize validation for better throughput 💀')
# parser for configuring the number of shards
sharding_parser = subparsers.add_parser('set-shards',
help='Configure number of shards')
sharding_parser.add_argument('num_shards', metavar='num_shards',
type=int, default=1,
help='Number of shards')
# parser for configuring the number of replicas
replicas_parser = subparsers.add_parser('set-replicas',
help='Configure number of replicas')
replicas_parser.add_argument('num_replicas', metavar='num_replicas',
type=int, default=1,
help='Number of replicas (i.e. the replication factor)')
# parser for adding nodes to the replica set
add_replicas_parser = subparsers.add_parser('add-replicas',
help='Add a set of nodes to the '
'replica set. This command '
'is specific to the MongoDB'
' backend.')
add_replicas_parser.add_argument('replicas', nargs='+',
type=utils.mongodb_host,
help='A list of space separated hosts to '
'add to the replicaset. Each host '
'should be in the form `host:port`.')
# parser for removing nodes from the replica set
rm_replicas_parser = subparsers.add_parser('remove-replicas',
help='Remove a set of nodes from the '
'replica set. This command '
'is specific to the MongoDB'
' backend.')
rm_replicas_parser.add_argument('replicas', nargs='+',
type=utils.mongodb_host,
help='A list of space separated hosts to '
'remove from the replicaset. Each host '
'should be in the form `host:port`.')
return parser

View File

@ -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.'
}
}
}
}

View File

@ -1,10 +0,0 @@
"""Module to store messages used in commands, such as error messages,
warnings, prompts, etc.
"""
CANNOT_START_KEYPAIR_NOT_FOUND = (
"Can't start BigchainDB, no keypair found. "
'Did you run `bigchaindb configure`?'
)
RETHINKDB_STARTUP_ERROR = 'Error starting RethinkDB, reason is: {}'

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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``.
"""
@ -6,17 +11,10 @@ import argparse
import builtins
import functools
import multiprocessing as mp
import subprocess
import sys
import rethinkdb as r
from pymongo import uri_parser
import bigchaindb
import bigchaindb.config_utils
from bigchaindb import backend
from bigchaindb.common.exceptions import StartupError
from bigchaindb.log.setup import setup_logging
from bigchaindb.version import __version__
@ -34,16 +32,18 @@ def configure_bigchaindb(command):
"""
@functools.wraps(command)
def configure(args):
config_from_cmdline = None
try:
config_from_cmdline = {
'log': {
'level_console': args.log_level,
'level_logfile': args.log_level,
},
'server': {'loglevel': args.log_level},
}
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:
config_from_cmdline = None
pass
bigchaindb.config_utils.autoconfigure(
filename=args.config, config=config_from_cmdline, force=True)
command(args)
@ -51,32 +51,6 @@ def configure_bigchaindb(command):
return configure
def start_logging_process(command):
"""Decorator to start the logging subscriber process.
Args:
command: The command to decorate.
Returns:
The command wrapper function.
.. 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:`bigchaindb.config` at the moment this decorator
is invoked.
"""
@functools.wraps(command)
def start_logging(args):
from bigchaindb import config
setup_logging(user_log_config=config.get('log'))
command(args)
return start_logging
def _convert(value, default=None, convert=None):
def convert_bool(value):
if value.lower() in ('true', 't', 'yes', 'y'):
@ -123,46 +97,6 @@ def input_on_stderr(prompt='', default=None, convert=None):
return _convert(value, default, convert)
def start_rethinkdb():
"""Start RethinkDB as a child process and wait for it to be
available.
Raises:
:class:`~bigchaindb.common.exceptions.StartupError` if
RethinkDB cannot be started.
"""
proc = subprocess.Popen(['rethinkdb', '--bind', 'all'],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
dbname = bigchaindb.config['database']['name']
line = ''
for line in proc.stdout:
if line.startswith('Server ready'):
# FIXME: seems like tables are not ready when the server is ready,
# that's why we need to query RethinkDB to know the state
# of the database. This code assumes the tables are ready
# when the database is ready. This seems a valid assumption.
try:
conn = backend.connect()
# Before checking if the db is ready, we need to query
# the server to check if it contains that db
if conn.run(r.db_list().contains(dbname)):
conn.run(r.db(dbname).wait())
except (r.ReqlOpFailedError, r.ReqlDriverError) as exc:
raise StartupError('Error waiting for the database `{}` '
'to be ready'.format(dbname)) from exc
return proc
# We are here when we exhaust the stdout of the process.
# The last `line` contains info about the error.
raise StartupError(line)
def start(parser, argv, scope):
"""Utility function to execute a subcommand.
@ -204,44 +138,17 @@ def start(parser, argv, scope):
return func(args)
def mongodb_host(host):
"""Utility function that works as a type for mongodb ``host`` args.
This function validates the ``host`` args provided by to the
``add-replicas`` and ``remove-replicas`` commands and checks if each arg
is in the form "host:port"
Args:
host (str): A string containing hostname and port (e.g. "host:port")
Raises:
ArgumentTypeError: if it fails to parse the argument
"""
# check if mongodb can parse the host
try:
hostname, port = uri_parser.parse_host(host, default_port=None)
except ValueError as exc:
raise argparse.ArgumentTypeError(exc.args[0])
# we do require the port to be provided.
if port is None or hostname == '':
raise argparse.ArgumentTypeError('expected host in the form '
'`host:port`. Got `{}` instead.'
.format(host))
return host
base_parser = argparse.ArgumentParser(add_help=False, prog='bigchaindb')
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', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
default='INFO',
choices=['DEBUG', 'BENCHMARK', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
help='Log level')
base_parser.add_argument('-y', '--yes', '--yes-please',

View File

@ -1,7 +1,16 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
import sha3
try:
from hashlib import sha3_256
except ImportError:
from sha3 import sha3_256
from cryptoconditions import crypto
@ -10,7 +19,7 @@ CryptoKeypair = namedtuple('CryptoKeypair', ('private_key', 'public_key'))
def hash_data(data):
"""Hash the provided data using SHA3-256"""
return sha3.sha3_256(data.encode()).hexdigest()
return sha3_256(data.encode()).hexdigest()
def generate_key_pair():
@ -30,3 +39,17 @@ def 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')

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 `bigchaindb` package.
"""
from bigchaindb.exceptions import BigchainDBError
@ -7,10 +12,6 @@ class ConfigurationError(BigchainDBError):
"""Raised when there is a problem with server configuration"""
class DatabaseAlreadyExists(BigchainDBError):
"""Raised when trying to create the database but the db is already there"""
class DatabaseDoesNotExist(BigchainDBError):
"""Raised when trying to delete the database but the db is not there"""
@ -23,13 +24,10 @@ class CyclicBlockchainError(BigchainDBError):
"""Raised when there is a cycle in the blockchain"""
class KeypairNotFoundException(BigchainDBError):
"""Raised if operation cannot proceed because the keypair was not given"""
class KeypairMismatchException(BigchainDBError):
"""Raised if the private key(s) provided for signing don't match any of the
current owner(s)"""
current owner(s)
"""
class OperationError(BigchainDBError):
@ -55,7 +53,8 @@ class DoubleSpend(ValidationError):
class InvalidHash(ValidationError):
"""Raised if there was an error checking the hash for a particular
operation"""
operation
"""
class SchemaValidationError(ValidationError):
@ -64,20 +63,8 @@ class SchemaValidationError(ValidationError):
class InvalidSignature(ValidationError):
"""Raised if there was an error checking the signature for a particular
operation"""
class ImproperVoteError(ValidationError):
"""Raised if a vote is not constructed correctly, or signed incorrectly"""
class MultipleVotesError(ValidationError):
"""Raised if a voter has voted more than once"""
class TransactionNotInValidBlock(ValidationError):
"""Raised when a transfer transaction is attempting to fulfill the
outputs of a transaction that is in an invalid or undecided block"""
operation
"""
class AssetIdMismatch(ValidationError):
@ -96,10 +83,6 @@ class TransactionOwnerError(ValidationError):
"""Raised if a user tries to transfer a transaction they don't own"""
class SybilError(ValidationError):
"""If a block or vote comes from an unidentifiable node"""
class DuplicateTransaction(ValidationError):
"""Raised if a duplicated transaction is found"""
@ -108,5 +91,25 @@ class ThresholdTooDeep(ValidationError):
"""Raised if threshold condition is too deep"""
class GenesisBlockAlreadyExistsError(ValidationError):
"""Raised when trying to create the already existing genesis block"""
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"""

View File

@ -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

View File

@ -1,13 +1,37 @@
<!---
Copyright © 2020 Interplanetary Database Association e.V.,
BigchainDB and IPDB 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
--->
# Introduction
This directory contains the schemas for the different JSON documents BigchainDB uses.
The aim is to provide:
- a strict definition/documentation 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)
- 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/bigchaindb/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/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).
## Learn about JSON Schema

View File

@ -1,11 +1,15 @@
""" Schema validation related functions and data """
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
import rapidjson_schema
from bigchaindb.common.exceptions import SchemaValidationError
@ -13,36 +17,35 @@ from bigchaindb.common.exceptions import SchemaValidationError
logger = logging.getLogger(__name__)
def drop_schema_descriptions(node):
""" Drop descriptions from schema, since they clutter log output """
if 'description' in node:
del node['description']
for n in node.get('properties', {}).values():
drop_schema_descriptions(n)
for n in node.get('definitions', {}).values():
drop_schema_descriptions(n)
for n in node.get('anyOf', []):
drop_schema_descriptions(n)
def _load_schema(name):
""" Load a schema from disk """
path = os.path.join(os.path.dirname(__file__), name + '.yaml')
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)
drop_schema_descriptions(schema)
fast_schema = rapidjson_schema.loads(rapidjson.dumps(schema))
fast_schema = rapidjson.Validator(rapidjson.dumps(schema))
return path, (schema, fast_schema)
TX_SCHEMA_PATH, TX_SCHEMA_COMMON = _load_schema('transaction')
_, TX_SCHEMA_CREATE = _load_schema('transaction_create')
_, TX_SCHEMA_TRANSFER = _load_schema('transaction_transfer')
VOTE_SCHEMA_PATH, VOTE_SCHEMA = _load_schema('vote')
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 """
"""Validate data against a schema"""
# Note
#
@ -56,7 +59,7 @@ def _validate_schema(schema, body):
# a helpful error message.
try:
schema[1].validate(rapidjson.dumps(body))
schema[1](rapidjson.dumps(body))
except ValueError as exc:
try:
jsonschema.validate(body, schema[0])
@ -67,8 +70,7 @@ def _validate_schema(schema, body):
def validate_transaction_schema(tx):
"""
Validate a transaction dict.
"""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.
@ -78,8 +80,3 @@ def validate_transaction_schema(tx):
_validate_schema(TX_SCHEMA_TRANSFER, tx)
else:
_validate_schema(TX_SCHEMA_CREATE, tx)
def validate_vote_schema(vote):
""" Validate a vote dict """
_validate_schema(VOTE_SCHEMA, vote)

View File

@ -1,247 +0,0 @@
---
"$schema": "http://json-schema.org/draft-04/schema#"
id: "http://www.bigchaindb.com/schema/transaction.json"
type: object
additionalProperties: false
title: Transaction Schema
description: |
A transaction represents the creation or transfer of assets in BigchainDB.
required:
- id
- inputs
- outputs
- operation
- metadata
- asset
- version
properties:
id:
"$ref": "#/definitions/sha3_hexdigest"
description: |
A sha3 digest of the transaction. The ID is calculated by removing all
derived hashes and signatures from the transaction, serializing it to
JSON with keys in sorted order and then hashing the resulting string
with sha3.
operation:
"$ref": "#/definitions/operation"
asset:
"$ref": "#/definitions/asset"
description: |
Description of the asset being transacted.
See: `Asset`_.
inputs:
type: array
title: "Transaction inputs"
description: |
Array of the inputs of a transaction.
See: Input_.
items:
"$ref": "#/definitions/input"
outputs:
type: array
description: |
Array of outputs provided by this transaction.
See: Output_.
items:
"$ref": "#/definitions/output"
metadata:
"$ref": "#/definitions/metadata"
description: |
User provided transaction metadata. This field may be ``null`` or may
contain an id and an object with freeform metadata.
See: `Metadata`_.
version:
type: string
pattern: "^1\\.0$"
description: |
BigchainDB transaction schema version.
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
description: |
A `UUID <https://tools.ietf.org/html/rfc4122.html>`_
of type 4 (random).
operation:
type: string
description: |
Type of the transaction:
A ``CREATE`` transaction creates an asset in BigchainDB. This
transaction has outputs but no inputs, so a dummy input is created.
A ``TRANSFER`` transaction transfers ownership of an asset, by providing
an input that meets the conditions of an earlier transaction's outputs.
A ``GENESIS`` transaction is a special case transaction used as the
sole member of the first block in a BigchainDB ledger.
enum:
- CREATE
- TRANSFER
- GENESIS
asset:
type: object
description: |
Description of the asset being transacted. In the case of a ``TRANSFER``
transaction, this field contains only the ID of asset. In the case
of a ``CREATE`` transaction, this field contains only the user-defined
payload.
additionalProperties: false
properties:
id:
"$ref": "#/definitions/sha3_hexdigest"
description: |
ID of the transaction that created the asset.
data:
description: |
User provided metadata associated with the asset. May also be ``null``.
anyOf:
- type: object
additionalProperties: true
- type: 'null'
output:
type: object
description: |
A transaction output. Describes the quantity of an asset and the
requirements that must be met to spend the output.
See also: Input_.
additionalProperties: false
required:
- amount
- condition
- public_keys
properties:
amount:
type: string
pattern: "^[0-9]{1,20}$"
description: |
Integral amount of the asset represented by this output.
In the case of a non divisible asset, this will always be 1.
condition:
description: |
Describes the condition that needs to be met to spend the output. Has the properties:
- **details**: Details of the condition.
- **uri**: Condition encoded as an ASCII string.
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"
description: |
List of public keys associated with the conditions on an output.
input:
type: "object"
description:
An input spends a previous output, by providing one or more fulfillments
that fulfill the conditions of the previous output.
additionalProperties: false
required:
- owners_before
- fulfillment
properties:
owners_before:
"$ref": "#/definitions/public_keys"
description: |
List of public keys of the previous owners of the asset.
fulfillment:
description: |
Fulfillment of an `Output.condition`_, or, put a different way, a payload
that satisfies the condition of a previous output to prove that the
creator(s) of this transaction have control over the listed asset.
anyOf:
- type: string
pattern: "^[a-zA-Z0-9_-]*$"
- "$ref": "#/definitions/condition_details"
fulfills:
anyOf:
- type: 'object'
description: |
Reference to the output that is being spent.
additionalProperties: false
required:
- output_index
- transaction_id
properties:
output_index:
"$ref": "#/definitions/offset"
description: |
Index of the output containing the condition being fulfilled
transaction_id:
"$ref": "#/definitions/sha3_hexdigest"
description: |
Transaction ID containing the output to spend
- type: 'null'
metadata:
anyOf:
- type: object
description: |
User provided transaction metadata. This field may be ``null`` or may
contain an non empty object with freeform metadata.
additionalProperties: true
minProperties: 1
- type: 'null'
condition_details:
description: |
Details needed to reconstruct the condition associated with an output.
Currently, BigchainDB only supports ed25519 and threshold condition types.
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"

View File

@ -0,0 +1,45 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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}$"

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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

View File

@ -0,0 +1,35 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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"

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
@ -10,8 +15,6 @@ properties:
properties:
id:
"$ref": "#/definitions/sha3_hexdigest"
description: |
ID of the transaction that created the asset.
required:
- id
inputs:

View File

@ -0,0 +1,34 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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

View File

@ -0,0 +1,168 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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"

View File

@ -0,0 +1,170 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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"

View File

@ -0,0 +1,68 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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}$"

View File

@ -0,0 +1,34 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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}$"

View File

@ -1,73 +0,0 @@
---
"$schema": "http://json-schema.org/draft-04/schema#"
id: "http://www.bigchaindb.com/schema/vote.json"
type: object
additionalProperties: false
title: Vote Schema
description: |
A Vote is an endorsement of a Block (identified by a hash) by
a node (identified by a public key).
The outer Vote object contains the details of the vote being made
as well as the signature and identifying information of the node
passing the vote.
required:
- node_pubkey
- signature
- vote
properties:
node_pubkey:
type: "string"
pattern: "[1-9a-zA-Z^OIl]{43,44}"
description: |
Ed25519 public key identifying the voting node.
signature:
type: "string"
pattern: "[1-9a-zA-Z^OIl]{86,88}"
description:
Ed25519 signature of the `Vote Details`_ object.
vote:
type: "object"
additionalProperties: false
description: |
`Vote Details`_ to be signed.
required:
- invalid_reason
- is_block_valid
- previous_block
- voting_for_block
- timestamp
properties:
previous_block:
"$ref": "#/definitions/sha3_hexdigest"
description: |
ID (SHA3 hash) of the block that precedes the block being voted on.
The notion of a "previous" block is subject to vote.
voting_for_block:
"$ref": "#/definitions/sha3_hexdigest"
description: |
ID (SHA3 hash) of the block being voted on.
is_block_valid:
type: "boolean"
description: |
This field is ``true`` if the block was deemed valid by the node.
invalid_reason:
anyOf:
- type: "string"
description: |
Reason the block is voted invalid, or ``null``.
.. container:: notice
**Note**: The invalid_reason was not being used and may be dropped in a future version of BigchainDB. See Issue `#217 <https://github.com/bigchaindb/bigchaindb/issues/217>`_ on GitHub.
- type: "null"
timestamp:
type: "string"
pattern: "[0-9]{10}"
description: |
Unix timestamp that the vote was created by the node, according
to the system time of the node.
definitions:
sha3_hexdigest:
pattern: "[0-9a-f]{64}"
type: string

View File

@ -1,21 +1,51 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
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 bigchaindb.common.crypto import PrivateKey, hash_data
from bigchaindb.common.exceptions import (KeypairMismatchException,
InputDoesNotExist, DoubleSpend,
InvalidHash, InvalidSignature,
AmountError, AssetIdMismatch,
ThresholdTooDeep)
from bigchaindb.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):
@ -48,7 +78,7 @@ class Input(object):
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_after` must be a list instance')
raise TypeError('`owners_before` must be a list instance')
self.fulfillment = fulfillment
self.fulfills = fulfills
@ -58,6 +88,11 @@ class Input(object):
# 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.
@ -70,7 +105,7 @@ class Input(object):
"""
try:
fulfillment = self.fulfillment.serialize_uri()
except (TypeError, AttributeError, ASN1EncodeError):
except (TypeError, AttributeError, ASN1EncodeError, ASN1DecodeError):
fulfillment = _fulfillment_to_details(self.fulfillment)
try:
@ -112,7 +147,7 @@ class Input(object):
InvalidSignature: If an Input's URI couldn't be parsed.
"""
fulfillment = data['fulfillment']
if not isinstance(fulfillment, Fulfillment):
if not isinstance(fulfillment, (Fulfillment, type(None))):
try:
fulfillment = Fulfillment.from_uri(data['fulfillment'])
except ASN1DecodeError:
@ -128,8 +163,7 @@ class Input(object):
def _fulfillment_to_details(fulfillment):
"""
Encode a fulfillment as a details dictionary
"""Encode a fulfillment as a details dictionary
Args:
fulfillment: Crypto-conditions Fulfillment object
@ -138,7 +172,7 @@ def _fulfillment_to_details(fulfillment):
if fulfillment.type_name == 'ed25519-sha-256':
return {
'type': 'ed25519-sha-256',
'public_key': base58.b58encode(fulfillment.public_key),
'public_key': base58.b58encode(fulfillment.public_key).decode(),
}
if fulfillment.type_name == 'threshold-sha-256':
@ -155,26 +189,25 @@ def _fulfillment_to_details(fulfillment):
raise UnsupportedTypeError(fulfillment.type_name)
def _fulfillment_from_details(data):
"""
Load a fulfillment for a signing spec dictionary
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':
try:
threshold = ThresholdSha256(data['threshold'])
for cond in data['subconditions']:
cond = _fulfillment_from_details(cond)
threshold.add_subfulfillment(cond)
return threshold
except RecursionError:
raise ThresholdTooDeep()
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'))
@ -463,22 +496,22 @@ class Transaction(object):
spend.
outputs (:obj:`list` of :class:`~bigchaindb.common.
transaction.Output`, optional): Define the assets to lock.
asset (dict): Asset payload for this Transaction. ``CREATE`` and
``GENESIS`` Transactions require a dict with a ``data``
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'
GENESIS = 'GENESIS'
ALLOWED_OPERATIONS = (CREATE, TRANSFER, GENESIS)
VERSION = '1.0'
ALLOWED_OPERATIONS = (CREATE, TRANSFER)
VERSION = '2.0'
def __init__(self, operation, asset, inputs=None, outputs=None,
metadata=None, version=None):
metadata=None, version=None, hash_id=None, tx_dict=None):
"""The constructor allows to create a customizable Transaction.
Note:
@ -496,23 +529,24 @@ class Transaction(object):
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 Transaction.ALLOWED_OPERATIONS:
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' and 'GENESIS' operations must be None or
# 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 in [Transaction.CREATE, Transaction.GENESIS] and
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 == Transaction.TRANSFER and
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".format(operation)))
'for \'TRANSFER\' Transactions'))
if outputs and not isinstance(outputs, list):
raise TypeError('`outputs` must be a list instance or None')
@ -529,6 +563,76 @@ class Transaction(object):
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 `([<list of public keys>],'
' <amount>)`'))
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):
@ -558,21 +662,22 @@ class Transaction(object):
Returns:
:class:`~bigchaindb.common.transaction.Transaction`
"""
if not isinstance(tx_signers, list):
raise TypeError('`tx_signers` must be a list instance')
(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(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')
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'
@ -581,10 +686,10 @@ class Transaction(object):
pub_keys, amount = recipient
outputs.append(Output.generate(pub_keys, amount))
# generate inputs
inputs.append(Input.generate(tx_signers))
if not isinstance(asset_id, str):
raise TypeError('`asset_id` must be a string')
return cls(cls.CREATE, {'data': asset}, inputs, outputs, metadata)
return (deepcopy(inputs), outputs)
@classmethod
def transfer(cls, inputs, recipients, asset_id, metadata=None):
@ -625,27 +730,7 @@ class Transaction(object):
Returns:
:class:`~bigchaindb.common.transaction.Transaction`
"""
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'
' <amount>)`'))
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')
inputs = deepcopy(inputs)
(inputs, outputs) = cls.validate_transfer(inputs, recipients, asset_id, metadata)
return cls(cls.TRANSFER, {'id': asset_id}, inputs, outputs, metadata)
def __eq__(self, other):
@ -756,6 +841,9 @@ class Transaction(object):
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
@ -781,8 +869,9 @@ class Transaction(object):
return cls._sign_threshold_signature_fulfillment(input_, message,
key_pairs)
else:
raise ValueError("Fulfillment couldn't be matched to "
'Cryptocondition fulfillment type.')
raise ValueError(
'Fulfillment couldn\'t be matched to '
'Cryptocondition fulfillment type.')
@classmethod
def _sign_simple_signature_fulfillment(cls, input_, message, key_pairs):
@ -800,13 +889,16 @@ class Transaction(object):
# 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.encode(),
base58.b58decode(key_pairs[public_key].encode()),
)
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'
@ -824,6 +916,11 @@ class Transaction(object):
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
@ -851,7 +948,8 @@ class Transaction(object):
# 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.encode(), base58.b58decode(private_key.encode()))
subffill.sign(
message.digest(), base58.b58decode(private_key.encode()))
return input_
def inputs_valid(self, outputs=None):
@ -859,7 +957,7 @@ class Transaction(object):
Outputs.
Note:
Given a `CREATE` or `GENESIS` Transaction is passed,
Given a `CREATE` Transaction is passed,
dummy values for Outputs are submitted for validation that
evaluate parts of the validation-checks to `True`.
@ -871,14 +969,14 @@ class Transaction(object):
Returns:
bool: If all Inputs are valid.
"""
if self.operation in (Transaction.CREATE, Transaction.GENESIS):
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 == Transaction.TRANSFER:
elif self.operation == self.TRANSFER:
return self._inputs_valid([output.fulfillment.condition_uri
for output in outputs])
else:
@ -905,32 +1003,32 @@ class Transaction(object):
raise ValueError('Inputs and '
'output_condition_uris must have the same count')
tx_dict = self.to_dict()
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 """
"""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))
@staticmethod
def _input_valid(input_, operation, tx_serialized, output_condition_uri=None):
@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` or `GENESIS` Transaction, this method
In case of a `CREATE` Transaction, this method
does not validate against `output_condition_uri`.
Args:
input_ (:class:`~bigchaindb.common.transaction.
Input`) The Input to be signed.
operation (str): The type of Transaction.
tx_serialized (str): The Transaction used as a message when
initially signing it.
message (str): The fulfillment message.
output_condition_uri (str, optional): An Output to check the
Input against.
@ -944,43 +1042,47 @@ class Transaction(object):
ParsingError, ASN1DecodeError, ASN1EncodeError):
return False
if operation in (Transaction.CREATE, Transaction.GENESIS):
# NOTE: In the case of a `CREATE` or `GENESIS` transaction, the
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=tx_serialized.encode())
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.
"""
tx = {
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,
}
tx_no_signatures = Transaction._remove_signatures(tx)
tx_serialized = Transaction._to_str(tx_no_signatures)
tx_id = Transaction._to_hash(tx_serialized)
tx['id'] = tx_id
return tx
@staticmethod
# TODO: Remove `_dict` prefix of variable.
def _remove_signatures(tx_dict):
@ -1010,7 +1112,7 @@ class Transaction(object):
@property
def id(self):
return self.to_hash()
return self._id
def to_hash(self):
return self.to_dict()['id']
@ -1024,8 +1126,8 @@ class Transaction(object):
tx = Transaction._remove_signatures(self.to_dict())
return Transaction._to_str(tx)
@staticmethod
def get_asset_id(transactions):
@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
@ -1049,7 +1151,7 @@ class Transaction(object):
transactions = [transactions]
# create a set of the transactions' asset ids
asset_ids = {tx.id if tx.operation == Transaction.CREATE
asset_ids = {tx.id if tx.operation == tx.CREATE
else tx.asset['id']
for tx in transactions}
@ -1067,14 +1169,17 @@ class Transaction(object):
tx_body (dict): The Transaction to be transformed.
"""
# NOTE: Remove reference to avoid side effects
tx_body = deepcopy(tx_body)
# tx_body = deepcopy(tx_body)
tx_body = rapidjson.loads(rapidjson.dumps(tx_body))
try:
proposed_tx_id = tx_body.pop('id')
proposed_tx_id = tx_body['id']
except KeyError:
raise InvalidHash('No transaction id found!')
tx_body_no_signatures = Transaction._remove_signatures(tx_body)
tx_body_serialized = Transaction._to_str(tx_body_no_signatures)
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:
@ -1083,7 +1188,8 @@ class Transaction(object):
raise InvalidHash(err_msg.format(proposed_tx_id))
@classmethod
def from_dict(cls, tx):
@memoize_from_dict
def from_dict(cls, tx, skip_schema_validation=True):
"""Transforms a Python dictionary to a Transaction object.
Args:
@ -1092,8 +1198,133 @@ class Transaction(object):
Returns:
:class:`~bigchaindb.common.transaction.Transaction`
"""
cls.validate_id(tx)
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'])
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:`~bigchaindb.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

View File

@ -0,0 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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'

View File

@ -1,7 +1,15 @@
import time
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb
from bigchaindb.common.exceptions import ValidationError
def gen_timestamp():
"""The Unix time, rounded to the nearest second.
@ -46,3 +54,112 @@ def deserialize(data):
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 = bigchaindb.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)

View File

@ -1,3 +1,8 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
@ -15,7 +20,7 @@ import os
import copy
import json
import logging
import collections
import collections.abc
from functools import lru_cache
from pkg_resources import iter_entry_points, ResolutionError
@ -24,7 +29,7 @@ from bigchaindb.common import exceptions
import bigchaindb
from bigchaindb.consensus import BaseConsensusRules
from bigchaindb.validation import BaseValidationRules
# TODO: move this to a proper configuration file for logging
logging.getLogger('requests').setLevel(logging.WARNING)
@ -47,7 +52,7 @@ def map_leafs(func, mapping):
path = []
for key, val in mapping.items():
if isinstance(val, collections.Mapping):
if isinstance(val, collections.abc.Mapping):
_inner(val, path + [key])
else:
mapping[key] = func(val, path=path+[key])
@ -75,7 +80,7 @@ def update(d, u):
mapping: An updated version of d (updated by u).
"""
for k, v in u.items():
if isinstance(v, collections.Mapping):
if isinstance(v, collections.abc.Mapping):
r = update(d.get(k, {}), v)
d[k] = r
else:
@ -108,7 +113,7 @@ def file_config(filename=None):
'Failed to parse the JSON configuration from `{}`, {}'.format(filename, err)
)
logger.info('Configuration loaded from `{}`'.format(filename))
logger.info('Configuration loaded from `{}`'.format(filename))
return config
@ -128,6 +133,7 @@ def env_config(config):
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)
@ -135,7 +141,8 @@ def env_config(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"""
are aligned with the ones in the default configuration
"""
def _coerce(current, value):
# Coerce a value to the `current` type.
@ -226,7 +233,8 @@ def is_configured():
def autoconfigure(filename=None, config=None, force=False):
"""Run ``file_config`` and ``env_config`` if the module has not
been initialized."""
been initialized.
"""
if not force and is_configured():
logger.debug('System already configured, skipping autoconfiguration')
return
@ -245,45 +253,56 @@ def autoconfigure(filename=None, config=None, force=False):
# override configuration with env variables
newconfig = env_config(newconfig)
if config:
newconfig = update(newconfig, config)
set_config(newconfig) # sets bigchaindb.config
@lru_cache()
def load_consensus_plugin(name=None):
"""Find and load the chosen consensus plugin.
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 ``bigchaindb.consensus.AbstractConsensusRules``
an uninstantiated subclass of ``bigchaindb.validation.AbstractValidationRules``
"""
if not name:
return BaseConsensusRules
return BaseValidationRules
# TODO: This will return the first plugin with group `bigchaindb.consensus`
# TODO: This will return the first plugin with group `bigchaindb.validation`
# and name `name` in the active WorkingSet.
# We should probably support Requirements specs in the config, e.g.
# consensus_plugin: 'my-plugin-package==0.0.1;default'
# validation_plugin: 'my-plugin-package==0.0.1;default'
plugin = None
for entry_point in iter_entry_points('bigchaindb.consensus', name):
for entry_point in iter_entry_points('bigchaindb.validation', name):
plugin = entry_point.load()
# No matching entry_point found
if not plugin:
raise ResolutionError(
'No plugin found in group `bigchaindb.consensus` with name `{}`'.
'No plugin found in group `bigchaindb.validation` with name `{}`'.
format(name))
# Is this strictness desireable?
# It will probably reduce developer headaches in the wild.
if not issubclass(plugin, (BaseConsensusRules,)):
if not issubclass(plugin, (BaseValidationRules,)):
raise TypeError('object of type "{}" does not implement `bigchaindb.'
'consensus.BaseConsensusRules`'.format(type(plugin)))
'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('bigchaindb.events', name):
plugins.append((name, entry_point.load()))
return plugins

View File

@ -1,23 +0,0 @@
from bigchaindb.voting import Voting
class BaseConsensusRules():
"""Base consensus rules for Bigchain.
A consensus plugin must expose a class inheriting from this one via an entry_point.
All methods listed below must be implemented.
"""
voting = Voting
@staticmethod
def validate_transaction(bigchain, transaction):
"""See :meth:`bigchaindb.models.Transaction.validate`
for documentation."""
return transaction.validate(bigchain)
@staticmethod
def validate_block(bigchain, block):
"""See :meth:`bigchaindb.models.Block.validate` for documentation."""
return block.validate(bigchain)

View File

@ -1,648 +1,271 @@
import random
import statsd
from time import time
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb import exceptions as core_exceptions
from bigchaindb.common import crypto, exceptions
from bigchaindb.common.utils import gen_timestamp, serialize
"""This module contains all the goodness to integrate BigchainDB
with Tendermint.
"""
import logging
import sys
import bigchaindb
from abci.application import BaseApplication
from abci import CodeTypeOk
from bigchaindb import backend, config_utils, fastquery
from bigchaindb.consensus import BaseConsensusRules
from bigchaindb.models import Block, Transaction
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,
calculate_hash)
from bigchaindb.lib import Block
import bigchaindb.upsert_validator.validator_utils as vutils
from bigchaindb.events import EventTypes, Event
class Bigchain(object):
"""Bigchain API
CodeTypeError = 1
logger = logging.getLogger(__name__)
Create, read, sign, write transactions to the database
class App(BaseApplication):
"""Bridge between BigchainDB and Tendermint.
The role of this class is to expose the BigchainDB
transaction logic to Tendermint Core.
"""
BLOCK_INVALID = 'invalid'
"""return if a block has been voted invalid"""
def __init__(self, abci, bigchaindb=None, events_queue=None,):
super().__init__(abci)
self.events_queue = events_queue
self.bigchaindb = bigchaindb 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()
BLOCK_VALID = TX_VALID = 'valid'
"""return if a block is valid, or tx is in valid block"""
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}.')
BLOCK_UNDECIDED = TX_UNDECIDED = 'undecided'
"""return if block is undecided, or tx is in undecided block"""
def abort_if_abci_chain_is_not_synced(self):
if self.chain is None or self.chain['is_synced']:
return
TX_IN_BACKLOG = 'backlog'
"""return if transaction is in backlog"""
validators = self.bigchaindb.get_validators()
self.log_abci_migration_error(self.chain['chain_id'], validators)
sys.exit(1)
def __init__(self, public_key=None, private_key=None, keyring=[], connection=None, backlog_reassign_delay=None):
"""Initialize the Bigchain instance
def init_chain(self, genesis):
"""Initialize chain upon genesis or a migration"""
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 bigchaindb.__init__).
app_hash = ''
height = 0
Args:
public_key (str): the base58 encoded public key for the ED25519 curve.
private_key (str): the base58 encoded private key for the ED25519 curve.
keyring (list[str]): list of base58 encoded public keys of the federation nodes.
connection (:class:`~bigchaindb.backend.connection.Connection`):
A connection to the database.
"""
known_chain = self.bigchaindb.get_latest_abci_chain()
if known_chain is not None:
chain_id = known_chain['chain_id']
config_utils.autoconfigure()
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)
self.me = public_key or bigchaindb.config['keypair']['public']
self.me_private = private_key or bigchaindb.config['keypair']['private']
self.nodes_except_me = keyring or bigchaindb.config['keyring']
if chain_id != genesis.chain_id:
validators = self.bigchaindb.get_validators()
self.log_abci_migration_error(chain_id, validators)
sys.exit(1)
if backlog_reassign_delay is None:
backlog_reassign_delay = bigchaindb.config['backlog_reassign_delay']
self.backlog_reassign_delay = backlog_reassign_delay
# set migration values for app hash and height
block = self.bigchaindb.get_latest_block()
app_hash = '' if block is None else block['app_hash']
height = 0 if block is None else block['height'] + 1
consensusPlugin = bigchaindb.config.get('consensus_plugin')
known_validators = self.bigchaindb.get_validators()
validator_set = [vutils.decode_validator(v)
for v in genesis.validators]
if consensusPlugin:
self.consensus = config_utils.load_consensus_plugin(consensusPlugin)
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.bigchaindb.store_block(block._asdict())
self.bigchaindb.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,
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.bigchaindb.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:
self.consensus = BaseConsensusRules
r.last_block_height = 0
r.last_block_app_hash = b''
return r
self.connection = connection if connection else backend.connect(**bigchaindb.config['database'])
if not self.me or not self.me_private:
raise exceptions.KeypairNotFoundException()
self.statsd = statsd.StatsClient(bigchaindb.config['graphite']['host'])
federation = property(lambda self: set(self.nodes_except_me + [self.me]))
""" Set of federation member public keys """
def write_transaction(self, signed_transaction):
"""Write the transaction to bigchain.
When first writing a transaction to the bigchain the transaction will be kept in a backlog until
it has been validated by the nodes of the federation.
def check_tx(self, raw_transaction):
"""Validate the transaction before entry into
the mempool.
Args:
signed_transaction (Transaction): transaction with the `signature` included.
Returns:
dict: database response
raw_tx: a raw string (in bytes) transaction.
"""
signed_transaction = signed_transaction.to_dict()
# we will assign this transaction to `one` node. This way we make sure that there are no duplicate
# transactions on the bigchain
if self.nodes_except_me:
assignee = random.choice(self.nodes_except_me)
self.abort_if_abci_chain_is_not_synced()
logger.debug('check_tx: %s', raw_transaction)
transaction = decode_transaction(raw_transaction)
if self.bigchaindb.is_valid_transaction(transaction):
logger.debug('check_tx: VALID')
return self.abci.ResponseCheckTx(code=CodeTypeOk)
else:
# I am the only node
assignee = self.me
logger.debug('check_tx: INVALID')
return self.abci.ResponseCheckTx(code=CodeTypeError)
signed_transaction.update({'assignee': assignee})
signed_transaction.update({'assignment_timestamp': time()})
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()
# write to the backlog
return backend.query.write_transaction(self.connection, signed_transaction)
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)
def reassign_transaction(self, transaction):
"""Assign a transaction to a new node
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:
transaction (dict): assigned transaction
Returns:
dict: database response or None if no reassignment is possible
raw_tx: a raw string (in bytes) transaction.
"""
other_nodes = tuple(
self.federation.difference([transaction['assignee']])
)
new_assignee = random.choice(other_nodes) if other_nodes else self.me
self.abort_if_abci_chain_is_not_synced()
return backend.query.update_transaction(
self.connection, transaction['id'],
{'assignee': new_assignee, 'assignment_timestamp': time()})
logger.debug('deliver_tx: %s', raw_transaction)
transaction = self.bigchaindb.is_valid_transaction(
decode_transaction(raw_transaction), self.block_transactions)
def delete_transaction(self, *transaction_id):
"""Delete a transaction from the backlog.
Args:
*transaction_id (str): the transaction(s) to delete
Returns:
The database response.
"""
return backend.query.delete_transaction(self.connection, *transaction_id)
def get_stale_transactions(self):
"""Get a cursor of stale transactions.
Transactions are considered stale if they have been assigned a node, but are still in the
backlog after some amount of time specified in the configuration
"""
return backend.query.get_stale_transactions(self.connection, self.backlog_reassign_delay)
def validate_transaction(self, transaction):
"""Validate a transaction.
Args:
transaction (Transaction): transaction to validate.
Returns:
The transaction if the transaction is valid else it raises an
exception describing the reason why the transaction is invalid.
"""
return self.consensus.validate_transaction(self, transaction)
def is_new_transaction(self, txid, exclude_block_id=None):
"""
Return True if the transaction does not exist in any
VALID or UNDECIDED block. Return False otherwise.
Args:
txid (str): Transaction ID
exclude_block_id (str): Exclude block from search
"""
block_statuses = self.get_blocks_status_containing_tx(txid)
block_statuses.pop(exclude_block_id, None)
for status in block_statuses.values():
if status != self.BLOCK_INVALID:
return False
return True
def get_block(self, block_id, include_status=False):
"""Get the block with the specified `block_id` (and optionally its status)
Returns the block corresponding to `block_id` or None if no match is
found.
Args:
block_id (str): transaction id of the transaction to get
include_status (bool): also return the status of the block
the return value is then a tuple: (block, status)
"""
# get block from database
block_dict = backend.query.get_block(self.connection, block_id)
# get the asset ids from the block
if block_dict:
asset_ids = Block.get_asset_ids(block_dict)
# get the assets from the database
assets = self.get_assets(asset_ids)
# add the assets to the block transactions
block_dict = Block.couple_assets(block_dict, assets)
status = None
if include_status:
if block_dict:
status = self.block_election_status(block_dict)
return block_dict, status
if not transaction:
logger.debug('deliver_tx: INVALID')
return self.abci.ResponseDeliverTx(code=CodeTypeError)
else:
return block_dict
logger.debug('storing tx')
self.block_txn_ids.append(transaction.id)
self.block_transactions.append(transaction)
return self.abci.ResponseDeliverTx(code=CodeTypeOk)
def get_transaction(self, txid, include_status=False):
"""Get the transaction with the specified `txid` (and optionally its status)
This query begins by looking in the bigchain table for all blocks containing
a transaction with the specified `txid`. If one of those blocks is valid, it
returns the matching transaction from that block. Else if some of those
blocks are undecided, it returns a matching transaction from one of them. If
the transaction was found in invalid blocks only, or in no blocks, then this
query looks for a matching transaction in the backlog table, and if it finds
one there, it returns that.
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:
txid (str): transaction id of the transaction to get
include_status (bool): also return the status of the transaction
the return value is then a tuple: (tx, status)
Returns:
A :class:`~.models.Transaction` instance if the transaction
was found in a valid block, an undecided block, or the backlog table,
otherwise ``None``.
If :attr:`include_status` is ``True``, also returns the
transaction's status if the transaction was found.
height (int): new height of the chain.
"""
response, tx_status = None, None
self.abort_if_abci_chain_is_not_synced()
validity = self.get_blocks_status_containing_tx(txid)
check_backlog = True
chain_shift = 0 if self.chain is None else self.chain['height']
if validity:
# Disregard invalid blocks, and return if there are no valid or undecided blocks
validity = {_id: status for _id, status in validity.items()
if status != Bigchain.BLOCK_INVALID}
if validity:
height = request_end_block.height + chain_shift
self.new_height = height
# The transaction _was_ found in an undecided or valid block,
# so there's no need to look in the backlog table
check_backlog = False
# 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.bigchaindb.store_pre_commit_state(pre_commit_state)
tx_status = self.TX_UNDECIDED
# If the transaction is in a valid or any undecided block, return it. Does not check
# if transactions in undecided blocks are consistent, but selects the valid block
# before undecided ones
for target_block_id in validity:
if validity[target_block_id] == Bigchain.BLOCK_VALID:
tx_status = self.TX_VALID
break
block_txn_hash = calculate_hash(self.block_txn_ids)
block = self.bigchaindb.get_latest_block()
# Query the transaction in the target block and return
response = backend.query.get_transaction_from_block(self.connection, txid, target_block_id)
if check_backlog:
response = backend.query.get_transaction_from_backlog(self.connection, txid)
if response:
tx_status = self.TX_IN_BACKLOG
if response:
if tx_status == self.TX_IN_BACKLOG:
response = Transaction.from_dict(response)
else:
# If we are reading from the bigchain collection the asset is
# not in the transaction so we need to fetch the asset and
# reconstruct the transaction.
response = Transaction.from_db(self, response)
if include_status:
return response, tx_status
if self.block_txn_ids:
self.block_txn_hash = calculate_hash([block['app_hash'], block_txn_hash])
else:
return response
self.block_txn_hash = block['app_hash']
def get_status(self, txid):
"""Retrieve the status of a transaction with `txid` from bigchain.
validator_update = Election.process_block(self.bigchaindb,
self.new_height,
self.block_transactions)
Args:
txid (str): transaction id of the transaction to query
return self.abci.ResponseEndBlock(validator_updates=validator_update)
Returns:
(string): transaction status ('valid', 'undecided',
or 'backlog'). If no transaction with that `txid` was found it
returns `None`
"""
_, status = self.get_transaction(txid, include_status=True)
return status
def commit(self):
"""Store the new height and along with block hash."""
def get_blocks_status_containing_tx(self, txid):
"""Retrieve block ids and statuses related to a transaction
self.abort_if_abci_chain_is_not_synced()
Transactions may occur in multiple blocks, but no more than one valid block.
data = self.block_txn_hash.encode('utf-8')
Args:
txid (str): transaction id of the transaction to query
# register a new block only when new transactions are received
if self.block_txn_ids:
self.bigchaindb.store_bulk_transactions(self.block_transactions)
Returns:
A dict of blocks containing the transaction,
e.g. {block_id_1: 'valid', block_id_2: 'invalid' ...}, or None
"""
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())
# First, get information on all blocks which contain this transaction
blocks = backend.query.get_blocks_status_from_transaction(self.connection, txid)
if blocks:
# Determine the election status of each block
validity = {block['id']: self.block_election_status(block)
for block in blocks}
logger.debug('Commit-ing new block with hash: apphash=%s ,'
'height=%s, txn ids=%s', data, self.new_height,
self.block_txn_ids)
# NOTE: If there are multiple valid blocks with this transaction,
# something has gone wrong
if list(validity.values()).count(Bigchain.BLOCK_VALID) > 1:
block_ids = str([block for block in validity
if validity[block] == Bigchain.BLOCK_VALID])
raise core_exceptions.CriticalDoubleInclusion(
'Transaction {tx} is present in '
'multiple valid blocks: {block_ids}'
.format(tx=txid, block_ids=block_ids))
if self.events_queue:
event = Event(EventTypes.BLOCK_VALID, {
'height': self.new_height,
'transactions': self.block_transactions
})
self.events_queue.put(event)
return validity
return self.abci.ResponseCommit(data=data)
else:
return None
def get_asset_by_id(self, asset_id):
"""Returns the asset associated with an asset_id.
def rollback(b):
pre_commit = b.get_pre_commit_state()
Args:
asset_id (str): The asset id.
if pre_commit is None:
# the pre_commit record is first stored in the first `end_block`
return
Returns:
dict if the asset exists else None.
"""
cursor = backend.query.get_asset_by_id(self.connection, asset_id)
cursor = list(cursor)
if cursor:
return cursor[0]['asset']
latest_block = b.get_latest_block()
if latest_block is None:
logger.error('Found precommit state but no blocks!')
sys.exit(1)
def get_spent(self, txid, output):
"""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, output)` is only used once.
This method will check if the `(txid, output)` has already been
spent in a transaction that is in either the `VALID`, `UNDECIDED` or
`BACKLOG` state.
Args:
txid (str): The id of the transaction
output (num): the index of the output in the respective transaction
Returns:
The transaction (Transaction) that used the `(txid, output)` as an
input else `None`
Raises:
CriticalDoubleSpend: If the given `(txid, output)` was spent in
more than one valid transaction.
"""
# checks if an input was already spent
# checks if the bigchain has any transaction with input {'txid': ...,
# 'output': ...}
transactions = list(backend.query.get_spent(self.connection, txid,
output))
# a transaction_id should have been spent at most one time
# determine if these valid transactions appear in more than one valid
# block
num_valid_transactions = 0
non_invalid_transactions = []
for transaction in transactions:
# ignore transactions in invalid blocks
# FIXME: Isn't there a faster solution than doing I/O again?
_, status = self.get_transaction(transaction['id'],
include_status=True)
if status == self.TX_VALID:
num_valid_transactions += 1
# `txid` can only have been spent in at most on valid block.
if num_valid_transactions > 1:
raise core_exceptions.CriticalDoubleSpend(
'`{}` was spent more than once. There is a problem'
' with the chain'.format(txid))
# if its not and invalid transaction
if status is not None:
non_invalid_transactions.append(transaction)
if non_invalid_transactions:
return Transaction.from_dict(non_invalid_transactions[0])
# Either no transaction was returned spending the `(txid, output)` as
# input or the returned transactions are not valid.
def get_owned_ids(self, owner):
"""Retrieve a list of ``txid`` s that can be used as inputs.
Args:
owner (str): base58 encoded public key.
Returns:
:obj:`list` of TransactionLink: list of ``txid`` s and ``output`` s
pointing to another transaction's condition
"""
return self.get_outputs_filtered(owner, spent=False)
@property
def fastquery(self):
return fastquery.FastQuery(self.connection, self.me)
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_transactions_filtered(self, asset_id, operation=None):
"""
Get a list of transactions filtered on some criteria
"""
txids = backend.query.get_txids_filtered(self.connection, asset_id,
operation)
for txid in txids:
tx, status = self.get_transaction(txid, True)
if status == self.TX_VALID:
yield tx
def create_block(self, validated_transactions):
"""Creates a block given a list of `validated_transactions`.
Note that this method does not validate the transactions. Transactions
should be validated before calling create_block.
Args:
validated_transactions (list(Transaction)): list of validated
transactions.
Returns:
Block: created block.
"""
# Prevent the creation of empty blocks
if not validated_transactions:
raise exceptions.OperationError('Empty block creation is not '
'allowed')
voters = list(self.federation)
block = Block(validated_transactions, self.me, gen_timestamp(), voters)
block = block.sign(self.me_private)
return block
# TODO: check that the votings structure is correctly constructed
def validate_block(self, block):
"""Validate a block.
Args:
block (Block): block to validate.
Returns:
The block if the block is valid else it raises and exception
describing the reason why the block is invalid.
"""
return self.consensus.validate_block(self, block)
def has_previous_vote(self, block_id):
"""Check for previous votes from this node
Args:
block_id (str): the id of the block to check
Returns:
bool: :const:`True` if this block already has a
valid vote from this node, :const:`False` otherwise.
"""
votes = list(backend.query.get_votes_by_block_id_and_voter(self.connection, block_id, self.me))
el, _ = self.consensus.voting.partition_eligible_votes(votes, [self.me])
return bool(el)
def write_block(self, block):
"""Write a block to bigchain.
Args:
block (Block): block to write to bigchain.
"""
# Decouple assets from block
assets, block_dict = block.decouple_assets()
# write the assets
if assets:
self.write_assets(assets)
# write the block
return backend.query.write_block(self.connection, block_dict)
def prepare_genesis_block(self):
"""Prepare a genesis block."""
metadata = {'message': 'Hello World from the BigchainDB'}
transaction = Transaction.create([self.me], [([self.me], 1)],
metadata=metadata)
# NOTE: The transaction model doesn't expose an API to generate a
# GENESIS transaction, as this is literally the only usage.
transaction.operation = 'GENESIS'
transaction = transaction.sign([self.me_private])
# create the block
return self.create_block([transaction])
def create_genesis_block(self):
"""Create the genesis block
Block created when bigchain is first initialized. This method is not atomic, there might be concurrency
problems if multiple instances try to write the genesis block when the BigchainDB Federation is started,
but it's a highly unlikely scenario.
"""
# 1. create one transaction
# 2. create the block with one transaction
# 3. write the block to the bigchain
blocks_count = backend.query.count_blocks(self.connection)
if blocks_count:
raise exceptions.GenesisBlockAlreadyExistsError('Cannot create the Genesis block')
block = self.prepare_genesis_block()
self.write_block(block)
return block
def vote(self, block_id, previous_block_id, decision, invalid_reason=None):
"""Create a signed vote for a block given the
:attr:`previous_block_id` and the :attr:`decision` (valid/invalid).
Args:
block_id (str): The id of the block to vote on.
previous_block_id (str): The id of the previous block.
decision (bool): Whether the block is valid or invalid.
invalid_reason (Optional[str]): Reason the block is invalid
"""
if block_id == previous_block_id:
raise exceptions.CyclicBlockchainError()
vote = {
'voting_for_block': block_id,
'previous_block': previous_block_id,
'is_block_valid': decision,
'invalid_reason': invalid_reason,
'timestamp': gen_timestamp()
}
vote_data = serialize(vote)
signature = crypto.PrivateKey(self.me_private).sign(vote_data.encode())
vote_signed = {
'node_pubkey': self.me,
'signature': signature.decode(),
'vote': vote
}
return vote_signed
def write_vote(self, vote):
"""Write the vote to the database."""
return backend.query.write_vote(self.connection, vote)
def get_last_voted_block(self):
"""Returns the last block that this node voted on."""
last_block_id = backend.query.get_last_voted_block_id(self.connection,
self.me)
return Block.from_dict(self.get_block(last_block_id))
def block_election(self, block):
if type(block) != dict:
block = block.to_dict()
votes = list(backend.query.get_votes_by_block_id(self.connection,
block['id']))
return self.consensus.voting.block_election(block, votes,
self.federation)
def block_election_status(self, block):
"""Tally the votes on a block, and return the status:
valid, invalid, or undecided."""
return self.block_election(block)['status']
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 write_assets(self, assets):
"""
Writes a list of assets into the database.
Args:
assets (:obj:`list` of :obj:`dict`): A list of assets to write to
the database.
"""
return backend.query.write_assets(self.connection, assets)
def text_search(self, search, *, limit=0):
"""
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.
"""
assets = backend.query.text_search(self.connection, search, limit=limit)
# TODO: This is not efficient. There may be a more efficient way to
# query by storing block ids with the assets and using fastquery.
# See https://github.com/bigchaindb/bigchaindb/issues/1496
for asset in assets:
tx, status = self.get_transaction(asset['id'], True)
if status == self.TX_VALID:
yield asset
# 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'])

View File

@ -0,0 +1,355 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb import backend
from bigchaindb.elections.vote import Vote
from bigchaindb.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,
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': <block_height>,
'validators': <validator_set>
}
"""
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 bigchaindb.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

View File

@ -0,0 +1,64 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb.common.transaction import Transaction
from bigchaindb.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/bigchaindb/BEPs/tree/master/21
Args:
bigchain (BigchainDB): an instantiated bigchaindb.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

View File

@ -1,33 +1,109 @@
from enum import Enum
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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
class EventTypes(Enum):
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:`~bigchaindb.events.EventTypes`
event_data (obj): the data of the event.
"""
self.type = event_type
self.data = event_data
class EventHandler:
class Exchange:
"""Dispatch events to subscribers."""
def __init__(self, events_queue):
self.events_queue = events_queue
def __init__(self):
self.publisher_queue = Queue()
self.started_queue = Queue()
def put_event(self, event, timeout=None):
# TODO: handle timeouts
self.events_queue.put(event, timeout=None)
# Map <event_types -> queues>
self.queues = defaultdict(list)
def get_event(self, timeout=None):
# TODO: handle timeouts
return self.events_queue.get(timeout=None)
def get_publisher_queue(self):
"""Get the queue used by the publisher.
Returns:
a :class:`multiprocessing.Queue`.
"""
def setup_events_queue():
# TODO: set bounds to the queue
return 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:`~bigchaindb.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)

View File

@ -1,14 +1,12 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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"""
class CriticalDoubleInclusion(BigchainDBError):
"""Data integrity error that requires attention"""
class CriticalDuplicateVote(BigchainDBError):
"""Data integrity error that requires attention"""

View File

@ -1,54 +1,22 @@
# Copyright © 2020 Interplanetary Database Association e.V.,
# BigchainDB and IPDB 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 bigchaindb.utils import condition_details_has_owner
from bigchaindb.backend import query
from bigchaindb.common.transaction import TransactionLink
class FastQuery:
"""
Database queries that join on block results from a single node.
class FastQuery():
"""Database queries that join on block results from a single node."""
* Votes are not validated for security (security is a replication concern)
* Votes come from only one node, and as such, non-byzantine fault tolerance
is reduced.
Previously, to consider the status of a block, all votes for that block
were retrieved and the election results were counted. This meant that a
faulty node may still have been able to obtain a correct election result.
However, from the point of view of a client, it is still neccesary to
query multiple nodes to insure against getting an incorrect response from
a byzantine node.
"""
def __init__(self, connection, me):
def __init__(self, connection):
self.connection = connection
self.me = me
def filter_valid_block_ids(self, block_ids, include_undecided=False):
"""
Given block ids, return only the ones that are valid.
"""
block_ids = list(set(block_ids))
votes = query.get_votes_for_blocks_by_voter(
self.connection, block_ids, self.me)
votes = {vote['vote']['voting_for_block']: vote['vote']['is_block_valid']
for vote in votes}
return [block_id for block_id in block_ids
if votes.get(block_id, include_undecided)]
def filter_valid_items(self, items, block_id_key=lambda b: b[0]):
"""
Given items with block ids, return only the ones that are valid or undecided.
"""
items = list(items)
block_ids = map(block_id_key, items)
valid_block_ids = set(self.filter_valid_block_ids(block_ids, True))
return [b for b in items if block_id_key(b) in valid_block_ids]
def get_outputs_by_public_key(self, public_key):
"""
Get outputs for a public key
"""
res = list(query.get_owned_ids(self.connection, public_key))
txs = [tx for _, tx in self.filter_valid_items(res)]
"""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'])
@ -56,30 +24,26 @@ class FastQuery:
public_key)]
def filter_spent_outputs(self, outputs):
"""
Remove outputs that have been spent
"""Remove outputs that have been spent
Args:
outputs: list of TransactionLink
"""
links = [o.to_dict() for o in outputs]
res = query.get_spending_transactions(self.connection, links)
txs = [tx for _, tx in self.filter_valid_items(res)]
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
"""Remove outputs that have not been spent
Args:
outputs: list of TransactionLink
"""
links = [o.to_dict() for o in outputs]
res = query.get_spending_transactions(self.connection, links)
txs = [tx for _, tx in self.filter_valid_items(res)]
txs = list(query.get_spending_transactions(self.connection, links))
spends = {TransactionLink.from_dict(input_['fulfills'])
for tx in txs
for input_ in tx['inputs']}

Some files were not shown because too many files have changed in this diff Show More