diff --git a/.ci/entrypoint.sh b/.ci/entrypoint.sh index e3cbbc0e..1d3f24f2 100755 --- a/.ci/entrypoint.sh +++ b/.ci/entrypoint.sh @@ -1,4 +1,8 @@ #!/bin/bash +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/.ci/travis-after-success.sh b/.ci/travis-after-success.sh index 3934bb48..518409c6 100755 --- a/.ci/travis-after-success.sh +++ b/.ci/travis-after-success.sh @@ -1,4 +1,8 @@ #!/bin/bash +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/.ci/travis-before-install.sh b/.ci/travis-before-install.sh index 28111c80..f3125904 100755 --- a/.ci/travis-before-install.sh +++ b/.ci/travis-before-install.sh @@ -1,4 +1,8 @@ #!/bin/bash +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + if [[ -z ${TOXENV} ]]; then sudo apt-get update diff --git a/.ci/travis-before-script.sh b/.ci/travis-before-script.sh index 8bf7ec27..f68fa67d 100755 --- a/.ci/travis-before-script.sh +++ b/.ci/travis-before-script.sh @@ -1,4 +1,8 @@ #!/bin/bash +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/.ci/travis-install.sh b/.ci/travis-install.sh index 977628f7..352e9779 100755 --- a/.ci/travis-install.sh +++ b/.ci/travis-install.sh @@ -1,4 +1,8 @@ #!/bin/bash +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/.ci/travis_script.sh b/.ci/travis_script.sh index 0fdacc76..b525f85c 100755 --- a/.ci/travis_script.sh +++ b/.ci/travis_script.sh @@ -1,4 +1,8 @@ #!/bin/bash +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 5ff026e0..36a235cb 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -1,3 +1,9 @@ + + # 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. diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a3e4098..cd2aedd6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/.readthedocs.yml b/.readthedocs.yml index c8b8b04c..c8d328b5 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/.travis.yml b/.travis.yml index d6413fe9..7226815d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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: trusty diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c531b83..abf01d7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ + + # Change Log (Release Notes) All _notable_ changes to this project will be documented in this file (`CHANGELOG.md`). diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index b5beacc0..39b1f2c1 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,3 +1,9 @@ + + # Contributor Code of Conduct As contributors and maintainers of this project, and in the interest of diff --git a/HOW_TO_HANDLE_PULL_REQUESTS.md b/HOW_TO_HANDLE_PULL_REQUESTS.md index 00ab9335..66b9c7a7 100644 --- a/HOW_TO_HANDLE_PULL_REQUESTS.md +++ b/HOW_TO_HANDLE_PULL_REQUESTS.md @@ -1,3 +1,9 @@ + + # How to Handle External Pull Requests See [BEP-16](https://github.com/bigchaindb/BEPs/tree/master/16). diff --git a/PYTHON_STYLE_GUIDE.md b/PYTHON_STYLE_GUIDE.md index 492235b1..c4ef39e7 100644 --- a/PYTHON_STYLE_GUIDE.md +++ b/PYTHON_STYLE_GUIDE.md @@ -1,3 +1,9 @@ + + # 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. diff --git a/README.md b/README.md index d9d907a8..669eb435 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ + + + # Our Release Process ## Notes diff --git a/ROADMAP.md b/ROADMAP.md index 266cd06f..c3e0db88 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,3 +1,9 @@ + + # BigchainDB Roadmap We moved the BigchainDB Roadmap to the bigchaindb/org repository; see: diff --git a/acceptance/README.md b/acceptance/README.md index e64eb3c8..ad6e7c4e 100644 --- a/acceptance/README.md +++ b/acceptance/README.md @@ -1,3 +1,9 @@ + + # Acceptance test suite This directory contains the acceptance test suite for BigchainDB. diff --git a/acceptance/python/src/test_basic.py b/acceptance/python/src/test_basic.py index a965e19f..8702ef65 100644 --- a/acceptance/python/src/test_basic.py +++ b/acceptance/python/src/test_basic.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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: @@ -36,7 +40,6 @@ def test_basic(): # 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. @@ -57,7 +60,6 @@ def test_basic(): # 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(fulfilled_creation_tx) @@ -69,7 +71,6 @@ def test_basic(): 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. diff --git a/acceptance/python/src/test_divisible_asset.py b/acceptance/python/src/test_divisible_asset.py index 467efccf..b9a725d9 100644 --- a/acceptance/python/src/test_divisible_asset.py +++ b/acceptance/python/src/test_divisible_asset.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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: diff --git a/acceptance/python/src/test_double_spend.py b/acceptance/python/src/test_double_spend.py index e785feee..2b9541b4 100644 --- a/acceptance/python/src/test_double_spend.py +++ b/acceptance/python/src/test_double_spend.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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. diff --git a/acceptance/python/src/test_multiple_owners.py b/acceptance/python/src/test_multiple_owners.py index 4a27c6c2..89e93860 100644 --- a/acceptance/python/src/test_multiple_owners.py +++ b/acceptance/python/src/test_multiple_owners.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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. diff --git a/acceptance/python/src/test_naughty_strings.py b/acceptance/python/src/test_naughty_strings.py index 54664183..df4cb7dc 100644 --- a/acceptance/python/src/test_naughty_strings.py +++ b/acceptance/python/src/test_naughty_strings.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 @@ -8,7 +12,8 @@ # 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. +# 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... diff --git a/acceptance/python/src/test_stream.py b/acceptance/python/src/test_stream.py index e2fcb421..e8c12c5a 100644 --- a/acceptance/python/src/test_stream.py +++ b/acceptance/python/src/test_stream.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/README.md b/bigchaindb/README.md index 3ed61495..f3353108 100644 --- a/bigchaindb/README.md +++ b/bigchaindb/README.md @@ -1,3 +1,9 @@ + + # Overview A high-level description of the files and subdirectories of BigchainDB. diff --git a/bigchaindb/__init__.py b/bigchaindb/__init__.py index f0abc7fb..5e69b684 100644 --- a/bigchaindb/__init__.py +++ b/bigchaindb/__init__.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/backend/README.md b/bigchaindb/backend/README.md index 94ee8690..46318d78 100644 --- a/bigchaindb/backend/README.md +++ b/bigchaindb/backend/README.md @@ -1,3 +1,9 @@ + + # Backend Interfaces ## Structure diff --git a/bigchaindb/backend/__init__.py b/bigchaindb/backend/__init__.py index 7c7c12f7..a91891b5 100644 --- a/bigchaindb/backend/__init__.py +++ b/bigchaindb/backend/__init__.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/backend/connection.py b/bigchaindb/backend/connection.py index 14bf6de3..ab86e5d8 100644 --- a/bigchaindb/backend/connection.py +++ b/bigchaindb/backend/connection.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 itertools import repeat from importlib import import_module import logging diff --git a/bigchaindb/backend/exceptions.py b/bigchaindb/backend/exceptions.py index 017e19e4..b69cab73 100644 --- a/bigchaindb/backend/exceptions.py +++ b/bigchaindb/backend/exceptions.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/backend/localmongodb/__init__.py b/bigchaindb/backend/localmongodb/__init__.py index 61ae1e6b..8f6976a9 100644 --- a/bigchaindb/backend/localmongodb/__init__.py +++ b/bigchaindb/backend/localmongodb/__init__.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/backend/localmongodb/connection.py b/bigchaindb/backend/localmongodb/connection.py index 7e6c0e2a..45d234ec 100644 --- a/bigchaindb/backend/localmongodb/connection.py +++ b/bigchaindb/backend/localmongodb/connection.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 logging from ssl import CERT_REQUIRED diff --git a/bigchaindb/backend/localmongodb/query.py b/bigchaindb/backend/localmongodb/query.py index 85af8dcb..c85e0854 100644 --- a/bigchaindb/backend/localmongodb/query.py +++ b/bigchaindb/backend/localmongodb/query.py @@ -1,10 +1,13 @@ +# Copyright BigchainDB GmbH and BigchainDB 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.common.exceptions import MultipleValidatorOperationError from bigchaindb.backend.utils import module_dispatch_registrar from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection from bigchaindb.common.transaction import Transaction @@ -101,7 +104,8 @@ def get_spent(conn, transaction_id, output): def get_latest_block(conn): return conn.run( conn.collection('blocks') - .find_one(sort=[('height', DESCENDING)])) + .find_one(projection={'_id': False}, + sort=[('height', DESCENDING)])) @register_query(LocalMongoDBConnection) @@ -268,13 +272,15 @@ def get_pre_commit_state(conn, commit_id): @register_query(LocalMongoDBConnection) -def store_validator_set(conn, validator_update): - try: - return conn.run( - conn.collection('validators') - .insert_one(validator_update)) - except DuplicateKeyError: - raise MultipleValidatorOperationError('Validator update already exists') +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) @@ -291,3 +297,16 @@ def get_validator_set(conn, height=None): ) return list(cursor)[0] + + +@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 diff --git a/bigchaindb/backend/localmongodb/schema.py b/bigchaindb/backend/localmongodb/schema.py index 1e7f3614..25ef7f4e 100644 --- a/bigchaindb/backend/localmongodb/schema.py +++ b/bigchaindb/backend/localmongodb/schema.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 @@ -27,8 +31,7 @@ def create_database(conn, dbname): @register_schema(LocalMongoDBConnection) def create_tables(conn, dbname): - for table_name in ['transactions', 'utxos', 'assets', 'blocks', 'metadata', - 'validators', 'pre_commit']: + for table_name in backend.schema.TABLES: logger.info('Create `%s` table.', table_name) # create the table # TODO: read and write concerns can be declared here diff --git a/bigchaindb/backend/query.py b/bigchaindb/backend/query.py index 5c738fb3..b2cef080 100644 --- a/bigchaindb/backend/query.py +++ b/bigchaindb/backend/query.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 @@ -354,3 +358,17 @@ def get_validator_set(conn, height): """ raise NotImplementedError + + +@singledispatch +def get_asset_tokens_for_public_key(connection, asset_id, + public_key, operation): + """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 + operation: filter transaction based on `operation` + Returns: + Iterator of transaction that list given owner in conditions. + """ + raise NotImplementedError diff --git a/bigchaindb/backend/schema.py b/bigchaindb/backend/schema.py index 96a12b27..04c1bdd0 100644 --- a/bigchaindb/backend/schema.py +++ b/bigchaindb/backend/schema.py @@ -1,13 +1,8 @@ -"""Database creation and schema-providing interfaces for backends. +# Copyright BigchainDB GmbH and BigchainDB 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. - -""" +"""Database creation and schema-providing interfaces for backends.""" from functools import singledispatch import logging @@ -19,7 +14,10 @@ from bigchaindb.common.utils import validate_all_values_for_key logger = logging.getLogger(__name__) -TABLES = ('bigchain', 'backlog', 'assets', 'metadata') +# Tables/collections that every backend database must create +TABLES = ('transactions', 'blocks', 'assets', 'metadata', + 'validators', 'pre_commit', 'utxos') + VALID_LANGUAGES = ('danish', 'dutch', 'english', 'finnish', 'french', 'german', 'hungarian', 'italian', 'norwegian', 'portuguese', 'romanian', 'russian', 'spanish', 'swedish', 'turkish', 'none', diff --git a/bigchaindb/backend/utils.py b/bigchaindb/backend/utils.py index e84d31f4..a64995a7 100644 --- a/bigchaindb/backend/utils.py +++ b/bigchaindb/backend/utils.py @@ -1,3 +1,8 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 ModuleDispatchRegistrationError(Exception): """Raised when there is a problem registering dispatched functions for a module diff --git a/bigchaindb/commands/bigchaindb.py b/bigchaindb/commands/bigchaindb.py index 63394df1..5e24e07c 100644 --- a/bigchaindb/commands/bigchaindb.py +++ b/bigchaindb/commands/bigchaindb.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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. """ diff --git a/bigchaindb/commands/utils.py b/bigchaindb/commands/utils.py index 3ce8ab7f..9e090d6d 100644 --- a/bigchaindb/commands/utils.py +++ b/bigchaindb/commands/utils.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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``. """ diff --git a/bigchaindb/common/crypto.py b/bigchaindb/common/crypto.py index 58b3faa0..a8e42c52 100644 --- a/bigchaindb/common/crypto.py +++ b/bigchaindb/common/crypto.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/exceptions.py b/bigchaindb/common/exceptions.py index 357e998d..8e44b722 100644 --- a/bigchaindb/common/exceptions.py +++ b/bigchaindb/common/exceptions.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/schema/README.md b/bigchaindb/common/schema/README.md index 1de4bd41..4592e59a 100644 --- a/bigchaindb/common/schema/README.md +++ b/bigchaindb/common/schema/README.md @@ -1,3 +1,9 @@ + + # Introduction This directory contains the schemas for the different JSON documents BigchainDB uses. diff --git a/bigchaindb/common/schema/__init__.py b/bigchaindb/common/schema/__init__.py index 2e44b7ae..914e5196 100644 --- a/bigchaindb/common/schema/__init__.py +++ b/bigchaindb/common/schema/__init__.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 @@ -5,7 +9,6 @@ import logging import jsonschema import yaml import rapidjson -import rapidjson_schema from bigchaindb.common.exceptions import SchemaValidationError @@ -18,7 +21,7 @@ def _load_schema(name, path=__file__): path = os.path.join(os.path.dirname(path), name + '.yaml') with open(path) as handle: schema = yaml.safe_load(handle) - fast_schema = rapidjson_schema.loads(rapidjson.dumps(schema)) + fast_schema = rapidjson.Validator(rapidjson.dumps(schema)) return path, (schema, fast_schema) @@ -53,7 +56,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]) diff --git a/bigchaindb/common/schema/transaction_create_v1.0.yaml b/bigchaindb/common/schema/transaction_create_v1.0.yaml index 3d393347..bcec0c33 100644 --- a/bigchaindb/common/schema/transaction_create_v1.0.yaml +++ b/bigchaindb/common/schema/transaction_create_v1.0.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/schema/transaction_create_v2.0.yaml b/bigchaindb/common/schema/transaction_create_v2.0.yaml index ed018ea5..5eb8c5a1 100644 --- a/bigchaindb/common/schema/transaction_create_v2.0.yaml +++ b/bigchaindb/common/schema/transaction_create_v2.0.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/schema/transaction_transfer_v1.0.yaml b/bigchaindb/common/schema/transaction_transfer_v1.0.yaml index 538ec5e6..bc26dff8 100644 --- a/bigchaindb/common/schema/transaction_transfer_v1.0.yaml +++ b/bigchaindb/common/schema/transaction_transfer_v1.0.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/schema/transaction_transfer_v2.0.yaml b/bigchaindb/common/schema/transaction_transfer_v2.0.yaml index 538ec5e6..bc26dff8 100644 --- a/bigchaindb/common/schema/transaction_transfer_v2.0.yaml +++ b/bigchaindb/common/schema/transaction_transfer_v2.0.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/schema/transaction_v1.0.yaml b/bigchaindb/common/schema/transaction_v1.0.yaml index 15b7d381..cd7ad304 100644 --- a/bigchaindb/common/schema/transaction_v1.0.yaml +++ b/bigchaindb/common/schema/transaction_v1.0.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/schema/transaction_v2.0.yaml b/bigchaindb/common/schema/transaction_v2.0.yaml index 6f7deea9..acc8c6b5 100644 --- a/bigchaindb/common/schema/transaction_v2.0.yaml +++ b/bigchaindb/common/schema/transaction_v2.0.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/schema/transaction_validator_election_v2.0.yaml b/bigchaindb/common/schema/transaction_validator_election_v2.0.yaml index ce107f58..2c93886c 100644 --- a/bigchaindb/common/schema/transaction_validator_election_v2.0.yaml +++ b/bigchaindb/common/schema/transaction_validator_election_v2.0.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/common/schema/transaction_validator_election_vote_v2.0.yaml b/bigchaindb/common/schema/transaction_validator_election_vote_v2.0.yaml index 714cfe3e..c17fb229 100644 --- a/bigchaindb/common/schema/transaction_validator_election_vote_v2.0.yaml +++ b/bigchaindb/common/schema/transaction_validator_election_vote_v2.0.yaml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 @@ -6,7 +10,9 @@ required: - operation - outputs properties: - operation: "VALIDATOR_ELECTION_VOTE" + operation: + type: string + value: "VALIDATOR_ELECTION_VOTE" outputs: type: array items: diff --git a/bigchaindb/common/transaction.py b/bigchaindb/common/transaction.py index f232eb81..d5b3eef8 100644 --- a/bigchaindb/common/transaction.py +++ b/bigchaindb/common/transaction.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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. @@ -570,7 +574,7 @@ class Transaction(object): @property def spent_outputs(self): - """tuple of :obj:`dict`: Inputs of this transaction. Each input + """Tuple of :obj:`dict`: Inputs of this transaction. Each input is represented as a dictionary containing a transaction id and output index. """ diff --git a/bigchaindb/common/utils.py b/bigchaindb/common/utils.py index ca7ec6cb..4e1f8ca2 100644 --- a/bigchaindb/common/utils.py +++ b/bigchaindb/common/utils.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/config_utils.py b/bigchaindb/config_utils.py index 7a350175..3836f437 100644 --- a/bigchaindb/config_utils.py +++ b/bigchaindb/config_utils.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/consensus.py b/bigchaindb/consensus.py index ba316762..a5a20efb 100644 --- a/bigchaindb/consensus.py +++ b/bigchaindb/consensus.py @@ -1,3 +1,6 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 BaseConsensusRules(): diff --git a/bigchaindb/core.py b/bigchaindb/core.py index f9613fe0..67b48df5 100644 --- a/bigchaindb/core.py +++ b/bigchaindb/core.py @@ -1,7 +1,11 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """This module contains all the goodness to integrate BigchainDB -with Tendermint.""" +with Tendermint. +""" import logging -import codecs from abci.application import BaseApplication from abci.types_pb2 import ( @@ -12,8 +16,6 @@ from abci.types_pb2 import ( ResponseDeliverTx, ResponseEndBlock, ResponseCommit, - Validator, - PubKey ) from bigchaindb import BigchainDB @@ -21,6 +23,8 @@ from bigchaindb.tendermint_utils import (decode_transaction, calculate_hash) from bigchaindb.lib import Block, PreCommitState from bigchaindb.backend.query import PRE_COMMIT_ID +from bigchaindb.upsert_validator import ValidatorElection +import bigchaindb.upsert_validator.validator_utils as vutils CodeTypeOk = 0 @@ -33,7 +37,8 @@ class App(BaseApplication): The role of this class is to expose the BigchainDB transactional logic to the Tendermint Consensus - State Machine.""" + State Machine. + """ def __init__(self, bigchaindb=None): self.bigchaindb = bigchaindb or BigchainDB() @@ -46,7 +51,7 @@ class App(BaseApplication): def init_chain(self, genesis): """Initialize chain with block of height 0""" - validator_set = [decode_validator(v) for v in genesis.validators] + validator_set = [vutils.decode_validator(v) for v in genesis.validators] block = Block(app_hash='', height=0, transactions=[]) self.bigchaindb.store_block(block._asdict()) self.bigchaindb.store_validator_set(1, validator_set) @@ -69,7 +74,8 @@ class App(BaseApplication): the mempool. Args: - raw_tx: a raw string (in bytes) transaction.""" + raw_tx: a raw string (in bytes) transaction. + """ logger.benchmark('CHECK_TX_INIT') logger.debug('check_tx: %s', raw_transaction) @@ -101,7 +107,8 @@ class App(BaseApplication): """Validate the transaction before mutating the state. Args: - raw_tx: a raw string (in bytes) transaction.""" + raw_tx: a raw string (in bytes) transaction. + """ logger.debug('deliver_tx: %s', raw_transaction) transaction = self.bigchaindb.is_valid_transaction( decode_transaction(raw_transaction), self.block_transactions) @@ -120,7 +127,8 @@ class App(BaseApplication): hash to be stored in the next block. Args: - height (int): new height of the chain.""" + height (int): new height of the chain. + """ height = request_end_block.height self.new_height = height @@ -132,11 +140,11 @@ class App(BaseApplication): else: self.block_txn_hash = block['app_hash'] - # TODO: calculate if an election has concluded - # NOTE: ensure the local validator set is updated - # validator_updates = self.bigchaindb.get_validator_update() - # validator_updates = [encode_validator(v) for v in validator_updates] - validator_updates = [] + # Check if the current block concluded any validator elections and + # update the locally tracked validator set + validator_updates = ValidatorElection.get_validator_update(self.bigchaindb, + self.new_height, + self.block_transactions) # Store pre-commit state to recover in case there is a crash # during `commit` @@ -167,22 +175,3 @@ class App(BaseApplication): self.block_txn_ids) logger.benchmark('COMMIT_BLOCK, height:%s', self.new_height) return ResponseCommit(data=data) - - -def encode_validator(v): - ed25519_public_key = v['pub_key']['data'] - # NOTE: tendermint expects public to be encoded in go-amino format - - pub_key = PubKey(type='ed25519', - data=bytes.fromhex(ed25519_public_key)) - - return Validator(pub_key=pub_key, - address=b'', - power=v['power']) - - -def decode_validator(v): - return {'address': codecs.encode(v.address, 'hex').decode().upper().rstrip('\n'), - 'pub_key': {'type': v.pub_key.type, - 'data': codecs.encode(v.pub_key.data, 'base64').decode().rstrip('\n')}, - 'voting_power': v.power} diff --git a/bigchaindb/event_stream.py b/bigchaindb/event_stream.py index 8a68b7f1..a7d39187 100644 --- a/bigchaindb/event_stream.py +++ b/bigchaindb/event_stream.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 asyncio import json import logging diff --git a/bigchaindb/events.py b/bigchaindb/events.py index e11037cb..75de6ded 100644 --- a/bigchaindb/events.py +++ b/bigchaindb/events.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 diff --git a/bigchaindb/exceptions.py b/bigchaindb/exceptions.py index bb5d7c01..3e54192c 100644 --- a/bigchaindb/exceptions.py +++ b/bigchaindb/exceptions.py @@ -1,3 +1,8 @@ +# Copyright BigchainDB GmbH and BigchainDB 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.""" diff --git a/bigchaindb/fastquery.py b/bigchaindb/fastquery.py index 2f3e4795..0cf873cf 100644 --- a/bigchaindb/fastquery.py +++ b/bigchaindb/fastquery.py @@ -1,19 +1,20 @@ +# Copyright BigchainDB GmbH and BigchainDB 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. - """ + """Database queries that join on block results from a single node.""" + def __init__(self, connection): self.connection = connection def get_outputs_by_public_key(self, public_key): - """ - Get outputs for a public key - """ + """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 @@ -22,8 +23,7 @@ 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 @@ -36,8 +36,7 @@ class FastQuery(): 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 diff --git a/bigchaindb/lib.py b/bigchaindb/lib.py index 7d745634..cbabf06a 100644 --- a/bigchaindb/lib.py +++ b/bigchaindb/lib.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """Module containing main contact points with Tendermint and MongoDB. @@ -24,6 +28,7 @@ from bigchaindb.tendermint_utils import encode_transaction, merkleroot from bigchaindb import exceptions as core_exceptions from bigchaindb.consensus import BaseConsensusRules + logger = logging.getLogger(__name__) @@ -418,16 +423,8 @@ class BigchainDB(object): def get_validators(self, height=None): result = backend.query.get_validator_set(self.connection, height) validators = result['validators'] - for v in validators: - v.pop('address') - v['voting_power'] = int(v['voting_power']) - return validators - def get_validator_update(self): - update = backend.query.get_validator_update(self.connection) - return [update['validator']] if update else [] - def delete_validator_update(self): return backend.query.delete_validator_update(self.connection) diff --git a/bigchaindb/log.py b/bigchaindb/log.py index 9fca6508..6b6ba931 100644 --- a/bigchaindb/log.py +++ b/bigchaindb/log.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 import logging diff --git a/bigchaindb/models.py b/bigchaindb/models.py index 58cc9a99..894f510d 100644 --- a/bigchaindb/models.py +++ b/bigchaindb/models.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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.exceptions import (InvalidSignature, DuplicateTransaction) from bigchaindb.common.transaction import Transaction diff --git a/bigchaindb/start.py b/bigchaindb/start.py index e606ac11..2b9667b5 100644 --- a/bigchaindb/start.py +++ b/bigchaindb/start.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + import logging import setproctitle diff --git a/bigchaindb/tendermint_utils.py b/bigchaindb/tendermint_utils.py index 3299456a..99ea85f5 100644 --- a/bigchaindb/tendermint_utils.py +++ b/bigchaindb/tendermint_utils.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + import base64 import hashlib import json diff --git a/bigchaindb/upsert_validator/__init__.py b/bigchaindb/upsert_validator/__init__.py index a318e861..90a02a0b 100644 --- a/bigchaindb/upsert_validator/__init__.py +++ b/bigchaindb/upsert_validator/__init__.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB 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.upsert_validator.validator_election import ValidatorElection # noqa from bigchaindb.upsert_validator.validator_election_vote import ValidatorElectionVote # noqa +from bigchaindb.upsert_validator.validator_election import ValidatorElection # noqa diff --git a/bigchaindb/upsert_validator/validator_election.py b/bigchaindb/upsert_validator/validator_election.py index 4717e708..a2c68412 100644 --- a/bigchaindb/upsert_validator/validator_election.py +++ b/bigchaindb/upsert_validator/validator_election.py @@ -1,3 +1,10 @@ +# Copyright BigchainDB GmbH and BigchainDB 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 base58 + +from bigchaindb import backend from bigchaindb.common.exceptions import (InvalidSignature, MultipleInputsError, InvalidProposer, @@ -11,6 +18,8 @@ from bigchaindb.common.schema import (_validate_schema, TX_SCHEMA_VALIDATOR_ELECTION, TX_SCHEMA_COMMON, TX_SCHEMA_CREATE) +from . import ValidatorElectionVote +from .validator_utils import (new_validator_set, encode_validator) class ValidatorElection(Transaction): @@ -28,15 +37,15 @@ class ValidatorElection(Transaction): super().__init__(operation, asset, inputs, outputs, metadata, version, hash_id) @classmethod - def current_validators(cls, bigchain): + 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(): + 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['pub_key']['value'])) + public_key = public_key_from_ed25519_key(key_from_base64(validator['pub_key']['data'])) validators[public_key] = validator['voting_power'] return validators @@ -46,7 +55,7 @@ class ValidatorElection(Transaction): """Convert validator dictionary to a recipient list for `Transaction`""" recipients = [] - for public_key, voting_power in cls.current_validators(bigchain).items(): + for public_key, voting_power in cls.get_validators(bigchain).items(): recipients.append(([public_key], voting_power)) return recipients @@ -80,7 +89,7 @@ class ValidatorElection(Transaction): bigchain (BigchainDB): an instantiated bigchaindb.lib.BigchainDB object. Returns: - `True` if the election is valid + ValidatorElection object Raises: ValidationError: If the election is invalid @@ -95,7 +104,7 @@ class ValidatorElection(Transaction): if not self.inputs_valid(input_conditions): raise InvalidSignature('Transaction signature is invalid.') - current_validators = self.current_validators(bigchain) + 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: @@ -114,7 +123,7 @@ class ValidatorElection(Transaction): if not self.is_same_topology(current_validators, self.outputs): raise UnequalValidatorSet('Validator set much be exactly same to the outputs of election') - return True + return self @classmethod def generate(cls, initiator, voters, election_data, metadata=None): @@ -141,3 +150,77 @@ class ValidatorElection(Transaction): @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)) + + @classmethod + def count_votes(cls, election_pk, transactions, getter=getattr): + votes = 0 + for txn in transactions: + if getter(txn, 'operation') == 'VALIDATOR_ELECTION_VOTE': + 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) + + @classmethod + def has_concluded(cls, bigchain, election_id, current_votes=[], height=None): + """Check if the given `election_id` can be concluded or not + NOTE: + * Election is concluded iff the current validator set is exactly equal + to the validator set encoded in election outputs + * Election can concluded only if the current votes achieves a supermajority + """ + election = bigchain.get_transaction(election_id) + + if election: + election_pk = election.to_public_key(election.id) + votes_commited = election.get_commited_votes(bigchain, election_pk) + votes_current = election.count_votes(election_pk, current_votes) + current_validators = election.get_validators(bigchain, height) + + if election.is_same_topology(current_validators, election.outputs): + total_votes = sum(current_validators.values()) + if (votes_commited < (2/3)*total_votes) and \ + (votes_commited + votes_current >= (2/3)*total_votes): + return election + return False + + @classmethod + def get_validator_update(cls, bigchain, new_height, txns): + votes = {} + for txn in txns: + if not isinstance(txn, ValidatorElectionVote): + continue + + election_id = txn.asset['id'] + election_votes = votes.get(election_id, []) + election_votes.append(txn) + votes[election_id] = election_votes + + election = cls.has_concluded(bigchain, election_id, election_votes, new_height) + # Once an election concludes any other conclusion for the same + # or any other election is invalidated + if election: + # The new validator set comes into effect from height = new_height+1 + validator_updates = [election.asset['data']] + curr_validator_set = bigchain.get_validators(new_height) + updated_validator_set = new_validator_set(curr_validator_set, + new_height, validator_updates) + + bigchain.store_validator_set(new_height+1, updated_validator_set) + return [encode_validator(election.asset['data'])] + return [] diff --git a/bigchaindb/upsert_validator/validator_election_vote.py b/bigchaindb/upsert_validator/validator_election_vote.py index 1405ff8f..7620b289 100644 --- a/bigchaindb/upsert_validator/validator_election_vote.py +++ b/bigchaindb/upsert_validator/validator_election_vote.py @@ -1,4 +1,6 @@ -import base58 +# Copyright BigchainDB GmbH and BigchainDB 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, @@ -26,7 +28,7 @@ class ValidatorElectionVote(Transaction): bigchain (BigchainDB): an instantiated bigchaindb.lib.BigchainDB object. Returns: - `True` if the election vote is valid + ValidatorElectionVote object Raises: ValidationError: If the election vote is invalid @@ -34,10 +36,6 @@ class ValidatorElectionVote(Transaction): self.validate_transfer_inputs(bigchain, current_transactions) return self - @classmethod - def to_public_key(cls, election_id): - return base58.b58encode(bytes.fromhex(election_id)) - @classmethod def generate(cls, inputs, recipients, election_id, metadata=None): (inputs, outputs) = cls.validate_transfer(inputs, recipients, election_id, metadata) diff --git a/bigchaindb/upsert_validator/validator_utils.py b/bigchaindb/upsert_validator/validator_utils.py new file mode 100644 index 00000000..7cb924d8 --- /dev/null +++ b/bigchaindb/upsert_validator/validator_utils.py @@ -0,0 +1,37 @@ +import codecs + +from abci.types_pb2 import (Validator, + PubKey) +from bigchaindb.tendermint_utils import public_key_to_base64 + + +def encode_validator(v): + ed25519_public_key = v['public_key'] + # NOTE: tendermint expects public to be encoded in go-amino format + pub_key = PubKey(type='ed25519', + data=bytes.fromhex(ed25519_public_key)) + return Validator(pub_key=pub_key, + address=b'', + power=v['power']) + + +def decode_validator(v): + return {'pub_key': {'type': v.pub_key.type, + 'data': codecs.encode(v.pub_key.data, 'base64').decode().rstrip('\n')}, + 'voting_power': v.power} + + +def new_validator_set(validators, height, updates): + validators_dict = {} + for v in validators: + validators_dict[v['pub_key']['data']] = v + + updates_dict = {} + for u in updates: + public_key64 = public_key_to_base64(u['public_key']) + updates_dict[public_key64] = {'pub_key': {'type': 'ed25519', + 'data': public_key64}, + 'voting_power': u['power']} + + new_validators_dict = {**validators_dict, **updates_dict} + return list(new_validators_dict.values()) diff --git a/bigchaindb/utils.py b/bigchaindb/utils.py index ba781214..78777133 100644 --- a/bigchaindb/utils.py +++ b/bigchaindb/utils.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + import contextlib import threading import queue diff --git a/bigchaindb/version.py b/bigchaindb/version.py index 70929438..3120eea1 100644 --- a/bigchaindb/version.py +++ b/bigchaindb/version.py @@ -1,2 +1,6 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + __version__ = '2.0.0b5' __short_version__ = '2.0b5' diff --git a/bigchaindb/web/routes.py b/bigchaindb/web/routes.py index 33d65ad7..94d6e63a 100644 --- a/bigchaindb/web/routes.py +++ b/bigchaindb/web/routes.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """API routes definition""" from flask_restful import Api from bigchaindb.web.views import ( diff --git a/bigchaindb/web/server.py b/bigchaindb/web/server.py index 348d3fec..f296a872 100644 --- a/bigchaindb/web/server.py +++ b/bigchaindb/web/server.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """This module contains basic functions to instantiate the BigchainDB API. The application is implemented in Flask and runs using Gunicorn. diff --git a/bigchaindb/web/strip_content_type_middleware.py b/bigchaindb/web/strip_content_type_middleware.py index 953c8b78..0b2164fa 100644 --- a/bigchaindb/web/strip_content_type_middleware.py +++ b/bigchaindb/web/strip_content_type_middleware.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + import logging logger = logging.getLogger(__name__) diff --git a/bigchaindb/web/views/assets.py b/bigchaindb/web/views/assets.py index 7639b78f..6829eaf4 100644 --- a/bigchaindb/web/views/assets.py +++ b/bigchaindb/web/views/assets.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """This module provides the blueprint for some basic API endpoints. For more information please refer to the documentation: http://bigchaindb.com/http-api diff --git a/bigchaindb/web/views/base.py b/bigchaindb/web/views/base.py index 9d804d89..3ca79f0c 100644 --- a/bigchaindb/web/views/base.py +++ b/bigchaindb/web/views/base.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """Common classes and methods for API handlers """ import logging diff --git a/bigchaindb/web/views/blocks.py b/bigchaindb/web/views/blocks.py index b00a478f..276fc632 100644 --- a/bigchaindb/web/views/blocks.py +++ b/bigchaindb/web/views/blocks.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """This module provides the blueprint for the blocks API endpoints. For more information please refer to the documentation: http://bigchaindb.com/http-api diff --git a/bigchaindb/web/views/info.py b/bigchaindb/web/views/info.py index 88086d0d..4b44157b 100644 --- a/bigchaindb/web/views/info.py +++ b/bigchaindb/web/views/info.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """API Index endpoint""" import flask diff --git a/bigchaindb/web/views/metadata.py b/bigchaindb/web/views/metadata.py index 1879fabe..2a6e6292 100644 --- a/bigchaindb/web/views/metadata.py +++ b/bigchaindb/web/views/metadata.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """This module provides the blueprint for some basic API endpoints. For more information please refer to the documentation: http://bigchaindb.com/http-api diff --git a/bigchaindb/web/views/outputs.py b/bigchaindb/web/views/outputs.py index 2f63c07f..0a087fbb 100644 --- a/bigchaindb/web/views/outputs.py +++ b/bigchaindb/web/views/outputs.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + from flask import current_app from flask_restful import reqparse, Resource diff --git a/bigchaindb/web/views/parameters.py b/bigchaindb/web/views/parameters.py index 58eb8a5f..ed78157a 100644 --- a/bigchaindb/web/views/parameters.py +++ b/bigchaindb/web/views/parameters.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + import re diff --git a/bigchaindb/web/views/transactions.py b/bigchaindb/web/views/transactions.py index cd64f0a9..9bbc209d 100644 --- a/bigchaindb/web/views/transactions.py +++ b/bigchaindb/web/views/transactions.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """This module provides the blueprint for some basic API endpoints. For more information please refer to the documentation: http://bigchaindb.com/http-api diff --git a/bigchaindb/web/views/validators.py b/bigchaindb/web/views/validators.py index 825b0c7d..a31f3357 100644 --- a/bigchaindb/web/views/validators.py +++ b/bigchaindb/web/views/validators.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + from flask import current_app from flask_restful import Resource diff --git a/bigchaindb/web/websocket_server.py b/bigchaindb/web/websocket_server.py index ad138d40..8aea0e20 100644 --- a/bigchaindb/web/websocket_server.py +++ b/bigchaindb/web/websocket_server.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """WebSocket server for the BigchainDB Event Stream API.""" # NOTE diff --git a/codecov.yml b/codecov.yml index 727c29ea..b46e4ecb 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + codecov: branch: master # the branch to show by default diff --git a/docker-compose.yml b/docker-compose.yml index 9c8fa3a7..cf50538c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + version: '2.1' services: diff --git a/docs/README.md b/docs/README.md index b93f72a1..84d59205 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,3 +1,9 @@ + + - [Documentation on ReadTheDocs](http://bigchaindb.readthedocs.org/) - [BigchainDB Upgrade Guides](upgrade-guides/) diff --git a/docs/contributing/source/conf.py b/docs/contributing/source/conf.py index 70ecc655..0358e6ab 100644 --- a/docs/contributing/source/conf.py +++ b/docs/contributing/source/conf.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# +# Copyright BigchainDB GmbH and BigchainDB 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 documentation build configuration file, created by # sphinx-quickstart on Thu Sep 29 11:13:27 2016. # diff --git a/docs/contributing/source/cross-project-policies/index.rst b/docs/contributing/source/cross-project-policies/index.rst index e98e0923..5d6adc4a 100644 --- a/docs/contributing/source/cross-project-policies/index.rst +++ b/docs/contributing/source/cross-project-policies/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Policies ======== diff --git a/docs/contributing/source/dev-setup-coding-and-contribution-process/index.rst b/docs/contributing/source/dev-setup-coding-and-contribution-process/index.rst index 9c96200b..bb9503d8 100644 --- a/docs/contributing/source/dev-setup-coding-and-contribution-process/index.rst +++ b/docs/contributing/source/dev-setup-coding-and-contribution-process/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Developer Setup, Coding & Contribution Process ============================================== diff --git a/docs/contributing/source/dev-setup-coding-and-contribution-process/run-dev-network-ansible.md b/docs/contributing/source/dev-setup-coding-and-contribution-process/run-dev-network-ansible.md index 3bb9dc47..f04539f1 100644 --- a/docs/contributing/source/dev-setup-coding-and-contribution-process/run-dev-network-ansible.md +++ b/docs/contributing/source/dev-setup-coding-and-contribution-process/run-dev-network-ansible.md @@ -1,3 +1,9 @@ + + # Run a BigchainDB network with Ansible **NOT for Production Use** diff --git a/docs/contributing/source/dev-setup-coding-and-contribution-process/run-dev-network-stack.md b/docs/contributing/source/dev-setup-coding-and-contribution-process/run-dev-network-stack.md index b4719128..96108d95 100644 --- a/docs/contributing/source/dev-setup-coding-and-contribution-process/run-dev-network-stack.md +++ b/docs/contributing/source/dev-setup-coding-and-contribution-process/run-dev-network-stack.md @@ -1,3 +1,9 @@ + + # Run a BigchainDB network **NOT for Production Use** diff --git a/docs/contributing/source/dev-setup-coding-and-contribution-process/run-node-as-processes.md b/docs/contributing/source/dev-setup-coding-and-contribution-process/run-node-as-processes.md index d39b2b9f..a0a0af7e 100644 --- a/docs/contributing/source/dev-setup-coding-and-contribution-process/run-node-as-processes.md +++ b/docs/contributing/source/dev-setup-coding-and-contribution-process/run-node-as-processes.md @@ -1,3 +1,9 @@ + + # Notes on Running a Local Dev Node as Processes The following doc describes how to run a local node for developing BigchainDB Tendermint version. diff --git a/docs/contributing/source/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.md b/docs/contributing/source/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.md index 8a8ae482..726a3088 100644 --- a/docs/contributing/source/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.md +++ b/docs/contributing/source/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.md @@ -1,3 +1,9 @@ + + # Notes on Running a Local Dev Node with Docker Compose ## Setting up a single node development environment with ``docker-compose`` diff --git a/docs/contributing/source/dev-setup-coding-and-contribution-process/write-code.rst b/docs/contributing/source/dev-setup-coding-and-contribution-process/write-code.rst index 60526086..58ecd9bc 100644 --- a/docs/contributing/source/dev-setup-coding-and-contribution-process/write-code.rst +++ b/docs/contributing/source/dev-setup-coding-and-contribution-process/write-code.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Write Code ========== diff --git a/docs/contributing/source/index.rst b/docs/contributing/source/index.rst index 69b4cd03..d64729a5 100644 --- a/docs/contributing/source/index.rst +++ b/docs/contributing/source/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Contributing to BigchainDB ========================== diff --git a/docs/contributing/source/ways-to-contribute/answer-questions.md b/docs/contributing/source/ways-to-contribute/answer-questions.md index 62b51f4f..6e937f0a 100644 --- a/docs/contributing/source/ways-to-contribute/answer-questions.md +++ b/docs/contributing/source/ways-to-contribute/answer-questions.md @@ -1,3 +1,9 @@ + + # Answer Questions People ask questions about BigchainDB in the following places: diff --git a/docs/contributing/source/ways-to-contribute/index.rst b/docs/contributing/source/ways-to-contribute/index.rst index 6ae77244..6bafc7ce 100644 --- a/docs/contributing/source/ways-to-contribute/index.rst +++ b/docs/contributing/source/ways-to-contribute/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Ways to Contribute ================== diff --git a/docs/contributing/source/ways-to-contribute/make-a-feature-request-or-proposal.md b/docs/contributing/source/ways-to-contribute/make-a-feature-request-or-proposal.md index 53e5ce0b..3419ef52 100644 --- a/docs/contributing/source/ways-to-contribute/make-a-feature-request-or-proposal.md +++ b/docs/contributing/source/ways-to-contribute/make-a-feature-request-or-proposal.md @@ -1,3 +1,9 @@ + + # Make a Feature Request or Proposal To make a feature request or proposal, [write a BigchainDB Enhancement Proposal (BEP)](write-a-bep.html). diff --git a/docs/contributing/source/ways-to-contribute/report-a-bug.md b/docs/contributing/source/ways-to-contribute/report-a-bug.md index 64850662..c8f19e93 100644 --- a/docs/contributing/source/ways-to-contribute/report-a-bug.md +++ b/docs/contributing/source/ways-to-contribute/report-a-bug.md @@ -1,3 +1,9 @@ + + # Report a Bug To report a bug, go to the relevant GitHub repository, click on the **Issues** tab, click on the **New issue** button, and read the instructions. diff --git a/docs/contributing/source/ways-to-contribute/write-a-bep.md b/docs/contributing/source/ways-to-contribute/write-a-bep.md index 9bb5e8f4..4403a449 100644 --- a/docs/contributing/source/ways-to-contribute/write-a-bep.md +++ b/docs/contributing/source/ways-to-contribute/write-a-bep.md @@ -1,3 +1,9 @@ + + # Write a BigchainDB Enhancement Proposal (BEP) If you have an idea for a new feature or enhancement, and you want some feedback before you write a full BigchainDB Enhancement Proposal (BEP), then feel free to: diff --git a/docs/contributing/source/ways-to-contribute/write-an-issue.md b/docs/contributing/source/ways-to-contribute/write-an-issue.md index 2cce2d88..397b6309 100644 --- a/docs/contributing/source/ways-to-contribute/write-an-issue.md +++ b/docs/contributing/source/ways-to-contribute/write-an-issue.md @@ -1,3 +1,9 @@ + + # Write an Issue To write an issue, go to the relevant GitHub repository, click on the **Issues** tab, click on the **New issue** button, and read the instructions. diff --git a/docs/contributing/source/ways-to-contribute/write-docs.md b/docs/contributing/source/ways-to-contribute/write-docs.md index e09c953f..34a1166c 100644 --- a/docs/contributing/source/ways-to-contribute/write-docs.md +++ b/docs/contributing/source/ways-to-contribute/write-docs.md @@ -1,3 +1,9 @@ + + # Write Docs If you're writing code, you should also update any related docs. However, you might want to write docs only, such as: diff --git a/docs/root/source/assets.rst b/docs/root/source/assets.rst index 4ca3892b..fdf5c945 100644 --- a/docs/root/source/assets.rst +++ b/docs/root/source/assets.rst @@ -1,9 +1,14 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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 BigchainDB is Good for Asset Registrations & Transfers ========================================================== BigchainDB can store data of any kind (within reason), but it's designed to be particularly good for storing asset registrations and transfers: -* The fundamental thing that one sends to a BigchainDB cluster, to be checked and stored (if valid), is a *transaction*, and there are two kinds: CREATE transactions and TRANSFER transactions. +* The fundamental thing that one sends to a BigchainDB network, to be checked and stored (if valid), is a *transaction*, and there are two kinds: CREATE transactions and TRANSFER transactions. * A CREATE transaction can be use to register any kind of asset (divisible or indivisible), along with arbitrary metadata. * An asset can have zero, one, or several owners. * The owners of an asset can specify (crypto-)conditions which must be satisfied by anyone wishing transfer the asset to new owners. For example, a condition might be that at least 3 of the 5 current owners must cryptographically sign a TRANSFER transaction. diff --git a/docs/root/source/bft.md b/docs/root/source/bft.md index 919a0df9..3eba27e9 100644 --- a/docs/root/source/bft.md +++ b/docs/root/source/bft.md @@ -1,3 +1,9 @@ + + # BigchainDB and Byzantine Fault Tolerance [BigchainDB Server](https://docs.bigchaindb.com/projects/server/en/latest/index.html) diff --git a/docs/root/source/conf.py b/docs/root/source/conf.py index e35b72fc..b9f0d122 100644 --- a/docs/root/source/conf.py +++ b/docs/root/source/conf.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# +# Copyright BigchainDB GmbH and BigchainDB 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 documentation build configuration file, created by # sphinx-quickstart on Thu Sep 29 11:13:27 2016. # diff --git a/docs/root/source/decentralized.md b/docs/root/source/decentralized.md index f38e12a2..4486839d 100644 --- a/docs/root/source/decentralized.md +++ b/docs/root/source/decentralized.md @@ -1,10 +1,16 @@ + + # How BigchainDB is Decentralized Decentralization means that no one owns or controls everything, and there is no single point of failure. -Ideally, each node in a BigchainDB cluster is owned and controlled by a different person or organization. Even if the cluster lives within one organization, it's still preferable to have each node controlled by a different person or subdivision. +Ideally, each node in a BigchainDB network is owned and controlled by a different person or organization. Even if the network lives within one organization, it's still preferable to have each node controlled by a different person or subdivision. -We use the phrase "BigchainDB consortium" (or just "consortium") to refer to the set of people and/or organizations who run the nodes of a BigchainDB cluster. A consortium requires some form of governance to make decisions such as membership and policies. The exact details of the governance process are determined by each consortium, but it can be very decentralized. +We use the phrase "BigchainDB consortium" (or just "consortium") to refer to the set of people and/or organizations who run the nodes of a BigchainDB network. A consortium requires some form of governance to make decisions such as membership and policies. The exact details of the governance process are determined by each consortium, but it can be very decentralized. If sharding is turned on (i.e. if the number of shards is larger than one), then the actual data is decentralized in that no one node stores all the data. @@ -12,8 +18,8 @@ Every node has its own locally-stored list of the public keys of other consortiu A consortium can increase its decentralization (and its resilience) by increasing its jurisdictional diversity, geographic diversity, and other kinds of diversity. This idea is expanded upon in [the section on node diversity](diversity.html). -There’s no node that has a long-term special position in the cluster. All nodes run the same software and perform the same duties. +There’s no node that has a long-term special position in the BigchainDB network. All nodes run the same software and perform the same duties. -If someone has (or gets) admin access to a node, they can mess with that node (e.g. change or delete data stored on that node), but those changes should remain isolated to that node. The BigchainDB cluster can only be compromised if more than one third of the nodes get compromised. See the [Tendermint documentation](https://tendermint.readthedocs.io/projects/tools/en/master/introduction.html) for more details. +If someone has (or gets) admin access to a node, they can mess with that node (e.g. change or delete data stored on that node), but those changes should remain isolated to that node. The BigchainDB network can only be compromised if more than one third of the nodes get compromised. See the [Tendermint documentation](https://tendermint.readthedocs.io/projects/tools/en/master/introduction.html) for more details. It’s worth noting that not even the admin or superuser of a node can transfer assets. The only way to create a valid transfer transaction is to fulfill the current crypto-conditions on the asset, and the admin/superuser can’t do that because the admin user doesn’t have the necessary information (e.g. private keys). diff --git a/docs/root/source/diversity.md b/docs/root/source/diversity.md index 767962e1..af80a0c4 100644 --- a/docs/root/source/diversity.md +++ b/docs/root/source/diversity.md @@ -1,3 +1,9 @@ + + # Kinds of Node Diversity Steps should be taken to make it difficult for any one actor or event to control or damage “enough” of the nodes. (Because BigchainDB Server uses Tendermint, "enough" is ⅓.) There are many kinds of diversity to consider, listed below. It may be quite difficult to have high diversity of all kinds. diff --git a/docs/root/source/immutable.md b/docs/root/source/immutable.md index c1aeb9f6..d9b6c72b 100644 --- a/docs/root/source/immutable.md +++ b/docs/root/source/immutable.md @@ -1,3 +1,9 @@ + + # How BigchainDB is Immutable The word _immutable_ means "unchanging over time or unable to be changed." For example, the decimal digits of π are immutable (3.14159…). diff --git a/docs/root/source/index.rst b/docs/root/source/index.rst index b6f478f8..4c9c32be 100644 --- a/docs/root/source/index.rst +++ b/docs/root/source/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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 Documentation ======================== @@ -8,7 +13,7 @@ including `decentralization `_, `immutability `_ and `native support for assets `_. -At a high level, one can communicate with a BigchainDB cluster (set of nodes) using the BigchainDB HTTP API, or a wrapper for that API, such as the BigchainDB Python Driver. Each BigchainDB node runs BigchainDB Server and various other software. The `terminology page `_ explains some of those terms in more detail. +At a high level, one can communicate with a BigchainDB network (set of nodes) using the BigchainDB HTTP API, or a wrapper for that API, such as the BigchainDB Python Driver. Each BigchainDB node runs BigchainDB Server and various other software. The `terminology page `_ explains some of those terms in more detail. .. raw:: html diff --git a/docs/root/source/permissions.rst b/docs/root/source/permissions.rst index 0c31d1dc..009929fb 100644 --- a/docs/root/source/permissions.rst +++ b/docs/root/source/permissions.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Permissions in BigchainDB ------------------------- diff --git a/docs/root/source/private-data.rst b/docs/root/source/private-data.rst index 7088931f..73264116 100644 --- a/docs/root/source/private-data.rst +++ b/docs/root/source/private-data.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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, Privacy and Private Data ------------------------------------ diff --git a/docs/root/source/production-ready.md b/docs/root/source/production-ready.md index afbf8cc5..f94f7bb0 100644 --- a/docs/root/source/production-ready.md +++ b/docs/root/source/production-ready.md @@ -1,3 +1,9 @@ + + # Production-Ready? Depending on your use case, BigchainDB may or may not be production-ready. You should ask your service provider. diff --git a/docs/root/source/query.rst b/docs/root/source/query.rst index 0c4b642a..6ea9130f 100644 --- a/docs/root/source/query.rst +++ b/docs/root/source/query.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Querying BigchainDB =================== diff --git a/docs/root/source/smart-contracts.rst b/docs/root/source/smart-contracts.rst index b031f2f2..a9cd59f7 100644 --- a/docs/root/source/smart-contracts.rst +++ b/docs/root/source/smart-contracts.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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 and Smart Contracts ============================== diff --git a/docs/root/source/store-files.md b/docs/root/source/store-files.md index 7ac2719e..ef52e5b0 100644 --- a/docs/root/source/store-files.md +++ b/docs/root/source/store-files.md @@ -1,3 +1,9 @@ + + # How to Store Files in BigchainDB While it's possible to store a file in a BigchainDB network, we don't recommend doing that. It works best for storing, indexing and querying _structured data_, not files. diff --git a/docs/root/source/terminology.md b/docs/root/source/terminology.md index ef05436e..5ed67c65 100644 --- a/docs/root/source/terminology.md +++ b/docs/root/source/terminology.md @@ -1,3 +1,9 @@ + + # Terminology There is some specialized terminology associated with BigchainDB. To get started, you should at least know the following: @@ -6,14 +12,14 @@ There is some specialized terminology associated with BigchainDB. To get started A **BigchainDB node** is a machine (or logical machine) running [BigchainDB Server](https://docs.bigchaindb.com/projects/server/en/latest/introduction.html) and related software. Each node is controlled by one person or organization. -## BigchainDB Cluster +## BigchainDB Network -A set of BigchainDB nodes can connect to each other to form a **BigchainDB cluster**. Each node in the cluster runs the same software. A cluster may have additional machines to do things such as cluster monitoring. +A set of BigchainDB nodes can connect to each other to form a **BigchainDB network**. Each node in the network runs the same software. A BigchainDB network may have additional machines to do things such as monitoring. ## BigchainDB Consortium -The people and organizations that run the nodes in a cluster belong to a **BigchainDB consortium** (i.e. another organization). A consortium must have some sort of governance structure to make decisions. If a cluster is run by a single company, then the "consortium" is just that company. +The people and organizations that run the nodes in a BigchainDB network belong to a **BigchainDB consortium** (i.e. another organization). A consortium must have some sort of governance structure to make decisions. If a BigchainDB network is run by a single company, then the "consortium" is just that company. -**What's the Difference Between a Cluster and a Consortium?** +**What's the Difference Between a BigchainDB Network and a Consortium?** -A cluster is just a bunch of connected nodes. A consortium is an organization which has a cluster, and where each node in the cluster has a different operator. \ No newline at end of file +A BigchaindB network is just a bunch of connected nodes. A consortium is an organization which has a BigchainDB network, and where each node in that network has a different operator. \ No newline at end of file diff --git a/docs/root/source/transaction-concepts.md b/docs/root/source/transaction-concepts.md index 6a3b183d..9eca8e50 100644 --- a/docs/root/source/transaction-concepts.md +++ b/docs/root/source/transaction-concepts.md @@ -1,3 +1,9 @@ + + # Transaction Concepts In BigchainDB, _transactions_ are used to register, issue, create or transfer diff --git a/docs/server/generate_http_server_api_documentation.py b/docs/server/generate_http_server_api_documentation.py index 9050d05c..cd7fcd71 100644 --- a/docs/server/generate_http_server_api_documentation.py +++ b/docs/server/generate_http_server_api_documentation.py @@ -1,3 +1,7 @@ +# Copyright BigchainDB GmbH and BigchainDB contributors +# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) +# Code is Apache-2.0 and docs are CC-BY-4.0 + """ Script to build http examples for http server api docs """ import json diff --git a/docs/server/source/appendices/all-in-one-bigchaindb.md b/docs/server/source/appendices/all-in-one-bigchaindb.md index 246b4e50..4fd6b245 100644 --- a/docs/server/source/appendices/all-in-one-bigchaindb.md +++ b/docs/server/source/appendices/all-in-one-bigchaindb.md @@ -1,3 +1,9 @@ + + # Run BigchainDB with all-in-one Docker For those who like using Docker and wish to experiment with BigchainDB in diff --git a/docs/server/source/appendices/aws-setup.md b/docs/server/source/appendices/aws-setup.md index 793f4d36..c130b392 100644 --- a/docs/server/source/appendices/aws-setup.md +++ b/docs/server/source/appendices/aws-setup.md @@ -1,33 +1,39 @@ -# Basic AWS Setup + + +# Basic AWS Setup Before you can deploy anything on AWS, you must do a few things. - ## Get an AWS Account If you don't already have an AWS account, you can [sign up for one for free at aws.amazon.com](https://aws.amazon.com/). - ## Install the AWS Command-Line Interface To install the AWS Command-Line Interface (CLI), just do: + ```text pip install awscli ``` - ## Create an AWS Access Key The next thing you'll need is AWS access keys (access key ID and secret access key). If you don't have those, see [the AWS documentation about access keys](https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys). -You should also pick a default AWS region name (e.g. `eu-central-1`). That's where your cluster will run. The AWS documentation has [a list of them](http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region). +You should also pick a default AWS region name (e.g. `eu-central-1`). The AWS documentation has [a list of them](http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region). Once you've got your AWS access key, and you've picked a default AWS region name, go to a terminal session and enter: + ```text aws configure ``` and answer the four questions. For example: + ```text AWS Access Key ID [None]: AKIAIOSFODNN7EXAMPLE AWS Secret Access Key [None]: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY @@ -37,17 +43,16 @@ Default output format [None]: [Press Enter] This writes two files: `~/.aws/credentials` and `~/.aws/config`. AWS tools and packages look for those files. - ## Generate an RSA Key Pair for SSH Eventually, you'll have one or more instances (virtual machines) running on AWS and you'll want to SSH to them. To do that, you need a public/private key pair. The public key will be sent to AWS, and you can tell AWS to put it in any instances you provision there. You'll keep the private key on your local workstation. See the [page about how to generate a key pair for SSH](generate-key-pair-for-ssh.html). - ## Send the Public Key to AWS To send the public key to AWS, use the AWS Command-Line Interface: + ```text aws ec2 import-key-pair \ --key-name "" \ diff --git a/docs/server/source/appendices/backend.rst b/docs/server/source/appendices/backend.rst index d0840515..42da43da 100644 --- a/docs/server/source/appendices/backend.rst +++ b/docs/server/source/appendices/backend.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + ########################### Database Backend Interfaces ########################### diff --git a/docs/server/source/appendices/commands.rst b/docs/server/source/appendices/commands.rst index 460145f4..116e0709 100644 --- a/docs/server/source/appendices/commands.rst +++ b/docs/server/source/appendices/commands.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + ###################### Command Line Interface ###################### diff --git a/docs/server/source/appendices/cryptography.rst b/docs/server/source/appendices/cryptography.rst index c44f3a91..154c7fac 100644 --- a/docs/server/source/appendices/cryptography.rst +++ b/docs/server/source/appendices/cryptography.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Cryptography ============ diff --git a/docs/server/source/appendices/firewall-notes.md b/docs/server/source/appendices/firewall-notes.md index a84b3105..20e1418a 100644 --- a/docs/server/source/appendices/firewall-notes.md +++ b/docs/server/source/appendices/firewall-notes.md @@ -1,3 +1,9 @@ + + # Notes for Firewall Setup This is a page of notes on the ports potentially used by BigchainDB nodes and the traffic they should expect, to help with firewall setup (or security group setup on cloud providers). This page is _not_ a firewall tutorial or step-by-step guide. diff --git a/docs/server/source/appendices/generate-key-pair-for-ssh.md b/docs/server/source/appendices/generate-key-pair-for-ssh.md index 18b19392..c61204c5 100644 --- a/docs/server/source/appendices/generate-key-pair-for-ssh.md +++ b/docs/server/source/appendices/generate-key-pair-for-ssh.md @@ -1,3 +1,9 @@ + + # Generate a Key Pair for SSH This page describes how to use `ssh-keygen` diff --git a/docs/server/source/appendices/index.rst b/docs/server/source/appendices/index.rst index 18e12ba2..ea02aed6 100755 --- a/docs/server/source/appendices/index.rst +++ b/docs/server/source/appendices/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Appendices ========== diff --git a/docs/server/source/appendices/json-serialization.rst b/docs/server/source/appendices/json-serialization.rst index 027c3c4b..72e8213b 100644 --- a/docs/server/source/appendices/json-serialization.rst +++ b/docs/server/source/appendices/json-serialization.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + JSON Serialization ================== diff --git a/docs/server/source/appendices/licenses.md b/docs/server/source/appendices/licenses.md index 89334e69..02df473b 100644 --- a/docs/server/source/appendices/licenses.md +++ b/docs/server/source/appendices/licenses.md @@ -1,3 +1,9 @@ + + # Licenses Information about how the BigchainDB Server code and documentation are licensed can be found in [the LICENSES.md file](https://github.com/bigchaindb/bigchaindb/blob/master/LICENSES.md) of the bigchaindb/bigchaindb repository on GitHub. diff --git a/docs/server/source/appendices/ntp-notes.md b/docs/server/source/appendices/ntp-notes.md index c1a2b261..d29ef505 100644 --- a/docs/server/source/appendices/ntp-notes.md +++ b/docs/server/source/appendices/ntp-notes.md @@ -1,3 +1,9 @@ + + # Notes on NTP Daemon Setup There are several NTP daemons available, including: diff --git a/docs/server/source/appendices/the-bigchaindb-class.rst b/docs/server/source/appendices/the-bigchaindb-class.rst index 8d604d2c..405fb61e 100644 --- a/docs/server/source/appendices/the-bigchaindb-class.rst +++ b/docs/server/source/appendices/the-bigchaindb-class.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + #################### The BigchainDB Class #################### diff --git a/docs/server/source/conf.py b/docs/server/source/conf.py index e986cecc..459877aa 100644 --- a/docs/server/source/conf.py +++ b/docs/server/source/conf.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# +# Copyright BigchainDB GmbH and BigchainDB 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 Server documentation build configuration file, created by # sphinx-quickstart on Tue Jan 19 14:42:58 2016. # diff --git a/docs/server/source/data-models/asset-model.rst b/docs/server/source/data-models/asset-model.rst index edca7cca..0e2409b0 100644 --- a/docs/server/source/data-models/asset-model.rst +++ b/docs/server/source/data-models/asset-model.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + The Asset Model =============== diff --git a/docs/server/source/data-models/block-model.rst b/docs/server/source/data-models/block-model.rst index 21c8ab5f..9622ca98 100644 --- a/docs/server/source/data-models/block-model.rst +++ b/docs/server/source/data-models/block-model.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _the-block-model: The Block Model diff --git a/docs/server/source/data-models/conditions.rst b/docs/server/source/data-models/conditions.rst index 54198a12..b551ad01 100644 --- a/docs/server/source/data-models/conditions.rst +++ b/docs/server/source/data-models/conditions.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Conditions ========== diff --git a/docs/server/source/data-models/index.rst b/docs/server/source/data-models/index.rst index 94eb584e..ed7a45f3 100644 --- a/docs/server/source/data-models/index.rst +++ b/docs/server/source/data-models/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Data Models =========== diff --git a/docs/server/source/data-models/inputs-outputs.rst b/docs/server/source/data-models/inputs-outputs.rst index d0f0df37..ff1ec159 100644 --- a/docs/server/source/data-models/inputs-outputs.rst +++ b/docs/server/source/data-models/inputs-outputs.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Inputs and Outputs ================== diff --git a/docs/server/source/data-models/transaction-model.rst b/docs/server/source/data-models/transaction-model.rst index e211f319..53da711d 100644 --- a/docs/server/source/data-models/transaction-model.rst +++ b/docs/server/source/data-models/transaction-model.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _the-transaction-model: The Transaction Model diff --git a/docs/server/source/dev-and-test/index.rst b/docs/server/source/dev-and-test/index.rst index dc3bbcd3..5e165b9c 100644 --- a/docs/server/source/dev-and-test/index.rst +++ b/docs/server/source/dev-and-test/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Develop & Test BigchainDB Server ================================ diff --git a/docs/server/source/drivers-clients/index.rst b/docs/server/source/drivers-clients/index.rst index 79954971..7fb59e22 100644 --- a/docs/server/source/drivers-clients/index.rst +++ b/docs/server/source/drivers-clients/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Drivers & Tools =============== diff --git a/docs/server/source/events/index.rst b/docs/server/source/events/index.rst index d554e88f..969980b8 100644 --- a/docs/server/source/events/index.rst +++ b/docs/server/source/events/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + The Events API ============== diff --git a/docs/server/source/events/websocket-event-stream-api.rst b/docs/server/source/events/websocket-event-stream-api.rst index f9778148..526df494 100644 --- a/docs/server/source/events/websocket-event-stream-api.rst +++ b/docs/server/source/events/websocket-event-stream-api.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _the-websocket-event-stream-api: The WebSocket Event Stream API diff --git a/docs/server/source/http-client-server-api.rst b/docs/server/source/http-client-server-api.rst index fd5c121d..2026b6db 100644 --- a/docs/server/source/http-client-server-api.rst +++ b/docs/server/source/http-client-server-api.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _the-http-client-server-api: The HTTP Client-Server API @@ -46,6 +51,15 @@ that allows you to discover the BigchainDB API endpoints: Transactions ------------ +.. note:: + + If you want to do more sophisticated queries + than those provided by the BigchainDB HTTP API, + then one option is to connect to MongoDB directly (if possible) + and do whatever queries MongoDB allows. + For more about that option, see + `the page about querying BigchainDB `_. + .. http:get:: /api/v1/transactions/{transaction_id} Get the transaction with the ID ``transaction_id``. @@ -179,6 +193,14 @@ The ``/api/v1/outputs`` endpoint returns transactions outputs filtered by a given public key, and optionally filtered to only include either spent or unspent outputs. +.. note:: + + If you want to do more sophisticated queries + than those provided by the BigchainDB HTTP API, + then one option is to connect to MongoDB directly (if possible) + and do whatever queries MongoDB allows. + For more about that option, see + `the page about querying BigchainDB `_. .. http:get:: /api/v1/outputs @@ -289,6 +311,15 @@ unspent outputs. Assets ------ +.. note:: + + If you want to do more sophisticated queries + than those provided by the BigchainDB HTTP API, + then one option is to connect to MongoDB directly (if possible) + and do whatever queries MongoDB allows. + For more about that option, see + `the page about querying BigchainDB `_. + .. http:get:: /api/v1/assets Return all the assets that match a given text search. @@ -297,10 +328,6 @@ Assets :query int limit: (Optional) Limit the number of returned assets. Defaults to ``0`` meaning return all matching assets. - .. note:: - - Currently this endpoint is only supported if using MongoDB. - .. http:get:: /api/v1/assets/?search={search} Return all assets that match a given text search. @@ -408,6 +435,15 @@ Assets Transaction Metadata -------------------- +.. note:: + + If you want to do more sophisticated queries + than those provided by the BigchainDB HTTP API, + then one option is to connect to MongoDB directly (if possible) + and do whatever queries MongoDB allows. + For more about that option, see + `the page about querying BigchainDB `_. + .. http:get:: /api/v1/metadata Return all the metadata objects that match a given text search. @@ -416,10 +452,6 @@ Transaction Metadata :query int limit: (Optional) Limit the number of returned metadata objects. Defaults to ``0`` meaning return all matching objects. - .. note:: - - Currently this endpoint is only supported if using MongoDB. - .. http:get:: /api/v1/metadata/?search={search} Return all metadata objects that match a given text search. diff --git a/docs/server/source/index.rst b/docs/server/source/index.rst index f8a4cb96..e21fdaad 100644 --- a/docs/server/source/index.rst +++ b/docs/server/source/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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 Server Documentation =============================== @@ -7,9 +12,9 @@ BigchainDB Server Documentation ← Back to All BigchainDB Docs introduction quickstart - simple-network-setup + network-operations/index production-nodes/index - clusters + networks dev-and-test/index server-reference/index http-client-server-api diff --git a/docs/server/source/introduction.md b/docs/server/source/introduction.md index 24905040..bd15d61e 100644 --- a/docs/server/source/introduction.md +++ b/docs/server/source/introduction.md @@ -1,3 +1,9 @@ + + # Introduction This is the documentation for BigchainDB Server, the BigchainDB software that one runs on servers (but not on clients). @@ -8,17 +14,15 @@ Note that there are a few kinds of nodes: - A **dev/test node** is a node created by a developer working on BigchainDB Server, e.g. for testing new or changed code. A dev/test node is typically run on the developer's local machine. -- A **bare-bones node** is a node deployed in the cloud, either as part of a testing cluster or as a starting point before upgrading the node to be production-ready. - -- A **production node** is a node that is part of a consortium's BigchainDB cluster. A production node has the most components and requirements. +- A **bare-bones node** is a node deployed in the cloud, either as part of a testing network or as a starting point before upgrading the node to be production-ready. +- A **production node** is a node that is part of a consortium's BigchainDB network. A production node has the most components and requirements. ## Setup Instructions for Various Cases -* [Quickstart](quickstart.html) -* [Set up a local BigchainDB node for development, experimenting and testing](https://docs.bigchaindb.com/projects/contributing/en/latest/dev-setup-coding-and-contribution-process/index.html) -* [Set up and run a BigchainDB cluster](clusters.html) - +- [Quickstart](quickstart.html) +- [Set up a local BigchainDB node for development, experimenting and testing](https://docs.bigchaindb.com/projects/contributing/en/latest/dev-setup-coding-and-contribution-process/index.html) +- [Set up and run a BigchainDB network](network-operations/index.html) ## Can I Help? diff --git a/docs/server/source/k8s-deployment-template/architecture.rst b/docs/server/source/k8s-deployment-template/architecture.rst index 2bfc9e4c..62079bc3 100644 --- a/docs/server/source/k8s-deployment-template/architecture.rst +++ b/docs/server/source/k8s-deployment-template/architecture.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Architecture of a BigchainDB Node Running in a Kubernetes Cluster ================================================================= diff --git a/docs/server/source/k8s-deployment-template/bigchaindb-network-on-kubernetes.rst b/docs/server/source/k8s-deployment-template/bigchaindb-network-on-kubernetes.rst index d3caf6a3..0af0649e 100644 --- a/docs/server/source/k8s-deployment-template/bigchaindb-network-on-kubernetes.rst +++ b/docs/server/source/k8s-deployment-template/bigchaindb-network-on-kubernetes.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _kubernetes-template-deploy-bigchaindb-network: Kubernetes Template: Deploying a BigchainDB network diff --git a/docs/server/source/k8s-deployment-template/ca-installation.rst b/docs/server/source/k8s-deployment-template/ca-installation.rst index 799e6bc8..e9622e9d 100644 --- a/docs/server/source/k8s-deployment-template/ca-installation.rst +++ b/docs/server/source/k8s-deployment-template/ca-installation.rst @@ -1,11 +1,16 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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-set-up-a-self-signed-certificate-authority: How to Set Up a Self-Signed Certificate Authority ================================================= This page enumerates the steps *we* use to set up a self-signed certificate authority (CA). -This is something that only needs to be done once per cluster, -by the organization managing the cluster, i.e. the CA is for the whole cluster. +This is something that only needs to be done once per BigchainDB network, +by the organization managing the network, i.e. the CA is for the whole network. We use Easy-RSA. diff --git a/docs/server/source/k8s-deployment-template/client-tls-certificate.rst b/docs/server/source/k8s-deployment-template/client-tls-certificate.rst index 0f773eaa..5826dc4e 100644 --- a/docs/server/source/k8s-deployment-template/client-tls-certificate.rst +++ b/docs/server/source/k8s-deployment-template/client-tls-certificate.rst @@ -1,10 +1,15 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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-generate-a-client-certificate-for-mongodb: How to Generate a Client Certificate for MongoDB ================================================ This page enumerates the steps *we* use to generate a client certificate to be -used by clients who want to connect to a TLS-secured MongoDB cluster. +used by clients who want to connect to a TLS-secured MongoDB database. We use Easy-RSA. @@ -37,7 +42,7 @@ and using: You should change the Common Name (e.g. ``bdb-instance-0``) to a value that reflects what the -client certificate is being used for, e.g. ``mdb-mon-instance-3`` or ``mdb-bak-instance-4``. (The final integer is specific to your BigchainDB node in the BigchainDB cluster.) +client certificate is being used for, e.g. ``mdb-mon-instance-3`` or ``mdb-bak-instance-4``. (The final integer is specific to your BigchainDB node in the BigchainDB network.) You will be prompted to enter the Distinguished Name (DN) information for this certificate. For each field, you can accept the default value [in brackets] by pressing Enter. @@ -61,7 +66,7 @@ Step 3: Get the Client Certificate Signed The CSR file created in the previous step should be located in ``pki/reqs/bdb-instance-0.req`` (or whatever Common Name you used in the ``gen-req`` command above). -You need to send it to the organization managing the cluster +You need to send it to the organization managing the BigchainDB network so that they can use their CA to sign the request. (The managing organization should already have a self-signed CA.) diff --git a/docs/server/source/k8s-deployment-template/cloud-manager.rst b/docs/server/source/k8s-deployment-template/cloud-manager.rst index 458a8eeb..38083e55 100644 --- a/docs/server/source/k8s-deployment-template/cloud-manager.rst +++ b/docs/server/source/k8s-deployment-template/cloud-manager.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _configure-mongodb-cloud-manager-for-monitoring: Configure MongoDB Cloud Manager for Monitoring diff --git a/docs/server/source/k8s-deployment-template/easy-rsa.rst b/docs/server/source/k8s-deployment-template/easy-rsa.rst index f0f609b2..f2f1554d 100644 --- a/docs/server/source/k8s-deployment-template/easy-rsa.rst +++ b/docs/server/source/k8s-deployment-template/easy-rsa.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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-install-and-configure-easyrsa: How to Install & Configure Easy-RSA diff --git a/docs/server/source/k8s-deployment-template/index.rst b/docs/server/source/k8s-deployment-template/index.rst index 44a3fc07..abc1de07 100644 --- a/docs/server/source/k8s-deployment-template/index.rst +++ b/docs/server/source/k8s-deployment-template/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Kubernetes Deployment Template ============================== @@ -12,7 +17,7 @@ Kubernetes Deployment Template and your organization has people who know Kubernetes, then this Kubernetes deployment template might be helpful. -This section outlines a way to deploy a BigchainDB node (or BigchainDB cluster) +This section outlines a way to deploy a BigchainDB node (or BigchainDB network) on Microsoft Azure using Kubernetes. You may choose to use it as a template or reference for your own deployment, but *we make no claim that it is suitable for your purposes*. diff --git a/docs/server/source/k8s-deployment-template/log-analytics.rst b/docs/server/source/k8s-deployment-template/log-analytics.rst index 04dda1a8..2c7c3271 100644 --- a/docs/server/source/k8s-deployment-template/log-analytics.rst +++ b/docs/server/source/k8s-deployment-template/log-analytics.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Log Analytics on Azure ====================== @@ -165,7 +170,7 @@ Until we figure out a way to obtain the *workspace key* via the command line, you can get it via the OMS Portal. To get to the OMS Portal, go to the Azure Portal and click on: -Resource Groups > (Your k8s cluster's resource group) > Log analytics (OMS) > (Name of the only item listed) > OMS Workspace > OMS Portal +Resource Groups > (Your Kubernetes cluster's resource group) > Log analytics (OMS) > (Name of the only item listed) > OMS Workspace > OMS Portal (Let us know if you find a faster way.) Then see `Microsoft's instructions to obtain your workspace ID and key diff --git a/docs/server/source/k8s-deployment-template/node-config-map-and-secrets.rst b/docs/server/source/k8s-deployment-template/node-config-map-and-secrets.rst index d308bc11..cbd18008 100644 --- a/docs/server/source/k8s-deployment-template/node-config-map-and-secrets.rst +++ b/docs/server/source/k8s-deployment-template/node-config-map-and-secrets.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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-configure-a-bigchaindb-node: How to Configure a BigchainDB Node @@ -69,7 +74,7 @@ This user is created on the *admin* database with the authorization to create ot vars.BDB_PERSISTENT_PEERS, BDB_VALIDATORS, BDB_VALIDATORS_POWERS, BDB_GENESIS_TIME and BDB_CHAIN_ID ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -These parameters are shared across the cluster. More information about the generation +These parameters are shared across the BigchainDB network. More information about the generation of these parameters can be found at :ref:`generate-the-blockchain-id-and-genesis-time`. @@ -77,7 +82,7 @@ vars.NODE_DNS_SERVER ^^^^^^^^^^^^^^^^^^^^ IP of Kubernetes service(kube-dns), can be retrieved using using CLI(kubectl) or k8s dashboard. This parameter is used by the Nginx gateway instance -to resolve the hostnames of all the services running in the k8s cluster. +to resolve the hostnames of all the services running in the Kubernetes cluster. .. code:: diff --git a/docs/server/source/k8s-deployment-template/node-on-kubernetes.rst b/docs/server/source/k8s-deployment-template/node-on-kubernetes.rst index e9032ec4..c2735563 100644 --- a/docs/server/source/k8s-deployment-template/node-on-kubernetes.rst +++ b/docs/server/source/k8s-deployment-template/node-on-kubernetes.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _kubernetes-template-deploy-a-single-bigchaindb-node: Kubernetes Template: Deploy a Single BigchainDB Node diff --git a/docs/server/source/k8s-deployment-template/revoke-tls-certificate.rst b/docs/server/source/k8s-deployment-template/revoke-tls-certificate.rst index 240525d6..560b39f9 100644 --- a/docs/server/source/k8s-deployment-template/revoke-tls-certificate.rst +++ b/docs/server/source/k8s-deployment-template/revoke-tls-certificate.rst @@ -1,10 +1,15 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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 Revoke an SSL/TLS Certificate ==================================== This page enumerates the steps *we* take to revoke a self-signed SSL/TLS -certificate in a cluster. +certificate in a BigchainDB network. It can only be done by someone with access to the self-signed CA -associated with the cluster's managing organization. +associated with the network's managing organization. Step 1: Revoke a Certificate ---------------------------- @@ -40,4 +45,4 @@ Generate a new CRL for your infrastructure using: The generated ``crl.pem`` file needs to be uploaded to your infrastructure to prevent the revoked certificate from being used again. -In particlar, the generated ``crl.pem`` file should be sent to all BigchainDB node operators in your BigchainDB cluster, so that they can update it in their MongoDB instance and their BigchainDB Server instance. +In particlar, the generated ``crl.pem`` file should be sent to all BigchainDB node operators in your BigchainDB network, so that they can update it in their MongoDB instance and their BigchainDB Server instance. diff --git a/docs/server/source/k8s-deployment-template/server-tls-certificate.rst b/docs/server/source/k8s-deployment-template/server-tls-certificate.rst index 622aeecc..bab23ed7 100644 --- a/docs/server/source/k8s-deployment-template/server-tls-certificate.rst +++ b/docs/server/source/k8s-deployment-template/server-tls-certificate.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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-generate-a-server-certificate-for-mongodb: How to Generate a Server Certificate for MongoDB @@ -42,7 +47,7 @@ and using something like: ./easyrsa --req-cn=mdb-instance-0 --subject-alt-name=DNS:localhost,DNS:mdb-instance-0 gen-req mdb-instance-0 nopass -You should replace the Common Name (``mdb-instance-0`` above) with the correct name for *your* MongoDB instance in the cluster, e.g. ``mdb-instance-5`` or ``mdb-instance-12``. (This name is decided by the organization managing the cluster.) +You should replace the Common Name (``mdb-instance-0`` above) with the correct name for *your* MongoDB instance in the network, e.g. ``mdb-instance-5`` or ``mdb-instance-12``. (This name is decided by the organization managing the network.) You will be prompted to enter the Distinguished Name (DN) information for this certificate. For each field, you can accept the default value [in brackets] by pressing Enter. @@ -63,7 +68,7 @@ Step 3: Get the Server Certificate Signed The CSR file created in the last step should be located in ``pki/reqs/mdb-instance-0.req`` (where the integer ``0`` may be different for you). -You need to send it to the organization managing the cluster +You need to send it to the organization managing the BigchainDB network so that they can use their CA to sign the request. (The managing organization should already have a self-signed CA.) diff --git a/docs/server/source/k8s-deployment-template/tectonic-azure.rst b/docs/server/source/k8s-deployment-template/tectonic-azure.rst index 03cfb433..01b571c8 100644 --- a/docs/server/source/k8s-deployment-template/tectonic-azure.rst +++ b/docs/server/source/k8s-deployment-template/tectonic-azure.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Walkthrough: Deploy a Kubernetes Cluster on Azure using Tectonic by CoreOS ========================================================================== diff --git a/docs/server/source/k8s-deployment-template/template-kubernetes-azure.rst b/docs/server/source/k8s-deployment-template/template-kubernetes-azure.rst index 9ff10cac..410797a1 100644 --- a/docs/server/source/k8s-deployment-template/template-kubernetes-azure.rst +++ b/docs/server/source/k8s-deployment-template/template-kubernetes-azure.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Template: Deploy a Kubernetes Cluster on Azure ============================================== diff --git a/docs/server/source/k8s-deployment-template/troubleshoot.rst b/docs/server/source/k8s-deployment-template/troubleshoot.rst index 785927dd..41933f1a 100644 --- a/docs/server/source/k8s-deployment-template/troubleshoot.rst +++ b/docs/server/source/k8s-deployment-template/troubleshoot.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _cluster-troubleshooting: Cluster Troubleshooting diff --git a/docs/server/source/k8s-deployment-template/upgrade-on-kubernetes.rst b/docs/server/source/k8s-deployment-template/upgrade-on-kubernetes.rst index 8d836564..870642ae 100644 --- a/docs/server/source/k8s-deployment-template/upgrade-on-kubernetes.rst +++ b/docs/server/source/k8s-deployment-template/upgrade-on-kubernetes.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Kubernetes Template: Upgrade all Software in a BigchainDB Node ============================================================== diff --git a/docs/server/source/k8s-deployment-template/workflow.rst b/docs/server/source/k8s-deployment-template/workflow.rst index 668f1a3c..028d539f 100644 --- a/docs/server/source/k8s-deployment-template/workflow.rst +++ b/docs/server/source/k8s-deployment-template/workflow.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + .. _kubernetes-template-overview: Overview @@ -15,7 +20,7 @@ Overview then this Kubernetes deployment template might be helpful. This page summarizes some steps to go through -to set up a BigchainDB cluster. +to set up a BigchainDB network. You can modify them to suit your needs. .. _generate-the-blockchain-id-and-genesis-time: @@ -25,7 +30,7 @@ Generate All Shared BigchainDB Setup Parameters There are some shared BigchainDB setup paramters that every node operator in the consortium shares -because they are properties of the Tendermint cluster. +because they are properties of the Tendermint network. They look like this: .. code:: @@ -41,7 +46,7 @@ Those paramters only have to be generated once, by one member of the consortium. That person will then share the results (Tendermint setup parameters) with all the node operators. -The above example parameters are for a cluster of 4 initial (seed) nodes. +The above example parameters are for a network of 4 initial (seed) nodes. Note how ``BDB_PERSISTENT_PEERS``, ``BDB_VALIDATORS`` and ``BDB_VALIDATOR_POWERS`` are lists with 4 items each. **If your consortium has a different number of initial nodes, @@ -114,7 +119,7 @@ to all POST requests with a secret token in the HTTP headers. You can make up that ``SECRET_TOKEN`` now. For example, ``superSECRET_token4-POST*requests``. You will put it in the ``vars`` file later. -Every BigchainDB node in a cluster can have a different secret token. +Every BigchainDB node in a BigchainDB network can have a different secret token. To make an HTTP POST request to your BigchainDB node, you must include an HTTP header named ``X-Secret-Access-Token`` and set it equal to your secret token, e.g. @@ -131,7 +136,7 @@ and set it equal to your secret token, e.g. between different Kubernetes clusters, especially if they are running different versions of Kubernetes. We tested this Kubernetes Deployment Template on Azure ACS in February 2018 and at that time ACS was deploying a **Kubernetes 1.7.7** cluster. If you can force your cluster to have that version of Kubernetes, - then you'll increase the likelihood that everything will work in your cluster. + then you'll increase the likelihood that everything will work. 4. Deploy your BigchainDB node inside your new Kubernetes cluster. You will fill up the ``vars`` file, diff --git a/docs/server/source/network-operations/index.rst b/docs/server/source/network-operations/index.rst new file mode 100644 index 00000000..938bbff4 --- /dev/null +++ b/docs/server/source/network-operations/index.rst @@ -0,0 +1,12 @@ + +.. Copyright BigchainDB GmbH and BigchainDB 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 Set Up and Run a BigchainDB Network +========================================== + +.. toctree:: + :maxdepth: 1 + + network-setup diff --git a/docs/server/source/simple-network-setup.md b/docs/server/source/network-operations/network-setup.md similarity index 99% rename from docs/server/source/simple-network-setup.md rename to docs/server/source/network-operations/network-setup.md index a1f07172..f42ca9ef 100644 --- a/docs/server/source/simple-network-setup.md +++ b/docs/server/source/network-operations/network-setup.md @@ -1,3 +1,9 @@ + + # How to Set Up a BigchainDB Network Note 1: These instructions will also work for a "network" with only one node. diff --git a/docs/server/source/clusters.md b/docs/server/source/networks.md similarity index 69% rename from docs/server/source/clusters.md rename to docs/server/source/networks.md index 23cbf1f3..22e4f9b0 100644 --- a/docs/server/source/clusters.md +++ b/docs/server/source/networks.md @@ -1,6 +1,12 @@ -# Clusters + -A **BigchainDB Cluster** is a set of connected **BigchainDB Nodes**, managed by a **BigchainDB Consortium** (i.e. an organization). Those terms are defined in the [BigchainDB Terminology page](https://docs.bigchaindb.com/en/latest/terminology.html). +# BigchainDB Networks + +A **BigchainDB network** is a set of connected **BigchainDB nodes**, managed by a **BigchainDB consortium** (i.e. an organization). Those terms are defined in the [BigchainDB Terminology page](https://docs.bigchaindb.com/en/latest/terminology.html). ## Consortium Structure & Governance @@ -9,18 +15,18 @@ It must make many decisions, e.g. How will new members be added? Who can read th A governance process is required to make those decisions, and therefore one of the first steps for any new consortium is to specify its governance process (if one doesn't already exist). This documentation doesn't explain how to create a consortium, nor does it outline the possible governance processes. -It's worth noting that the decentralization of a BigchainDB cluster depends, +It's worth noting that the decentralization of a BigchainDB network depends, to some extent, on the decentralization of the associated consortium. See the pages about [decentralization](https://docs.bigchaindb.com/en/latest/decentralized.html) and [node diversity](https://docs.bigchaindb.com/en/latest/diversity.html). -## Cluster DNS Records and SSL Certificates +## DNS Records and SSL Certificates -We now describe how *we* set up the external (public-facing) DNS records for a BigchainDB cluster. Your consortium may opt to do it differently. +We now describe how *we* set up the external (public-facing) DNS records for a BigchainDB network. Your consortium may opt to do it differently. There were several goals: -* Allow external users/clients to connect directly to any BigchainDB node in the cluster (over the internet), if they want. +* Allow external users/clients to connect directly to any BigchainDB node in the network (over the internet), if they want. * Each BigchainDB node operator should get an SSL certificate for their BigchainDB node, so that their BigchainDB node can serve the [BigchainDB HTTP API](http-client-server-api.html) via HTTPS. (The same certificate might also be used to serve the [WebSocket API](websocket-event-stream-api.html).) * There should be no sharing of SSL certificates among BigchainDB node operators. -* Optional: Allow clients to connect to a "random" BigchainDB node in the cluster at one particular domain (or subdomain). +* Optional: Allow clients to connect to a "random" BigchainDB node in the network at one particular domain (or subdomain). ### Node Operator Responsibilities @@ -30,8 +36,8 @@ There were several goals: ### Consortium Responsibilities -Optional: The consortium managing the BigchainDB cluster could register a domain name and set up CNAME records mapping that domain name (or one of its subdomains) to each of the nodes in the cluster. For example, if the consortium registered `bdbcluster.io`, they could set up CNAME records like the following: +Optional: The consortium managing the BigchainDB network could register a domain name and set up CNAME records mapping that domain name (or one of its subdomains) to each of the nodes in the network. For example, if the consortium registered `bdbnetwork.io`, they could set up CNAME records like the following: -* CNAME record mapping `api.bdbcluster.io` to `abc-org73.net` -* CNAME record mapping `api.bdbcluster.io` to `api.dynabob8.io` -* CNAME record mapping `api.bdbcluster.io` to `figmentdb3.ninja` +* CNAME record mapping `api.bdbnetwork.io` to `abc-org73.net` +* CNAME record mapping `api.bdbnetwork.io` to `api.dynabob8.io` +* CNAME record mapping `api.bdbnetwork.io` to `figmentdb3.ninja` diff --git a/docs/server/source/production-nodes/index.rst b/docs/server/source/production-nodes/index.rst index 6ada923e..9d53c08c 100644 --- a/docs/server/source/production-nodes/index.rst +++ b/docs/server/source/production-nodes/index.rst @@ -1,3 +1,8 @@ + +.. Copyright BigchainDB GmbH and BigchainDB contributors + SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0) + Code is Apache-2.0 and docs are CC-BY-4.0 + Production Nodes ================ diff --git a/docs/server/source/production-nodes/node-assumptions.md b/docs/server/source/production-nodes/node-assumptions.md index d8d74f0e..962859bd 100644 --- a/docs/server/source/production-nodes/node-assumptions.md +++ b/docs/server/source/production-nodes/node-assumptions.md @@ -1,12 +1,17 @@ + + # Production Node Assumptions Be sure you know the key BigchainDB terminology: -* [BigchainDB node, BigchainDB cluster and BigchainDB consortium](https://docs.bigchaindb.com/en/latest/terminology.html) +* [BigchainDB node, BigchainDB network and BigchainDB consortium](https://docs.bigchaindb.com/en/latest/terminology.html) * [dev/test node, bare-bones node and production node](../introduction.html) We make some assumptions about production nodes: -1. Production nodes use MongoDB (not RethinkDB, PostgreSQL, Couchbase or whatever). 1. Each production node is set up and managed by an experienced professional system administrator or a team of them. -1. Each production node in a cluster is managed by a different person or team. +1. Each production node in a network is managed by a different person or team. diff --git a/docs/server/source/production-nodes/node-components.md b/docs/server/source/production-nodes/node-components.md index ae286b9b..267c0e88 100644 --- a/docs/server/source/production-nodes/node-components.md +++ b/docs/server/source/production-nodes/node-components.md @@ -1,3 +1,9 @@ + + # Production Node Components A production BigchainDB node must include: @@ -11,7 +17,7 @@ It could also include several other components, including: * NGINX or similar, to provide authentication, rate limiting, etc. * An NTP daemon running on all machines running BigchainDB Server or mongod, and possibly other machines -* **Not** MongoDB Automation Agent. It's for automating the deployment of an entire MongoDB cluster, not just one MongoDB node within a cluster. +* Probably _not_ MongoDB Automation Agent. It's for automating the deployment of an entire MongoDB cluster. * MongoDB Monitoring Agent * MongoDB Backup Agent * Log aggregation software diff --git a/docs/server/source/production-nodes/node-requirements.md b/docs/server/source/production-nodes/node-requirements.md index 7a19329b..a9daaaf9 100644 --- a/docs/server/source/production-nodes/node-requirements.md +++ b/docs/server/source/production-nodes/node-requirements.md @@ -1,3 +1,9 @@ + + # Production Node Requirements **This page is about the requirements of BigchainDB Server.** You can find the requirements of MongoDB, Tendermint and other [production node components](node-components.html) in the documentation for that software. diff --git a/docs/server/source/production-nodes/node-security-and-privacy.md b/docs/server/source/production-nodes/node-security-and-privacy.md index 3b26ddbb..188697dc 100644 --- a/docs/server/source/production-nodes/node-security-and-privacy.md +++ b/docs/server/source/production-nodes/node-security-and-privacy.md @@ -1,3 +1,9 @@ + + # Production Node Security & Privacy Here are some references about how to secure an Ubuntu 18.04 server: diff --git a/docs/server/source/production-nodes/reverse-proxy-notes.md b/docs/server/source/production-nodes/reverse-proxy-notes.md index 991c9d42..5f4d22a6 100644 --- a/docs/server/source/production-nodes/reverse-proxy-notes.md +++ b/docs/server/source/production-nodes/reverse-proxy-notes.md @@ -1,3 +1,9 @@ + + # Using a Reverse Proxy You may want to: diff --git a/docs/server/source/quickstart.md b/docs/server/source/quickstart.md index 93eed4d1..92193e64 100644 --- a/docs/server/source/quickstart.md +++ b/docs/server/source/quickstart.md @@ -1,3 +1,9 @@ + + # Quickstart