diff --git a/CHANGELOG.md b/CHANGELOG.md index bffdd155..e89ccc85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,14 @@ For reference, the possible headings are: * **Known Issues** * **Notes** +## [2.0 Beta 3] - 2018-07-18 + +Tag name: v2.0.0b3 + +### Fixed + +Fixed a bug in transaction validation. For some more-complex situations, it would say that a valid transaction was invalid. This bug was actually fixed before; it was [issue #1271](https://github.com/bigchaindb/bigchaindb/issues/1271). The unit test for it was turned off while we integrated Tendermint. Then the query implementation code got changed, reintroducing the bug, but the unit test was off so the bug wasn't caught. When we turned the test back on, shortly after releasing Beta 2, it failed, unveiling the bug. [Pull request #2389](https://github.com/bigchaindb/bigchaindb/pull/2389) + ## [2.0 Beta 2] - 2018-07-16 Tag name: v2.0.0b2 diff --git a/bigchaindb/backend/localmongodb/query.py b/bigchaindb/backend/localmongodb/query.py index 6aca2197..b2b381c4 100644 --- a/bigchaindb/backend/localmongodb/query.py +++ b/bigchaindb/backend/localmongodb/query.py @@ -99,11 +99,13 @@ 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}} + return conn.run( conn.collection('transactions') - .find({'inputs.fulfills.transaction_id': transaction_id, - 'inputs.fulfills.output_index': output}, - {'_id': 0})) + .find(query, {'_id': 0})) @register_query(LocalMongoDBConnection) diff --git a/bigchaindb/version.py b/bigchaindb/version.py index edc112cd..72f9eecf 100644 --- a/bigchaindb/version.py +++ b/bigchaindb/version.py @@ -1,2 +1,2 @@ -__version__ = '2.0.0b2' -__short_version__ = '2.0b2' +__version__ = '2.0.0b3' +__short_version__ = '2.0b3' diff --git a/docs/contributing/source/ways-to-contribute/write-a-bep.md b/docs/contributing/source/ways-to-contribute/write-a-bep.md index 182f850c..9bb5e8f4 100644 --- a/docs/contributing/source/ways-to-contribute/write-a-bep.md +++ b/docs/contributing/source/ways-to-contribute/write-a-bep.md @@ -1,7 +1,14 @@ -# Write a BigchaindB Enhancement Proposal (BEP) +# Write a BigchainDB Enhancement Proposal (BEP) -- Review [1/C4](https://github.com/bigchaindb/BEPs/tree/master/1), the process we use to accept any new code or PR of any kind, including one that adds a BEP to `bigchaindb/BEPs`. -- Review [2/COSS](https://github.com/bigchaindb/BEPs/tree/master/2). Maybe print it for reference. It outlines what can go in a BEP. -- Don't spend weeks on your BEP. Version 1 should take up to a few hours to write. You can add to it in the future. The process is iterative. If you need more than a few hours, then consider writing multiple BEPs. -- Do _not_ start writing code before you think about it. You should always write a BEP first. Once you do that, you can start implementing it. To do that, make a pull request and say it implements your BEP. -- Do _not_ write your BEP as an issue (i.e. a GitHub issue). +If you have an idea for a new feature or enhancement, and you want some feedback before you write a full BigchainDB Enhancement Proposal (BEP), then feel free to: + - ask in the [bigchaindb/bigchaindb Gitter chat room](https://gitter.im/bigchaindb/bigchaindb) or + - [open a new issue in the bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs/issues/new) and give it the label **BEP idea**. + +If you want to discuss an existing BEP, then [open a new issue in the bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs/issues/new) and give it the label **discuss existing BEP**. + +## Steps to Write a New BEP + +1. Look at the structure of existing BEPs in the [bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs). Note the section headings. [BEP-2](https://github.com/bigchaindb/BEPs/tree/master/2) (our variant of the consensus-oriented specification system [COSS]) says more about the expected structure and process. +1. Write a first draft of your BEP. It doesn't have to be long or perfect. +1. Push your BEP draft to the [bigchaindb/BEPs repo](https://github.com/bigchaindb/BEPs) and make a pull request. [BEP-1](https://github.com/bigchaindb/BEPs/tree/master/1) (our variant of C4) outlines the process we use to handle all pull requests. In particular, we try to merge all pull requests quickly. +1. Your BEP can be revised by pushing more pull requests. diff --git a/docs/server/source/simple-network-setup.md b/docs/server/source/simple-network-setup.md index 165cf006..752b39ba 100644 --- a/docs/server/source/simple-network-setup.md +++ b/docs/server/source/simple-network-setup.md @@ -52,10 +52,11 @@ BigchainDB Server requires **Python 3.6+**, so make sure your system has it. Ins sudo apt install -y python3-pip libssl-dev ``` -Now install the latest version of BigchainDB. Check the [project page on PyPI][bdb:pypi] for the last version (which was `2.0.0a6` at the time of writing) and install it: +Now install the latest version of BigchainDB. You can find the latest version by going to the [BigchainDB project release history page on PyPI][bdb:pypi]. For example, to install version 2.0.0b3, you would do: ``` -sudo pip3 install bigchaindb==2.0.0a6 +# Change 2.0.0b3 to the latest version as explained above: +sudo pip3 install bigchaindb==2.0.0b3 ``` Check that you installed the correct version of BigchainDB Server using `bigchaindb --version`. diff --git a/k8s/bigchaindb/bigchaindb-ss.yaml b/k8s/bigchaindb/bigchaindb-ss.yaml index 636da377..027c3fed 100644 --- a/k8s/bigchaindb/bigchaindb-ss.yaml +++ b/k8s/bigchaindb/bigchaindb-ss.yaml @@ -154,7 +154,7 @@ spec: timeoutSeconds: 15 # BigchainDB container - name: bigchaindb - image: bigchaindb/bigchaindb:2.0.0-beta2 + image: bigchaindb/bigchaindb:2.0.0-beta3 imagePullPolicy: Always args: - start diff --git a/k8s/dev-setup/bigchaindb.yaml b/k8s/dev-setup/bigchaindb.yaml index e8db3042..d62685fc 100644 --- a/k8s/dev-setup/bigchaindb.yaml +++ b/k8s/dev-setup/bigchaindb.yaml @@ -34,7 +34,7 @@ spec: terminationGracePeriodSeconds: 10 containers: - name: bigchaindb - image: bigchaindb/bigchaindb:2.0.0-beta2 + image: bigchaindb/bigchaindb:2.0.0-beta3 imagePullPolicy: Always args: - start diff --git a/tests/test_core.py b/tests/test_core.py index d473c9d1..6ef550f6 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -3,6 +3,10 @@ import pytest pytestmark = [pytest.mark.tendermint, pytest.mark.bdb] +pytestmark = pytest.mark.tendermint + + +@pytest.mark.skipif(reason='will be fixed in another PR') @pytest.fixture def config(request, monkeypatch): backend = request.config.getoption('--database-backend') @@ -31,6 +35,7 @@ def config(request, monkeypatch): return config +@pytest.mark.skipif(reason='will be fixed in another PR') def test_bigchain_class_default_initialization(config): from bigchaindb.tendermint import BigchainDB from bigchaindb.consensus import BaseConsensusRules @@ -62,7 +67,19 @@ def test_bigchain_class_initialization_with_parameters(): assert bigchain.consensus == BaseConsensusRules -@pytest.mark.skip +def test_get_blocks_status_containing_tx(monkeypatch): + from bigchaindb.backend import query as backend_query + from bigchaindb.tendermint import BigchainDB + blocks = [ + {'id': 1}, {'id': 2} + ] + monkeypatch.setattr(backend_query, 'get_blocks_status_from_transaction', lambda x: blocks) + monkeypatch.setattr(BigchainDB, 'block_election_status', lambda x, y, z: BigchainDB.BLOCK_VALID) + bigchain = BigchainDB(public_key='pubkey', private_key='privkey') + with pytest.raises(Exception): + bigchain.get_blocks_status_containing_tx('txid') + + @pytest.mark.genesis def test_get_spent_issue_1271(b, alice, bob, carol): from bigchaindb.models import Transaction @@ -71,6 +88,8 @@ def test_get_spent_issue_1271(b, alice, bob, carol): [carol.public_key], [([carol.public_key], 8)], ).sign([carol.private_key]) + assert b.validate_transaction(tx_1) + b.store_bulk_transactions([tx_1]) tx_2 = Transaction.transfer( tx_1.to_inputs(), @@ -79,6 +98,8 @@ def test_get_spent_issue_1271(b, alice, bob, carol): ([carol.public_key], 4)], asset_id=tx_1.id, ).sign([carol.private_key]) + assert b.validate_transaction(tx_2) + b.store_bulk_transactions([tx_2]) tx_3 = Transaction.transfer( tx_2.to_inputs()[2:3], @@ -86,20 +107,25 @@ def test_get_spent_issue_1271(b, alice, bob, carol): ([carol.public_key], 3)], asset_id=tx_1.id, ).sign([carol.private_key]) + assert b.validate_transaction(tx_3) + b.store_bulk_transactions([tx_3]) tx_4 = Transaction.transfer( tx_2.to_inputs()[1:2] + tx_3.to_inputs()[0:1], [([bob.public_key], 3)], asset_id=tx_1.id, ).sign([alice.private_key]) + assert b.validate_transaction(tx_4) + b.store_bulk_transactions([tx_4]) tx_5 = Transaction.transfer( tx_2.to_inputs()[0:1], [([alice.public_key], 2)], asset_id=tx_1.id, ).sign([bob.private_key]) - block_5 = b.create_block([tx_1, tx_2, tx_3, tx_4, tx_5]) - b.write_block(block_5) + assert b.validate_transaction(tx_5) + b.store_bulk_transactions([tx_5]) + assert b.get_spent(tx_2.id, 0) == tx_5 assert not b.get_spent(tx_5.id, 0) assert b.get_outputs_filtered(alice.public_key)