Compare commits
87 Commits
Author | SHA1 | Date |
---|---|---|
yongtheskill | 3c89d306ef | |
Jürgen Eckel | ad83ef1d35 | |
Tim Gates | 0961aa6b26 | |
zzappie | 6a6a19207c | |
David Dashyan | caf31647e0 | |
David Dashyan | 8630e74f77 | |
David Dashyan | 5166fa6b46 | |
David Dashyan | 22cf5f26c3 | |
David Dashyan | 62ae66fef7 | |
Andrijan Ostrun | d77ab60651 | |
David Dashyan | af2517b2ae | |
David Dashyan | 8895d50f5b | |
David Dashyan | 40a92756f9 | |
David Dashyan | 41f7534f3a | |
David Dashyan | 26cb560bb1 | |
David Dashyan | 2b0babb95b | |
Amartya Gaur | b272fb342a | |
Karthikeyan Singaravelan | e86666b6b3 | |
David Dashyan | d9dfa98819 | |
lana-shanghai | 4a008e51e3 | |
David Dashyan | 2accca9ff1 | |
David Dashyan | 186cd87444 | |
David Dashyan | 9e99c024d3 | |
David Dashyan | 09391351a4 | |
Zac Hatfield-Dodds | f795301f90 | |
David Dashyan | 7df59994e9 | |
Yuliya Palamarchuk | 86472157db | |
Jürgen Eckel | b54c31539f | |
David Dashyan | ecd6e9cc46 | |
David Dashyan | f12d44ff82 | |
Jürgen Eckel | 9bcefdf3e2 | |
Giuseppe Raveduto | 16a9888d1e | |
Simon Pfeifhofer | 645d457b7b | |
Nikita Chernyi | 2975c372c8 | |
Troy McConaghy | df23bec320 | |
Mike Klimontov | c801c833fc | |
Troy McConaghy | a5452169b9 | |
Troy McConaghy | a24c0f429b | |
Troy McConaghy | 835fdfcf59 | |
manjush08 | 20a59a9640 | |
manjush08 | f0dc9986aa | |
Chuseuiti | 6bed80cff3 | |
Troy McConaghy | 7781f5aae8 | |
Troy McConaghy | eb2f8ddc73 | |
Troy McConaghy | d8f51d8999 | |
Troy McConaghy | 3b72181b3d | |
Troy McConaghy | ca012ae8b6 | |
Troy McConaghy | 1a9c5d47e6 | |
Kuro1 | edcd59e235 | |
Troy McConaghy | 11817b9590 | |
Troy McConaghy | d9725d483b | |
xunconnectedx | f0df5bd2e0 | |
Troy McConaghy | f8191b0d8e | |
Troy McConaghy | dcfe23f292 | |
Troy McConaghy | 5de2fef284 | |
gamjapark | a62cc4e101 | |
Troy McConaghy | 288c2ecd2a | |
Troy McConaghy | fe467fddbd | |
Troy McConaghy | 0b935c09c7 | |
Salah Alsasa | 1bd5845a83 | |
Troy McConaghy | d85b9df615 | |
Troy McConaghy | ff906b0abe | |
Troy McConaghy | 20e6c6a686 | |
gamjapark | 73afc38697 | |
Troy McConaghy | c5fea574b5 | |
Troy McConaghy | ee7bd938dc | |
Troy McConaghy | e2b3c78d9c | |
Troy McConaghy | f1353a3db9 | |
Troy McConaghy | c1993c3787 | |
Troy McConaghy | 5c1511b479 | |
Troy McConaghy | 3da13eda3d | |
Lev Berman | 0c4d6ec906 | |
Troy McConaghy | f4d6ccbacf | |
Troy McConaghy | 009cbe4e11 | |
Troy McConaghy | 54ac7adaa9 | |
Troy McConaghy | 4f01dd4997 | |
Vanshdeep Singh | 72d7986a58 | |
Vanshdeep Singh | 78dafce146 | |
Troy McConaghy | bedb1945a9 | |
Lev Berman | cb74cb43d2 | |
Lev Berman | 40ea961d4a | |
Lev Berman | 24ca0b32a9 | |
Troy McConaghy | 39be7a2fdf | |
Muawia Khan | eb139fba00 | |
codegeschrei | 407571ddf4 | |
Troy McConaghy | 2f6bbaeb4b | |
Lev Berman | 126e90e732 |
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -12,9 +13,6 @@ if [[ -n ${TOXENV} ]]; then
|
|||
pip install --upgrade tox
|
||||
elif [[ ${BIGCHAINDB_CI_ABCI} == 'enable' ]]; then
|
||||
docker-compose build --no-cache --build-arg abci_status=enable bigchaindb
|
||||
elif [[ $TRAVIS_PYTHON_VERSION == 3.5 ]]; then
|
||||
docker-compose build --build-arg python_version=3.5 --no-cache bigchaindb
|
||||
pip install --upgrade codecov
|
||||
elif [[ $BIGCHAINDB_INTEGRATION_TEST == 'enable' ]]; then
|
||||
docker-compose build bigchaindb python-driver
|
||||
else
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#!/bin/bash
|
||||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Logs or terminal output**
|
||||
If applicable, add add textual content to help explain your problem.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- Distribution: [e.g. Ubuntu 18.04]
|
||||
- Bigchaindb version:
|
||||
- Tendermint version:
|
||||
- Mongodb version:
|
||||
- Python full version: [e.g. Python 3.6.6]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
|
@ -95,3 +95,5 @@ network/*/data
|
|||
|
||||
# Docs that are fetched at build time
|
||||
docs/contributing/source/cross-project-policies/*.md
|
||||
|
||||
.DS_Store
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
43
.travis.yml
43
.travis.yml
|
@ -1,10 +1,11 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020, 2021 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
sudo: required
|
||||
|
||||
dist: trusty
|
||||
dist: focal
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
@ -13,26 +14,19 @@ language: python
|
|||
cache: pip
|
||||
|
||||
python:
|
||||
- 3.5
|
||||
- 3.6
|
||||
- 3.7
|
||||
- 3.8
|
||||
|
||||
env:
|
||||
global:
|
||||
- DOCKER_COMPOSE_VERSION=1.19.0
|
||||
- DOCKER_COMPOSE_VERSION=1.29.2
|
||||
matrix:
|
||||
- TOXENV=flake8
|
||||
- TOXENV=docsroot
|
||||
- TOXENV=docsserver
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
exclude:
|
||||
- python: 3.5
|
||||
env: TOXENV=flake8
|
||||
- python: 3.5
|
||||
env: TOXENV=docsroot
|
||||
- python: 3.5
|
||||
env: TOXENV=docsserver
|
||||
include:
|
||||
- python: 3.6
|
||||
env:
|
||||
|
@ -46,6 +40,31 @@ matrix:
|
|||
- python: 3.6
|
||||
env:
|
||||
- BIGCHAINDB_ACCEPTANCE_TEST=enable
|
||||
- python: 3.7
|
||||
env:
|
||||
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
|
||||
- BIGCHAINDB_DATABASE_SSL=
|
||||
- python: 3.7
|
||||
env:
|
||||
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
|
||||
- BIGCHAINDB_DATABASE_SSL=
|
||||
- BIGCHAINDB_CI_ABCI=enable
|
||||
- python: 3.7
|
||||
env:
|
||||
- BIGCHAINDB_ACCEPTANCE_TEST=enable
|
||||
- python: 3.8
|
||||
env:
|
||||
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
|
||||
- BIGCHAINDB_DATABASE_SSL=
|
||||
- python: 3.8
|
||||
env:
|
||||
- BIGCHAINDB_DATABASE_BACKEND=localmongodb
|
||||
- BIGCHAINDB_DATABASE_SSL=
|
||||
- BIGCHAINDB_CI_ABCI=enable
|
||||
- python: 3.8
|
||||
env:
|
||||
- BIGCHAINDB_ACCEPTANCE_TEST=enable
|
||||
|
||||
|
||||
before_install: sudo .ci/travis-before-install.sh
|
||||
|
||||
|
|
96
CHANGELOG.md
96
CHANGELOG.md
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
@ -24,6 +25,99 @@ For reference, the possible headings are:
|
|||
* **Known Issues**
|
||||
* **Notes**
|
||||
|
||||
## [2.2.2] - 2020-08-12
|
||||
|
||||
### Security
|
||||
|
||||
Several dependencies updated including Flask that had vulnerability.
|
||||
|
||||
### Fixed
|
||||
|
||||
* Updated priv_validator key format in stack script (#2707)
|
||||
|
||||
### External Contributors
|
||||
|
||||
* @aostrun - [#2708](https://github.com/bigchaindb/bigchaindb/pull/2708)
|
||||
|
||||
## [2.2.1] - 2020-04-14
|
||||
|
||||
### Fixed
|
||||
|
||||
Gevent library API update is incompatible with bigchaindb-abci 1.0.1 version.
|
||||
Updated bigchaindb-abci.
|
||||
|
||||
## [2.2.0] - 2020-02-20
|
||||
|
||||
### Added
|
||||
|
||||
Support for multiple ABCI versions.
|
||||
|
||||
## [2.1.0] - 2019-11-06
|
||||
|
||||
### Added
|
||||
|
||||
Option for last transaction retrieval added.
|
||||
|
||||
## [2.0] - 2019-09-26
|
||||
|
||||
### Changed
|
||||
|
||||
Migrated from Tendermint 0.22.8 to 0.31.5.
|
||||
|
||||
## [2.0 Beta 9] - 2018-11-27
|
||||
|
||||
### Changed
|
||||
|
||||
Removed support for TLSv1 and TLSv1.1 in all NGINX config files. Kept support for TLSv1.2 and added support for TLSv1.3. [Pull Request #2601](https://github.com/bigchaindb/bigchaindb/pull/2601)
|
||||
|
||||
### Fixed
|
||||
|
||||
Fixed two issues with schema validation. Pull requests [#2606](https://github.com/bigchaindb/bigchaindb/pull/2606) & [#2607](https://github.com/bigchaindb/bigchaindb/pull/2607)
|
||||
|
||||
### External Contributors
|
||||
|
||||
[@gamjapark](https://github.com/gamjapark) and team translated all the [BigchainDB root docs](https://docs.bigchaindb.com/en/latest/korean/index.html) into Korean. [Pull Request #2603](https://github.com/bigchaindb/bigchaindb/pull/2603)
|
||||
|
||||
## [2.0 Beta 8] - 2018-11-03
|
||||
|
||||
### Changed
|
||||
|
||||
* Revised the [Simple Deployment Template](http://docs.bigchaindb.com/projects/server/en/latest/simple-deployment-template/index.html) in the docs. Added NGINX to the mix. Pull Requests [#2578](https://github.com/bigchaindb/bigchaindb/pull/2578) and [#2579](https://github.com/bigchaindb/bigchaindb/pull/2579)
|
||||
* Revised `nginx/nginx.conf` to enable CORS. [Pull Request #2580](https://github.com/bigchaindb/bigchaindb/pull/2580)
|
||||
|
||||
### Fixed
|
||||
|
||||
* Fixed a typo in the Kubernetes ConfigMap template. [Pull Request #2583](https://github.com/bigchaindb/bigchaindb/pull/2583)
|
||||
|
||||
### External Contributors
|
||||
|
||||
[@gamjapark](https://github.com/gamjapark) translated the main `README.md` file into Korean. [Pull Request #2592](https://github.com/bigchaindb/bigchaindb/pull/2592)
|
||||
|
||||
## [2.0 Beta 7] - 2018-09-28
|
||||
|
||||
Tag name: v2.0.0b7
|
||||
|
||||
### Added
|
||||
|
||||
Completed the implementation of chain-migration elections (BEP-42). Pull requests [#2553](https://github.com/bigchaindb/bigchaindb/pull/2553), [#2556](https://github.com/bigchaindb/bigchaindb/pull/2556), [#2558](https://github.com/bigchaindb/bigchaindb/pull/2558), [#2563](https://github.com/bigchaindb/bigchaindb/pull/2563) and [#2566](https://github.com/bigchaindb/bigchaindb/pull/2566)
|
||||
|
||||
### Changed
|
||||
|
||||
* Code that used the Python driver's (deprecated) transactions.send() method now uses its transactions.send_commit() method instead. [Pull request #2547](https://github.com/bigchaindb/bigchaindb/pull/2547)
|
||||
* Code that implied pluggable "consensus" now implies pluggable transaction "validation" (a more accurate word). [Pull request #2561](https://github.com/bigchaindb/bigchaindb/pull/2561)
|
||||
|
||||
### Removed
|
||||
|
||||
Benchmark logs. [Pull request #2565](https://github.com/bigchaindb/bigchaindb/pull/2565)
|
||||
|
||||
### Fixed
|
||||
|
||||
A bug caused by an incorrect MongoDB query. [Pull request #2567](https://github.com/bigchaindb/bigchaindb/pull/2567)
|
||||
|
||||
### Notes
|
||||
|
||||
There's now better documentation about logs, log rotation, and the `server.bind` config setting. Pull requests [#2546](https://github.com/bigchaindb/bigchaindb/pull/2546) and [#2575](https://github.com/bigchaindb/bigchaindb/pull/2575)
|
||||
|
||||
## [2.0 Beta 6] - 2018-09-17
|
||||
|
||||
Tag name: v2.0.0b6
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
@ -41,7 +42,7 @@ This Code of Conduct applies both within project spaces and in public spaces
|
|||
when an individual is representing the project or its community.
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior directed at yourself or another community member may be
|
||||
reported by contacting a project maintainer at [conduct@bigchaindb.com](mailto:conduct@bigchaindb.com). All
|
||||
reported by contacting a project maintainer at [contact@bigchaindb.com](mailto:contact@bigchaindb.com). All
|
||||
complaints will be reviewed and investigated and will result in a response that
|
||||
is appropriate to the circumstances. Maintainers are
|
||||
obligated to maintain confidentiality with regard to the reporter of an
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
FROM python:3.6
|
||||
LABEL maintainer "dev@bigchaindb.com"
|
||||
LABEL maintainer "contact@ipdb.global"
|
||||
RUN mkdir -p /usr/src/app
|
||||
COPY . /usr/src/app/
|
||||
WORKDIR /usr/src/app
|
||||
RUN apt-get -qq update \
|
||||
&& apt-get -y upgrade \
|
||||
&& apt-get install -y jq \
|
||||
&& pip install --no-cache-dir --process-dependency-links . \
|
||||
&& pip install . \
|
||||
&& apt-get autoremove \
|
||||
&& apt-get clean
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
FROM alpine:latest
|
||||
LABEL maintainer "dev@bigchaindb.com"
|
||||
FROM alpine:3.9
|
||||
LABEL maintainer "contact@ipdb.global"
|
||||
|
||||
ARG TM_VERSION=0.22.8
|
||||
ARG TM_VERSION=v0.31.5
|
||||
RUN mkdir -p /usr/src/app
|
||||
ENV HOME /root
|
||||
COPY . /usr/src/app/
|
||||
|
@ -13,7 +13,7 @@ RUN apk --update add sudo bash \
|
|||
libffi-dev openssl-dev build-base jq \
|
||||
&& apk add --no-cache libstdc++ dpkg gnupg \
|
||||
&& pip3 install --upgrade pip cffi \
|
||||
&& pip install --no-cache-dir --process-dependency-links -e . \
|
||||
&& pip install -e . \
|
||||
&& apk del build-dependencies \
|
||||
&& rm -f /var/cache/apk/*
|
||||
|
||||
|
@ -21,7 +21,7 @@ RUN apk --update add sudo bash \
|
|||
RUN apk --update add mongodb monit
|
||||
|
||||
# Install Tendermint
|
||||
RUN wget https://github.com/tendermint/tendermint/releases/download/v${TM_VERSION}/tendermint_${TM_VERSION}_linux_amd64.zip \
|
||||
RUN wget https://github.com/tendermint/tendermint/releases/download/${TM_VERSION}/tendermint_${TM_VERSION}_linux_amd64.zip \
|
||||
&& unzip tendermint_${TM_VERSION}_linux_amd64.zip \
|
||||
&& mv tendermint /usr/local/bin/ \
|
||||
&& rm tendermint_${TM_VERSION}_linux_amd64.zip
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
FROM alpine:latest
|
||||
LABEL maintainer "dev@bigchaindb.com"
|
||||
LABEL maintainer "contact@ipdb.global"
|
||||
RUN mkdir -p /usr/src/app
|
||||
COPY . /usr/src/app/
|
||||
WORKDIR /usr/src/app
|
||||
RUN apk --update add sudo \
|
||||
&& apk --update add python3 openssl ca-certificates git\
|
||||
&& apk --update add python3 py-pip openssl ca-certificates git\
|
||||
&& apk --update add --virtual build-dependencies python3-dev \
|
||||
libffi-dev openssl-dev build-base \
|
||||
&& apk add --no-cache libstdc++ \
|
||||
&& pip3 install --upgrade pip cffi \
|
||||
&& pip install --no-cache-dir --process-dependency-links -e .[dev] \
|
||||
&& pip install -e . \
|
||||
&& apk del build-dependencies \
|
||||
&& rm -f /var/cache/apk/*
|
||||
# When developing with Python in a docker container, we are using PYTHONBUFFERED
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
ARG python_version=3.6
|
||||
FROM python:${python_version}
|
||||
LABEL maintainer "dev@bigchaindb.com"
|
||||
LABEL maintainer "contact@ipdb.global"
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y vim \
|
||||
&& apt-get install -y git \
|
||||
&& pip install -U pip \
|
||||
&& pip install pynacl \
|
||||
&& apt-get autoremove \
|
||||
&& apt-get clean
|
||||
|
||||
|
@ -32,5 +31,5 @@ ENV BIGCHAINDB_CI_ABCI ${abci_status}
|
|||
RUN mkdir -p /usr/src/app
|
||||
COPY . /usr/src/app/
|
||||
WORKDIR /usr/src/app
|
||||
RUN pip install --no-cache-dir --process-dependency-links -e .[dev]
|
||||
RUN bigchaindb -y configure
|
||||
RUN pip install -e .[dev]
|
||||
RUN bigchaindb -y configure
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
<!---
|
||||
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
|
||||
|
||||
See [BEP-16](https://github.com/bigchaindb/BEPs/tree/master/16).
|
|
@ -2,10 +2,12 @@
|
|||
|
||||
## Copyrights
|
||||
|
||||
Except as noted in the **Exceptions** section below, for all code and documentation in this repository, BigchainDB GmbH ("We") either:
|
||||
For all the code and documentation in this repository, the copyright is owned by one or more of the following:
|
||||
|
||||
1. owns the copyright, or
|
||||
2. owns the right to sublicense it under any license (because all external contributors must agree to a Contributor License Agreement).
|
||||
- BigchainDB GmbH
|
||||
- A BigchainDB contributor who agreed to a BigchainDB Contributor License Agreement (CLA) with BigchainDB GmbH. (See [BEP-16](https://github.com/bigchaindb/BEPs/tree/master/16).)
|
||||
- A BigchainDB contributor who signed off on the Developer Certificate of Origin (DCO) for all their contributions. (See [BEP-24](https://github.com/bigchaindb/BEPs/tree/master/24).)
|
||||
- (Rarely, see the **Exceptions Section** below) A third pary who licensed the code in question under an open source license.
|
||||
|
||||
## Code Licenses
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -88,8 +88,6 @@ cov: check-deps ## Check code coverage and open the result in the browser
|
|||
|
||||
doc: check-deps ## Generate HTML documentation and open it in the browser
|
||||
@$(DC) run --rm --no-deps bdocs make -C docs/root html
|
||||
@$(DC) run --rm --no-deps bdocs make -C docs/server html
|
||||
@$(DC) run --rm --no-deps bdocs make -C docs/contributing html
|
||||
$(BROWSER) docs/root/build/html/index.html
|
||||
|
||||
doc-acceptance: check-deps ## Create documentation for acceptance tests
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
@ -91,6 +92,6 @@ flake8 --max-line-length 119 bigchaindb/
|
|||
|
||||
## Writing and Running (Python) Tests
|
||||
|
||||
The content of this section was moved to [`bigchaindb/tests/README.md`](./tests/README.md).
|
||||
The content of this section was moved to [`bigchaindb/tests/README.md`](https://github.com/bigchaindb/bigchaindb/blob/master/tests/README.md).
|
||||
|
||||
Note: We automatically run all tests on all pull requests (using Travis CI), so you should definitely run all tests locally before you submit a pull request. See the above-linked README file for instructions.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
@ -12,7 +13,7 @@ so show the latest GitHub release instead.
|
|||
[![Codecov branch](https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb/master.svg)](https://codecov.io/github/bigchaindb/bigchaindb?branch=master)
|
||||
[![Latest release](https://img.shields.io/github/release/bigchaindb/bigchaindb/all.svg)](https://github.com/bigchaindb/bigchaindb/releases)
|
||||
[![Status on PyPI](https://img.shields.io/pypi/status/bigchaindb.svg)](https://pypi.org/project/BigchainDB/)
|
||||
[![Travis branch](https://img.shields.io/travis/bigchaindb/bigchaindb/master.svg)](https://travis-ci.org/bigchaindb/bigchaindb)
|
||||
[![Travis branch](https://img.shields.io/travis/bigchaindb/bigchaindb/master.svg)](https://travis-ci.com/bigchaindb/bigchaindb)
|
||||
[![Documentation Status](https://readthedocs.org/projects/bigchaindb-server/badge/?version=latest)](https://docs.bigchaindb.com/projects/server/en/latest/)
|
||||
[![Join the chat at https://gitter.im/bigchaindb/bigchaindb](https://badges.gitter.im/bigchaindb/bigchaindb.svg)](https://gitter.im/bigchaindb/bigchaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<!---
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
||||
<!--- There is no shield to get the latest version
|
||||
(including pre-release versions) from PyPI,
|
||||
so show the latest GitHub release instead.
|
||||
--->
|
||||
|
||||
[![Codecov branch](https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb/master.svg)](https://codecov.io/github/bigchaindb/bigchaindb?branch=master)
|
||||
[![Latest release](https://img.shields.io/github/release/bigchaindb/bigchaindb/all.svg)](https://github.com/bigchaindb/bigchaindb/releases)
|
||||
[![Status on PyPI](https://img.shields.io/pypi/status/bigchaindb.svg)](https://pypi.org/project/BigchainDB/)
|
||||
[![Travis branch](https://img.shields.io/travis/bigchaindb/bigchaindb/master.svg)](https://travis-ci.com/bigchaindb/bigchaindb)
|
||||
[![Documentation Status](https://readthedocs.org/projects/bigchaindb-server/badge/?version=latest)](https://docs.bigchaindb.com/projects/server/en/latest/)
|
||||
[![Join the chat at https://gitter.im/bigchaindb/bigchaindb](https://badges.gitter.im/bigchaindb/bigchaindb.svg)](https://gitter.im/bigchaindb/bigchaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
# BigchainDB 服务器
|
||||
|
||||
BigchainDB 是区块链数据库. 这是 _BigchainDB 服务器_ 的仓库.
|
||||
|
||||
## 基础知识
|
||||
|
||||
* [尝试快速开始](https://docs.bigchaindb.com/projects/server/en/latest/quickstart.html)
|
||||
* [阅读 BigchainDB 2.0 白皮书](https://www.bigchaindb.com/whitepaper/)
|
||||
* [查阅漫游指南](https://www.bigchaindb.com/developers/guide/)
|
||||
|
||||
## 运行和测试 `master` 分支的 BigchainDB 服务器
|
||||
|
||||
运行和测试最新版本的 BigchainDB 服务器非常简单. 确认你有安装最新版本的 [Docker Compose](https://docs.docker.com/compose/install/). 当你准备好了, 打开一个终端并运行:
|
||||
|
||||
```text
|
||||
git clone https://github.com/bigchaindb/bigchaindb.git
|
||||
cd bigchaindb
|
||||
make run
|
||||
```
|
||||
|
||||
BigchainDB 应该可以通过 `http://localhost:9984/` 访问.
|
||||
|
||||
这里也有一些其他的命令你可以运行:
|
||||
|
||||
* `make start`: 通过源码和守护进程的方式运行 BigchainDB (通过 `make stop` 停止).
|
||||
* `make stop`: 停止运行 BigchainDB.
|
||||
* `make logs`: 附在日志上.
|
||||
* `make test`: 运行所有单元和验收测试.
|
||||
* `make test-unit-watch`: 运行所有测试并等待. 每次更改代码时都会再次运行测试.
|
||||
* `make cov`: 检查代码覆盖率并在浏览器中打开结果.
|
||||
* `make doc`: 生成 HTML 文档并在浏览器中打开它.
|
||||
* `make clean`: 删除所有构建, 测试, 覆盖和 Python 生成物.
|
||||
* `make reset`: 停止并移除所有容器. 警告: 您将丢失存储在 BigchainDB 中的所有数据.
|
||||
|
||||
查看所有可用命令, 请运行 `make`.
|
||||
|
||||
## 一般人员链接
|
||||
|
||||
* [BigchainDB.com](https://www.bigchaindb.com/) - BigchainDB 主网站, 包括新闻订阅
|
||||
* [路线图](https://github.com/bigchaindb/org/blob/master/ROADMAP.md)
|
||||
* [博客](https://medium.com/the-bigchaindb-blog)
|
||||
* [推特](https://twitter.com/BigchainDB)
|
||||
|
||||
## 开发人员链接
|
||||
|
||||
* [所有的 BigchainDB 文档](https://docs.bigchaindb.com/en/latest/)
|
||||
* [BigchainDB 服务器 文档](https://docs.bigchaindb.com/projects/server/en/latest/index.html)
|
||||
* [CONTRIBUTING.md](.github/CONTRIBUTING.md) - how to contribute
|
||||
* [社区指南](CODE_OF_CONDUCT.md)
|
||||
* [公开问题](https://github.com/bigchaindb/bigchaindb/issues)
|
||||
* [公开的 pull request](https://github.com/bigchaindb/bigchaindb/pulls)
|
||||
* [Gitter 聊天室](https://gitter.im/bigchaindb/bigchaindb)
|
||||
|
||||
## 法律声明
|
||||
|
||||
* [许可](LICENSES.md) - 开源代码 & 开源内容
|
||||
* [印记](https://www.bigchaindb.com/imprint/)
|
||||
* [联系我们](https://www.bigchaindb.com/contact/)
|
|
@ -0,0 +1,65 @@
|
|||
[![Codecov branch](https://img.shields.io/codecov/c/github/bigchaindb/bigchaindb/master.svg)](https://codecov.io/github/bigchaindb/bigchaindb?branch=master)
|
||||
[![Latest release](https://img.shields.io/github/release/bigchaindb/bigchaindb/all.svg)](https://github.com/bigchaindb/bigchaindb/releases)
|
||||
[![Status on PyPI](https://img.shields.io/pypi/status/bigchaindb.svg)](https://pypi.org/project/BigchainDB/)
|
||||
[![Travis branch](https://img.shields.io/travis/bigchaindb/bigchaindb/master.svg)](https://travis-ci.org/bigchaindb/bigchaindb)
|
||||
[![Documentation Status](https://readthedocs.org/projects/bigchaindb-server/badge/?version=latest)](https://docs.bigchaindb.com/projects/server/en/latest/)
|
||||
[![Join the chat at https://gitter.im/bigchaindb/bigchaindb](https://badges.gitter.im/bigchaindb/bigchaindb.svg)](https://gitter.im/bigchaindb/bigchaindb?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
# BigchainDB 서버
|
||||
|
||||
BigchaingDB는 블록체인 데이터베이스입니다. 이 저장소는 _BigchaingDB 서버_를 위한 저장소입니다.
|
||||
|
||||
### 기본 사항
|
||||
|
||||
* [빠른 시작 사용해보기](https://docs.bigchaindb.com/projects/server/en/latest/quickstart.html)
|
||||
* [BigchainDB 2.0 백서 읽기](https://www.bigchaindb.com/whitepaper/)
|
||||
* [BigchainDB에 대한 _Hitchiker's Guide_를 확인십시오.](https://www.bigchaindb.com/developers/guide/)
|
||||
|
||||
### `master` Branch에서 BigchainDB 서버 실행 및 테스트
|
||||
|
||||
BigchaingDB 서버의 최신 버전을 실행하고 테스트하는 것은 어렵지 않습니다. [Docker Compose](https://docs.docker.com/compose/install/)의 최신 버전이 설치되어 있는지 확인하십시오. 준비가 되었다면, 터미널에서 다음을 실행하십시오.
|
||||
|
||||
```text
|
||||
git clone https://github.com/bigchaindb/bigchaindb.git
|
||||
cd bigchaindb
|
||||
make run
|
||||
```
|
||||
|
||||
이제 BigchainDB는 `http://localhost:9984/`에 연결되어야 합니다.
|
||||
|
||||
또한, 실행시키기 위한 다른 명령어들도 있습니다.
|
||||
|
||||
* `make start` : 소스로부터 BigchainDB를 실행하고 데몬화합니다. \(이는 `make stop` 을 하면 중지합니다.\)
|
||||
* `make stop` : BigchainDB를 중지합니다.
|
||||
* `make logs` : 로그에 첨부합니다.
|
||||
* `make text` : 모든 유닛과 허가 테스트를 실행합니다.
|
||||
* `make test-unit-watch` : 모든 테스트를 수행하고 기다립니다. 코드를 변경할 때마다 테스트는 다시 실행될 것입니다.
|
||||
* `make cov` : 코드 커버리지를 확인하고 브라우저에서 결과를 엽니다.
|
||||
* `make doc` : HTML 문서를 만들고, 브라우저에서 엽니다.
|
||||
* `make clean` : 모든 빌드와 테스트, 커버리지 및 파이썬 아티팩트를 제거합니다.
|
||||
* `make reset` : 모든 컨테이너들을 중지하고 제거합니다. 경고 : BigchainDB에 저장된 모든 데이터를 잃을 수 있습니다.
|
||||
|
||||
사용 가능한 모든 명령어를 보기 위해서는 `make` 를 실행하십시오.
|
||||
|
||||
### 모두를 위한 링크들
|
||||
|
||||
* [BigchainDB.com ](https://www.bigchaindb.com/)- 뉴스 레터 가입을 포함하는 BigchainDB 주요 웹 사이트
|
||||
* [로드맵](https://github.com/bigchaindb/org/blob/master/ROADMAP.md)
|
||||
* [블로그](https://medium.com/the-bigchaindb-blog)
|
||||
* [트위터](https://twitter.com/BigchainDB)
|
||||
|
||||
### 개발자들을 위한 링크들
|
||||
|
||||
* [모든 BigchainDB 문서](https://docs.bigchaindb.com/en/latest/)
|
||||
* [BigchainDB 서버 문서](https://docs.bigchaindb.com/projects/server/en/latest/index.html)
|
||||
* [CONTRIBUTING.md](https://github.com/bigchaindb/bigchaindb/blob/master/.github/CONTRIBUTING.md) - 기여를 하는 방법
|
||||
* [커뮤니티 가이드라인](https://github.com/bigchaindb/bigchaindb/blob/master/CODE_OF_CONDUCT.md)
|
||||
* [이슈 작성](https://github.com/bigchaindb/bigchaindb/issues)
|
||||
* [pull request 하기](https://github.com/bigchaindb/bigchaindb/pulls)
|
||||
* [Gitter 채팅방](https://gitter.im/bigchaindb/bigchaindb)
|
||||
|
||||
### 합법
|
||||
|
||||
* [라이선스](https://github.com/bigchaindb/bigchaindb/blob/master/LICENSES.md) - 오픈 소스 & 오픈 콘텐츠
|
||||
* [발행](https://www.bigchaindb.com/imprint/)
|
||||
* [연락처](https://www.bigchaindb.com/contact/)
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
@ -45,33 +46,39 @@ The following steps are what we do to release a new version of _BigchainDB Serve
|
|||
- In `bigchaindb/version.py`:
|
||||
- update `__version__` to e.g. `0.9.0` (with no `.dev` on the end)
|
||||
- update `__short_version__` to e.g. `0.9` (with no `.dev` on the end)
|
||||
- In the docs about installing BigchainDB (and Tendermint), and in the associated scripts, recommend/install a version of Tendermint that _actually works_ with the soon-to-be-released version of BigchainDB. You can find all such references by doing a search for the previously-recommended version number, such as `0.22.8`.
|
||||
- In the docs about installing BigchainDB (and Tendermint), and in the associated scripts, recommend/install a version of Tendermint that _actually works_ with the soon-to-be-released version of BigchainDB. You can find all such references by doing a search for the previously-recommended version number, such as `0.31.5`.
|
||||
- In `setup.py`, _maybe_ update the development status item in the `classifiers` list. For example, one allowed value is `"Development Status :: 5 - Production/Stable"`. The [allowed values are listed at pypi.python.org](https://pypi.python.org/pypi?%3Aaction=list_classifiers).
|
||||
|
||||
1. **Wait for all the tests to pass!**
|
||||
1. Merge the pull request into the `master` branch.
|
||||
1. Go to the [bigchaindb/bigchaindb Releases page on GitHub](https://github.com/bigchaindb/bigchaindb/releases)
|
||||
2. **Wait for all the tests to pass!**
|
||||
3. Merge the pull request into the `master` branch.
|
||||
4. Go to the [bigchaindb/bigchaindb Releases page on GitHub](https://github.com/bigchaindb/bigchaindb/releases)
|
||||
and click the "Draft a new release" button.
|
||||
1. Fill in the details:
|
||||
5. Fill in the details:
|
||||
- **Tag version:** version number preceded by `v`, e.g. `v0.9.1`
|
||||
- **Target:** the last commit that was just merged. In other words, that commit will get a Git tag with the value given for tag version above.
|
||||
- **Title:** Same as tag version above, e.g `v0.9.1`
|
||||
- **Description:** The body of the changelog entry (Added, Changed, etc.)
|
||||
1. Click "Publish release" to publish the release on GitHub.
|
||||
1. On your local computer, make sure you're on the `master` branch and that it's up-to-date with the `master` branch in the bigchaindb/bigchaindb repository (e.g. `git pull upstream master`). We're going to use that to push a new `bigchaindb` package to PyPI.
|
||||
1. Make sure you have a `~/.pypirc` file containing credentials for PyPI.
|
||||
1. Do `make release` to build and publish the new `bigchaindb` package on PyPI.
|
||||
1. [Log in to readthedocs.org](https://readthedocs.org/accounts/login/) and go to the **BigchainDB Server** project, then:
|
||||
6. Click "Publish release" to publish the release on GitHub.
|
||||
7. On your local computer, make sure you're on the `master` branch and that it's up-to-date with the `master` branch in the bigchaindb/bigchaindb repository (e.g. `git pull upstream master`). We're going to use that to push a new `bigchaindb` package to PyPI.
|
||||
8. Make sure you have a `~/.pypirc` file containing credentials for PyPI.
|
||||
9. Do `make release` to build and publish the new `bigchaindb` package on PyPI. For this step you need to have `twine` installed. If you get an error like `Makefile:135: recipe for target 'clean-pyc' failed` then try doing
|
||||
```text
|
||||
sudo chown -R $(whoami):$(whoami) .
|
||||
```
|
||||
10. [Log in to readthedocs.org](https://readthedocs.org/accounts/login/) and go to the **BigchainDB Server** project, then:
|
||||
- Click on "Builds", select "latest" from the drop-down menu, then click the "Build Version:" button.
|
||||
- Wait for the build of "latest" to finish. This can take a few minutes.
|
||||
- Go to Admin --> Advanced Settings
|
||||
and make sure that "Default branch:" (i.e. what "latest" points to)
|
||||
is set to the new release's tag, e.g. `v0.9.1`.
|
||||
(Don't miss the `v` in front.)
|
||||
(It won't be an option if you didn't wait for the build of "latest" to finish.)
|
||||
Then scroll to the bottom and click "Save".
|
||||
- Go to Admin --> Versions
|
||||
and under **Choose Active Versions**, do these things:
|
||||
1. Make sure that the new version's tag is "Active" and "Public"
|
||||
1. Make sure the **stable** branch is _not_ active.
|
||||
1. Scroll to the bottom of the page and click the "Submit" button.
|
||||
1. Go to [Docker Hub](https://hub.docker.com/) and sign in, then:
|
||||
2. Make sure the **stable** branch is _not_ active.
|
||||
3. Scroll to the bottom of the page and click "Save".
|
||||
11. Go to [Docker Hub](https://hub.docker.com/) and sign in, then:
|
||||
- Click on "Organizations"
|
||||
- Click on "bigchaindb"
|
||||
- Click on "bigchaindb/bigchaindb"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
|
|
@ -5,5 +5,5 @@ RUN pip install --upgrade \
|
|||
pycco \
|
||||
websocket-client~=0.47.0 \
|
||||
pytest~=3.0 \
|
||||
bigchaindb-driver~=0.5.0 \
|
||||
bigchaindb-driver~=0.6.2 \
|
||||
blns
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -61,7 +62,7 @@ def test_basic():
|
|||
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)
|
||||
sent_transfer_tx = bdb.transactions.send_commit(fulfilled_creation_tx)
|
||||
|
||||
# And just to be 100% sure, she also checks if she can retrieve
|
||||
# it from the BigchainDB node.
|
||||
|
@ -107,7 +108,7 @@ def test_basic():
|
|||
private_keys=alice.private_key)
|
||||
|
||||
# She finally sends the transaction to a BigchainDB node.
|
||||
sent_transfer_tx = bdb.transactions.send(fulfilled_transfer_tx)
|
||||
sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)
|
||||
|
||||
# And just to be 100% sure, she also checks if she can retrieve
|
||||
# it from the BigchainDB node.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -74,7 +75,7 @@ def test_divisible_assets():
|
|||
prepared_token_tx,
|
||||
private_keys=alice.private_key)
|
||||
|
||||
bdb.transactions.send(fulfilled_token_tx, mode='commit')
|
||||
bdb.transactions.send_commit(fulfilled_token_tx)
|
||||
|
||||
# We store the `id` of the transaction to use it later on.
|
||||
bike_token_id = fulfilled_token_tx['id']
|
||||
|
@ -116,8 +117,7 @@ def test_divisible_assets():
|
|||
prepared_transfer_tx,
|
||||
private_keys=bob.private_key)
|
||||
|
||||
sent_transfer_tx = bdb.transactions.send(fulfilled_transfer_tx,
|
||||
mode='commit')
|
||||
sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)
|
||||
|
||||
# First, Bob checks if the transaction was successful.
|
||||
assert bdb.transactions.retrieve(
|
||||
|
@ -167,7 +167,7 @@ def test_divisible_assets():
|
|||
# Remember Bob, last time you spent 3 tokens already,
|
||||
# so you only have 7 left.
|
||||
with pytest.raises(BadRequest) as error:
|
||||
bdb.transactions.send(fulfilled_transfer_tx, mode='commit')
|
||||
bdb.transactions.send_commit(fulfilled_transfer_tx)
|
||||
|
||||
# Now Bob gets an error saying that the amount he wanted to spent is
|
||||
# higher than the amount of tokens he has left.
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -30,7 +31,7 @@ def test_double_create():
|
|||
|
||||
def send_and_queue(tx):
|
||||
try:
|
||||
bdb.transactions.send(tx)
|
||||
bdb.transactions.send_commit(tx)
|
||||
results.put('OK')
|
||||
except bigchaindb_driver.exceptions.TransportError as e:
|
||||
results.put('FAIL')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -64,7 +65,7 @@ def test_multiple_owners():
|
|||
prepared_dw_tx,
|
||||
private_keys=[alice.private_key, bob.private_key])
|
||||
|
||||
bdb.transactions.send(fulfilled_dw_tx, mode='commit')
|
||||
bdb.transactions.send_commit(fulfilled_dw_tx)
|
||||
|
||||
# We store the `id` of the transaction to use it later on.
|
||||
dw_id = fulfilled_dw_tx['id']
|
||||
|
@ -109,8 +110,7 @@ def test_multiple_owners():
|
|||
prepared_transfer_tx,
|
||||
private_keys=[alice.private_key, bob.private_key])
|
||||
|
||||
sent_transfer_tx = bdb.transactions.send(fulfilled_transfer_tx,
|
||||
mode='commit')
|
||||
sent_transfer_tx = bdb.transactions.send_commit(fulfilled_transfer_tx)
|
||||
|
||||
# They check if the transaction was successful.
|
||||
assert bdb.transactions.retrieve(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -54,7 +55,7 @@ def send_naughty_tx(asset, metadata):
|
|||
|
||||
# The fulfilled tx gets sent to the BDB network
|
||||
try:
|
||||
sent_transaction = bdb.transactions.send(fulfilled_transaction)
|
||||
sent_transaction = bdb.transactions.send_commit(fulfilled_transaction)
|
||||
except BadRequest as e:
|
||||
sent_transaction = e
|
||||
|
||||
|
@ -65,8 +66,12 @@ def send_naughty_tx(asset, metadata):
|
|||
# Then she expects a nicely formatted error code
|
||||
status_code = sent_transaction.status_code
|
||||
error = sent_transaction.error
|
||||
regex = '\{"message":"Invalid transaction \\(ValidationError\\): Invalid key name .* in asset object. ' \
|
||||
'The key name cannot contain characters .* or null characters","status":400\}\n'
|
||||
regex = (
|
||||
r'\{\s*\n*'
|
||||
r'\s*"message":\s*"Invalid transaction \(ValidationError\):\s*'
|
||||
r'Invalid key name.*The key name cannot contain characters.*\n*'
|
||||
r'\s*"status":\s*400\n*'
|
||||
r'\s*\}\n*')
|
||||
assert status_code == 400
|
||||
assert re.fullmatch(regex, error), sent_transaction
|
||||
# Otherwise, she expects to see her transaction in the database
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -100,7 +101,7 @@ def test_stream():
|
|||
# transactions to be in the shared queue: this is a two phase test,
|
||||
# first we send a bunch of transactions, then we check if they are
|
||||
# valid (and, in this case, they should).
|
||||
bdb.transactions.send(tx, mode='async')
|
||||
bdb.transactions.send_async(tx)
|
||||
|
||||
# The `id` of every sent transaction is then stored in a list.
|
||||
sent.append(tx['id'])
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
@ -18,9 +19,9 @@ The `BigchainDB` class is defined here. Most node-level operations and database
|
|||
|
||||
`Block`, `Transaction`, and `Asset` classes are defined here. The classes mirror the block and transaction structure from the [documentation](https://docs.bigchaindb.com/projects/server/en/latest/data-models/index.html), but also include methods for validation and signing.
|
||||
|
||||
### [`consensus.py`](./consensus.py)
|
||||
### [`validation.py`](./validation.py)
|
||||
|
||||
Base class for consensus methods (verification of votes, blocks, and transactions). The actual logic is mostly found in `transaction` and `block` models, defined in [`models.py`](./models.py).
|
||||
Base class for validation methods (verification of votes, blocks, and transactions). The actual logic is mostly found in `transaction` and `block` models, defined in [`models.py`](./models.py).
|
||||
|
||||
### [`processes.py`](./processes.py)
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -70,6 +71,7 @@ config = {
|
|||
'tendermint': {
|
||||
'host': 'localhost',
|
||||
'port': 26657,
|
||||
'version': 'v0.31.5', # look for __tm_supported_versions__
|
||||
},
|
||||
# FIXME: hardcoding to localmongodb for now
|
||||
'database': _database_map['localmongodb'],
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
from itertools import repeat
|
||||
from importlib import import_module
|
||||
import logging
|
||||
from importlib import import_module
|
||||
from itertools import repeat
|
||||
|
||||
import bigchaindb
|
||||
from bigchaindb.common.exceptions import ConfigurationError
|
||||
from bigchaindb.backend.exceptions import ConnectionError
|
||||
|
||||
from bigchaindb.backend.utils import get_bigchaindb_config_value, get_bigchaindb_config_value_or_key_error
|
||||
from bigchaindb.common.exceptions import ConfigurationError
|
||||
|
||||
BACKENDS = {
|
||||
'localmongodb': 'bigchaindb.backend.localmongodb.connection.LocalMongoDBConnection',
|
||||
|
@ -47,10 +48,10 @@ def connect(backend=None, host=None, port=None, name=None, max_tries=None,
|
|||
Authentication failure after connecting to the database.
|
||||
"""
|
||||
|
||||
backend = backend or bigchaindb.config['database']['backend']
|
||||
host = host or bigchaindb.config['database']['host']
|
||||
port = port or bigchaindb.config['database']['port']
|
||||
dbname = name or bigchaindb.config['database']['name']
|
||||
backend = backend or get_bigchaindb_config_value_or_key_error('backend')
|
||||
host = host or get_bigchaindb_config_value_or_key_error('host')
|
||||
port = port or get_bigchaindb_config_value_or_key_error('port')
|
||||
dbname = name or get_bigchaindb_config_value_or_key_error('name')
|
||||
# Not sure how to handle this here. This setting is only relevant for
|
||||
# mongodb.
|
||||
# I added **kwargs for both RethinkDBConnection and MongoDBConnection
|
||||
|
@ -60,15 +61,15 @@ def connect(backend=None, host=None, port=None, name=None, max_tries=None,
|
|||
# UPD: RethinkDBConnection is not here anymore cause we no longer support RethinkDB.
|
||||
# The problem described above might be reconsidered next time we introduce a backend,
|
||||
# if it ever happens.
|
||||
replicaset = replicaset or bigchaindb.config['database'].get('replicaset')
|
||||
ssl = ssl if ssl is not None else bigchaindb.config['database'].get('ssl', False)
|
||||
login = login or bigchaindb.config['database'].get('login')
|
||||
password = password or bigchaindb.config['database'].get('password')
|
||||
ca_cert = ca_cert or bigchaindb.config['database'].get('ca_cert', None)
|
||||
certfile = certfile or bigchaindb.config['database'].get('certfile', None)
|
||||
keyfile = keyfile or bigchaindb.config['database'].get('keyfile', None)
|
||||
keyfile_passphrase = keyfile_passphrase or bigchaindb.config['database'].get('keyfile_passphrase', None)
|
||||
crlfile = crlfile or bigchaindb.config['database'].get('crlfile', None)
|
||||
replicaset = replicaset or get_bigchaindb_config_value('replicaset')
|
||||
ssl = ssl if ssl is not None else get_bigchaindb_config_value('ssl', False)
|
||||
login = login or get_bigchaindb_config_value('login')
|
||||
password = password or get_bigchaindb_config_value('password')
|
||||
ca_cert = ca_cert or get_bigchaindb_config_value('ca_cert')
|
||||
certfile = certfile or get_bigchaindb_config_value('certfile')
|
||||
keyfile = keyfile or get_bigchaindb_config_value('keyfile')
|
||||
keyfile_passphrase = keyfile_passphrase or get_bigchaindb_config_value('keyfile_passphrase', None)
|
||||
crlfile = crlfile or get_bigchaindb_config_value('crlfile')
|
||||
|
||||
try:
|
||||
module_name, _, class_name = BACKENDS[backend].rpartition('.')
|
||||
|
@ -117,7 +118,7 @@ class Connection:
|
|||
self.host = host or dbconf['host']
|
||||
self.port = port or dbconf['port']
|
||||
self.dbname = dbname or dbconf['name']
|
||||
self.connection_timeout = connection_timeout if connection_timeout is not None\
|
||||
self.connection_timeout = connection_timeout if connection_timeout is not None \
|
||||
else dbconf['connection_timeout']
|
||||
self.max_tries = max_tries if max_tries is not None else dbconf['max_tries']
|
||||
self.max_tries_counter = range(self.max_tries) if self.max_tries != 0 else repeat(0)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -7,13 +8,13 @@ from ssl import CERT_REQUIRED
|
|||
|
||||
import pymongo
|
||||
|
||||
import bigchaindb
|
||||
from bigchaindb.utils import Lazy
|
||||
from bigchaindb.common.exceptions import ConfigurationError
|
||||
from bigchaindb.backend.connection import Connection
|
||||
from bigchaindb.backend.exceptions import (DuplicateKeyError,
|
||||
OperationError,
|
||||
ConnectionError)
|
||||
from bigchaindb.backend.connection import Connection
|
||||
from bigchaindb.backend.utils import get_bigchaindb_config_value
|
||||
from bigchaindb.common.exceptions import ConfigurationError
|
||||
from bigchaindb.utils import Lazy
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -33,15 +34,15 @@ class LocalMongoDBConnection(Connection):
|
|||
"""
|
||||
|
||||
super().__init__(**kwargs)
|
||||
self.replicaset = replicaset or bigchaindb.config['database'].get('replicaset')
|
||||
self.ssl = ssl if ssl is not None else bigchaindb.config['database'].get('ssl', False)
|
||||
self.login = login or bigchaindb.config['database'].get('login')
|
||||
self.password = password or bigchaindb.config['database'].get('password')
|
||||
self.ca_cert = ca_cert or bigchaindb.config['database'].get('ca_cert', None)
|
||||
self.certfile = certfile or bigchaindb.config['database'].get('certfile', None)
|
||||
self.keyfile = keyfile or bigchaindb.config['database'].get('keyfile', None)
|
||||
self.keyfile_passphrase = keyfile_passphrase or bigchaindb.config['database'].get('keyfile_passphrase', None)
|
||||
self.crlfile = crlfile or bigchaindb.config['database'].get('crlfile', None)
|
||||
self.replicaset = replicaset or get_bigchaindb_config_value('replicaset')
|
||||
self.ssl = ssl if ssl is not None else get_bigchaindb_config_value('ssl', False)
|
||||
self.login = login or get_bigchaindb_config_value('login')
|
||||
self.password = password or get_bigchaindb_config_value('password')
|
||||
self.ca_cert = ca_cert or get_bigchaindb_config_value('ca_cert')
|
||||
self.certfile = certfile or get_bigchaindb_config_value('certfile')
|
||||
self.keyfile = keyfile or get_bigchaindb_config_value('keyfile')
|
||||
self.keyfile_passphrase = keyfile_passphrase or get_bigchaindb_config_value('keyfile_passphrase')
|
||||
self.crlfile = crlfile or get_bigchaindb_config_value('crlfile')
|
||||
|
||||
@property
|
||||
def db(self):
|
||||
|
@ -62,7 +63,7 @@ class LocalMongoDBConnection(Connection):
|
|||
try:
|
||||
try:
|
||||
return query.run(self.conn)
|
||||
except pymongo.errors.AutoReconnect as exc:
|
||||
except pymongo.errors.AutoReconnect:
|
||||
logger.warning('Lost connection to the database, '
|
||||
'retrying query.')
|
||||
return query.run(self.conn)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -91,8 +92,11 @@ def get_assets(conn, asset_ids):
|
|||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_spent(conn, transaction_id, output):
|
||||
query = {'inputs.fulfills': {'transaction_id': transaction_id,
|
||||
'output_index': output}}
|
||||
query = {'inputs':
|
||||
{'$elemMatch':
|
||||
{'$and': [{'fulfills.transaction_id': transaction_id},
|
||||
{'fulfills.output_index': output}]}}}
|
||||
|
||||
return conn.run(
|
||||
conn.collection('transactions')
|
||||
.find(query, {'_id': 0}))
|
||||
|
@ -117,29 +121,19 @@ def store_block(conn, block):
|
|||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_txids_filtered(conn, asset_id, operation=None):
|
||||
match_create = {
|
||||
'operation': 'CREATE',
|
||||
'id': asset_id
|
||||
}
|
||||
match_transfer = {
|
||||
'operation': 'TRANSFER',
|
||||
'asset.id': asset_id
|
||||
}
|
||||
def get_txids_filtered(conn, asset_id, operation=None, last_tx=None):
|
||||
|
||||
if operation == Transaction.CREATE:
|
||||
match = match_create
|
||||
elif operation == Transaction.TRANSFER:
|
||||
match = match_transfer
|
||||
else:
|
||||
match = {'$or': [match_create, match_transfer]}
|
||||
match = {
|
||||
Transaction.CREATE: {'operation': 'CREATE', 'id': asset_id},
|
||||
Transaction.TRANSFER: {'operation': 'TRANSFER', 'asset.id': asset_id},
|
||||
None: {'$or': [{'asset.id': asset_id}, {'id': asset_id}]},
|
||||
}[operation]
|
||||
|
||||
cursor = conn.run(conn.collection('transactions').find(match))
|
||||
|
||||
if last_tx:
|
||||
cursor = cursor.sort([('$natural', DESCENDING)]).limit(1)
|
||||
|
||||
pipeline = [
|
||||
{'$match': match}
|
||||
]
|
||||
cursor = conn.run(
|
||||
conn.collection('transactions')
|
||||
.aggregate(pipeline))
|
||||
return (elem['id'] for elem in cursor)
|
||||
|
||||
|
||||
|
@ -180,15 +174,18 @@ def get_owned_ids(conn, owner):
|
|||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_spending_transactions(conn, inputs):
|
||||
transaction_ids = [i['transaction_id'] for i in inputs]
|
||||
output_indexes = [i['output_index'] for i in inputs]
|
||||
query = {'inputs':
|
||||
{'$elemMatch':
|
||||
{'$and':
|
||||
[
|
||||
{'fulfills.transaction_id': {'$in': transaction_ids}},
|
||||
{'fulfills.output_index': {'$in': output_indexes}}
|
||||
]}}}
|
||||
|
||||
cursor = conn.run(
|
||||
conn.collection('transactions').aggregate([
|
||||
{'$match': {
|
||||
'inputs.fulfills': {
|
||||
'$in': inputs,
|
||||
},
|
||||
}},
|
||||
{'$project': {'_id': False}}
|
||||
]))
|
||||
conn.collection('transactions').find(query, {'_id': False}))
|
||||
return cursor
|
||||
|
||||
|
||||
|
@ -255,18 +252,15 @@ def get_unspent_outputs(conn, *, query=None):
|
|||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def store_pre_commit_state(conn, state):
|
||||
commit_id = state['commit_id']
|
||||
return conn.run(
|
||||
conn.collection('pre_commit')
|
||||
.replace_one({'commit_id': commit_id}, state, upsert=True)
|
||||
.replace_one({}, state, upsert=True)
|
||||
)
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_pre_commit_state(conn, commit_id):
|
||||
return conn.run(conn.collection('pre_commit')
|
||||
.find_one({'commit_id': commit_id},
|
||||
projection={'_id': False}))
|
||||
def get_pre_commit_state(conn):
|
||||
return conn.run(conn.collection('pre_commit').find_one())
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
|
@ -282,17 +276,40 @@ def store_validator_set(conn, validators_update):
|
|||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def store_election_results(conn, election):
|
||||
height = election['height']
|
||||
def delete_validator_set(conn, height):
|
||||
return conn.run(
|
||||
conn.collection('validators').delete_many({'height': height})
|
||||
)
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def store_election(conn, election_id, height, is_concluded):
|
||||
return conn.run(
|
||||
conn.collection('elections').replace_one(
|
||||
{'height': height},
|
||||
election,
|
||||
upsert=True
|
||||
{'election_id': election_id,
|
||||
'height': height},
|
||||
{'election_id': election_id,
|
||||
'height': height,
|
||||
'is_concluded': is_concluded},
|
||||
upsert=True,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def store_elections(conn, elections):
|
||||
return conn.run(
|
||||
conn.collection('elections').insert_many(elections)
|
||||
)
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def delete_elections(conn, height):
|
||||
return conn.run(
|
||||
conn.collection('elections').delete_many({'height': height})
|
||||
)
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_validator_set(conn, height=None):
|
||||
query = {}
|
||||
|
@ -313,13 +330,12 @@ def get_validator_set(conn, height=None):
|
|||
def get_election(conn, election_id):
|
||||
query = {'election_id': election_id}
|
||||
|
||||
cursor = conn.run(
|
||||
return conn.run(
|
||||
conn.collection('elections')
|
||||
.find(query, projection={'_id': False})
|
||||
.find_one(query, projection={'_id': False},
|
||||
sort=[('height', DESCENDING)])
|
||||
)
|
||||
|
||||
return next(cursor, None)
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_asset_tokens_for_public_key(conn, asset_id, public_key):
|
||||
|
@ -346,6 +362,13 @@ def store_abci_chain(conn, height, chain_id, is_synced=True):
|
|||
)
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def delete_abci_chain(conn, height):
|
||||
return conn.run(
|
||||
conn.collection('abci_chains').delete_many({'height': height})
|
||||
)
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_latest_abci_chain(conn):
|
||||
return conn.run(
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -42,10 +43,11 @@ INDEXES = {
|
|||
('output_index', ASCENDING)], dict(name='utxo', unique=True)),
|
||||
],
|
||||
'pre_commit': [
|
||||
('commit_id', dict(name='pre_commit_id', unique=True)),
|
||||
('height', dict(name='height', unique=True)),
|
||||
],
|
||||
'elections': [
|
||||
('election_id', dict(name='election_id', unique=True)),
|
||||
([('height', DESCENDING), ('election_id', ASCENDING)],
|
||||
dict(name='election_id_height', unique=True)),
|
||||
],
|
||||
'validators': [
|
||||
('height', dict(name='height', unique=True)),
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -8,9 +9,6 @@ from functools import singledispatch
|
|||
|
||||
from bigchaindb.backend.exceptions import OperationError
|
||||
|
||||
VALIDATOR_UPDATE_ID = 'a_unique_id_string'
|
||||
PRE_COMMIT_ID = 'a_unique_id_string'
|
||||
|
||||
|
||||
@singledispatch
|
||||
def store_asset(connection, asset):
|
||||
|
@ -316,12 +314,11 @@ def get_unspent_outputs(connection, *, query=None):
|
|||
|
||||
|
||||
@singledispatch
|
||||
def store_pre_commit_state(connection, commit_id, state):
|
||||
"""Store pre-commit state in a document with `id` as `commit_id`.
|
||||
def store_pre_commit_state(connection, state):
|
||||
"""Store pre-commit state.
|
||||
|
||||
Args:
|
||||
commit_id (string): `id` of document where `state` should be stored.
|
||||
state (dict): commit state.
|
||||
state (dict): pre-commit state.
|
||||
|
||||
Returns:
|
||||
The result of the operation.
|
||||
|
@ -331,14 +328,11 @@ def store_pre_commit_state(connection, commit_id, state):
|
|||
|
||||
|
||||
@singledispatch
|
||||
def get_pre_commit_state(connection, commit_id):
|
||||
"""Get pre-commit state where `id` is `commit_id`.
|
||||
|
||||
Args:
|
||||
commit_id (string): `id` of document where `state` should be stored.
|
||||
def get_pre_commit_state(connection):
|
||||
"""Get pre-commit state.
|
||||
|
||||
Returns:
|
||||
Document with `id` as `commit_id`
|
||||
Document representing the pre-commit state.
|
||||
"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
@ -352,8 +346,29 @@ def store_validator_set(conn, validator_update):
|
|||
|
||||
|
||||
@singledispatch
|
||||
def store_election_results(conn, election):
|
||||
"""Store election results"""
|
||||
def delete_validator_set(conn, height):
|
||||
"""Delete the validator set at the given height."""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@singledispatch
|
||||
def store_election(conn, election_id, height, is_concluded):
|
||||
"""Store election record"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@singledispatch
|
||||
def store_elections(conn, elections):
|
||||
"""Store election records in bulk"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@singledispatch
|
||||
def delete_elections(conn, height):
|
||||
"""Delete all election records at the given height"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
|
@ -369,7 +384,7 @@ def get_validator_set(conn, height):
|
|||
|
||||
@singledispatch
|
||||
def get_election(conn, election_id):
|
||||
"""Return a validator set change with the specified election_id
|
||||
"""Return the election record
|
||||
"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
@ -396,6 +411,14 @@ def store_abci_chain(conn, height, chain_id, is_synced=True):
|
|||
Args:
|
||||
is_synced: True if the chain is known by both ABCI client and server
|
||||
"""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
@singledispatch
|
||||
def delete_abci_chain(conn, height):
|
||||
"""Delete the ABCI chain at the given height."""
|
||||
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -10,7 +11,7 @@ import logging
|
|||
import bigchaindb
|
||||
from bigchaindb.backend.connection import connect
|
||||
from bigchaindb.common.exceptions import ValidationError
|
||||
from bigchaindb.common.utils import validate_all_values_for_key
|
||||
from bigchaindb.common.utils import validate_all_values_for_key_in_obj, validate_all_values_for_key_in_list
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -101,7 +102,9 @@ def validate_language_key(obj, key):
|
|||
if backend == 'localmongodb':
|
||||
data = obj.get(key, {})
|
||||
if isinstance(data, dict):
|
||||
validate_all_values_for_key(data, 'language', validate_language)
|
||||
validate_all_values_for_key_in_obj(data, 'language', validate_language)
|
||||
elif isinstance(data, list):
|
||||
validate_all_values_for_key_in_list(data, 'language', validate_language)
|
||||
|
||||
|
||||
def validate_language(value):
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import bigchaindb
|
||||
|
||||
|
||||
class ModuleDispatchRegistrationError(Exception):
|
||||
"""Raised when there is a problem registering dispatched functions for a
|
||||
|
@ -21,6 +24,16 @@ def module_dispatch_registrar(module):
|
|||
('`{module}` does not contain a single-dispatchable '
|
||||
'function named `{func}`. The module being registered '
|
||||
'was not implemented correctly!').format(
|
||||
func=func_name, module=module.__name__)) from ex
|
||||
func=func_name, module=module.__name__)) from ex
|
||||
|
||||
return wrapper
|
||||
|
||||
return dispatch_wrapper
|
||||
|
||||
|
||||
def get_bigchaindb_config_value(key, default_value=None):
|
||||
return bigchaindb.config['database'].get(key, default_value)
|
||||
|
||||
|
||||
def get_bigchaindb_config_value_or_key_error(key):
|
||||
return bigchaindb.config['database'][key]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -13,8 +14,10 @@ import copy
|
|||
import json
|
||||
import sys
|
||||
|
||||
from bigchaindb.core import rollback
|
||||
from bigchaindb.migrations.chain_migration_election import ChainMigrationElection
|
||||
from bigchaindb.utils import load_node_key
|
||||
from bigchaindb.common.transaction_mode_types import BROADCAST_TX_COMMIT
|
||||
from bigchaindb.common.exceptions import (DatabaseDoesNotExist,
|
||||
ValidationError)
|
||||
from bigchaindb.elections.vote import Vote
|
||||
|
@ -22,8 +25,6 @@ import bigchaindb
|
|||
from bigchaindb import (backend, ValidatorElection,
|
||||
BigchainDB)
|
||||
from bigchaindb.backend import schema
|
||||
from bigchaindb.backend import query
|
||||
from bigchaindb.backend.query import PRE_COMMIT_ID
|
||||
from bigchaindb.commands import utils
|
||||
from bigchaindb.commands.utils import (configure_bigchaindb,
|
||||
input_on_stderr)
|
||||
|
@ -118,7 +119,6 @@ def run_election_new(args, bigchain):
|
|||
|
||||
|
||||
def create_new_election(sk, bigchain, election_class, data):
|
||||
|
||||
try:
|
||||
key = load_node_key(sk)
|
||||
voters = election_class.recipients(bigchain)
|
||||
|
@ -133,7 +133,7 @@ def create_new_election(sk, bigchain, election_class, data):
|
|||
logger.error(fd_404)
|
||||
return False
|
||||
|
||||
resp = bigchain.write_transaction(election, 'broadcast_tx_commit')
|
||||
resp = bigchain.write_transaction(election, BROADCAST_TX_COMMIT)
|
||||
if resp == (202, ''):
|
||||
logger.info('[SUCCESS] Submitted proposal with id: {}'.format(election.id))
|
||||
return election.id
|
||||
|
@ -208,7 +208,7 @@ def run_election_approve(args, bigchain):
|
|||
tx.id).sign([key.private_key])
|
||||
approval.validate(bigchain)
|
||||
|
||||
resp = bigchain.write_transaction(approval, 'broadcast_tx_commit')
|
||||
resp = bigchain.write_transaction(approval, BROADCAST_TX_COMMIT)
|
||||
|
||||
if resp == (202, ''):
|
||||
logger.info('[SUCCESS] Your vote has been submitted')
|
||||
|
@ -263,7 +263,6 @@ def run_drop(args):
|
|||
return
|
||||
|
||||
conn = backend.connect()
|
||||
dbname = bigchaindb.config['database']['name']
|
||||
try:
|
||||
schema.drop_database(conn, dbname)
|
||||
except DatabaseDoesNotExist:
|
||||
|
@ -271,16 +270,7 @@ def run_drop(args):
|
|||
|
||||
|
||||
def run_recover(b):
|
||||
pre_commit = query.get_pre_commit_state(b.connection, PRE_COMMIT_ID)
|
||||
|
||||
# Initially the pre-commit collection would be empty
|
||||
if pre_commit:
|
||||
latest_block = query.get_latest_block(b.connection)
|
||||
|
||||
# NOTE: the pre-commit state can only be ahead of the commited state
|
||||
# by 1 block
|
||||
if latest_block and (latest_block['height'] < pre_commit['height']):
|
||||
query.delete_transactions(b.connection, pre_commit['transactions'])
|
||||
rollback(b)
|
||||
|
||||
|
||||
@configure_bigchaindb
|
||||
|
@ -362,6 +352,7 @@ def create_parser():
|
|||
help='The election_id of the election.')
|
||||
approve_election_parser.add_argument('--private-key',
|
||||
dest='sk',
|
||||
required=True,
|
||||
help='Path to the private key of the election initiator.')
|
||||
|
||||
show_election_parser = election_subparser.add_parser('show',
|
||||
|
|
|
@ -13,6 +13,7 @@ elections = {
|
|||
},
|
||||
'--private-key': {
|
||||
'dest': 'sk',
|
||||
'required': True,
|
||||
'help': 'Path to the private key of the election initiator.'
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +23,7 @@ elections = {
|
|||
'args': {
|
||||
'--private-key': {
|
||||
'dest': 'sk',
|
||||
'required': True,
|
||||
'help': 'Path to the private key of the election initiator.'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,11 +1,16 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
# Separate all crypto code so that we can easily test several implementations
|
||||
from collections import namedtuple
|
||||
|
||||
import sha3
|
||||
try:
|
||||
from hashlib import sha3_256
|
||||
except ImportError:
|
||||
from sha3 import sha3_256
|
||||
|
||||
from cryptoconditions import crypto
|
||||
|
||||
|
||||
|
@ -14,7 +19,7 @@ CryptoKeypair = namedtuple('CryptoKeypair', ('private_key', 'public_key'))
|
|||
|
||||
def hash_data(data):
|
||||
"""Hash the provided data using SHA3-256"""
|
||||
return sha3.sha3_256(data.encode()).hexdigest()
|
||||
return sha3_256(data.encode()).hexdigest()
|
||||
|
||||
|
||||
def generate_key_pair():
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<!---
|
||||
Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
BigchainDB and IPDB software contributors.
|
||||
SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -19,7 +20,10 @@ import base58
|
|||
from cryptoconditions import Fulfillment, ThresholdSha256, Ed25519Sha256
|
||||
from cryptoconditions.exceptions import (
|
||||
ParsingError, ASN1DecodeError, ASN1EncodeError, UnsupportedTypeError)
|
||||
from sha3 import sha3_256
|
||||
try:
|
||||
from hashlib import sha3_256
|
||||
except ImportError:
|
||||
from sha3 import sha3_256
|
||||
|
||||
from bigchaindb.common.crypto import PrivateKey, hash_data
|
||||
from bigchaindb.common.exceptions import (KeypairMismatchException,
|
||||
|
@ -74,7 +78,7 @@ class Input(object):
|
|||
if fulfills is not None and not isinstance(fulfills, TransactionLink):
|
||||
raise TypeError('`fulfills` must be a TransactionLink instance')
|
||||
if not isinstance(owners_before, list):
|
||||
raise TypeError('`owners_after` must be a list instance')
|
||||
raise TypeError('`owners_before` must be a list instance')
|
||||
|
||||
self.fulfillment = fulfillment
|
||||
self.fulfills = fulfills
|
||||
|
@ -542,7 +546,7 @@ class Transaction(object):
|
|||
elif (operation == self.TRANSFER and
|
||||
not (isinstance(asset, dict) and 'id' in asset)):
|
||||
raise TypeError(('`asset` must be a dict holding an `id` property '
|
||||
"for 'TRANSFER' Transactions".format(operation)))
|
||||
'for \'TRANSFER\' Transactions'))
|
||||
|
||||
if outputs and not isinstance(outputs, list):
|
||||
raise TypeError('`outputs` must be a list instance or None')
|
||||
|
@ -865,8 +869,9 @@ class Transaction(object):
|
|||
return cls._sign_threshold_signature_fulfillment(input_, message,
|
||||
key_pairs)
|
||||
else:
|
||||
raise ValueError("Fulfillment couldn't be matched to "
|
||||
'Cryptocondition fulfillment type.')
|
||||
raise ValueError(
|
||||
'Fulfillment couldn\'t be matched to '
|
||||
'Cryptocondition fulfillment type.')
|
||||
|
||||
@classmethod
|
||||
def _sign_simple_signature_fulfillment(cls, input_, message, key_pairs):
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
BROADCAST_TX_COMMIT = 'broadcast_tx_commit'
|
||||
BROADCAST_TX_ASYNC = 'broadcast_tx_async'
|
||||
BROADCAST_TX_SYNC = 'broadcast_tx_sync'
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -76,10 +77,20 @@ def validate_txn_obj(obj_name, obj, key, validation_fun):
|
|||
if backend == 'localmongodb':
|
||||
data = obj.get(key, {})
|
||||
if isinstance(data, dict):
|
||||
validate_all_keys(obj_name, data, validation_fun)
|
||||
validate_all_keys_in_obj(obj_name, data, validation_fun)
|
||||
elif isinstance(data, list):
|
||||
validate_all_items_in_list(obj_name, data, validation_fun)
|
||||
|
||||
|
||||
def validate_all_keys(obj_name, obj, validation_fun):
|
||||
def validate_all_items_in_list(obj_name, data, validation_fun):
|
||||
for item in data:
|
||||
if isinstance(item, dict):
|
||||
validate_all_keys_in_obj(obj_name, item, validation_fun)
|
||||
elif isinstance(item, list):
|
||||
validate_all_items_in_list(obj_name, item, validation_fun)
|
||||
|
||||
|
||||
def validate_all_keys_in_obj(obj_name, obj, validation_fun):
|
||||
"""Validate all (nested) keys in `obj` by using `validation_fun`.
|
||||
|
||||
Args:
|
||||
|
@ -97,10 +108,12 @@ def validate_all_keys(obj_name, obj, validation_fun):
|
|||
for key, value in obj.items():
|
||||
validation_fun(obj_name, key)
|
||||
if isinstance(value, dict):
|
||||
validate_all_keys(obj_name, value, validation_fun)
|
||||
validate_all_keys_in_obj(obj_name, value, validation_fun)
|
||||
elif isinstance(value, list):
|
||||
validate_all_items_in_list(obj_name, value, validation_fun)
|
||||
|
||||
|
||||
def validate_all_values_for_key(obj, key, validation_fun):
|
||||
def validate_all_values_for_key_in_obj(obj, key, validation_fun):
|
||||
"""Validate value for all (nested) occurrence of `key` in `obj`
|
||||
using `validation_fun`.
|
||||
|
||||
|
@ -117,7 +130,17 @@ def validate_all_values_for_key(obj, key, validation_fun):
|
|||
if vkey == key:
|
||||
validation_fun(value)
|
||||
elif isinstance(value, dict):
|
||||
validate_all_values_for_key(value, key, validation_fun)
|
||||
validate_all_values_for_key_in_obj(value, key, validation_fun)
|
||||
elif isinstance(value, list):
|
||||
validate_all_values_for_key_in_list(value, key, validation_fun)
|
||||
|
||||
|
||||
def validate_all_values_for_key_in_list(input_list, key, validation_fun):
|
||||
for item in input_list:
|
||||
if isinstance(item, dict):
|
||||
validate_all_values_for_key_in_obj(item, key, validation_fun)
|
||||
elif isinstance(item, list):
|
||||
validate_all_values_for_key_in_list(item, key, validation_fun)
|
||||
|
||||
|
||||
def validate_key(obj_name, key):
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -19,7 +20,7 @@ import os
|
|||
import copy
|
||||
import json
|
||||
import logging
|
||||
import collections
|
||||
import collections.abc
|
||||
from functools import lru_cache
|
||||
|
||||
from pkg_resources import iter_entry_points, ResolutionError
|
||||
|
@ -28,7 +29,7 @@ from bigchaindb.common import exceptions
|
|||
|
||||
import bigchaindb
|
||||
|
||||
from bigchaindb.consensus import BaseConsensusRules
|
||||
from bigchaindb.validation import BaseValidationRules
|
||||
|
||||
# TODO: move this to a proper configuration file for logging
|
||||
logging.getLogger('requests').setLevel(logging.WARNING)
|
||||
|
@ -51,7 +52,7 @@ def map_leafs(func, mapping):
|
|||
path = []
|
||||
|
||||
for key, val in mapping.items():
|
||||
if isinstance(val, collections.Mapping):
|
||||
if isinstance(val, collections.abc.Mapping):
|
||||
_inner(val, path + [key])
|
||||
else:
|
||||
mapping[key] = func(val, path=path+[key])
|
||||
|
@ -79,7 +80,7 @@ def update(d, u):
|
|||
mapping: An updated version of d (updated by u).
|
||||
"""
|
||||
for k, v in u.items():
|
||||
if isinstance(v, collections.Mapping):
|
||||
if isinstance(v, collections.abc.Mapping):
|
||||
r = update(d.get(k, {}), v)
|
||||
d[k] = r
|
||||
else:
|
||||
|
@ -258,38 +259,38 @@ def autoconfigure(filename=None, config=None, force=False):
|
|||
|
||||
|
||||
@lru_cache()
|
||||
def load_consensus_plugin(name=None):
|
||||
"""Find and load the chosen consensus plugin.
|
||||
def load_validation_plugin(name=None):
|
||||
"""Find and load the chosen validation plugin.
|
||||
|
||||
Args:
|
||||
name (string): the name of the entry_point, as advertised in the
|
||||
setup.py of the providing package.
|
||||
|
||||
Returns:
|
||||
an uninstantiated subclass of ``bigchaindb.consensus.AbstractConsensusRules``
|
||||
an uninstantiated subclass of ``bigchaindb.validation.AbstractValidationRules``
|
||||
"""
|
||||
if not name:
|
||||
return BaseConsensusRules
|
||||
return BaseValidationRules
|
||||
|
||||
# TODO: This will return the first plugin with group `bigchaindb.consensus`
|
||||
# TODO: This will return the first plugin with group `bigchaindb.validation`
|
||||
# and name `name` in the active WorkingSet.
|
||||
# We should probably support Requirements specs in the config, e.g.
|
||||
# consensus_plugin: 'my-plugin-package==0.0.1;default'
|
||||
# validation_plugin: 'my-plugin-package==0.0.1;default'
|
||||
plugin = None
|
||||
for entry_point in iter_entry_points('bigchaindb.consensus', name):
|
||||
for entry_point in iter_entry_points('bigchaindb.validation', name):
|
||||
plugin = entry_point.load()
|
||||
|
||||
# No matching entry_point found
|
||||
if not plugin:
|
||||
raise ResolutionError(
|
||||
'No plugin found in group `bigchaindb.consensus` with name `{}`'.
|
||||
'No plugin found in group `bigchaindb.validation` with name `{}`'.
|
||||
format(name))
|
||||
|
||||
# Is this strictness desireable?
|
||||
# It will probably reduce developer headaches in the wild.
|
||||
if not issubclass(plugin, (BaseConsensusRules,)):
|
||||
if not issubclass(plugin, (BaseValidationRules,)):
|
||||
raise TypeError('object of type "{}" does not implement `bigchaindb.'
|
||||
'consensus.BaseConsensusRules`'.format(type(plugin)))
|
||||
'validation.BaseValidationRules`'.format(type(plugin)))
|
||||
|
||||
return plugin
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
# 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():
|
||||
"""Base consensus rules for Bigchain.
|
||||
|
||||
A consensus plugin must expose a class inheriting from this one via an entry_point.
|
||||
|
||||
All methods listed below must be implemented.
|
||||
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def validate_transaction(bigchain, transaction):
|
||||
"""See :meth:`bigchaindb.models.Transaction.validate`
|
||||
for documentation.
|
||||
"""
|
||||
return transaction.validate(bigchain)
|
||||
|
||||
@staticmethod
|
||||
def validate_block(bigchain, block):
|
||||
"""See :meth:`bigchaindb.models.Block.validate` for documentation."""
|
||||
return block.validate(bigchain)
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -9,15 +10,7 @@ import logging
|
|||
import sys
|
||||
|
||||
from abci.application import BaseApplication
|
||||
from abci.types_pb2 import (
|
||||
ResponseInitChain,
|
||||
ResponseInfo,
|
||||
ResponseCheckTx,
|
||||
ResponseBeginBlock,
|
||||
ResponseDeliverTx,
|
||||
ResponseEndBlock,
|
||||
ResponseCommit,
|
||||
)
|
||||
from abci import CodeTypeOk
|
||||
|
||||
from bigchaindb import BigchainDB
|
||||
from bigchaindb.elections.election import Election
|
||||
|
@ -25,13 +18,11 @@ from bigchaindb.version import __tm_supported_versions__
|
|||
from bigchaindb.utils import tendermint_version_is_compatible
|
||||
from bigchaindb.tendermint_utils import (decode_transaction,
|
||||
calculate_hash)
|
||||
from bigchaindb.lib import Block, PreCommitState
|
||||
from bigchaindb.backend.query import PRE_COMMIT_ID
|
||||
from bigchaindb.lib import Block
|
||||
import bigchaindb.upsert_validator.validator_utils as vutils
|
||||
from bigchaindb.events import EventTypes, Event
|
||||
|
||||
|
||||
CodeTypeOk = 0
|
||||
CodeTypeError = 1
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -40,11 +31,11 @@ class App(BaseApplication):
|
|||
"""Bridge between BigchainDB and Tendermint.
|
||||
|
||||
The role of this class is to expose the BigchainDB
|
||||
transactional logic to the Tendermint Consensus
|
||||
State Machine.
|
||||
transaction logic to Tendermint Core.
|
||||
"""
|
||||
|
||||
def __init__(self, bigchaindb=None, events_queue=None):
|
||||
def __init__(self, abci, bigchaindb=None, events_queue=None,):
|
||||
super().__init__(abci)
|
||||
self.events_queue = events_queue
|
||||
self.bigchaindb = bigchaindb or BigchainDB()
|
||||
self.block_txn_ids = []
|
||||
|
@ -55,9 +46,9 @@ class App(BaseApplication):
|
|||
self.chain = self.bigchaindb.get_latest_abci_chain()
|
||||
|
||||
def log_abci_migration_error(self, chain_id, validators):
|
||||
logger.error(f'An ABCI chain migration is in process. ' +
|
||||
'Download the new ABCI client and configure it with ' +
|
||||
'chain_id={chain_id} and validators={validators}.')
|
||||
logger.error('An ABCI chain migration is in process. '
|
||||
'Download the new ABCI client and configure it with '
|
||||
f'chain_id={chain_id} and validators={validators}.')
|
||||
|
||||
def abort_if_abci_chain_is_not_synced(self):
|
||||
if self.chain is None or self.chain['is_synced']:
|
||||
|
@ -78,8 +69,8 @@ class App(BaseApplication):
|
|||
chain_id = known_chain['chain_id']
|
||||
|
||||
if known_chain['is_synced']:
|
||||
msg = f'Got invalid InitChain ABCI request ({genesis}) - ' + \
|
||||
'the chain {chain_id} is already synced.'
|
||||
msg = (f'Got invalid InitChain ABCI request ({genesis}) - '
|
||||
f'the chain {chain_id} is already synced.')
|
||||
logger.error(msg)
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -110,7 +101,7 @@ class App(BaseApplication):
|
|||
genesis.chain_id, True)
|
||||
self.chain = {'height': abci_chain_height, 'is_synced': True,
|
||||
'chain_id': genesis.chain_id}
|
||||
return ResponseInitChain()
|
||||
return self.abci.ResponseInitChain()
|
||||
|
||||
def info(self, request):
|
||||
"""Return height of the latest committed block."""
|
||||
|
@ -125,7 +116,7 @@ class App(BaseApplication):
|
|||
|
||||
logger.info(f"Tendermint version: {request.version}")
|
||||
|
||||
r = ResponseInfo()
|
||||
r = self.abci.ResponseInfo()
|
||||
block = self.bigchaindb.get_latest_block()
|
||||
if block:
|
||||
chain_shift = 0 if self.chain is None else self.chain['height']
|
||||
|
@ -146,17 +137,14 @@ class App(BaseApplication):
|
|||
|
||||
self.abort_if_abci_chain_is_not_synced()
|
||||
|
||||
logger.benchmark('CHECK_TX_INIT')
|
||||
logger.debug('check_tx: %s', raw_transaction)
|
||||
transaction = decode_transaction(raw_transaction)
|
||||
if self.bigchaindb.is_valid_transaction(transaction):
|
||||
logger.debug('check_tx: VALID')
|
||||
logger.benchmark('CHECK_TX_END, tx_id:%s', transaction['id'])
|
||||
return ResponseCheckTx(code=CodeTypeOk)
|
||||
return self.abci.ResponseCheckTx(code=CodeTypeOk)
|
||||
else:
|
||||
logger.debug('check_tx: INVALID')
|
||||
logger.benchmark('CHECK_TX_END, tx_id:%s', transaction['id'])
|
||||
return ResponseCheckTx(code=CodeTypeError)
|
||||
return self.abci.ResponseCheckTx(code=CodeTypeError)
|
||||
|
||||
def begin_block(self, req_begin_block):
|
||||
"""Initialize list of transaction.
|
||||
|
@ -167,13 +155,13 @@ class App(BaseApplication):
|
|||
self.abort_if_abci_chain_is_not_synced()
|
||||
|
||||
chain_shift = 0 if self.chain is None else self.chain['height']
|
||||
logger.benchmark('BEGIN BLOCK, height:%s, num_txs:%s',
|
||||
req_begin_block.header.height + chain_shift,
|
||||
req_begin_block.header.num_txs)
|
||||
logger.debug('BEGIN BLOCK, height:%s, num_txs:%s',
|
||||
req_begin_block.header.height + chain_shift,
|
||||
req_begin_block.header.num_txs)
|
||||
|
||||
self.block_txn_ids = []
|
||||
self.block_transactions = []
|
||||
return ResponseBeginBlock()
|
||||
return self.abci.ResponseBeginBlock()
|
||||
|
||||
def deliver_tx(self, raw_transaction):
|
||||
"""Validate the transaction before mutating the state.
|
||||
|
@ -190,12 +178,12 @@ class App(BaseApplication):
|
|||
|
||||
if not transaction:
|
||||
logger.debug('deliver_tx: INVALID')
|
||||
return ResponseDeliverTx(code=CodeTypeError)
|
||||
return self.abci.ResponseDeliverTx(code=CodeTypeError)
|
||||
else:
|
||||
logger.debug('storing tx')
|
||||
self.block_txn_ids.append(transaction.id)
|
||||
self.block_transactions.append(transaction)
|
||||
return ResponseDeliverTx(code=CodeTypeOk)
|
||||
return self.abci.ResponseDeliverTx(code=CodeTypeOk)
|
||||
|
||||
def end_block(self, request_end_block):
|
||||
"""Calculate block hash using transaction ids and previous block
|
||||
|
@ -211,6 +199,14 @@ class App(BaseApplication):
|
|||
|
||||
height = request_end_block.height + chain_shift
|
||||
self.new_height = height
|
||||
|
||||
# store pre-commit state to recover in case there is a crash during
|
||||
# `end_block` or `commit`
|
||||
logger.debug(f'Updating pre-commit state: {self.new_height}')
|
||||
pre_commit_state = dict(height=self.new_height,
|
||||
transactions=self.block_txn_ids)
|
||||
self.bigchaindb.store_pre_commit_state(pre_commit_state)
|
||||
|
||||
block_txn_hash = calculate_hash(self.block_txn_ids)
|
||||
block = self.bigchaindb.get_latest_block()
|
||||
|
||||
|
@ -219,18 +215,11 @@ class App(BaseApplication):
|
|||
else:
|
||||
self.block_txn_hash = block['app_hash']
|
||||
|
||||
# Process all concluded elections in the current block and get any update to the validator set
|
||||
update = Election.approved_elections(self.bigchaindb,
|
||||
self.new_height,
|
||||
self.block_transactions)
|
||||
validator_update = Election.process_block(self.bigchaindb,
|
||||
self.new_height,
|
||||
self.block_transactions)
|
||||
|
||||
# Store pre-commit state to recover in case there is a crash during `commit`
|
||||
pre_commit_state = PreCommitState(commit_id=PRE_COMMIT_ID,
|
||||
height=self.new_height,
|
||||
transactions=self.block_txn_ids)
|
||||
logger.debug('Updating PreCommitState: %s', self.new_height)
|
||||
self.bigchaindb.store_pre_commit_state(pre_commit_state._asdict())
|
||||
return ResponseEndBlock(validator_updates=update)
|
||||
return self.abci.ResponseEndBlock(validator_updates=validator_update)
|
||||
|
||||
def commit(self):
|
||||
"""Store the new height and along with block hash."""
|
||||
|
@ -253,7 +242,6 @@ class App(BaseApplication):
|
|||
logger.debug('Commit-ing new block with hash: apphash=%s ,'
|
||||
'height=%s, txn ids=%s', data, self.new_height,
|
||||
self.block_txn_ids)
|
||||
logger.benchmark('COMMIT_BLOCK, height:%s', self.new_height)
|
||||
|
||||
if self.events_queue:
|
||||
event = Event(EventTypes.BLOCK_VALID, {
|
||||
|
@ -262,4 +250,22 @@ class App(BaseApplication):
|
|||
})
|
||||
self.events_queue.put(event)
|
||||
|
||||
return ResponseCommit(data=data)
|
||||
return self.abci.ResponseCommit(data=data)
|
||||
|
||||
|
||||
def rollback(b):
|
||||
pre_commit = b.get_pre_commit_state()
|
||||
|
||||
if pre_commit is None:
|
||||
# the pre_commit record is first stored in the first `end_block`
|
||||
return
|
||||
|
||||
latest_block = b.get_latest_block()
|
||||
if latest_block is None:
|
||||
logger.error('Found precommit state but no blocks!')
|
||||
sys.exit(1)
|
||||
|
||||
# NOTE: the pre-commit state is always at most 1 block ahead of the commited state
|
||||
if latest_block['height'] < pre_commit['height']:
|
||||
Election.rollback(b, pre_commit['height'], pre_commit['transactions'])
|
||||
b.delete_transactions(pre_commit['transactions'])
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
from collections import defaultdict
|
||||
from collections import OrderedDict
|
||||
|
||||
import base58
|
||||
from uuid import uuid4
|
||||
|
@ -22,9 +23,13 @@ from bigchaindb.common.schema import (_validate_schema,
|
|||
|
||||
|
||||
class Election(Transaction):
|
||||
"""Represents election transactions.
|
||||
|
||||
To implement a custom election, create a class deriving from this one
|
||||
with OPERATION set to the election operation, ALLOWED_OPERATIONS
|
||||
set to (OPERATION,), CREATE set to OPERATION.
|
||||
"""
|
||||
|
||||
# NOTE: this transaction class extends create so the operation inheritance is achieved
|
||||
# by setting an ELECTION_TYPE and renaming CREATE = ELECTION_TYPE and ALLOWED_OPERATIONS = (ELECTION_TYPE,)
|
||||
OPERATION = None
|
||||
# Custom validation schema
|
||||
TX_SCHEMA_CUSTOM = None
|
||||
|
@ -34,7 +39,6 @@ class Election(Transaction):
|
|||
INCONCLUSIVE = 'inconclusive'
|
||||
# Vote ratio to approve an election
|
||||
ELECTION_THRESHOLD = 2 / 3
|
||||
CHANGES_VALIDATOR_SET = True
|
||||
|
||||
@classmethod
|
||||
def get_validator_change(cls, bigchain):
|
||||
|
@ -45,8 +49,10 @@ class Election(Transaction):
|
|||
'validators': <validator_set>
|
||||
}
|
||||
"""
|
||||
height = bigchain.get_latest_block()['height']
|
||||
return bigchain.get_validator_change(height)
|
||||
latest_block = bigchain.get_latest_block()
|
||||
if latest_block is None:
|
||||
return None
|
||||
return bigchain.get_validator_change(latest_block['height'])
|
||||
|
||||
@classmethod
|
||||
def get_validators(cls, bigchain, height=None):
|
||||
|
@ -186,50 +192,52 @@ class Election(Transaction):
|
|||
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
|
||||
def has_concluded(self, bigchain, current_votes=[]):
|
||||
"""Check if the election can be concluded or not.
|
||||
|
||||
* Elections can only be concluded if the validator set has not changed
|
||||
since the election was initiated.
|
||||
* Elections can be concluded only if the current votes form a supermajority.
|
||||
|
||||
Custom elections may override this function and introduce additional checks.
|
||||
"""
|
||||
election = bigchain.get_transaction(election_id)
|
||||
if self.has_validator_set_changed(bigchain):
|
||||
return False
|
||||
|
||||
if election:
|
||||
election_pk = election.to_public_key(election.id)
|
||||
votes_committed = election.get_commited_votes(bigchain, election_pk)
|
||||
votes_current = election.count_votes(election_pk, current_votes)
|
||||
current_validators = election.get_validators(bigchain, height)
|
||||
election_pk = self.to_public_key(self.id)
|
||||
votes_committed = self.get_commited_votes(bigchain, election_pk)
|
||||
votes_current = self.count_votes(election_pk, current_votes)
|
||||
|
||||
total_votes = sum(output.amount for output in self.outputs)
|
||||
if (votes_committed < (2/3) * total_votes) and \
|
||||
(votes_committed + votes_current >= (2/3)*total_votes):
|
||||
return True
|
||||
|
||||
if election.is_same_topology(current_validators, election.outputs):
|
||||
total_votes = sum(current_validators.values())
|
||||
if (votes_committed < (2/3)*total_votes) and \
|
||||
(votes_committed + votes_current >= (2/3)*total_votes):
|
||||
return election
|
||||
return False
|
||||
|
||||
def get_status(self, bigchain):
|
||||
concluded = self.get_election(self.id, bigchain)
|
||||
if concluded:
|
||||
election = self.get_election(self.id, bigchain)
|
||||
if election and election['is_concluded']:
|
||||
return self.CONCLUDED
|
||||
|
||||
latest_change = self.get_validator_change(bigchain)
|
||||
latest_change_height = latest_change['height']
|
||||
election_height = bigchain.get_block_containing_tx(self.id)[0]
|
||||
return self.INCONCLUSIVE if self.has_validator_set_changed(bigchain) else self.ONGOING
|
||||
|
||||
if latest_change_height >= election_height:
|
||||
return self.INCONCLUSIVE
|
||||
else:
|
||||
return self.ONGOING
|
||||
def has_validator_set_changed(self, bigchain):
|
||||
latest_change = self.get_validator_change(bigchain)
|
||||
if latest_change is None:
|
||||
return False
|
||||
|
||||
latest_change_height = latest_change['height']
|
||||
|
||||
election = self.get_election(self.id, bigchain)
|
||||
|
||||
return latest_change_height > election['height']
|
||||
|
||||
def get_election(self, election_id, bigchain):
|
||||
result = bigchain.get_election(election_id)
|
||||
return result
|
||||
return bigchain.get_election(election_id)
|
||||
|
||||
@classmethod
|
||||
def store_election_results(cls, bigchain, election, height):
|
||||
bigchain.store_election_results(height, election)
|
||||
def store(self, bigchain, height, is_concluded):
|
||||
bigchain.store_election(self.id, height, is_concluded)
|
||||
|
||||
def show_election(self, bigchain):
|
||||
data = self.asset['data']
|
||||
|
@ -244,42 +252,104 @@ class Election(Transaction):
|
|||
return response
|
||||
|
||||
@classmethod
|
||||
def approved_elections(cls, bigchain, new_height, txns):
|
||||
elections = defaultdict(list)
|
||||
def _get_initiated_elections(cls, height, txns):
|
||||
elections = []
|
||||
for tx in txns:
|
||||
if not isinstance(tx, Election):
|
||||
continue
|
||||
|
||||
elections.append({'election_id': tx.id, 'height': height,
|
||||
'is_concluded': False})
|
||||
return elections
|
||||
|
||||
@classmethod
|
||||
def _get_votes(cls, txns):
|
||||
elections = OrderedDict()
|
||||
for tx in txns:
|
||||
if not isinstance(tx, Vote):
|
||||
continue
|
||||
|
||||
election_id = tx.asset['id']
|
||||
if election_id not in elections:
|
||||
elections[election_id] = []
|
||||
elections[election_id].append(tx)
|
||||
|
||||
validator_set_updated = False
|
||||
validator_set_change = []
|
||||
for election_id, votes in elections.items():
|
||||
election = Election.has_concluded(bigchain, election_id, votes, new_height)
|
||||
|
||||
if not election:
|
||||
continue
|
||||
|
||||
if election.makes_validator_set_change():
|
||||
if validator_set_updated:
|
||||
continue
|
||||
validator_set_change.append(election.get_validator_set_change(bigchain, new_height))
|
||||
validator_set_updated = True
|
||||
|
||||
election.on_approval(bigchain, election, new_height)
|
||||
|
||||
return validator_set_change
|
||||
|
||||
def makes_validator_set_change(self):
|
||||
return self.CHANGES_VALIDATOR_SET
|
||||
|
||||
def get_validator_set_change(self, bigchain, new_height):
|
||||
if self.makes_validator_set_change():
|
||||
return self.change_validator_set(bigchain, new_height)
|
||||
|
||||
def change_validator_set(self, bigchain, new_height):
|
||||
raise NotImplementedError
|
||||
return elections
|
||||
|
||||
@classmethod
|
||||
def on_approval(cls, bigchain, election, new_height):
|
||||
def process_block(cls, bigchain, new_height, txns):
|
||||
"""Looks for election and vote transactions inside the block, records
|
||||
and processes elections.
|
||||
|
||||
Every election is recorded in the database.
|
||||
|
||||
Every vote has a chance to conclude the corresponding election. When
|
||||
an election is concluded, the corresponding database record is
|
||||
marked as such.
|
||||
|
||||
Elections and votes are processed in the order in which they
|
||||
appear in the block. Elections are concluded in the order of
|
||||
appearance of their first votes in the block.
|
||||
|
||||
For every election concluded in the block, calls its `on_approval`
|
||||
method. The returned value of the last `on_approval`, if any,
|
||||
is a validator set update to be applied in one of the following blocks.
|
||||
|
||||
`on_approval` methods are implemented by elections of particular type.
|
||||
The method may contain side effects but should be idempotent. To account
|
||||
for other concluded elections, if it requires so, the method should
|
||||
rely on the database state.
|
||||
"""
|
||||
# elections initiated in this block
|
||||
initiated_elections = cls._get_initiated_elections(new_height, txns)
|
||||
|
||||
if initiated_elections:
|
||||
bigchain.store_elections(initiated_elections)
|
||||
|
||||
# elections voted for in this block and their votes
|
||||
elections = cls._get_votes(txns)
|
||||
|
||||
validator_update = None
|
||||
for election_id, votes in elections.items():
|
||||
election = bigchain.get_transaction(election_id)
|
||||
if election is None:
|
||||
continue
|
||||
|
||||
if not election.has_concluded(bigchain, votes):
|
||||
continue
|
||||
|
||||
validator_update = election.on_approval(bigchain, new_height)
|
||||
election.store(bigchain, new_height, is_concluded=True)
|
||||
|
||||
return [validator_update] if validator_update else []
|
||||
|
||||
@classmethod
|
||||
def rollback(cls, bigchain, new_height, txn_ids):
|
||||
"""Looks for election and vote transactions inside the block and
|
||||
cleans up the database artifacts possibly created in `process_blocks`.
|
||||
|
||||
Part of the `end_block`/`commit` crash recovery.
|
||||
"""
|
||||
|
||||
# delete election records for elections initiated at this height and
|
||||
# elections concluded at this height
|
||||
bigchain.delete_elections(new_height)
|
||||
|
||||
txns = [bigchain.get_transaction(tx_id) for tx_id in txn_ids]
|
||||
|
||||
elections = cls._get_votes(txns)
|
||||
for election_id in elections:
|
||||
election = bigchain.get_transaction(election_id)
|
||||
election.on_rollback(bigchain, new_height)
|
||||
|
||||
def on_approval(self, bigchain, new_height):
|
||||
"""Override to update the database state according to the
|
||||
election rules. Consider the current database state to account for
|
||||
other concluded elections, if required.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def on_rollback(self, bigchain, new_height):
|
||||
"""Override to clean up the database artifacts possibly created
|
||||
in `on_approval`. Part of the `end_block`/`commit` crash recovery.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -9,12 +10,13 @@ MongoDB.
|
|||
import logging
|
||||
from collections import namedtuple
|
||||
from uuid import uuid4
|
||||
|
||||
import rapidjson
|
||||
|
||||
try:
|
||||
from hashlib import sha3_256
|
||||
except ImportError:
|
||||
# NOTE: neeeded for Python < 3.6
|
||||
# NOTE: needed for Python < 3.6
|
||||
from sha3 import sha3_256
|
||||
|
||||
import requests
|
||||
|
@ -25,9 +27,12 @@ from bigchaindb.models import Transaction
|
|||
from bigchaindb.common.exceptions import (SchemaValidationError,
|
||||
ValidationError,
|
||||
DoubleSpend)
|
||||
from bigchaindb.common.transaction_mode_types import (BROADCAST_TX_COMMIT,
|
||||
BROADCAST_TX_ASYNC,
|
||||
BROADCAST_TX_SYNC)
|
||||
from bigchaindb.tendermint_utils import encode_transaction, merkleroot
|
||||
from bigchaindb import exceptions as core_exceptions
|
||||
from bigchaindb.consensus import BaseConsensusRules
|
||||
from bigchaindb.validation import BaseValidationRules
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -56,20 +61,20 @@ class BigchainDB(object):
|
|||
A connection to the database.
|
||||
"""
|
||||
config_utils.autoconfigure()
|
||||
self.mode_commit = 'broadcast_tx_commit'
|
||||
self.mode_list = ('broadcast_tx_async',
|
||||
'broadcast_tx_sync',
|
||||
self.mode_commit = BROADCAST_TX_COMMIT
|
||||
self.mode_list = (BROADCAST_TX_ASYNC,
|
||||
BROADCAST_TX_SYNC,
|
||||
self.mode_commit)
|
||||
self.tendermint_host = bigchaindb.config['tendermint']['host']
|
||||
self.tendermint_port = bigchaindb.config['tendermint']['port']
|
||||
self.endpoint = 'http://{}:{}/'.format(self.tendermint_host, self.tendermint_port)
|
||||
|
||||
consensusPlugin = bigchaindb.config.get('consensus_plugin')
|
||||
validationPlugin = bigchaindb.config.get('validation_plugin')
|
||||
|
||||
if consensusPlugin:
|
||||
self.consensus = config_utils.load_consensus_plugin(consensusPlugin)
|
||||
if validationPlugin:
|
||||
self.validation = config_utils.load_validation_plugin(validationPlugin)
|
||||
else:
|
||||
self.consensus = BaseConsensusRules
|
||||
self.validation = BaseValidationRules
|
||||
|
||||
self.connection = connection if connection else backend.connect(**bigchaindb.config['database'])
|
||||
|
||||
|
@ -143,6 +148,9 @@ class BigchainDB(object):
|
|||
backend.query.store_assets(self.connection, assets)
|
||||
return backend.query.store_transactions(self.connection, txns)
|
||||
|
||||
def delete_transactions(self, txs):
|
||||
return backend.query.delete_transactions(self.connection, txs)
|
||||
|
||||
def update_utxoset(self, transaction):
|
||||
"""Update the UTXO set given ``transaction``. That is, remove
|
||||
the outputs that the given ``transaction`` spends, and add the
|
||||
|
@ -251,11 +259,14 @@ class BigchainDB(object):
|
|||
|
||||
return transaction
|
||||
|
||||
def get_transactions_filtered(self, asset_id, operation=None):
|
||||
def get_transactions(self, txn_ids):
|
||||
return backend.query.get_transactions(self.connection, txn_ids)
|
||||
|
||||
def get_transactions_filtered(self, asset_id, operation=None, last_tx=None):
|
||||
"""Get a list of transactions filtered on some criteria
|
||||
"""
|
||||
txids = backend.query.get_txids_filtered(self.connection, asset_id,
|
||||
operation)
|
||||
operation, last_tx)
|
||||
for txid in txids:
|
||||
yield self.get_transaction(txid)
|
||||
|
||||
|
@ -436,8 +447,10 @@ class BigchainDB(object):
|
|||
return [] if result is None else result['validators']
|
||||
|
||||
def get_election(self, election_id):
|
||||
result = backend.query.get_election(self.connection, election_id)
|
||||
return result
|
||||
return backend.query.get_election(self.connection, election_id)
|
||||
|
||||
def get_pre_commit_state(self):
|
||||
return backend.query.get_pre_commit_state(self.connection)
|
||||
|
||||
def store_pre_commit_state(self, state):
|
||||
return backend.query.store_pre_commit_state(self.connection, state)
|
||||
|
@ -450,10 +463,16 @@ class BigchainDB(object):
|
|||
return backend.query.store_validator_set(self.connection, {'height': height,
|
||||
'validators': validators})
|
||||
|
||||
def delete_validator_set(self, height):
|
||||
return backend.query.delete_validator_set(self.connection, height)
|
||||
|
||||
def store_abci_chain(self, height, chain_id, is_synced=True):
|
||||
return backend.query.store_abci_chain(self.connection, height,
|
||||
chain_id, is_synced)
|
||||
|
||||
def delete_abci_chain(self, height):
|
||||
return backend.query.delete_abci_chain(self.connection, height)
|
||||
|
||||
def get_latest_abci_chain(self):
|
||||
return backend.query.get_latest_abci_chain(self.connection)
|
||||
|
||||
|
@ -481,15 +500,15 @@ class BigchainDB(object):
|
|||
|
||||
self.store_abci_chain(block['height'] + 1, new_chain_id, False)
|
||||
|
||||
def store_election_results(self, height, election):
|
||||
"""Store election results
|
||||
:param height: the block height at which the election concluded
|
||||
:param election: a concluded election
|
||||
"""
|
||||
return backend.query.store_election_results(self.connection, {'height': height,
|
||||
'election_id': election.id})
|
||||
def store_election(self, election_id, height, is_concluded):
|
||||
return backend.query.store_election(self.connection, election_id,
|
||||
height, is_concluded)
|
||||
|
||||
def store_elections(self, elections):
|
||||
return backend.query.store_elections(self.connection, elections)
|
||||
|
||||
def delete_elections(self, height):
|
||||
return backend.query.delete_elections(self.connection, height)
|
||||
|
||||
|
||||
Block = namedtuple('Block', ('app_hash', 'height', 'transactions'))
|
||||
|
||||
PreCommitState = namedtuple('PreCommitState', ('commit_id', 'height', 'transactions'))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -11,8 +12,6 @@ import os
|
|||
|
||||
|
||||
DEFAULT_LOG_DIR = os.getcwd()
|
||||
BENCHMARK_LOG_LEVEL = 15
|
||||
|
||||
|
||||
DEFAULT_LOGGING_CONFIG = {
|
||||
'version': 1,
|
||||
|
@ -29,11 +28,6 @@ DEFAULT_LOGGING_CONFIG = {
|
|||
'format': ('[%(asctime)s] [%(levelname)s] (%(name)s) '
|
||||
'%(message)s (%(processName)-10s - pid: %(process)d)'),
|
||||
'datefmt': '%Y-%m-%d %H:%M:%S',
|
||||
},
|
||||
'benchmark': {
|
||||
'class': 'logging.Formatter',
|
||||
'format': ('%(asctime)s, %(levelname)s, %(message)s'),
|
||||
'datefmt': '%Y-%m-%d %H:%M:%S',
|
||||
}
|
||||
},
|
||||
'handlers': {
|
||||
|
@ -59,31 +53,16 @@ DEFAULT_LOGGING_CONFIG = {
|
|||
'backupCount': 5,
|
||||
'formatter': 'file',
|
||||
'level': logging.ERROR,
|
||||
},
|
||||
'benchmark': {
|
||||
'class': 'logging.handlers.RotatingFileHandler',
|
||||
'filename': os.path.join(DEFAULT_LOG_DIR, 'bigchaindb-benchmark.log'),
|
||||
'mode': 'w',
|
||||
'maxBytes': 209715200,
|
||||
'backupCount': 5,
|
||||
'formatter': 'benchmark',
|
||||
'level': BENCHMARK_LOG_LEVEL,
|
||||
}
|
||||
},
|
||||
'loggers': {},
|
||||
'root': {
|
||||
'level': logging.DEBUG,
|
||||
'handlers': ['console', 'file', 'errors', 'benchmark'],
|
||||
'handlers': ['console', 'file', 'errors'],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def benchmark(self, message, *args, **kws):
|
||||
# Yes, logger takes its '*args' as 'args'.
|
||||
if self.isEnabledFor(BENCHMARK_LOG_LEVEL):
|
||||
self._log(BENCHMARK_LOG_LEVEL, message, args, **kws)
|
||||
|
||||
|
||||
def _normalize_log_level(level):
|
||||
try:
|
||||
return level.upper()
|
||||
|
@ -104,11 +83,6 @@ def setup_logging():
|
|||
|
||||
"""
|
||||
|
||||
# Add a new logging level for logging benchmark
|
||||
logging.addLevelName(BENCHMARK_LOG_LEVEL, 'BENCHMARK')
|
||||
logging.BENCHMARK = BENCHMARK_LOG_LEVEL
|
||||
logging.Logger.benchmark = benchmark
|
||||
|
||||
logging_configs = DEFAULT_LOGGING_CONFIG
|
||||
new_logging_configs = bigchaindb.config['log']
|
||||
|
||||
|
@ -127,7 +101,6 @@ def setup_logging():
|
|||
if 'level_logfile' in new_logging_configs:
|
||||
level = _normalize_log_level(new_logging_configs['level_logfile'])
|
||||
logging_configs['handlers']['file']['level'] = level
|
||||
logging_configs['handlers']['benchmark']['level'] = level
|
||||
|
||||
if 'fmt_console' in new_logging_configs:
|
||||
fmt = new_logging_configs['fmt_console']
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import json
|
||||
|
||||
from bigchaindb.common.schema import TX_SCHEMA_CHAIN_MIGRATION_ELECTION
|
||||
from bigchaindb.elections.election import Election
|
||||
|
||||
|
@ -8,8 +10,39 @@ class ChainMigrationElection(Election):
|
|||
CREATE = OPERATION
|
||||
ALLOWED_OPERATIONS = (OPERATION,)
|
||||
TX_SCHEMA_CUSTOM = TX_SCHEMA_CHAIN_MIGRATION_ELECTION
|
||||
CHANGES_VALIDATOR_SET = False
|
||||
|
||||
@classmethod
|
||||
def on_approval(cls, bigchain, election, new_height):
|
||||
def has_concluded(self, bigchaindb, *args, **kwargs):
|
||||
chain = bigchaindb.get_latest_abci_chain()
|
||||
if chain is not None and not chain['is_synced']:
|
||||
# do not conclude the migration election if
|
||||
# there is another migration in progress
|
||||
return False
|
||||
|
||||
return super().has_concluded(bigchaindb, *args, **kwargs)
|
||||
|
||||
def on_approval(self, bigchain, *args, **kwargs):
|
||||
bigchain.migrate_abci_chain()
|
||||
|
||||
def show_election(self, bigchain):
|
||||
output = super().show_election(bigchain)
|
||||
chain = bigchain.get_latest_abci_chain()
|
||||
if chain is None or chain['is_synced']:
|
||||
return output
|
||||
|
||||
output += f'\nchain_id={chain["chain_id"]}'
|
||||
block = bigchain.get_latest_block()
|
||||
output += f'\napp_hash={block["app_hash"]}'
|
||||
validators = [
|
||||
{
|
||||
'pub_key': {
|
||||
'type': 'tendermint/PubKeyEd25519',
|
||||
'value': k,
|
||||
},
|
||||
'power': v,
|
||||
} for k, v in self.get_validators(bigchain).items()
|
||||
]
|
||||
output += f'\nvalidators={json.dumps(validators, indent=4)}'
|
||||
return output
|
||||
|
||||
def on_rollback(self, bigchain, new_height):
|
||||
bigchain.delete_abci_chain(new_height)
|
||||
|
|
|
@ -1,16 +1,20 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
from bigchaindb.backend.schema import validate_language_key
|
||||
from bigchaindb.common.exceptions import (InvalidSignature,
|
||||
DuplicateTransaction)
|
||||
from bigchaindb.common.schema import validate_transaction_schema
|
||||
from bigchaindb.common.transaction import Transaction
|
||||
from bigchaindb.common.utils import (validate_txn_obj, validate_key)
|
||||
from bigchaindb.common.schema import validate_transaction_schema
|
||||
from bigchaindb.backend.schema import validate_language_key
|
||||
|
||||
|
||||
class Transaction(Transaction):
|
||||
ASSET = 'asset'
|
||||
METADATA = 'metadata'
|
||||
DATA = 'data'
|
||||
|
||||
def validate(self, bigchain, current_transactions=[]):
|
||||
"""Validate transaction spend
|
||||
|
@ -46,9 +50,10 @@ class Transaction(Transaction):
|
|||
@classmethod
|
||||
def validate_schema(cls, tx_body):
|
||||
validate_transaction_schema(tx_body)
|
||||
validate_txn_obj('asset', tx_body['asset'], 'data', validate_key)
|
||||
validate_txn_obj('metadata', tx_body, 'metadata', validate_key)
|
||||
validate_language_key(tx_body['asset'], 'data')
|
||||
validate_txn_obj(cls.ASSET, tx_body[cls.ASSET], cls.DATA, validate_key)
|
||||
validate_txn_obj(cls.METADATA, tx_body, cls.METADATA, validate_key)
|
||||
validate_language_key(tx_body[cls.ASSET], cls.DATA)
|
||||
validate_language_key(tx_body, cls.METADATA)
|
||||
|
||||
|
||||
class FastTransaction:
|
||||
|
|
|
@ -1,31 +1,28 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import multiprocessing as mp
|
||||
from collections import defaultdict
|
||||
|
||||
from abci.types_pb2 import ResponseCheckTx, ResponseDeliverTx
|
||||
|
||||
from bigchaindb import BigchainDB, App
|
||||
from bigchaindb import App, BigchainDB
|
||||
from bigchaindb.tendermint_utils import decode_transaction
|
||||
|
||||
|
||||
CodeTypeOk = 0
|
||||
from abci import CodeTypeOk
|
||||
|
||||
|
||||
class ParallelValidationApp(App):
|
||||
def __init__(self, bigchaindb=None, events_queue=None):
|
||||
super().__init__(bigchaindb, events_queue)
|
||||
def __init__(self, bigchaindb=None, events_queue=None, abci=None):
|
||||
super().__init__(bigchaindb, events_queue, abci=abci)
|
||||
self.parallel_validator = ParallelValidator()
|
||||
self.parallel_validator.start()
|
||||
|
||||
def check_tx(self, raw_transaction):
|
||||
return ResponseCheckTx(code=CodeTypeOk)
|
||||
return self.abci.ResponseCheckTx(code=CodeTypeOk)
|
||||
|
||||
def deliver_tx(self, raw_transaction):
|
||||
self.parallel_validator.validate(raw_transaction)
|
||||
return ResponseDeliverTx(code=CodeTypeOk)
|
||||
return self.abci.ResponseDeliverTx(code=CodeTypeOk)
|
||||
|
||||
def end_block(self, request_end_block):
|
||||
result = self.parallel_validator.result(timeout=30)
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import logging
|
||||
import setproctitle
|
||||
|
||||
from abci import TmVersion, ABCI
|
||||
|
||||
import bigchaindb
|
||||
from bigchaindb.lib import BigchainDB
|
||||
from bigchaindb.core import App
|
||||
|
@ -19,10 +22,8 @@ logger = logging.getLogger(__name__)
|
|||
BANNER = """
|
||||
****************************************************************************
|
||||
* *
|
||||
* ┏┓ ╻┏━╸┏━╸╻ ╻┏━┓╻┏┓╻╺┳┓┏┓ ┏━┓ ┏━┓ ╺┳┓┏━╸╻ ╻ *
|
||||
* ┣┻┓┃┃╺┓┃ ┣━┫┣━┫┃┃┗┫ ┃┃┣┻┓ ┏━┛ ┃┃┃ ┃┃┣╸ ┃┏┛ *
|
||||
* ┗━┛╹┗━┛┗━╸╹ ╹╹ ╹╹╹ ╹╺┻┛┗━┛ ┗━╸╹┗━┛╹╺┻┛┗━╸┗┛ *
|
||||
* codename "fluffy cat" *
|
||||
* BigchainDB 2.2.2 *
|
||||
* codename "jumping sloth" *
|
||||
* Initialization complete. BigchainDB Server is ready and waiting. *
|
||||
* *
|
||||
* You can send HTTP requests via the HTTP API documented in the *
|
||||
|
@ -62,15 +63,26 @@ def start(args):
|
|||
# We need to import this after spawning the web server
|
||||
# because import ABCIServer will monkeypatch all sockets
|
||||
# for gevent.
|
||||
from abci import ABCIServer
|
||||
from abci.server import ABCIServer
|
||||
|
||||
setproctitle.setproctitle('bigchaindb')
|
||||
|
||||
# Start the ABCIServer
|
||||
abci = ABCI(TmVersion(bigchaindb.config['tendermint']['version']))
|
||||
if args.experimental_parallel_validation:
|
||||
app = ABCIServer(app=ParallelValidationApp(events_queue=exchange.get_publisher_queue()))
|
||||
app = ABCIServer(
|
||||
app=ParallelValidationApp(
|
||||
abci=abci.types,
|
||||
events_queue=exchange.get_publisher_queue(),
|
||||
)
|
||||
)
|
||||
else:
|
||||
app = ABCIServer(app=App(events_queue=exchange.get_publisher_queue()))
|
||||
app = ABCIServer(
|
||||
app=App(
|
||||
abci=abci.types,
|
||||
events_queue=exchange.get_publisher_queue(),
|
||||
)
|
||||
)
|
||||
app.run()
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -36,18 +37,32 @@ class ValidatorElection(Election):
|
|||
super(ValidatorElection, cls).validate_schema(tx)
|
||||
validate_asset_public_key(tx['asset']['data']['public_key'])
|
||||
|
||||
def change_validator_set(self, bigchain, new_height):
|
||||
# The new validator set comes into effect from height = new_height+1
|
||||
# (upcoming changes to Tendermint will change this to height = new_height+2)
|
||||
def has_concluded(self, bigchain, *args, **kwargs):
|
||||
latest_block = bigchain.get_latest_block()
|
||||
if latest_block is not None:
|
||||
latest_block_height = latest_block['height']
|
||||
latest_validator_change = bigchain.get_validator_change()['height']
|
||||
|
||||
# TODO change to `latest_block_height + 3` when upgrading to Tendermint 0.24.0.
|
||||
if latest_validator_change == latest_block_height + 2:
|
||||
# do not conclude the election if there is a change assigned already
|
||||
return False
|
||||
|
||||
return super().has_concluded(bigchain, *args, **kwargs)
|
||||
|
||||
def on_approval(self, bigchain, new_height):
|
||||
validator_updates = [self.asset['data']]
|
||||
curr_validator_set = bigchain.get_validators(new_height)
|
||||
updated_validator_set = new_validator_set(curr_validator_set,
|
||||
validator_updates)
|
||||
|
||||
updated_validator_set = [v for v in updated_validator_set if v['voting_power'] > 0]
|
||||
bigchain.store_validator_set(new_height+1, updated_validator_set)
|
||||
updated_validator_set = [v for v in updated_validator_set
|
||||
if v['voting_power'] > 0]
|
||||
|
||||
# TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0.
|
||||
bigchain.store_validator_set(new_height + 1, updated_validator_set)
|
||||
return encode_validator(self.asset['data'])
|
||||
|
||||
@classmethod
|
||||
def on_approval(cls, bigchain, election, new_height):
|
||||
pass
|
||||
def on_rollback(self, bigchaindb, new_height):
|
||||
# TODO change to `new_height + 2` when upgrading to Tendermint 0.24.0.
|
||||
bigchaindb.delete_validator_set(new_height + 1)
|
||||
|
|
|
@ -1,20 +1,28 @@
|
|||
import codecs
|
||||
import base64
|
||||
import binascii
|
||||
import codecs
|
||||
|
||||
from abci.types_pb2 import (Validator,
|
||||
PubKey)
|
||||
from bigchaindb.common.exceptions import InvalidPublicKey
|
||||
import bigchaindb
|
||||
from abci import types_v0_22_8, types_v0_31_5, TmVersion
|
||||
from bigchaindb.common.exceptions import InvalidPublicKey, BigchainDBError
|
||||
|
||||
|
||||
def encode_validator(v):
|
||||
ed25519_public_key = v['public_key']['value']
|
||||
# NOTE: tendermint expects public to be encoded in go-amino format
|
||||
pub_key = PubKey(type='ed25519',
|
||||
data=bytes.fromhex(ed25519_public_key))
|
||||
return Validator(pub_key=pub_key,
|
||||
address=b'',
|
||||
power=v['power'])
|
||||
try:
|
||||
version = TmVersion(bigchaindb.config["tendermint"]["version"])
|
||||
except ValueError:
|
||||
raise BigchainDBError('Invalid tendermint version, '
|
||||
'check BigchainDB configuration file')
|
||||
|
||||
validator_update_t, pubkey_t = {
|
||||
TmVersion.v0_22_8: (types_v0_22_8.Validator, types_v0_22_8.PubKey),
|
||||
TmVersion.v0_31_5: (types_v0_31_5.ValidatorUpdate, types_v0_31_5.PubKey)
|
||||
}[version]
|
||||
pub_key = pubkey_t(type='ed25519', data=bytes.fromhex(ed25519_public_key))
|
||||
|
||||
return validator_update_t(pub_key=pub_key, power=v['power'])
|
||||
|
||||
|
||||
def decode_validator(v):
|
||||
|
@ -57,7 +65,7 @@ def validate_asset_public_key(pk):
|
|||
if len(pk_decoded) != 32:
|
||||
raise InvalidPublicKey('Public key should be of size 32 bytes')
|
||||
|
||||
except binascii.Error as e:
|
||||
except binascii.Error:
|
||||
raise InvalidPublicKey('Invalid `type` specified for public key `value`')
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
||||
class BaseValidationRules():
|
||||
"""Base validation rules for BigchainDB.
|
||||
|
||||
A validation plugin must expose a class inheriting from this one via an entry_point.
|
||||
|
||||
All methods listed below must be implemented.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def validate_transaction(bigchaindb, transaction):
|
||||
"""See :meth:`bigchaindb.models.Transaction.validate`
|
||||
for documentation.
|
||||
"""
|
||||
return transaction.validate(bigchaindb)
|
||||
|
||||
@staticmethod
|
||||
def validate_block(bigchaindb, block):
|
||||
"""See :meth:`bigchaindb.models.Block.validate` for documentation."""
|
||||
return block.validate(bigchaindb)
|
|
@ -1,8 +1,10 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
__version__ = '2.0.0b6'
|
||||
__short_version__ = '2.0b6'
|
||||
# supported Tendermint version
|
||||
__tm_supported_versions__ = ["0.22.8"]
|
||||
__version__ = '2.2.2'
|
||||
__short_version__ = '2.2'
|
||||
|
||||
# Supported Tendermint versions
|
||||
__tm_supported_versions__ = ["0.31.5", "0.22.8"]
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -36,7 +37,10 @@ def base_ws_uri():
|
|||
customized (typically when running behind NAT, firewall, etc.)
|
||||
"""
|
||||
|
||||
scheme = config['wsserver']['advertised_scheme']
|
||||
host = config['wsserver']['advertised_host']
|
||||
port = config['wsserver']['advertised_port']
|
||||
config_wsserver = config['wsserver']
|
||||
|
||||
scheme = config_wsserver['advertised_scheme']
|
||||
host = config_wsserver['advertised_host']
|
||||
port = config_wsserver['advertised_port']
|
||||
|
||||
return '{}://{}:{}'.format(scheme, host, port)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
import re
|
||||
|
||||
from bigchaindb.common.transaction_mode_types import (BROADCAST_TX_COMMIT,
|
||||
BROADCAST_TX_ASYNC,
|
||||
BROADCAST_TX_SYNC)
|
||||
|
||||
|
||||
def valid_txid(txid):
|
||||
if re.match('^[a-fA-F0-9]{64}$', txid):
|
||||
|
@ -38,9 +43,9 @@ def valid_operation(op):
|
|||
|
||||
def valid_mode(mode):
|
||||
if mode == 'async':
|
||||
return 'broadcast_tx_async'
|
||||
return BROADCAST_TX_ASYNC
|
||||
if mode == 'sync':
|
||||
return 'broadcast_tx_sync'
|
||||
return BROADCAST_TX_SYNC
|
||||
if mode == 'commit':
|
||||
return 'broadcast_tx_commit'
|
||||
return BROADCAST_TX_COMMIT
|
||||
raise ValueError('Mode must be "async", "sync" or "commit"')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
@ -11,6 +12,7 @@ import logging
|
|||
from flask import current_app, request, jsonify
|
||||
from flask_restful import Resource, reqparse
|
||||
|
||||
from bigchaindb.common.transaction_mode_types import BROADCAST_TX_ASYNC
|
||||
from bigchaindb.common.exceptions import SchemaValidationError, ValidationError
|
||||
from bigchaindb.web.views.base import make_error
|
||||
from bigchaindb.web.views import parameters
|
||||
|
@ -47,8 +49,9 @@ class TransactionListApi(Resource):
|
|||
parser.add_argument('operation', type=parameters.valid_operation)
|
||||
parser.add_argument('asset_id', type=parameters.valid_txid,
|
||||
required=True)
|
||||
parser.add_argument('last_tx', type=parameters.valid_bool,
|
||||
required=False)
|
||||
args = parser.parse_args()
|
||||
|
||||
with current_app.config['bigchain_pool']() as bigchain:
|
||||
txs = bigchain.get_transactions_filtered(**args)
|
||||
|
||||
|
@ -62,7 +65,7 @@ class TransactionListApi(Resource):
|
|||
"""
|
||||
parser = reqparse.RequestParser()
|
||||
parser.add_argument('mode', type=parameters.valid_mode,
|
||||
default='broadcast_tx_async')
|
||||
default=BROADCAST_TX_ASYNC)
|
||||
args = parser.parse_args()
|
||||
mode = str(args['mode'])
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
# Copyright BigchainDB GmbH and BigchainDB contributors
|
||||
# Copyright © 2020 Interplanetary Database Association e.V.,
|
||||
# BigchainDB and IPDB software contributors.
|
||||
# SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
# Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue