mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: Support for latest Tendermint missing (#2375)
Solution: Upgrade to py-abci 0.5.1 to use latest Tendermint
This commit is contained in:
parent
1118ddffa2
commit
c7503f5689
@ -25,6 +25,6 @@ ENV BIGCHAINDB_WSSERVER_SCHEME ws
|
||||
ENV BIGCHAINDB_WSSERVER_ADVERTISED_HOST 0.0.0.0
|
||||
ENV BIGCHAINDB_WSSERVER_ADVERTISED_SCHEME ws
|
||||
|
||||
ENV BIGCHAINDB_TENDERMINT_PORT 46657
|
||||
ENV BIGCHAINDB_TENDERMINT_PORT 26657
|
||||
ARG backend
|
||||
RUN bigchaindb -y configure "$backend"
|
@ -25,7 +25,7 @@ ENV BIGCHAINDB_WSSERVER_SCHEME ws
|
||||
ENV BIGCHAINDB_WSSERVER_ADVERTISED_HOST 0.0.0.0
|
||||
ENV BIGCHAINDB_WSSERVER_ADVERTISED_SCHEME ws
|
||||
|
||||
ENV BIGCHAINDB_TENDERMINT_PORT 46657
|
||||
ENV BIGCHAINDB_TENDERMINT_PORT 26657
|
||||
|
||||
ENV BIGCHAINDB_CI_ABCI ${abci_status}
|
||||
|
||||
|
@ -61,7 +61,7 @@ config = {
|
||||
},
|
||||
'tendermint': {
|
||||
'host': 'localhost',
|
||||
'port': 46657,
|
||||
'port': 26657,
|
||||
},
|
||||
# FIXME: hardcoding to localmongodb for now
|
||||
'database': _database_map['localmongodb'],
|
||||
|
@ -2,16 +2,28 @@
|
||||
with Tendermint."""
|
||||
import logging
|
||||
|
||||
from abci.application import BaseApplication, Result
|
||||
from abci.types_pb2 import ResponseEndBlock, ResponseInfo, Validator
|
||||
from abci.application import BaseApplication
|
||||
from abci.types_pb2 import (
|
||||
ResponseInitChain,
|
||||
ResponseInfo,
|
||||
ResponseCheckTx,
|
||||
ResponseBeginBlock,
|
||||
ResponseDeliverTx,
|
||||
ResponseEndBlock,
|
||||
ResponseCommit,
|
||||
Validator,
|
||||
PubKey
|
||||
)
|
||||
|
||||
from bigchaindb.tendermint import BigchainDB
|
||||
from bigchaindb.tendermint.utils import (decode_transaction,
|
||||
calculate_hash,
|
||||
amino_encoded_public_key)
|
||||
calculate_hash)
|
||||
from bigchaindb.tendermint.lib import Block, PreCommitState
|
||||
from bigchaindb.backend.query import PRE_COMMIT_ID
|
||||
|
||||
|
||||
CodeTypeOk = 0
|
||||
CodeTypeError = 1
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -35,8 +47,9 @@ class App(BaseApplication):
|
||||
|
||||
block = Block(app_hash='', height=0, transactions=[])
|
||||
self.bigchaindb.store_block(block._asdict())
|
||||
return ResponseInitChain()
|
||||
|
||||
def info(self):
|
||||
def info(self, request):
|
||||
"""Return height of the latest committed block."""
|
||||
r = ResponseInfo()
|
||||
block = self.bigchaindb.get_latest_block()
|
||||
@ -61,11 +74,11 @@ class App(BaseApplication):
|
||||
if self.bigchaindb.is_valid_transaction(transaction):
|
||||
logger.debug('check_tx: VALID')
|
||||
logger.benchmark('CHECK_TX_END, tx_id:%s', transaction['id'])
|
||||
return Result.ok()
|
||||
return ResponseCheckTx(code=CodeTypeOk)
|
||||
else:
|
||||
logger.debug('check_tx: INVALID')
|
||||
logger.benchmark('CHECK_TX_END, tx_id:%s', transaction['id'])
|
||||
return Result.error()
|
||||
return ResponseCheckTx(code=CodeTypeError)
|
||||
|
||||
def begin_block(self, req_begin_block):
|
||||
"""Initialize list of transaction.
|
||||
@ -79,6 +92,7 @@ class App(BaseApplication):
|
||||
|
||||
self.block_txn_ids = []
|
||||
self.block_transactions = []
|
||||
return ResponseBeginBlock()
|
||||
|
||||
def deliver_tx(self, raw_transaction):
|
||||
"""Validate the transaction before mutating the state.
|
||||
@ -91,19 +105,21 @@ class App(BaseApplication):
|
||||
|
||||
if not transaction:
|
||||
logger.debug('deliver_tx: INVALID')
|
||||
return Result.error(log='Invalid transaction')
|
||||
return ResponseDeliverTx(code=CodeTypeError)
|
||||
else:
|
||||
logger.debug('storing tx')
|
||||
self.block_txn_ids.append(transaction.id)
|
||||
self.block_transactions.append(transaction)
|
||||
return Result.ok()
|
||||
return ResponseDeliverTx(code=CodeTypeOk)
|
||||
|
||||
def end_block(self, height):
|
||||
def end_block(self, request_end_block):
|
||||
"""Calculate block hash using transaction ids and previous block
|
||||
hash to be stored in the next block.
|
||||
|
||||
Args:
|
||||
height (int): new height of the chain."""
|
||||
|
||||
height = request_end_block.height
|
||||
self.new_height = height
|
||||
block_txn_hash = calculate_hash(self.block_txn_ids)
|
||||
block = self.bigchaindb.get_latest_block()
|
||||
@ -126,15 +142,11 @@ class App(BaseApplication):
|
||||
transactions=self.block_txn_ids)
|
||||
logger.debug('Updating PreCommitState: %s', self.new_height)
|
||||
self.bigchaindb.store_pre_commit_state(pre_commit_state._asdict())
|
||||
|
||||
# NOTE: interface for `ResponseEndBlock` has be changed in the latest
|
||||
# version of py-abci i.e. the validator updates should be return
|
||||
# as follows:
|
||||
# ResponseEndBlock(validator_updates=validator_updates)
|
||||
return ResponseEndBlock(validator_updates=validator_updates)
|
||||
|
||||
def commit(self):
|
||||
"""Store the new height and along with block hash."""
|
||||
|
||||
data = self.block_txn_hash.encode('utf-8')
|
||||
|
||||
# register a new block only when new transactions are received
|
||||
@ -151,12 +163,16 @@ class App(BaseApplication):
|
||||
'height=%s, txn ids=%s', data, self.new_height,
|
||||
self.block_txn_ids)
|
||||
logger.benchmark('COMMIT_BLOCK, height:%s', self.new_height)
|
||||
return data
|
||||
return ResponseCommit(data=data)
|
||||
|
||||
|
||||
def encode_validator(v):
|
||||
ed25519_public_key = v['pub_key']['data']
|
||||
# NOTE: tendermint expects public to be encoded in go-amino format
|
||||
pub_key = amino_encoded_public_key(ed25519_public_key)
|
||||
|
||||
pub_key = PubKey(type='ed25519',
|
||||
data=bytes.fromhex(ed25519_public_key))
|
||||
|
||||
return Validator(pub_key=pub_key,
|
||||
address=b'',
|
||||
power=v['power'])
|
||||
|
@ -34,26 +34,26 @@ services:
|
||||
BIGCHAINDB_WSSERVER_HOST: 0.0.0.0
|
||||
BIGCHAINDB_WSSERVER_ADVERTISED_HOST: bigchaindb
|
||||
BIGCHAINDB_TENDERMINT_HOST: tendermint
|
||||
BIGCHAINDB_TENDERMINT_PORT: 46657
|
||||
BIGCHAINDB_TENDERMINT_PORT: 26657
|
||||
ports:
|
||||
- "9984:9984"
|
||||
- "9985:9985"
|
||||
- "46658"
|
||||
- "26658"
|
||||
healthcheck:
|
||||
test: ["CMD", "bash", "-c", "curl http://bigchaindb:9984 && curl http://tendermint:46657/abci_query"]
|
||||
test: ["CMD", "bash", "-c", "curl http://bigchaindb:9984 && curl http://tendermint:26657/abci_query"]
|
||||
interval: 3s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
command: '.ci/entrypoint.sh'
|
||||
tendermint:
|
||||
image: tendermint/tendermint:0.19.9
|
||||
image: tendermint/tendermint:0.22.0
|
||||
# volumes:
|
||||
# - ./tmdata:/tendermint
|
||||
entrypoint: ''
|
||||
ports:
|
||||
- "46656:46656"
|
||||
- "46657:46657"
|
||||
command: sh -c "tendermint init && tendermint node --consensus.create_empty_blocks=false --proxy_app=tcp://bigchaindb:46658"
|
||||
- "26656:26656"
|
||||
- "26657:26657"
|
||||
command: sh -c "tendermint init && tendermint node --consensus.create_empty_blocks=false --proxy_app=tcp://bigchaindb:26658"
|
||||
bdb:
|
||||
image: busybox
|
||||
depends_on:
|
||||
@ -64,7 +64,7 @@ services:
|
||||
# curl client to check the health of development env
|
||||
curl-client:
|
||||
image: appropriate/curl
|
||||
command: /bin/sh -c "curl -s http://bigchaindb:9984/ > /dev/null && curl -s http://tendermint:46657/ > /dev/null"
|
||||
command: /bin/sh -c "curl -s http://bigchaindb:9984/ > /dev/null && curl -s http://tendermint:26657/ > /dev/null"
|
||||
|
||||
# BigchainDB setup to do acceptance testing with Python
|
||||
python-acceptance:
|
||||
|
@ -9,7 +9,7 @@ The following ports should expect unsolicited inbound traffic:
|
||||
1. **Port 22** can expect inbound SSH (TCP) traffic from the node administrator (i.e. a small set of IP addresses).
|
||||
1. **Port 9984** can expect inbound HTTP (TCP) traffic from BigchainDB clients sending transactions to the BigchainDB HTTP API.
|
||||
1. **Port 9985** can expect inbound WebSocket traffic from BigchainDB clients.
|
||||
1. **Port 46656** can expect inbound Tendermint P2P traffic from other Tendermint peers.
|
||||
1. **Port 26656** can expect inbound Tendermint P2P traffic from other Tendermint peers.
|
||||
1. **Port 9986** can expect inbound HTTP (TCP) traffic from clients accessing the Public Key of a Tendermint instance.
|
||||
|
||||
All other ports should only get inbound traffic in response to specific requests from inside the node.
|
||||
@ -56,17 +56,17 @@ Port 9985 is the default port for the [BigchainDB WebSocket Event Stream API](..
|
||||
Port 9986 is the default port to access the Public Key of a Tendermint instance, it is used by a NGINX instance
|
||||
that runs with Tendermint instance(Pod), and only hosts the Public Key.
|
||||
|
||||
## Port 46656
|
||||
## Port 26656
|
||||
|
||||
Port 46656 is the default port used by Tendermint Core to communicate with other instances of Tendermint Core (peers).
|
||||
Port 26656 is the default port used by Tendermint Core to communicate with other instances of Tendermint Core (peers).
|
||||
|
||||
## Port 46657
|
||||
## Port 26657
|
||||
|
||||
Port 46657 is the default port used by Tendermint Core for RPC traffic. BigchainDB nodes use that internally; they don't expect incoming traffic from the outside world on port 46657.
|
||||
Port 26657 is the default port used by Tendermint Core for RPC traffic. BigchainDB nodes use that internally; they don't expect incoming traffic from the outside world on port 26657.
|
||||
|
||||
## Port 46658
|
||||
## Port 26658
|
||||
|
||||
Port 46658 is the default port used by Tendermint Core for ABCI traffic. BigchainDB nodes use that internally; they don't expect incoming traffic from the outside world on port 46658.
|
||||
Port 26658 is the default port used by Tendermint Core for ABCI traffic. BigchainDB nodes use that internally; they don't expect incoming traffic from the outside world on port 26658.
|
||||
|
||||
## Other Ports
|
||||
|
||||
|
@ -56,7 +56,7 @@ BigchainDB Node
|
||||
| | |
|
||||
| v |
|
||||
| |
|
||||
| "443" +----------+ "46656/9986" |
|
||||
| "443" +----------+ "26656/9986" |
|
||||
| | "Rate" | |
|
||||
| +---------------------------+"Limiting"+-----------------------+ |
|
||||
| | | "Logic" | | |
|
||||
@ -70,7 +70,7 @@ BigchainDB Node
|
||||
| v | v |
|
||||
| +-------------+ | +------------+ |
|
||||
| |"HTTPS" | | +------------------> |"Tendermint"| |
|
||||
| |"Termination"| | | "9986" |"Service" | "46656" |
|
||||
| |"Termination"| | | "9986" |"Service" | "26656" |
|
||||
| | | | | +-------+ | <----+ |
|
||||
| +-----+-------+ | | | +------------+ | |
|
||||
| | | | | | |
|
||||
@ -205,6 +205,6 @@ In a multi-node deployment, Tendermint nodes/peers communicate with each other v
|
||||
the public ports exposed by the NGINX gateway.
|
||||
|
||||
We use port **9986** (configurable) to allow tendermint nodes to access the public keys
|
||||
of the peers and port **46656** (configurable) for the rest of the communications between
|
||||
of the peers and port **26656** (configurable) for the rest of the communications between
|
||||
the peers.
|
||||
|
||||
|
@ -674,7 +674,7 @@ To test the BigchainDB instance:
|
||||
|
||||
$ curl -X GET http://bdb-instance-0:9986/pub_key.json
|
||||
|
||||
$ curl -X GET http://bdb-instance-0:46657/abci_info
|
||||
$ curl -X GET http://bdb-instance-0:26657/abci_info
|
||||
|
||||
$ wsc -er ws://bdb-instance-0:9985/api/v1/streams/valid_transactions
|
||||
|
||||
|
@ -440,7 +440,7 @@ consensus(Tendermint) backend that we are using:
|
||||
**Example using environment variables**
|
||||
```text
|
||||
export BIGCHAINDB_TENDERMINT_HOST=tendermint
|
||||
export BIGCHAINDB_TENDERMINT_PORT=46657
|
||||
export BIGCHAINDB_TENDERMINT_PORT=26657
|
||||
```
|
||||
|
||||
**Default values**
|
||||
@ -448,6 +448,6 @@ export BIGCHAINDB_TENDERMINT_PORT=46657
|
||||
```js
|
||||
"tendermint": {
|
||||
"host": "localhost",
|
||||
"port": 46657,
|
||||
"port": 26657,
|
||||
}
|
||||
```
|
||||
|
@ -86,13 +86,13 @@ sudo mv tendermint /usr/local/bin
|
||||
|
||||
### Set Up the Firewall
|
||||
|
||||
Make sure to accept inbound connections on ports `9984`, `9985`, and `46656`. You might also want to add port `22` so that you can continue to access the machine via SSH.
|
||||
Make sure to accept inbound connections on ports `9984`, `9985`, and `26656`. You might also want to add port `22` so that you can continue to access the machine via SSH.
|
||||
|
||||
```
|
||||
sudo ufw allow 22/tcp
|
||||
sudo ufw allow 9984/tcp
|
||||
sudo ufw allow 9985/tcp
|
||||
sudo ufw allow 46656/tcp
|
||||
sudo ufw allow 26656/tcp
|
||||
sudo ufw enable
|
||||
```
|
||||
|
||||
@ -214,9 +214,9 @@ The Member must edit the `.tendermint/config/config.toml` file and make the foll
|
||||
create_empty_blocks = false
|
||||
...
|
||||
|
||||
persistent_peers = "<Member 1 node id>@<Member 1 hostname>:46656,\
|
||||
<Member 2 node id>@<Member 2 hostname>:46656,\
|
||||
<Member N node id>@<Member N hostname>:46656,"
|
||||
persistent_peers = "<Member 1 node id>@<Member 1 hostname>:26656,\
|
||||
<Member 2 node id>@<Member 2 hostname>:26656,\
|
||||
<Member N node id>@<Member N hostname>:26656,"
|
||||
```
|
||||
|
||||
## Member: Start MongoDB, BigchainDB and Tendermint
|
||||
|
@ -9,9 +9,9 @@ spec:
|
||||
ports:
|
||||
spec:
|
||||
ports:
|
||||
- port: 46656
|
||||
- port: 26656
|
||||
name: p2p
|
||||
- port: 46657
|
||||
- port: 26657
|
||||
name: pubkey
|
||||
- port: 9986
|
||||
name: nginx
|
||||
|
@ -126,9 +126,9 @@ spec:
|
||||
- name: bdb-config-data
|
||||
mountPath: /tendermint_node_data
|
||||
ports:
|
||||
- containerPort: 46656
|
||||
- containerPort: 26656
|
||||
name: p2p
|
||||
- containerPort: 46657
|
||||
- containerPort: 26657
|
||||
name: rpc
|
||||
livenessProbe:
|
||||
exec:
|
||||
@ -266,7 +266,7 @@ spec:
|
||||
- containerPort: 9985
|
||||
protocol: TCP
|
||||
name: bdb-ws-port
|
||||
- containerPort: 46658
|
||||
- containerPort: 26658
|
||||
protocol: TCP
|
||||
name: bdb-abci-port
|
||||
volumeMounts:
|
||||
|
@ -17,16 +17,16 @@ spec:
|
||||
targetPort: 9985
|
||||
name: bdb-ws-port
|
||||
protocol: TCP
|
||||
- port: 46658
|
||||
targetPort: 46658
|
||||
- port: 26658
|
||||
targetPort: 26658
|
||||
name: tm-abci-port
|
||||
protocol: TCP
|
||||
- port: 46656
|
||||
targetPort: 46656
|
||||
- port: 26656
|
||||
targetPort: 26656
|
||||
name: tm-p2p-port
|
||||
protocol: TCP
|
||||
- port: 46657
|
||||
targetPort: 46657
|
||||
- port: 26657
|
||||
targetPort: 26657
|
||||
name: tm-rpc-port
|
||||
protocol: TCP
|
||||
- port: 9986
|
||||
|
@ -6,5 +6,5 @@ RUN apk --update add bash
|
||||
COPY genesis.json.template /etc/tendermint/genesis.json
|
||||
COPY tendermint_entrypoint.bash /
|
||||
VOLUME /tendermint /tendermint_node_data
|
||||
EXPOSE 46656 46657
|
||||
EXPOSE 26656 26657
|
||||
ENTRYPOINT ["/tendermint_entrypoint.bash"]
|
||||
|
@ -146,15 +146,15 @@ data:
|
||||
|
||||
# bdb-abci-port is used by Tendermint Core for ABCI traffic. BigchainDB nodes
|
||||
# use that internally.
|
||||
bdb-abci-port: "46658"
|
||||
bdb-abci-port: "26658"
|
||||
|
||||
# bdb-p2p-port is used by Tendermint Core to communicate with
|
||||
# other peers in the network. This port is accessible publicly.
|
||||
bdb-p2p-port: "46656"
|
||||
bdb-p2p-port: "26656"
|
||||
|
||||
# bdb-rpc-port is used by Tendermint Core to rpc. BigchainDB nodes
|
||||
# use this port internally.
|
||||
bbd-rpc-port: "46657"
|
||||
bbd-rpc-port: "26657"
|
||||
|
||||
# bdb-pub-key-access is the port number used to host/publish the
|
||||
# public key of the tendemrint node in this cluster.
|
||||
|
@ -7,5 +7,5 @@ RUN apt-get update \
|
||||
&& apt-get clean
|
||||
COPY nginx.conf.template /etc/nginx/nginx.conf
|
||||
COPY nginx_entrypoint.bash /
|
||||
EXPOSE 80 27017 9986 46656
|
||||
EXPOSE 80 27017 9986 26656
|
||||
ENTRYPOINT ["/nginx_entrypoint.bash"]
|
||||
|
@ -79,7 +79,7 @@ spec:
|
||||
- containerPort: 9986
|
||||
protocol: TCP
|
||||
name: bdb-pub-key
|
||||
- containerPort: 46656
|
||||
- containerPort: 26656
|
||||
protocol: TCP
|
||||
name: bdb-p2p-port
|
||||
livenessProbe:
|
||||
|
@ -8,5 +8,5 @@ RUN apt-get update \
|
||||
COPY nginx.conf.threescale.template /etc/nginx/nginx-threescale.conf
|
||||
COPY nginx.conf.template /etc/nginx/nginx.conf
|
||||
COPY nginx_entrypoint.bash /
|
||||
EXPOSE 80 443 27017 9986 46656
|
||||
EXPOSE 80 443 27017 9986 26656
|
||||
ENTRYPOINT ["/nginx_entrypoint.bash"]
|
||||
|
@ -103,7 +103,7 @@ spec:
|
||||
- containerPort: 9986
|
||||
protocol: TCP
|
||||
name: bdb-pub-key
|
||||
- containerPort: 46656
|
||||
- containerPort: 26656
|
||||
protocol: TCP
|
||||
name: bdb-p2p-port
|
||||
livenessProbe:
|
||||
|
@ -25,8 +25,8 @@ spec:
|
||||
targetPort: 9986
|
||||
name: tm-pub-key-access
|
||||
protocol: TCP
|
||||
- port: 46656
|
||||
targetPort: 46656
|
||||
- port: 26656
|
||||
targetPort: 26656
|
||||
protocol: TCP
|
||||
name: tm-p2p-port
|
||||
- port: 80
|
||||
|
@ -379,15 +379,15 @@ data:
|
||||
|
||||
# bdb-abci-port is used by Tendermint Core for ABCI traffic. BigchainDB nodes
|
||||
# use that internally.
|
||||
bdb-abci-port: "46658"
|
||||
bdb-abci-port: "26658"
|
||||
|
||||
# bdb-p2p-port is used by Tendermint Core to communicate with
|
||||
# other peers in the network. This port is accessible publicly.
|
||||
bdb-p2p-port: "46656"
|
||||
bdb-p2p-port: "26656"
|
||||
|
||||
# bdb-rpc-port is used by Tendermint Core to rpc. BigchainDB nodes
|
||||
# use this port internally.
|
||||
bdb-rpc-port: "46657"
|
||||
bdb-rpc-port: "26657"
|
||||
|
||||
# bdb-pub-key-access is the port number used to host/publish the
|
||||
# public key of the tendemrint node in this cluster.
|
||||
|
@ -38,6 +38,6 @@ mongodb_docker_name: "mongodb"
|
||||
tendermint_docker_name: "tendermint"
|
||||
bigchaindb_default_server_port: 9984
|
||||
bigchaindb_default_ws_port: 9985
|
||||
bigchaindb_tendermint_port: 46657
|
||||
bigchaindb_tendermint_port: 26657
|
||||
tendermint_abci_port: 45558
|
||||
bigchaindb_docker_net: "bigchaindb_docker_net"
|
||||
bigchaindb_docker_net: "bigchaindb_docker_net"
|
||||
|
@ -36,6 +36,6 @@
|
||||
BIGCHAINDB_WSSERVER_HOST: 0.0.0.0
|
||||
BIGCHAINDB_WSSERVER_PORT: 9985
|
||||
BIGCHAINDB_TENDERMINT_HOST: 127.0.0.1
|
||||
BIGCHAINDB_TENDERMINT_PORT: 46657
|
||||
BIGCHAINDB_TENDERMINT_PORT: 26657
|
||||
when: mdb_pchk.stdout| int != 0 and bdb_pchk.stdout| int == 0 and tm_pchk.stdout| int != 0
|
||||
tags: [bigchaindb]
|
||||
tags: [bigchaindb]
|
||||
|
@ -13,9 +13,9 @@ bigchaindb_docker_net: "bigchaindb_docker_net"
|
||||
tendermint_host_mount_dir: "{{ home_dir }}/tendermint_docker"
|
||||
tendermint_host_mount_config_dir: "{{ home_dir }}/tendermint_config"
|
||||
tendermint_home: /tendermint/config
|
||||
tendermint_p2p_port: 46656
|
||||
tendermint_rpc_port: 46657
|
||||
tendermint_abci_port: 46658
|
||||
tendermint_p2p_port: 26656
|
||||
tendermint_rpc_port: 26657
|
||||
tendermint_abci_port: 26658
|
||||
|
||||
directories:
|
||||
- "{{ tendermint_home }}"
|
||||
@ -24,4 +24,4 @@ tendermint_conf_files: [
|
||||
{ src: "genesis.json", dest: "{{ tendermint_home }}/genesis.json"},
|
||||
{ src: "config.toml", dest: "{{ tendermint_home}}/config.toml"},
|
||||
{ src: "access_pub_key.conf", dest: "/etc/nginx/conf.d/access_pub_key.conf"}
|
||||
]
|
||||
]
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
# TCP or UNIX socket address of the ABCI application,
|
||||
# or the name of an ABCI application compiled in with the Tendermint binary
|
||||
proxy_app = "tcp://127.0.0.1:46658"
|
||||
proxy_app = "tcp://127.0.0.1:26658"
|
||||
|
||||
# A custom human readable name for this node
|
||||
moniker = "d16137710ef8"
|
||||
@ -51,7 +51,7 @@ filter_peers = false
|
||||
[rpc]
|
||||
|
||||
# TCP or UNIX socket address for the RPC server to listen on
|
||||
laddr = "tcp://0.0.0.0:46657"
|
||||
laddr = "tcp://0.0.0.0:26657"
|
||||
|
||||
# TCP or UNIX socket address for the gRPC server to listen on
|
||||
# NOTE: This server only supports /broadcast_tx_commit
|
||||
@ -64,7 +64,7 @@ unsafe = false
|
||||
[p2p]
|
||||
|
||||
# Address to listen for incoming connections
|
||||
laddr = "tcp://0.0.0.0:46656"
|
||||
laddr = "tcp://0.0.0.0:26656"
|
||||
|
||||
# Comma separated list of seed nodes to connect to
|
||||
seeds = ""
|
||||
|
@ -56,8 +56,8 @@
|
||||
mv /tendermint_config/node_key"{{ item|string }}".json /tendermint/config/node_key.json &&
|
||||
peers=() && for i in $( seq {{ stack_size }} );do peers+=($(cat /tendermint_config/node_id$i)@"{{ tendermint_docker_name }}$i:{{ tendermint_p2p_port }}");done &&
|
||||
peers=$(IFS=","; echo "${peers[*]}") && echo $peers &&
|
||||
tendermint node --p2p.persistent_peers="$peers" --p2p.laddr "tcp://"{{ tendermint_docker_name }}{{ item|string }}":46656"
|
||||
--proxy_app="tcp://"{{ bigchaindb_docker_name }}{{ item|string }}":46658" --consensus.create_empty_blocks=false --p2p.pex=false'
|
||||
tendermint node --p2p.persistent_peers="$peers" --p2p.laddr "tcp://"{{ tendermint_docker_name }}{{ item|string }}":26656"
|
||||
--proxy_app="tcp://"{{ bigchaindb_docker_name }}{{ item|string }}":26658" --consensus.create_empty_blocks=false --p2p.pex=false'
|
||||
state: started
|
||||
keep_volumes: true
|
||||
with_sequence: start=1 end="{{ stack_size|int }}" stride=1
|
||||
@ -87,4 +87,4 @@
|
||||
|
||||
- import_tasks: common.yml
|
||||
when: stack_type|lower == "local"
|
||||
tags: [tendermint]
|
||||
tags: [tendermint]
|
||||
|
@ -94,5 +94,5 @@ done
|
||||
peers=$(IFS=','; echo "${peers[*]}")
|
||||
|
||||
echo "INFO: starting tendermint..."
|
||||
/usr/local/bin/tendermint node --home "/tendermint" --p2p.persistent_peers="$peers" --proxy_app="tcp://0.0.0.0:46658" --consensus.create_empty_blocks=false --p2p.pex=false
|
||||
{% endraw %}
|
||||
/usr/local/bin/tendermint node --home "/tendermint" --p2p.persistent_peers="$peers" --proxy_app="tcp://0.0.0.0:26658" --consensus.create_empty_blocks=false --p2p.pex=false
|
||||
{% endraw %}
|
||||
|
2
setup.py
2
setup.py
@ -87,7 +87,7 @@ install_requires = [
|
||||
'pyyaml~=3.12',
|
||||
'aiohttp~=2.3',
|
||||
'python-rapidjson-schema==0.1.1',
|
||||
'bigchaindb-abci==0.4.5',
|
||||
'bigchaindb-abci==0.5.1',
|
||||
'setproctitle~=1.1.0',
|
||||
]
|
||||
|
||||
|
@ -109,7 +109,7 @@ def _configure_bigchaindb(request):
|
||||
'database': bigchaindb._database_map[backend],
|
||||
'tendermint': {
|
||||
'host': 'localhost',
|
||||
'port': 46657,
|
||||
'port': 26657,
|
||||
}
|
||||
}
|
||||
config['database']['name'] = test_db_name
|
||||
@ -445,7 +445,7 @@ def tendermint_host():
|
||||
|
||||
@pytest.fixture
|
||||
def tendermint_port():
|
||||
return int(os.getenv('BIGCHAINDB_TENDERMINT_PORT', 46657))
|
||||
return int(os.getenv('BIGCHAINDB_TENDERMINT_PORT', 26657))
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -1,7 +1,12 @@
|
||||
import json
|
||||
import pytest
|
||||
|
||||
from abci.types_pb2 import RequestBeginBlock
|
||||
from abci.types_pb2 import (
|
||||
RequestBeginBlock,
|
||||
RequestEndBlock
|
||||
)
|
||||
|
||||
from bigchaindb.tendermint.core import CodeTypeOk, CodeTypeError
|
||||
|
||||
|
||||
pytestmark = [pytest.mark.tendermint, pytest.mark.bdb]
|
||||
@ -25,7 +30,7 @@ def test_check_tx__signed_create_is_ok(b):
|
||||
|
||||
app = App(b)
|
||||
result = app.check_tx(encode_tx_to_bytes(tx))
|
||||
assert result.is_ok()
|
||||
assert result.code == CodeTypeOk
|
||||
|
||||
|
||||
def test_check_tx__unsigned_create_is_error(b):
|
||||
@ -41,7 +46,7 @@ def test_check_tx__unsigned_create_is_error(b):
|
||||
|
||||
app = App(b)
|
||||
result = app.check_tx(encode_tx_to_bytes(tx))
|
||||
assert result.is_error()
|
||||
assert result.code == CodeTypeError
|
||||
|
||||
|
||||
@pytest.mark.bdb
|
||||
@ -64,9 +69,9 @@ def test_deliver_tx__valid_create_updates_db(b):
|
||||
app.begin_block(begin_block)
|
||||
|
||||
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
||||
assert result.is_ok()
|
||||
assert result.code == CodeTypeOk
|
||||
|
||||
app.end_block(99)
|
||||
app.end_block(RequestEndBlock(height=99))
|
||||
app.commit()
|
||||
assert b.get_transaction(tx.id).id == tx.id
|
||||
|
||||
@ -97,14 +102,14 @@ def test_deliver_tx__double_spend_fails(b):
|
||||
app.begin_block(begin_block)
|
||||
|
||||
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
||||
assert result.is_ok()
|
||||
assert result.code == CodeTypeOk
|
||||
|
||||
app.end_block(99)
|
||||
app.end_block(RequestEndBlock(height=99))
|
||||
app.commit()
|
||||
|
||||
assert b.get_transaction(tx.id).id == tx.id
|
||||
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
||||
assert result.is_error()
|
||||
assert result.code == CodeTypeError
|
||||
|
||||
|
||||
def test_deliver_transfer_tx__double_spend_fails(b):
|
||||
@ -132,7 +137,7 @@ def test_deliver_transfer_tx__double_spend_fails(b):
|
||||
.sign([alice.private_key])
|
||||
|
||||
result = app.deliver_tx(encode_tx_to_bytes(tx))
|
||||
assert result.is_ok()
|
||||
assert result.code == CodeTypeOk
|
||||
|
||||
tx_transfer = Transaction.transfer(tx.to_inputs(),
|
||||
[([bob.public_key], 1)],
|
||||
@ -140,7 +145,7 @@ def test_deliver_transfer_tx__double_spend_fails(b):
|
||||
.sign([alice.private_key])
|
||||
|
||||
result = app.deliver_tx(encode_tx_to_bytes(tx_transfer))
|
||||
assert result.is_ok()
|
||||
assert result.code == CodeTypeOk
|
||||
|
||||
double_spend = Transaction.transfer(tx.to_inputs(),
|
||||
[([carly.public_key], 1)],
|
||||
@ -148,7 +153,7 @@ def test_deliver_transfer_tx__double_spend_fails(b):
|
||||
.sign([alice.private_key])
|
||||
|
||||
result = app.deliver_tx(encode_tx_to_bytes(double_spend))
|
||||
assert result.is_error()
|
||||
assert result.code == CodeTypeError
|
||||
|
||||
|
||||
def test_end_block_return_validator_updates(b):
|
||||
@ -170,7 +175,7 @@ def test_end_block_return_validator_updates(b):
|
||||
'update_id': VALIDATOR_UPDATE_ID}
|
||||
query.store_validator_update(b.connection, validator_update)
|
||||
|
||||
resp = app.end_block(99)
|
||||
resp = app.end_block(RequestEndBlock(height=99))
|
||||
assert resp.validator_updates[0] == encode_validator(validator)
|
||||
|
||||
updates = b.get_validator_update()
|
||||
@ -194,7 +199,7 @@ def test_store_pre_commit_state_in_end_block(b, alice):
|
||||
begin_block = RequestBeginBlock()
|
||||
app.begin_block(begin_block)
|
||||
app.deliver_tx(encode_tx_to_bytes(tx))
|
||||
app.end_block(99)
|
||||
app.end_block(RequestEndBlock(height=99))
|
||||
|
||||
resp = query.get_pre_commit_state(b.connection, PRE_COMMIT_ID)
|
||||
assert resp['commit_id'] == PRE_COMMIT_ID
|
||||
@ -203,7 +208,7 @@ def test_store_pre_commit_state_in_end_block(b, alice):
|
||||
|
||||
app.begin_block(begin_block)
|
||||
app.deliver_tx(encode_tx_to_bytes(tx))
|
||||
app.end_block(100)
|
||||
app.end_block(RequestEndBlock(height=100))
|
||||
resp = query.get_pre_commit_state(b.connection, PRE_COMMIT_ID)
|
||||
assert resp['commit_id'] == PRE_COMMIT_ID
|
||||
assert resp['height'] == 100
|
||||
|
@ -4,8 +4,7 @@ import pytest
|
||||
|
||||
|
||||
from abci.server import ProtocolHandler
|
||||
from abci.encoding import read_message
|
||||
from abci.messages import to_request_deliver_tx, to_request_check_tx
|
||||
from abci.encoding import read_messages
|
||||
from copy import deepcopy
|
||||
from io import BytesIO
|
||||
|
||||
@ -22,14 +21,14 @@ def test_app(tb):
|
||||
app = App(b)
|
||||
p = ProtocolHandler(app)
|
||||
|
||||
data = p.process('info', None)
|
||||
res, err = read_message(BytesIO(data), types.Response)
|
||||
data = p.process('info', types.Request(info=types.RequestInfo(version='2')))
|
||||
res = next(read_messages(BytesIO(data), types.Response))
|
||||
assert res
|
||||
assert res.info.last_block_app_hash == b''
|
||||
assert res.info.last_block_height == 0
|
||||
assert not b.get_latest_block()
|
||||
|
||||
p.process('init_chain', None)
|
||||
p.process('init_chain', types.Request(init_chain=types.RequestInitChain()))
|
||||
block0 = b.get_latest_block()
|
||||
assert block0
|
||||
assert block0['height'] == 0
|
||||
@ -42,9 +41,9 @@ def test_app(tb):
|
||||
.sign([alice.private_key])
|
||||
etxn = json.dumps(tx.to_dict()).encode('utf8')
|
||||
|
||||
r = to_request_check_tx(etxn)
|
||||
r = types.Request(check_tx=types.RequestCheckTx(tx=etxn))
|
||||
data = p.process('check_tx', r)
|
||||
res, err = read_message(BytesIO(data), types.Response)
|
||||
res = next(read_messages(BytesIO(data), types.Response))
|
||||
assert res
|
||||
assert res.check_tx.code == 0
|
||||
|
||||
@ -52,25 +51,24 @@ def test_app(tb):
|
||||
r.begin_block.hash = b''
|
||||
p.process('begin_block', r)
|
||||
|
||||
r = to_request_deliver_tx(etxn)
|
||||
r = types.Request(deliver_tx=types.RequestDeliverTx(tx=etxn))
|
||||
data = p.process('deliver_tx', r)
|
||||
res, err = read_message(BytesIO(data), types.Response)
|
||||
res = next(read_messages(BytesIO(data), types.Response))
|
||||
assert res
|
||||
assert res.deliver_tx.code == 0
|
||||
|
||||
new_block_txn_hash = calculate_hash([tx.id])
|
||||
|
||||
r = types.Request()
|
||||
r.end_block.height = 1
|
||||
r = types.Request(end_block=types.RequestEndBlock(height=1))
|
||||
data = p.process('end_block', r)
|
||||
res, err = read_message(BytesIO(data), types.Response)
|
||||
res = next(read_messages(BytesIO(data), types.Response))
|
||||
assert res
|
||||
assert 'end_block' == res.WhichOneof('value')
|
||||
|
||||
new_block_hash = calculate_hash([block0['app_hash'], new_block_txn_hash])
|
||||
|
||||
data = p.process('commit', None)
|
||||
res, err = read_message(BytesIO(data), types.Response)
|
||||
res = next(read_messages(BytesIO(data), types.Response))
|
||||
assert res.commit.data == new_block_hash.encode('utf-8')
|
||||
assert b.get_transaction(tx.id).id == tx.id
|
||||
|
||||
@ -89,7 +87,7 @@ def test_app(tb):
|
||||
p.process('end_block', r)
|
||||
|
||||
data = p.process('commit', None)
|
||||
res, err = read_message(BytesIO(data), types.Response)
|
||||
res = next(read_messages(BytesIO(data), types.Response))
|
||||
assert res.commit.data == new_block_hash.encode('utf-8')
|
||||
|
||||
block0 = b.get_latest_block()
|
||||
@ -109,8 +107,8 @@ def test_upsert_validator(b, alice):
|
||||
import time
|
||||
|
||||
conn = connect()
|
||||
public_key = '1718D2DBFF00158A0852A17A01C78F4DCF3BA8E4FB7B8586807FAC182A535034'
|
||||
power = 1
|
||||
public_key = '9B3119650DF82B9A5D8A12E38953EA47475C09F0C48A4E6A0ECE182944B24403'
|
||||
|
||||
validator = {'pub_key': {'type': 'AC26791624DE60',
|
||||
'data': public_key},
|
||||
@ -133,7 +131,7 @@ def test_upsert_validator(b, alice):
|
||||
validators = [(v['pub_key']['value'], v['voting_power']) for v in validators]
|
||||
|
||||
public_key64 = public_key_to_base64(public_key)
|
||||
assert ((public_key64, power) in validators)
|
||||
assert ((public_key64, str(power)) in validators)
|
||||
|
||||
|
||||
@pytest.mark.abci
|
||||
|
@ -1,7 +1,7 @@
|
||||
# This is a TOML config file.
|
||||
# For more information, see https://github.com/toml-lang/toml
|
||||
|
||||
proxy_app = "tcp://bigchaindb:46658"
|
||||
proxy_app = "tcp://bigchaindb:26658"
|
||||
moniker = "anonymous"
|
||||
fast_sync = true
|
||||
db_backend = "leveldb"
|
||||
@ -11,8 +11,8 @@ log_level = "state:debug,*:error"
|
||||
create_empty_blocks = false
|
||||
|
||||
[rpc]
|
||||
laddr = "tcp://0.0.0.0:46657"
|
||||
laddr = "tcp://0.0.0.0:26657"
|
||||
|
||||
[p2p]
|
||||
laddr = "tcp://0.0.0.0:46656"
|
||||
laddr = "tcp://0.0.0.0:26656"
|
||||
seeds = ""
|
||||
|
Loading…
x
Reference in New Issue
Block a user