Skip to content

Commit 6763e04

Browse files
committed
updated readme and setup
1 parent 7894669 commit 6763e04

File tree

6 files changed

+128
-77
lines changed

6 files changed

+128
-77
lines changed

CHANGE_LOG.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
July 2021 - v0.8.3
3+
- Removed ABCI re-exports. You must import the full proper module path
4+
abci.application
5+
abci.server
6+
abci.utils
7+
You can also access all the tendermint protobuf classes in the tendermint package
8+
- Refactored to src directory
9+
- Change readme to markdown
10+
- More tests

README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
[![pypi](https://img.shields.io/pypi/v/abci.svg)](https://pypi.python.org/pypi/abci)
2+
[![build](https://travis-ci.org/davebryson/py-abci.svg?branch=master)](https://https://travis-ci.org/davebryson/py-abci)
3+
[![codecoverage](https://codecov.io/gh/davebryson/py-abci/branch/master/graph/badge.svg)](https://codecov.io/gh/davebryson/py-abci)
4+
5+
# Py-ABCI
6+
Build Tendermint blockchain applications in Python. It's fun. This library provides the core functionality needed to create Tendermint ABCI applications.
7+
8+
## Supported Tendermint Version
9+
* Tendermint *0.34.11*
10+
* ABCI *0.17.0*
11+
12+
## Installation
13+
Requires Python >= 3.9
14+
15+
`pip install abci`
16+
17+
You'll need a binary version of the Tendermint engine.
18+
Available here: https://github.com/tendermint/tendermint/releases
19+
20+
**Make sure the Tendermint version you download matches the current support version of this library**
21+
22+
## Quick Start - demo
23+
24+
A very simple demo application is included and available from the command line as `counter`. You can find the code here: https://github.com/davebryson/py-abci/blob/master/src/example/counter.py
25+
26+
To try it out:
27+
1. Make sure you have the Tendermint binary setup locally and in your path. To test it's working
28+
open a terminal window and type:
29+
```text
30+
>> tendermint version
31+
```
32+
It should output your version of Tendermint that should match the currently supported version
33+
of this library.
34+
35+
2. Next, initialize Tendermint by running:
36+
```text
37+
>> tendermint init
38+
```
39+
40+
3. Start the Tendermint node:
41+
```text
42+
>> tendermint node
43+
```
44+
The node will start, but will be waiting for you application to start.
45+
46+
4. Open another terminal, and start the `counter` application. The `counter` will be available
47+
from within the Python environment where you installed `abci`
48+
```text
49+
>> counter
50+
```
51+
You'll see the application start, and in the Tendermint terminal, you'll see the output of
52+
blocks being produced
53+
54+
5. Now, open a 3rd terminal window to send some transaction to the blockchain. To do this we'll
55+
use the `curl` application to send transaction to the local blockchain over http. For example:
56+
```text
57+
>> curl http://localhost:26657/broadcast_tx_commit?tx=0x01
58+
>> curl http://localhost:26657/broadcast_tx_commit?tx=0x02
59+
```
60+
The counter application expects you to send `transactions` as numbers encoded as hex in order: 1,2,3...
61+
It will reject and out-of-order numbers. You can always see the latest accepted value by sending the
62+
request:
63+
```text
64+
>> curl http://localhost:26657/abci_query
65+
```
66+
67+
To shut down the application enter `CTRL-C`
68+
69+
## Get Started
70+
To start building your own application:
71+
1. Extend the `abci.application.BaseApplication` class
72+
2. Implement the Tendermint ABCI callbacks - see https://docs.tendermint.com/v0.34/spec/abci for details on how they work
73+
3. Start it:
74+
```python
75+
from abci.server import ABCIServer
76+
77+
app = ABCIServer(app=MyApplication())
78+
app.run()
79+
```
80+
See the ``counter.py`` application in the ``example`` directory https://github.com/davebryson/py-abci/blob/master/src/example/counter.py for a full example.
81+
82+
83+
## Developing on the code base
84+
If you're working directly on the code base. Install a local editable version:
85+
86+
`pip install --editable '.[test]'`
87+
88+
## Updating the Protobuf code
89+
90+
**You should only re-generate the protobuf code if you're updating the associated protobuf files,
91+
and/or contributing to this code base. You do not need to rebuild protos to create apps.**
92+
93+
A note on protobuf: The primary code directory is `abci`, but you'll notice additional
94+
directories: `gogoproto`, `tendermint`, and `protos`.
95+
96+
The `gogoproto` and `tendermint` directories are the protobuf generated code used by ``abci``. It adds proper Python modules and preserves all the import statements used by Tendermint for the various protobuf files spread
97+
across their codebase. The ``protos`` directory is the source .proto files.
98+
99+
To (re)build the protobuf files:
100+
101+
1. Install `protoc` so it's available in your PATH as a command
102+
2. Run `make update-proto`
103+
104+

README.rst

Lines changed: 0 additions & 72 deletions
This file was deleted.

breaking_changes.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

setup.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name = abci
33
version = attr: abci.__version__
44
description = Python based ABCI Server for Tendermint
5-
long_description = file: README.rst
6-
long_description_content_type = text/x-rst
5+
long_description = file: README.md
6+
long_description_content_type = text/markdown
77
url = https://github.com/davebryson/py-abci
88
author = Dave Bryson
99
license = Apache 2.0

tests/test_wire.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from tendermint.abci.types_pb2 import (
66
Request,
7+
RequestDeliverTx,
78
RequestEcho,
89
RequestInfo,
910
)
@@ -13,6 +14,7 @@ def test_raw_decoding():
1314
from io import BytesIO
1415

1516
# info + flush request
17+
# Note this is TM version specific!
1618
inbound = b"\x1e\x1a\r\n\x070.34.11\x10\x0b\x18\x08\x04\x12\x00"
1719
data = BytesIO(inbound)
1820

@@ -37,3 +39,13 @@ def test_encoding_decoding():
3739
buffer1 = BytesIO(raw1)
3840
req = next(read_messages(buffer1, Request))
3941
assert "info" == req.WhichOneof("value")
42+
43+
44+
def test_check_reading_batch():
45+
bits = b""
46+
for i in range(20):
47+
tx = (i).to_bytes(2, byteorder="big")
48+
bits += write_message(RequestDeliverTx(tx=tx))
49+
50+
result = [m.tx for m in read_messages(BytesIO(bits), RequestDeliverTx)]
51+
assert len(result) == 20

0 commit comments

Comments
 (0)