mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Merge branch 'master' into activating-tests
This commit is contained in:
commit
d1f68b67a3
@ -1,4 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/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
|
set -e -x
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/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
|
set -e -x
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/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
|
if [[ -z ${TOXENV} ]]; then
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/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
|
set -e -x
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/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
|
set -e -x
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/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
|
set -e -x
|
||||||
|
|
||||||
|
|||||||
6
.github/CONTRIBUTING.md
vendored
6
.github/CONTRIBUTING.md
vendored
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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 Contribute to the BigchainDB Project
|
# 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.
|
There are many ways you can contribute to the BigchainDB project, some very easy and others more involved.
|
||||||
|
|||||||
@ -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:
|
repos:
|
||||||
- repo: git://github.com/pre-commit/pre-commit-hooks
|
- repo: git://github.com/pre-commit/pre-commit-hooks
|
||||||
sha: v1.1.1
|
sha: v1.1.1
|
||||||
|
|||||||
@ -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:
|
build:
|
||||||
image: latest
|
image: latest
|
||||||
|
|
||||||
|
|||||||
@ -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
|
sudo: required
|
||||||
|
|
||||||
dist: trusty
|
dist: trusty
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Change Log (Release Notes)
|
# Change Log (Release Notes)
|
||||||
|
|
||||||
All _notable_ changes to this project will be documented in this file (`CHANGELOG.md`).
|
All _notable_ changes to this project will be documented in this file (`CHANGELOG.md`).
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Contributor Code of Conduct
|
# Contributor Code of Conduct
|
||||||
|
|
||||||
As contributors and maintainers of this project, and in the interest of
|
As contributors and maintainers of this project, and in the interest of
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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 Handle External Pull Requests
|
# How to Handle External Pull Requests
|
||||||
|
|
||||||
See [BEP-16](https://github.com/bigchaindb/BEPs/tree/master/16).
|
See [BEP-16](https://github.com/bigchaindb/BEPs/tree/master/16).
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Python Style Guide
|
# 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.
|
This guide starts out with our general Python coding style guidelines and ends with a section on how we write & run (Python) tests.
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
<!--- There is no shield to get the latest version
|
<!--- There is no shield to get the latest version
|
||||||
(including pre-release versions) from PyPI,
|
(including pre-release versions) from PyPI,
|
||||||
so show the latest GitHub release instead.
|
so show the latest GitHub release instead.
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Our Release Process
|
# Our Release Process
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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 Roadmap
|
# BigchainDB Roadmap
|
||||||
|
|
||||||
We moved the BigchainDB Roadmap to the bigchaindb/org repository; see:
|
We moved the BigchainDB Roadmap to the bigchaindb/org repository; see:
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Acceptance test suite
|
# Acceptance test suite
|
||||||
This directory contains the acceptance test suite for BigchainDB.
|
This directory contains the acceptance test suite for BigchainDB.
|
||||||
|
|
||||||
|
|||||||
@ -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
|
# # Basic Acceptance Test
|
||||||
# Here we check that the primitives of the system behave as expected.
|
# Here we check that the primitives of the system behave as expected.
|
||||||
# As you will see, this script tests basic stuff like:
|
# 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.
|
# The two keypairs will be called—drum roll—Alice and Bob.
|
||||||
alice, bob = generate_keypair(), generate_keypair()
|
alice, bob = generate_keypair(), generate_keypair()
|
||||||
|
|
||||||
|
|
||||||
# ## Alice registers her bike in BigchainDB
|
# ## Alice registers her bike in BigchainDB
|
||||||
# Alice has a nice bike, and here she creates the "digital twin"
|
# Alice has a nice bike, and here she creates the "digital twin"
|
||||||
# of her bike.
|
# of her bike.
|
||||||
@ -57,7 +60,6 @@ def test_basic():
|
|||||||
# a variable with a short and easy name
|
# a variable with a short and easy name
|
||||||
bike_id = fulfilled_creation_tx['id']
|
bike_id = fulfilled_creation_tx['id']
|
||||||
|
|
||||||
|
|
||||||
# Now she is ready to send it to the BigchainDB Network.
|
# Now she is ready to send it to the BigchainDB Network.
|
||||||
sent_transfer_tx = bdb.transactions.send(fulfilled_creation_tx)
|
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 len(bdb.outputs.get(alice.public_key, spent=False)) == 1
|
||||||
assert bdb.outputs.get(alice.public_key)[0]['transaction_id'] == bike_id
|
assert bdb.outputs.get(alice.public_key)[0]['transaction_id'] == bike_id
|
||||||
|
|
||||||
|
|
||||||
# ## Alice transfers her bike to Bob
|
# ## Alice transfers her bike to Bob
|
||||||
# After registering her bike, Alice is ready to transfer it to Bob.
|
# After registering her bike, Alice is ready to transfer it to Bob.
|
||||||
# She needs to create a new `TRANSFER` transaction.
|
# She needs to create a new `TRANSFER` transaction.
|
||||||
|
|||||||
@ -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
|
# # Divisible assets integration testing
|
||||||
# This test checks if we can successfully divide assets.
|
# This test checks if we can successfully divide assets.
|
||||||
# The script tests various things like:
|
# The script tests various things like:
|
||||||
|
|||||||
@ -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
|
# # Double Spend testing
|
||||||
# This test challenge the system with double spends.
|
# This test challenge the system with double spends.
|
||||||
|
|
||||||
|
|||||||
@ -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
|
# # Multiple owners integration testing
|
||||||
# This test checks if we can successfully create and transfer a transaction
|
# This test checks if we can successfully create and transfer a transaction
|
||||||
# with multiple owners.
|
# with multiple owners.
|
||||||
|
|||||||
@ -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
|
# ## Testing potentially hazardous strings
|
||||||
# This test uses a library of `naughty` strings (code injections, weird unicode chars., etc.) as both keys and values.
|
# 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
|
# 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.
|
# env variables.
|
||||||
import os
|
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
|
import re
|
||||||
|
|
||||||
# We'll use a nice library of naughty strings...
|
# We'll use a nice library of naughty strings...
|
||||||
|
|||||||
@ -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
|
# # Stream Acceptance Test
|
||||||
# This test checks if the event stream works correctly. The basic idea of this
|
# 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
|
# test is to generate some random **valid** transaction, send them to a
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Overview
|
# Overview
|
||||||
|
|
||||||
A high-level description of the files and subdirectories of BigchainDB.
|
A high-level description of the files and subdirectories of BigchainDB.
|
||||||
|
|||||||
@ -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 copy
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Backend Interfaces
|
# Backend Interfaces
|
||||||
|
|
||||||
## Structure
|
## Structure
|
||||||
|
|||||||
@ -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.
|
"""Generic backend database interfaces expected by BigchainDB.
|
||||||
|
|
||||||
The interfaces in this module allow BigchainDB to be agnostic about its
|
The interfaces in this module allow BigchainDB to be agnostic about its
|
||||||
|
|||||||
@ -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 itertools import repeat
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
@ -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
|
from bigchaindb.exceptions import BigchainDBError
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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.
|
"""MongoDB backend implementation.
|
||||||
|
|
||||||
Contains a MongoDB-specific implementation of the
|
Contains a MongoDB-specific implementation of the
|
||||||
|
|||||||
@ -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 time
|
||||||
import logging
|
import logging
|
||||||
from ssl import CERT_REQUIRED
|
from ssl import CERT_REQUIRED
|
||||||
|
|||||||
@ -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"""
|
"""Query implementation for MongoDB"""
|
||||||
|
|
||||||
from pymongo import DESCENDING
|
from pymongo import DESCENDING
|
||||||
|
|
||||||
from bigchaindb import backend
|
from bigchaindb import backend
|
||||||
from bigchaindb.backend.exceptions import DuplicateKeyError
|
from bigchaindb.backend.exceptions import DuplicateKeyError
|
||||||
from bigchaindb.common.exceptions import MultipleValidatorOperationError
|
|
||||||
from bigchaindb.backend.utils import module_dispatch_registrar
|
from bigchaindb.backend.utils import module_dispatch_registrar
|
||||||
from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection
|
from bigchaindb.backend.localmongodb.connection import LocalMongoDBConnection
|
||||||
from bigchaindb.common.transaction import Transaction
|
from bigchaindb.common.transaction import Transaction
|
||||||
@ -101,7 +104,8 @@ def get_spent(conn, transaction_id, output):
|
|||||||
def get_latest_block(conn):
|
def get_latest_block(conn):
|
||||||
return conn.run(
|
return conn.run(
|
||||||
conn.collection('blocks')
|
conn.collection('blocks')
|
||||||
.find_one(sort=[('height', DESCENDING)]))
|
.find_one(projection={'_id': False},
|
||||||
|
sort=[('height', DESCENDING)]))
|
||||||
|
|
||||||
|
|
||||||
@register_query(LocalMongoDBConnection)
|
@register_query(LocalMongoDBConnection)
|
||||||
@ -268,13 +272,15 @@ def get_pre_commit_state(conn, commit_id):
|
|||||||
|
|
||||||
|
|
||||||
@register_query(LocalMongoDBConnection)
|
@register_query(LocalMongoDBConnection)
|
||||||
def store_validator_set(conn, validator_update):
|
def store_validator_set(conn, validators_update):
|
||||||
try:
|
height = validators_update['height']
|
||||||
return conn.run(
|
return conn.run(
|
||||||
conn.collection('validators')
|
conn.collection('validators').replace_one(
|
||||||
.insert_one(validator_update))
|
{'height': height},
|
||||||
except DuplicateKeyError:
|
validators_update,
|
||||||
raise MultipleValidatorOperationError('Validator update already exists')
|
upsert=True
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@register_query(LocalMongoDBConnection)
|
@register_query(LocalMongoDBConnection)
|
||||||
@ -291,3 +297,16 @@ def get_validator_set(conn, height=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
return list(cursor)[0]
|
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
|
||||||
|
|||||||
@ -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."""
|
"""Utils to initialize and drop the database."""
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -27,8 +31,7 @@ def create_database(conn, dbname):
|
|||||||
|
|
||||||
@register_schema(LocalMongoDBConnection)
|
@register_schema(LocalMongoDBConnection)
|
||||||
def create_tables(conn, dbname):
|
def create_tables(conn, dbname):
|
||||||
for table_name in ['transactions', 'utxos', 'assets', 'blocks', 'metadata',
|
for table_name in backend.schema.TABLES:
|
||||||
'validators', 'pre_commit']:
|
|
||||||
logger.info('Create `%s` table.', table_name)
|
logger.info('Create `%s` table.', table_name)
|
||||||
# create the table
|
# create the table
|
||||||
# TODO: read and write concerns can be declared here
|
# TODO: read and write concerns can be declared here
|
||||||
|
|||||||
@ -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."""
|
"""Query interfaces for backends."""
|
||||||
|
|
||||||
from functools import singledispatch
|
from functools import singledispatch
|
||||||
@ -354,3 +358,17 @@ def get_validator_set(conn, height):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
raise NotImplementedError
|
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
|
||||||
|
|||||||
@ -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:
|
"""Database creation and schema-providing interfaces for backends."""
|
||||||
TABLES (tuple): The three standard tables BigchainDB relies on:
|
|
||||||
|
|
||||||
* ``backlog`` for incoming transactions awaiting to be put into
|
|
||||||
a block.
|
|
||||||
* ``bigchain`` for blocks.
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
from functools import singledispatch
|
from functools import singledispatch
|
||||||
import logging
|
import logging
|
||||||
@ -19,7 +14,10 @@ from bigchaindb.common.utils import validate_all_values_for_key
|
|||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
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',
|
VALID_LANGUAGES = ('danish', 'dutch', 'english', 'finnish', 'french', 'german',
|
||||||
'hungarian', 'italian', 'norwegian', 'portuguese', 'romanian',
|
'hungarian', 'italian', 'norwegian', 'portuguese', 'romanian',
|
||||||
'russian', 'spanish', 'swedish', 'turkish', 'none',
|
'russian', 'spanish', 'swedish', 'turkish', 'none',
|
||||||
|
|||||||
@ -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):
|
class ModuleDispatchRegistrationError(Exception):
|
||||||
"""Raised when there is a problem registering dispatched functions for a
|
"""Raised when there is a problem registering dispatched functions for a
|
||||||
module
|
module
|
||||||
|
|||||||
@ -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,
|
"""Implementation of the `bigchaindb` command,
|
||||||
the command-line interface (CLI) for BigchainDB Server.
|
the command-line interface (CLI) for BigchainDB Server.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -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
|
"""Utility functions and basic common arguments
|
||||||
for ``argparse.ArgumentParser``.
|
for ``argparse.ArgumentParser``.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -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
|
# Separate all crypto code so that we can easily test several implementations
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
|
|||||||
@ -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.
|
"""Custom exceptions used in the `bigchaindb` package.
|
||||||
"""
|
"""
|
||||||
from bigchaindb.exceptions import BigchainDBError
|
from bigchaindb.exceptions import BigchainDBError
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Introduction
|
# Introduction
|
||||||
|
|
||||||
This directory contains the schemas for the different JSON documents BigchainDB uses.
|
This directory contains the schemas for the different JSON documents BigchainDB uses.
|
||||||
|
|||||||
@ -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"""
|
"""Schema validation related functions and data"""
|
||||||
import os.path
|
import os.path
|
||||||
import logging
|
import logging
|
||||||
@ -5,7 +9,6 @@ import logging
|
|||||||
import jsonschema
|
import jsonschema
|
||||||
import yaml
|
import yaml
|
||||||
import rapidjson
|
import rapidjson
|
||||||
import rapidjson_schema
|
|
||||||
|
|
||||||
from bigchaindb.common.exceptions import SchemaValidationError
|
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')
|
path = os.path.join(os.path.dirname(path), name + '.yaml')
|
||||||
with open(path) as handle:
|
with open(path) as handle:
|
||||||
schema = yaml.safe_load(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)
|
return path, (schema, fast_schema)
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +56,7 @@ def _validate_schema(schema, body):
|
|||||||
# a helpful error message.
|
# a helpful error message.
|
||||||
|
|
||||||
try:
|
try:
|
||||||
schema[1].validate(rapidjson.dumps(body))
|
schema[1](rapidjson.dumps(body))
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
try:
|
try:
|
||||||
jsonschema.validate(body, schema[0])
|
jsonschema.validate(body, schema[0])
|
||||||
|
|||||||
@ -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#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@ -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#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@ -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#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@ -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#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@ -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#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@ -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#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@ -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#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@ -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#"
|
"$schema": "http://json-schema.org/draft-04/schema#"
|
||||||
type: object
|
type: object
|
||||||
@ -6,7 +10,9 @@ required:
|
|||||||
- operation
|
- operation
|
||||||
- outputs
|
- outputs
|
||||||
properties:
|
properties:
|
||||||
operation: "VALIDATOR_ELECTION_VOTE"
|
operation:
|
||||||
|
type: string
|
||||||
|
value: "VALIDATOR_ELECTION_VOTE"
|
||||||
outputs:
|
outputs:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
|||||||
@ -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
|
"""Transaction related models to parse and construct transaction
|
||||||
payloads.
|
payloads.
|
||||||
|
|
||||||
@ -570,7 +574,7 @@ class Transaction(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def spent_outputs(self):
|
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
|
is represented as a dictionary containing a transaction id and
|
||||||
output index.
|
output index.
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -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 time
|
||||||
import re
|
import re
|
||||||
import rapidjson
|
import rapidjson
|
||||||
|
|||||||
@ -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.
|
"""Utils for reading and setting configuration settings.
|
||||||
|
|
||||||
The value of each BigchainDB Server configuration setting is
|
The value of each BigchainDB Server configuration setting is
|
||||||
|
|||||||
@ -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():
|
class BaseConsensusRules():
|
||||||
|
|||||||
@ -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
|
"""This module contains all the goodness to integrate BigchainDB
|
||||||
with Tendermint."""
|
with Tendermint.
|
||||||
|
"""
|
||||||
import logging
|
import logging
|
||||||
import codecs
|
|
||||||
|
|
||||||
from abci.application import BaseApplication
|
from abci.application import BaseApplication
|
||||||
from abci.types_pb2 import (
|
from abci.types_pb2 import (
|
||||||
@ -12,8 +16,6 @@ from abci.types_pb2 import (
|
|||||||
ResponseDeliverTx,
|
ResponseDeliverTx,
|
||||||
ResponseEndBlock,
|
ResponseEndBlock,
|
||||||
ResponseCommit,
|
ResponseCommit,
|
||||||
Validator,
|
|
||||||
PubKey
|
|
||||||
)
|
)
|
||||||
|
|
||||||
from bigchaindb import BigchainDB
|
from bigchaindb import BigchainDB
|
||||||
@ -21,6 +23,8 @@ from bigchaindb.tendermint_utils import (decode_transaction,
|
|||||||
calculate_hash)
|
calculate_hash)
|
||||||
from bigchaindb.lib import Block, PreCommitState
|
from bigchaindb.lib import Block, PreCommitState
|
||||||
from bigchaindb.backend.query import PRE_COMMIT_ID
|
from bigchaindb.backend.query import PRE_COMMIT_ID
|
||||||
|
from bigchaindb.upsert_validator import ValidatorElection
|
||||||
|
import bigchaindb.upsert_validator.validator_utils as vutils
|
||||||
|
|
||||||
|
|
||||||
CodeTypeOk = 0
|
CodeTypeOk = 0
|
||||||
@ -33,7 +37,8 @@ class App(BaseApplication):
|
|||||||
|
|
||||||
The role of this class is to expose the BigchainDB
|
The role of this class is to expose the BigchainDB
|
||||||
transactional logic to the Tendermint Consensus
|
transactional logic to the Tendermint Consensus
|
||||||
State Machine."""
|
State Machine.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, bigchaindb=None):
|
def __init__(self, bigchaindb=None):
|
||||||
self.bigchaindb = bigchaindb or BigchainDB()
|
self.bigchaindb = bigchaindb or BigchainDB()
|
||||||
@ -46,7 +51,7 @@ class App(BaseApplication):
|
|||||||
def init_chain(self, genesis):
|
def init_chain(self, genesis):
|
||||||
"""Initialize chain with block of height 0"""
|
"""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=[])
|
block = Block(app_hash='', height=0, transactions=[])
|
||||||
self.bigchaindb.store_block(block._asdict())
|
self.bigchaindb.store_block(block._asdict())
|
||||||
self.bigchaindb.store_validator_set(1, validator_set)
|
self.bigchaindb.store_validator_set(1, validator_set)
|
||||||
@ -69,7 +74,8 @@ class App(BaseApplication):
|
|||||||
the mempool.
|
the mempool.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
raw_tx: a raw string (in bytes) transaction."""
|
raw_tx: a raw string (in bytes) transaction.
|
||||||
|
"""
|
||||||
|
|
||||||
logger.benchmark('CHECK_TX_INIT')
|
logger.benchmark('CHECK_TX_INIT')
|
||||||
logger.debug('check_tx: %s', raw_transaction)
|
logger.debug('check_tx: %s', raw_transaction)
|
||||||
@ -101,7 +107,8 @@ class App(BaseApplication):
|
|||||||
"""Validate the transaction before mutating the state.
|
"""Validate the transaction before mutating the state.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
raw_tx: a raw string (in bytes) transaction."""
|
raw_tx: a raw string (in bytes) transaction.
|
||||||
|
"""
|
||||||
logger.debug('deliver_tx: %s', raw_transaction)
|
logger.debug('deliver_tx: %s', raw_transaction)
|
||||||
transaction = self.bigchaindb.is_valid_transaction(
|
transaction = self.bigchaindb.is_valid_transaction(
|
||||||
decode_transaction(raw_transaction), self.block_transactions)
|
decode_transaction(raw_transaction), self.block_transactions)
|
||||||
@ -120,7 +127,8 @@ class App(BaseApplication):
|
|||||||
hash to be stored in the next block.
|
hash to be stored in the next block.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
height (int): new height of the chain."""
|
height (int): new height of the chain.
|
||||||
|
"""
|
||||||
|
|
||||||
height = request_end_block.height
|
height = request_end_block.height
|
||||||
self.new_height = height
|
self.new_height = height
|
||||||
@ -132,11 +140,11 @@ class App(BaseApplication):
|
|||||||
else:
|
else:
|
||||||
self.block_txn_hash = block['app_hash']
|
self.block_txn_hash = block['app_hash']
|
||||||
|
|
||||||
# TODO: calculate if an election has concluded
|
# Check if the current block concluded any validator elections and
|
||||||
# NOTE: ensure the local validator set is updated
|
# update the locally tracked validator set
|
||||||
# validator_updates = self.bigchaindb.get_validator_update()
|
validator_updates = ValidatorElection.get_validator_update(self.bigchaindb,
|
||||||
# validator_updates = [encode_validator(v) for v in validator_updates]
|
self.new_height,
|
||||||
validator_updates = []
|
self.block_transactions)
|
||||||
|
|
||||||
# Store pre-commit state to recover in case there is a crash
|
# Store pre-commit state to recover in case there is a crash
|
||||||
# during `commit`
|
# during `commit`
|
||||||
@ -167,22 +175,3 @@ class App(BaseApplication):
|
|||||||
self.block_txn_ids)
|
self.block_txn_ids)
|
||||||
logger.benchmark('COMMIT_BLOCK, height:%s', self.new_height)
|
logger.benchmark('COMMIT_BLOCK, height:%s', self.new_height)
|
||||||
return ResponseCommit(data=data)
|
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}
|
|
||||||
|
|||||||
@ -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 asyncio
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
@ -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 queue import Empty
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from multiprocessing import Queue
|
from multiprocessing import Queue
|
||||||
|
|||||||
@ -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):
|
class BigchainDBError(Exception):
|
||||||
"""Base class for BigchainDB exceptions."""
|
"""Base class for BigchainDB exceptions."""
|
||||||
|
|
||||||
|
|||||||
@ -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.utils import condition_details_has_owner
|
||||||
from bigchaindb.backend import query
|
from bigchaindb.backend import query
|
||||||
from bigchaindb.common.transaction import TransactionLink
|
from bigchaindb.common.transaction import TransactionLink
|
||||||
|
|
||||||
|
|
||||||
class FastQuery():
|
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):
|
def __init__(self, connection):
|
||||||
self.connection = connection
|
self.connection = connection
|
||||||
|
|
||||||
def get_outputs_by_public_key(self, public_key):
|
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))
|
txs = list(query.get_owned_ids(self.connection, public_key))
|
||||||
return [TransactionLink(tx['id'], index)
|
return [TransactionLink(tx['id'], index)
|
||||||
for tx in txs
|
for tx in txs
|
||||||
@ -22,8 +23,7 @@ class FastQuery():
|
|||||||
public_key)]
|
public_key)]
|
||||||
|
|
||||||
def filter_spent_outputs(self, outputs):
|
def filter_spent_outputs(self, outputs):
|
||||||
"""
|
"""Remove outputs that have been spent
|
||||||
Remove outputs that have been spent
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
outputs: list of TransactionLink
|
outputs: list of TransactionLink
|
||||||
@ -36,8 +36,7 @@ class FastQuery():
|
|||||||
return [ff for ff in outputs if ff not in spends]
|
return [ff for ff in outputs if ff not in spends]
|
||||||
|
|
||||||
def filter_unspent_outputs(self, outputs):
|
def filter_unspent_outputs(self, outputs):
|
||||||
"""
|
"""Remove outputs that have not been spent
|
||||||
Remove outputs that have not been spent
|
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
outputs: list of TransactionLink
|
outputs: list of TransactionLink
|
||||||
|
|||||||
@ -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
|
"""Module containing main contact points with Tendermint and
|
||||||
MongoDB.
|
MongoDB.
|
||||||
|
|
||||||
@ -24,6 +28,7 @@ from bigchaindb.tendermint_utils import encode_transaction, merkleroot
|
|||||||
from bigchaindb import exceptions as core_exceptions
|
from bigchaindb import exceptions as core_exceptions
|
||||||
from bigchaindb.consensus import BaseConsensusRules
|
from bigchaindb.consensus import BaseConsensusRules
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
@ -418,16 +423,8 @@ class BigchainDB(object):
|
|||||||
def get_validators(self, height=None):
|
def get_validators(self, height=None):
|
||||||
result = backend.query.get_validator_set(self.connection, height)
|
result = backend.query.get_validator_set(self.connection, height)
|
||||||
validators = result['validators']
|
validators = result['validators']
|
||||||
for v in validators:
|
|
||||||
v.pop('address')
|
|
||||||
v['voting_power'] = int(v['voting_power'])
|
|
||||||
|
|
||||||
return validators
|
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):
|
def delete_validator_update(self):
|
||||||
return backend.query.delete_validator_update(self.connection)
|
return backend.query.delete_validator_update(self.connection)
|
||||||
|
|
||||||
|
|||||||
@ -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 bigchaindb
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|||||||
@ -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,
|
from bigchaindb.common.exceptions import (InvalidSignature,
|
||||||
DuplicateTransaction)
|
DuplicateTransaction)
|
||||||
from bigchaindb.common.transaction import Transaction
|
from bigchaindb.common.transaction import Transaction
|
||||||
|
|||||||
@ -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 logging
|
||||||
import setproctitle
|
import setproctitle
|
||||||
|
|
||||||
|
|||||||
@ -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 base64
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
|||||||
@ -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_vote import ValidatorElectionVote # noqa
|
||||||
|
from bigchaindb.upsert_validator.validator_election import ValidatorElection # noqa
|
||||||
|
|||||||
@ -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,
|
from bigchaindb.common.exceptions import (InvalidSignature,
|
||||||
MultipleInputsError,
|
MultipleInputsError,
|
||||||
InvalidProposer,
|
InvalidProposer,
|
||||||
@ -11,6 +18,8 @@ from bigchaindb.common.schema import (_validate_schema,
|
|||||||
TX_SCHEMA_VALIDATOR_ELECTION,
|
TX_SCHEMA_VALIDATOR_ELECTION,
|
||||||
TX_SCHEMA_COMMON,
|
TX_SCHEMA_COMMON,
|
||||||
TX_SCHEMA_CREATE)
|
TX_SCHEMA_CREATE)
|
||||||
|
from . import ValidatorElectionVote
|
||||||
|
from .validator_utils import (new_validator_set, encode_validator)
|
||||||
|
|
||||||
|
|
||||||
class ValidatorElection(Transaction):
|
class ValidatorElection(Transaction):
|
||||||
@ -28,15 +37,15 @@ class ValidatorElection(Transaction):
|
|||||||
super().__init__(operation, asset, inputs, outputs, metadata, version, hash_id)
|
super().__init__(operation, asset, inputs, outputs, metadata, version, hash_id)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def current_validators(cls, bigchain):
|
def get_validators(cls, bigchain, height=None):
|
||||||
"""Return a dictionary of validators with key as `public_key` and
|
"""Return a dictionary of validators with key as `public_key` and
|
||||||
value as the `voting_power`
|
value as the `voting_power`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
validators = {}
|
validators = {}
|
||||||
for validator in bigchain.get_validators():
|
for validator in bigchain.get_validators(height):
|
||||||
# NOTE: we assume that Tendermint encodes public key in base64
|
# 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']
|
validators[public_key] = validator['voting_power']
|
||||||
|
|
||||||
return validators
|
return validators
|
||||||
@ -46,7 +55,7 @@ class ValidatorElection(Transaction):
|
|||||||
"""Convert validator dictionary to a recipient list for `Transaction`"""
|
"""Convert validator dictionary to a recipient list for `Transaction`"""
|
||||||
|
|
||||||
recipients = []
|
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))
|
recipients.append(([public_key], voting_power))
|
||||||
|
|
||||||
return recipients
|
return recipients
|
||||||
@ -80,7 +89,7 @@ class ValidatorElection(Transaction):
|
|||||||
bigchain (BigchainDB): an instantiated bigchaindb.lib.BigchainDB object.
|
bigchain (BigchainDB): an instantiated bigchaindb.lib.BigchainDB object.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`True` if the election is valid
|
ValidatorElection object
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValidationError: If the election is invalid
|
ValidationError: If the election is invalid
|
||||||
@ -95,7 +104,7 @@ class ValidatorElection(Transaction):
|
|||||||
if not self.inputs_valid(input_conditions):
|
if not self.inputs_valid(input_conditions):
|
||||||
raise InvalidSignature('Transaction signature is invalid.')
|
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
|
# NOTE: Proposer should be a single node
|
||||||
if len(self.inputs) != 1 or len(self.inputs[0].owners_before) != 1:
|
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):
|
if not self.is_same_topology(current_validators, self.outputs):
|
||||||
raise UnequalValidatorSet('Validator set much be exactly same to the outputs of election')
|
raise UnequalValidatorSet('Validator set much be exactly same to the outputs of election')
|
||||||
|
|
||||||
return True
|
return self
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls, initiator, voters, election_data, metadata=None):
|
def generate(cls, initiator, voters, election_data, metadata=None):
|
||||||
@ -141,3 +150,77 @@ class ValidatorElection(Transaction):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def transfer(cls, tx_signers, recipients, metadata=None, asset=None):
|
def transfer(cls, tx_signers, recipients, metadata=None, asset=None):
|
||||||
raise NotImplementedError
|
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 []
|
||||||
|
|||||||
@ -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.transaction import Transaction
|
||||||
from bigchaindb.common.schema import (_validate_schema,
|
from bigchaindb.common.schema import (_validate_schema,
|
||||||
@ -26,7 +28,7 @@ class ValidatorElectionVote(Transaction):
|
|||||||
bigchain (BigchainDB): an instantiated bigchaindb.lib.BigchainDB object.
|
bigchain (BigchainDB): an instantiated bigchaindb.lib.BigchainDB object.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
`True` if the election vote is valid
|
ValidatorElectionVote object
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValidationError: If the election vote is invalid
|
ValidationError: If the election vote is invalid
|
||||||
@ -34,10 +36,6 @@ class ValidatorElectionVote(Transaction):
|
|||||||
self.validate_transfer_inputs(bigchain, current_transactions)
|
self.validate_transfer_inputs(bigchain, current_transactions)
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def to_public_key(cls, election_id):
|
|
||||||
return base58.b58encode(bytes.fromhex(election_id))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls, inputs, recipients, election_id, metadata=None):
|
def generate(cls, inputs, recipients, election_id, metadata=None):
|
||||||
(inputs, outputs) = cls.validate_transfer(inputs, recipients, election_id, metadata)
|
(inputs, outputs) = cls.validate_transfer(inputs, recipients, election_id, metadata)
|
||||||
|
|||||||
37
bigchaindb/upsert_validator/validator_utils.py
Normal file
37
bigchaindb/upsert_validator/validator_utils.py
Normal file
@ -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())
|
||||||
@ -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 contextlib
|
||||||
import threading
|
import threading
|
||||||
import queue
|
import queue
|
||||||
|
|||||||
@ -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'
|
__version__ = '2.0.0b5'
|
||||||
__short_version__ = '2.0b5'
|
__short_version__ = '2.0b5'
|
||||||
|
|||||||
@ -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"""
|
"""API routes definition"""
|
||||||
from flask_restful import Api
|
from flask_restful import Api
|
||||||
from bigchaindb.web.views import (
|
from bigchaindb.web.views import (
|
||||||
|
|||||||
@ -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.
|
"""This module contains basic functions to instantiate the BigchainDB API.
|
||||||
|
|
||||||
The application is implemented in Flask and runs using Gunicorn.
|
The application is implemented in Flask and runs using Gunicorn.
|
||||||
|
|||||||
@ -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 logging
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@ -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.
|
"""This module provides the blueprint for some basic API endpoints.
|
||||||
|
|
||||||
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
||||||
|
|||||||
@ -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
|
"""Common classes and methods for API handlers
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|||||||
@ -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.
|
"""This module provides the blueprint for the blocks API endpoints.
|
||||||
|
|
||||||
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
||||||
|
|||||||
@ -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"""
|
"""API Index endpoint"""
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
|
|||||||
@ -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.
|
"""This module provides the blueprint for some basic API endpoints.
|
||||||
|
|
||||||
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
||||||
|
|||||||
@ -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 import current_app
|
||||||
from flask_restful import reqparse, Resource
|
from flask_restful import reqparse, Resource
|
||||||
|
|
||||||
|
|||||||
@ -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
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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.
|
"""This module provides the blueprint for some basic API endpoints.
|
||||||
|
|
||||||
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
For more information please refer to the documentation: http://bigchaindb.com/http-api
|
||||||
|
|||||||
@ -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 import current_app
|
||||||
from flask_restful import Resource
|
from flask_restful import Resource
|
||||||
|
|
||||||
|
|||||||
@ -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."""
|
"""WebSocket server for the BigchainDB Event Stream API."""
|
||||||
|
|
||||||
# NOTE
|
# NOTE
|
||||||
|
|||||||
@ -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:
|
codecov:
|
||||||
branch: master # the branch to show by default
|
branch: master # the branch to show by default
|
||||||
|
|
||||||
|
|||||||
@ -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'
|
version: '2.1'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
- [Documentation on ReadTheDocs](http://bigchaindb.readthedocs.org/)
|
- [Documentation on ReadTheDocs](http://bigchaindb.readthedocs.org/)
|
||||||
- [BigchainDB Upgrade Guides](upgrade-guides/)
|
- [BigchainDB Upgrade Guides](upgrade-guides/)
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
#!/usr/bin/env python3
|
#!/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
|
# BigchainDB documentation build configuration file, created by
|
||||||
# sphinx-quickstart on Thu Sep 29 11:13:27 2016.
|
# sphinx-quickstart on Thu Sep 29 11:13:27 2016.
|
||||||
#
|
#
|
||||||
|
|||||||
@ -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
|
Policies
|
||||||
========
|
========
|
||||||
|
|
||||||
|
|||||||
@ -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
|
Developer Setup, Coding & Contribution Process
|
||||||
==============================================
|
==============================================
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Run a BigchainDB network with Ansible
|
# Run a BigchainDB network with Ansible
|
||||||
|
|
||||||
**NOT for Production Use**
|
**NOT for Production Use**
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Run a BigchainDB network
|
# Run a BigchainDB network
|
||||||
|
|
||||||
**NOT for Production Use**
|
**NOT for Production Use**
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Notes on Running a Local Dev Node as Processes
|
# Notes on Running a Local Dev Node as Processes
|
||||||
|
|
||||||
The following doc describes how to run a local node for developing BigchainDB Tendermint version.
|
The following doc describes how to run a local node for developing BigchainDB Tendermint version.
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Notes on Running a Local Dev Node with Docker Compose
|
# Notes on Running a Local Dev Node with Docker Compose
|
||||||
|
|
||||||
## Setting up a single node development environment with ``docker-compose``
|
## Setting up a single node development environment with ``docker-compose``
|
||||||
|
|||||||
@ -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
|
Write Code
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
|||||||
@ -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
|
Contributing to BigchainDB
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Answer Questions
|
# Answer Questions
|
||||||
|
|
||||||
People ask questions about BigchainDB in the following places:
|
People ask questions about BigchainDB in the following places:
|
||||||
|
|||||||
@ -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
|
Ways to Contribute
|
||||||
==================
|
==================
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Make a Feature Request or Proposal
|
# Make a Feature Request or Proposal
|
||||||
|
|
||||||
To make a feature request or proposal, [write a BigchainDB Enhancement Proposal (BEP)](write-a-bep.html).
|
To make a feature request or proposal, [write a BigchainDB Enhancement Proposal (BEP)](write-a-bep.html).
|
||||||
|
|||||||
@ -1,3 +1,9 @@
|
|||||||
|
<!---
|
||||||
|
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
|
||||||
|
--->
|
||||||
|
|
||||||
# Report a Bug
|
# 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.
|
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.
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user