Coder Social home page Coder Social logo

py-tendermint's Introduction

py-Tendermint

A Python microframework for building blockchain applications with Tendermint

Inspired by Flask, py-tendermint makes it easy to quickly prototype a Tendermint ABCI application.

NOTE: the current version is broken due to ABCI changes For the interim, see py-abci

py-tendermint hides some of the repetitive setup for you by providing:

  • A Patricia Trie backed by persistent storage
  • Common Transaction model based on RLP (from Ethereum)
  • RPC Client
  • Accounts
  • ed25519 Keys

If you want to stay closer to the metal, check out the Tendermint Python ABCI library: https://github.com/davebryson/py-abci

Requirements

  • Python 3.6.x
  • Tendermint engine (of course)

Install

  • python setup.py install (pip install in the future)

Install

  • python setup.py install (pip install in the future)

Try it out

  • Run Tendermint 'init': tendermint --home ~/.pytendermint init Note we use a different home directory. to keep all our blockchain apps seperated.
  • In another terminal, start the app: python examples/simpleapp.py
  • Now start tendermint: tendermint --home ~/.pytendermint node
  • Finally, open another terminal and talk to the app: python examples/simpleapp_client.py

py-tendermint's People

Contributors

davebryson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

py-tendermint's Issues

Issues with tendermint 0.15 (abci)

Need to update to the latest pyabci with support for recent Tendermint abci protobuf changes. Will do once pushed to pypi. In the meantime, Tendermint 0.13 should still be working

"Failed to establish a new connection: [Errno 111] Connection refused" after running simpleapp_clien.py

python3 examples/simpleapp_client.py check-status

Error:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 171, in _new_conn
(self._dns_host, self.port), self.timeout, **extra_kw)
File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 79, in create_connection
raise err
File "/usr/local/lib/python3.6/dist-packages/urllib3/util/connection.py", line 69, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 600, in urlopen
chunked=chunked)
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 354, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 196, in connect
conn = self._new_conn()
File "/usr/local/lib/python3.6/dist-packages/urllib3/connection.py", line 180, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7fe26a656be0>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 445, in send
timeout=timeout
File "/usr/local/lib/python3.6/dist-packages/urllib3/connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/local/lib/python3.6/dist-packages/urllib3/util/retry.py", line 398, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=46657): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe26a656be0>: Failed to establish a new connection: [Errno 111] Connection refused',))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "examples/simpleapp_client.py", line 36, in
cli()
File "/usr/local/lib/python3.6/dist-packages/Click-7.0-py3.6.egg/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/Click-7.0-py3.6.egg/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.6/dist-packages/Click-7.0-py3.6.egg/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.6/dist-packages/Click-7.0-py3.6.egg/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.6/dist-packages/Click-7.0-py3.6.egg/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "examples/simpleapp_client.py", line 16, in check_status
print(rpc.status())
File "/usr/local/lib/python3.6/dist-packages/tendermint-0.3.0-py3.6.egg/tendermint/client.py", line 72, in status
return self.call('status', [])
File "/usr/local/lib/python3.6/dist-packages/tendermint-0.3.0-py3.6.egg/tendermint/client.py", line 42, in call
timeout=3
File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 559, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/requests/adapters.py", line 513, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='127.0.0.1', port=46657): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe26a656be0>: Failed to establish a new connection: [Errno 111] Connection refused',))

installation broken

using python3 setup.py install

Need this diff to get it to work:

-        'rlp>=0.6.0',
-        'trie>=0.2.4',
+        'rlp==0.4.7',
+        'trie==0.2.4',

Please provide requirements.txt file

etherum-utils 0.6.2 kept throwing errors RuntimeError: Format missing, but need one (identified source as text as no file with that name was found). and the working version is 0.6.1

Error when trying example counter app

I'm running tendermint version 0.11.1.

I started a tendermint node and the example counter app from the readme.
Then I tried to send a transaction with curl:
curl "http://localhost:46657/broadcast_tx_commit?tx=0x01"
but got this error:

Traceback (most recent call last):
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/rlp-0.4.7-py3.6.egg/rlp/sedes/lists.py", line 239, in deserialize
    values = cls.get_sedes().deserialize(serial)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/rlp-0.4.7-py3.6.egg/rlp/sedes/lists.py", line 66, in deserialize
    raise ListDeserializationError('Can only deserialize sequences', serial)
rlp.exceptions.ListDeserializationError: Can only deserialize sequences

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/gevent-1.2.2-py3.6-linux-x86_64.egg/gevent/greenlet.py", line 536, in run
    result = self._run(*self.args, **self.kwargs)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/gevent-1.2.2-py3.6-linux-x86_64.egg/gevent/baseserver.py", line 26, in _handle_and_close_when_done
    return handle(*args_tuple)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/vanilla-0.1.1-py3.6.egg/vanilla/app.py", line 330, in __handle_connection
    result = self.__handle_abci_call(req_type, req)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/vanilla-0.1.1-py3.6.egg/vanilla/app.py", line 188, in __handle_abci_call
    return handler(req)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/vanilla-0.1.1-py3.6.egg/vanilla/app.py", line 220, in check_tx
    decoded_tx = self.__decode_incoming_tx(req.check_tx.tx)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/vanilla-0.1.1-py3.6.egg/vanilla/app.py", line 217, in __decode_incoming_tx
    return Transaction.decode(rawtx)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/vanilla-0.1.1-py3.6.egg/vanilla/transactions.py", line 61, in decode
    outer = rlp.decode(bits, sedes=cls)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/rlp-0.4.7-py3.6.egg/rlp/codec.py", line 216, in decode
    obj = sedes.deserialize(item, **kwargs)
  File "/home/zaibon/dev/go/src/github.com/incubaid/blockchain_research/tendermint/pocs/kvs/.env/lib/python3.6/site-packages/rlp-0.4.7-py3.6.egg/rlp/sedes/lists.py", line 241, in deserialize
    raise ObjectDeserializationError(serial=serial, sedes=cls, list_exception=e)
rlp.exceptions.ObjectDeserializationError: Deserialization failed because of underlying list ("Can only deserialize sequences")
Fri Oct 27 11:50:36 2017 <Greenlet at 0x7f3fe010cc28: _handle_and_close_when_done(<bound method VanillaApp.__handle_connection of <v, <bound method StreamServer.do_close of <StreamServ, (<gevent._socket3.socket [closed]  object, fd=-1, )> failed with ObjectDeserializationError

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.